ppudump.pp 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038
  1. {
  2. Copyright (c) 1998-2002 by the FPC Development Team
  3. Dumps the contents of a FPC unit file (PPU File)
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************}
  16. program ppudump;
  17. {$mode objfpc}
  18. {$H+}
  19. {$define IN_PPUDUMP}
  20. uses
  21. { do NOT add symconst or globtype to make merging easier }
  22. { do include symconst and globtype now before splitting 2.5 PM 2011-06-15 }
  23. SysUtils,
  24. constexp,
  25. symconst,
  26. ppu,
  27. systems,
  28. globals,
  29. globtype,
  30. widestr,
  31. tokens;
  32. const
  33. Version = 'Version 2.5.1';
  34. Title = 'PPU-Analyser';
  35. Copyright = 'Copyright (c) 1998-2010 by the Free Pascal Development Team';
  36. { verbosity }
  37. v_none = $0;
  38. v_header = $1;
  39. v_defs = $2;
  40. v_syms = $4;
  41. v_interface = $8;
  42. v_implementation = $10;
  43. // v_browser = $20;
  44. v_all = $ff;
  45. { not needed anymore $i systems.inc }
  46. { List of all supported cpus }
  47. const
  48. CpuTxt : array[tsystemcpu] of string[9]=
  49. (
  50. { 0 } 'none',
  51. { 1 } 'i386',
  52. { 2 } 'm68k',
  53. { 3 } 'alpha',
  54. { 4 } 'powerpc',
  55. { 5 } 'sparc',
  56. { 6 } 'vis',
  57. { 7 } 'ia64',
  58. { 8 } 'x86_64',
  59. { 9 } 'mips',
  60. { 10 } 'arm',
  61. { 11 } 'powerpc64',
  62. { 12 } 'avr',
  63. { 13 } 'mipsel'
  64. );
  65. { List of all supported system-cpu couples }
  66. const
  67. Targets : array[tsystem] of string[18]=(
  68. { 0 } 'none',
  69. { 1 } 'GO32V1 (obsolete)',
  70. { 2 } 'GO32V2',
  71. { 3 } 'Linux-i386',
  72. { 4 } 'OS/2',
  73. { 5 } 'Win32',
  74. { 6 } 'FreeBSD-i386',
  75. { 7 } 'Amiga',
  76. { 8 } 'Atari',
  77. { 9 } 'MacOS-m68k',
  78. { 10 } 'Linux-m68k',
  79. { 11 } 'PalmOS-m68k',
  80. { 12 } 'Linux-alpha',
  81. { 13 } 'Linux-ppc',
  82. { 14 } 'MacOS-ppc',
  83. { 15 } 'Solaris-i386',
  84. { 16 } 'BeOS-i386',
  85. { 17 } 'NetBSD-i386',
  86. { 18 } 'NetBSD-m68k',
  87. { 19 } 'Netware-i386-clib',
  88. { 20 } 'Qnx-i386',
  89. { 21 } 'WDOSX-i386',
  90. { 22 } 'Solaris-sparc',
  91. { 23 } 'Linux-sparc',
  92. { 24 } 'OpenBSD-i386',
  93. { 25 } 'OpenBSD-m68k',
  94. { 26 } 'Linux-x86-64',
  95. { 27 } 'MacOSX-ppc',
  96. { 28 } 'OS/2 via EMX',
  97. { 29 } 'NetBSD-powerpc',
  98. { 30 } 'OpenBSD-powerpc',
  99. { 31 } 'Linux-arm',
  100. { 32 } 'Watcom-i386',
  101. { 33 } 'MorphOS-powerpc',
  102. { 34 } 'FreeBSD-x86-64',
  103. { 35 } 'Netware-i386-libc',
  104. { 36 } 'Amiga-PowerPC',
  105. { 37 } 'Win64-x64',
  106. { 38 } 'WinCE-ARM',
  107. { 39 } 'Win64-iA64',
  108. { 40 } 'WinCE-i386',
  109. { 41 } 'Linux-x64',
  110. { 42 } 'GBA-arm',
  111. { 43 } 'Linux-powerpc64',
  112. { 44 } 'Darwin-i386',
  113. { 45 } 'PalmOS-arm',
  114. { 46 } 'MacOSX-powerpc64',
  115. { 47 } 'NDS-arm',
  116. { 48 } 'Embedded-i386',
  117. { 49 } 'Embedded-m68k',
  118. { 50 } 'Embedded-alpha',
  119. { 51 } 'Embedded-powerpc',
  120. { 52 } 'Embedded-sparc',
  121. { 53 } 'Embedded-vm',
  122. { 54 } 'Embedded-iA64',
  123. { 55 } 'Embedded-x64',
  124. { 56 } 'Embedded-mips',
  125. { 57 } 'Embedded-arm',
  126. { 58 } 'Embedded-powerpc64',
  127. { 59 } 'Symbian-i386',
  128. { 60 } 'Symbian-arm',
  129. { 61 } 'MacOSX-x64',
  130. { 62 } 'Embedded-avr',
  131. { 63 } 'Haiku-i386',
  132. { 64 } 'Darwin-ARM',
  133. { 65 } 'Solaris-x86-64',
  134. { 66 } 'Linux-MIPS',
  135. { 67 } 'Linux-MIPSel',
  136. { 68 } 'NativeNT-i386',
  137. { 69 } 'iPhoneSim-i386',
  138. { 70 } 'Wii-powerpc',
  139. { 71 } 'OpenBSD-x86-64',
  140. { 72 } 'NetBSD-x86-64'
  141. );
  142. const
  143. { in widestr, we have the following definition
  144. type
  145. tcompilerwidechar = word;
  146. thus widecharsize seems to always be 2 bytes }
  147. widecharsize : longint = 2;
  148. cpu : tsystemcpu = cpu_no;
  149. { This type is defined in scanner.pas unit }
  150. type
  151. tspecialgenerictoken = (
  152. ST_LOADSETTINGS,
  153. ST_LINE,
  154. ST_COLUMN,
  155. ST_FILEINDEX,
  156. ST_LOADMESSAGES);
  157. var
  158. ppufile : tppufile;
  159. ppuversion : dword;
  160. space : string;
  161. verbose : longint;
  162. derefdata : pbyte;
  163. derefdatalen : longint;
  164. {****************************************************************************
  165. Helper Routines
  166. ****************************************************************************}
  167. {****************************************************************************
  168. Routine to read 80-bit reals
  169. ****************************************************************************
  170. }
  171. type
  172. TSplit80bitReal = packed record
  173. case byte of
  174. 0: (bytes: Array[0..9] of byte);
  175. 1: (words: Array[0..4] of word);
  176. 2: (cards: Array[0..1] of cardinal; w: word);
  177. end;
  178. const
  179. maxDigits = 17;
  180. function Real80bitToStr(var e : TSplit80bitReal) : string;
  181. var
  182. Temp : string;
  183. new : TSplit80bitReal;
  184. fraczero, expmaximal, sign, outside_double : boolean;
  185. exp : smallint;
  186. ext : extended;
  187. d : double;
  188. i : longint;
  189. mantval : qword;
  190. begin
  191. if ppufile.change_endian then
  192. begin
  193. for i:=0 to 9 do
  194. new.bytes[i]:=e.bytes[9-i];
  195. e:=new;
  196. end;
  197. if sizeof(ext)=10 then
  198. begin
  199. ext:=pextended(@e)^;
  200. str(ext,result);
  201. exit;
  202. end;
  203. { extended, format (MSB): 1 Sign bit, 15 bit exponent, 64 bit mantissa }
  204. sign := (e.w and $8000) <> 0;
  205. expMaximal := (e.w and $7fff) = 32767;
  206. exp:=(e.w and $7fff) - 16383 - 63;
  207. fraczero := (e.cards[0] = 0) and
  208. ((e.cards[1] and $7fffffff) = 0);
  209. mantval := qword(e.cards[0]) or (qword(e.cards[1]) shl 32);
  210. if expMaximal then
  211. if fraczero then
  212. if sign then
  213. temp := '-Inf'
  214. else temp := '+Inf'
  215. else temp := 'Nan'
  216. else
  217. begin
  218. d:=double(mantval);
  219. if sign then
  220. d:=-d;
  221. outside_double:=false;
  222. Try
  223. if exp > 0 then
  224. begin
  225. for i:=1 to exp do
  226. d:=d *2.0;
  227. end
  228. else if exp < 0 then
  229. begin
  230. for i:=1 to -exp do
  231. d:=d /2.0;
  232. end;
  233. Except
  234. outside_double:=true;
  235. end;
  236. if (mantval<>0) and (d=0.0) then
  237. outside_double:=true;
  238. if outside_double then
  239. Temp:='Extended value outside double bound'
  240. else
  241. system.str(d,temp);
  242. end;
  243. result:=temp;
  244. end;
  245. const has_errors : boolean = false;
  246. has_more_infos : boolean = false;
  247. Procedure HasMoreInfos;
  248. begin
  249. Writeln('!! Entry has more information stored');
  250. has_more_infos:=true;
  251. end;
  252. Procedure WriteError(const S : string);
  253. Begin
  254. Writeln(S);
  255. has_errors:=true;
  256. End;
  257. function Unknown(const st : string; val :longint) : string;
  258. Begin
  259. Unknown:='<!! Unknown'+st+' value '+tostr(val)+'>';
  260. has_errors:=true;
  261. end;
  262. function ToStr(w:longint):String;
  263. begin
  264. Str(w,ToStr);
  265. end;
  266. Function Target2Str(w:longint):string;
  267. begin
  268. if w<=ord(high(tsystem)) then
  269. Target2Str:=Targets[tsystem(w)]
  270. else
  271. Target2Str:=Unknown('target',w);
  272. end;
  273. Function Cpu2Str(w:longint):string;
  274. begin
  275. if w<=ord(high(tsystemcpu)) then
  276. begin
  277. cpu:=tsystemcpu(w);
  278. Cpu2Str:=CpuTxt[cpu];
  279. end
  280. else
  281. Cpu2Str:=Unknown('cpu',w);
  282. end;
  283. Function Varspez2Str(w:longint):string;
  284. const
  285. { in symconst unit
  286. tvarspez = (vs_value,vs_const,vs_var,vs_out,vs_constref); }
  287. varspezstr : array[tvarspez] of string[6]=('Value','Const','Var','Out','Hidden');
  288. begin
  289. if w<=ord(high(varspezstr)) then
  290. Varspez2Str:=varspezstr[tvarspez(w)]
  291. else
  292. Varspez2Str:=Unknown('varspez',w);
  293. end;
  294. Function VarRegable2Str(w:longint):string;
  295. { tvarregable type is defined in symconst unit }
  296. const
  297. varregableStr : array[tvarregable] of string[6]=('None','IntReg','FPUReg','MMReg','Addr');
  298. begin
  299. if w<=ord(high(varregablestr)) then
  300. Varregable2Str:=varregablestr[tvarregable(w)]
  301. else
  302. Varregable2Str:=Unknown('regable',w);
  303. end;
  304. Function Visibility2Str(w:longint):string;
  305. const
  306. { tvisibility type is defined in symconst unit }
  307. visibilityName : array[tvisibility] of string[16] = (
  308. 'hidden','strict private','private','strict protected','protected',
  309. 'public','published'
  310. );
  311. begin
  312. if w<=ord(high(visibilityName)) then
  313. result:=visibilityName[tvisibility(w)]
  314. else
  315. result:=Unknown('visibility',w);
  316. end;
  317. function PPUFlags2Str(flags:longint):string;
  318. type
  319. tflagopt=record
  320. mask : longint;
  321. str : string[30];
  322. end;
  323. const
  324. flagopts=24;
  325. flagopt : array[1..flagopts] of tflagopt=(
  326. (mask: $1 ;str:'init'),
  327. (mask: $2 ;str:'final'),
  328. (mask: $4 ;str:'big_endian'),
  329. (mask: $8 ;str:'dbx'),
  330. // (mask: $10 ;str:'browser'),
  331. (mask: $20 ;str:'in_library'),
  332. (mask: $40 ;str:'smart_linked'),
  333. (mask: $80 ;str:'static_linked'),
  334. (mask: $100 ;str:'shared_linked'),
  335. // (mask: $200 ;str:'local_browser'),
  336. (mask: $400 ;str:'no_link'),
  337. (mask: $800 ;str:'has_resources'),
  338. (mask: $1000 ;str:'little_endian'),
  339. (mask: $2000 ;str:'release'),
  340. (mask: $4000 ;str:'local_threadvars'),
  341. (mask: $8000 ;str:'fpu_emulation_on'),
  342. (mask: $210000 ;str:'has_debug_info'),
  343. (mask: $10000 ;str:'stabs_debug_info'),
  344. (mask: $200000 ;str:'dwarf_debug_info'),
  345. (mask: $20000 ;str:'local_symtable'),
  346. (mask: $40000 ;str:'uses_variants'),
  347. (mask: $80000 ;str:'has_resourcefiles'),
  348. (mask: $100000 ;str:'has_exports'),
  349. (mask: $400000 ;str:'has_wideinits'),
  350. (mask: $800000 ;str:'has_classinits'),
  351. (mask: $1000000 ;str:'has_resstrinits')
  352. );
  353. var
  354. i,ntflags : longint;
  355. first : boolean;
  356. s : string;
  357. begin
  358. s:='';
  359. if flags<>0 then
  360. begin
  361. ntflags:=flags;
  362. first:=true;
  363. for i:=1to flagopts do
  364. if (flags and flagopt[i].mask)<>0 then
  365. begin
  366. if first then
  367. first:=false
  368. else
  369. s:=s+', ';
  370. s:=s+flagopt[i].str;
  371. ntflags:=ntflags and (not flagopt[i].mask);
  372. end;
  373. end
  374. else
  375. s:='none';
  376. if ntflags<>0 then
  377. begin
  378. s:=s+' unknown '+hexstr(ntflags,8);
  379. has_errors:=true;
  380. end;
  381. PPUFlags2Str:=s;
  382. end;
  383. Function L0(l:longint):string;
  384. {
  385. return the string of value l, if l<10 then insert a zero, so
  386. the string is always at least 2 chars '01','02',etc
  387. }
  388. var
  389. s : string;
  390. begin
  391. Str(l,s);
  392. if l<10 then
  393. s:='0'+s;
  394. L0:=s;
  395. end;
  396. function filetimestring( t : longint) : string;
  397. {
  398. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  399. }
  400. var
  401. DT : TDateTime;
  402. hsec : word;
  403. Year,Month,Day: Word;
  404. hour,min,sec : word;
  405. begin
  406. if t=-1 then
  407. begin
  408. Result := 'Not Found';
  409. has_errors:=true;
  410. exit;
  411. end;
  412. DT := FileDateToDateTime(t);
  413. DecodeTime(DT,hour,min,sec,hsec);
  414. DecodeDate(DT,year,month,day);
  415. Result := L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  416. end;
  417. {****************************************************************************
  418. Read Routines
  419. ****************************************************************************}
  420. procedure readrecsymtableoptions;
  421. var
  422. usefieldalignment : shortint;
  423. begin
  424. if ppufile.readentry<>ibrecsymtableoptions then
  425. begin
  426. has_errors:=true;
  427. exit;
  428. end;
  429. writeln(space,' recordalignment: ',shortint(ppufile.getbyte));
  430. usefieldalignment:=shortint(ppufile.getbyte);
  431. writeln(space,' usefieldalignment: ',usefieldalignment);
  432. if (usefieldalignment=C_alignment) then
  433. writeln(space,' fieldalignment: ',shortint(ppufile.getbyte));
  434. end;
  435. procedure readsymtableoptions(const s: string);
  436. type
  437. tsymtblopt=record
  438. mask : tsymtableoption;
  439. str : string[30];
  440. end;
  441. const
  442. symtblopts=ord(high(tsymtableoption)) + 1;
  443. symtblopt : array[1..symtblopts] of tsymtblopt=(
  444. (mask:sto_has_helper; str:'Has helper')
  445. );
  446. var
  447. options : tsymtableoptions;
  448. first : boolean;
  449. i : integer;
  450. begin
  451. if ppufile.readentry<>ibsymtableoptions then
  452. begin
  453. has_errors:=true;
  454. exit;
  455. end;
  456. ppufile.getsmallset(options);
  457. if space<>'' then
  458. writeln(space,'------ ',s,' ------');
  459. write(space,'Symtable options: ');
  460. if options<>[] then
  461. begin
  462. first:=true;
  463. for i:=1 to symtblopts do
  464. if (symtblopt[i].mask in options) then
  465. begin
  466. if first then
  467. first:=false
  468. else
  469. write(', ');
  470. write(symtblopt[i].str);
  471. end;
  472. end
  473. else
  474. write('none');
  475. writeln;
  476. end;
  477. procedure readdefinitions(const s:string); forward;
  478. procedure readsymbols(const s:string); forward;
  479. procedure readsymtable(const s: string);
  480. begin
  481. readsymtableoptions(s);
  482. readdefinitions(s);
  483. readsymbols(s);
  484. end;
  485. Procedure ReadLinkContainer(const prefix:string);
  486. {
  487. Read a serie of strings and write to the screen starting every line
  488. with prefix
  489. }
  490. function maskstr(m:longint):string;
  491. { link options are in globtype unit
  492. const
  493. link_none = $0;
  494. link_always = $1;
  495. link_static = $2;
  496. link_smart = $4;
  497. link_shared = $8; }
  498. var
  499. s : string;
  500. begin
  501. s:='';
  502. if (m and link_always)<>0 then
  503. s:=s+'always ';
  504. if (m and link_static)<>0 then
  505. s:=s+'static ';
  506. if (m and link_smart)<>0 then
  507. s:=s+'smart ';
  508. if (m and link_shared)<>0 then
  509. s:=s+'shared ';
  510. maskstr:=s;
  511. end;
  512. var
  513. s : string;
  514. m : longint;
  515. begin
  516. while not ppufile.endofentry do
  517. begin
  518. s:=ppufile.getstring;
  519. m:=ppufile.getlongint;
  520. WriteLn(prefix,s,' (',maskstr(m),')');
  521. end;
  522. end;
  523. Procedure ReadContainer(const prefix:string);
  524. {
  525. Read a serie of strings and write to the screen starting every line
  526. with prefix
  527. }
  528. begin
  529. while not ppufile.endofentry do
  530. WriteLn(prefix,ppufile.getstring);
  531. end;
  532. procedure ReadLoadUnit;
  533. var
  534. ucrc,uintfcrc, indcrc : cardinal;
  535. begin
  536. while not ppufile.EndOfEntry do
  537. begin
  538. write('Uses unit: ',ppufile.getstring);
  539. ucrc:=cardinal(ppufile.getlongint);
  540. uintfcrc:=cardinal(ppufile.getlongint);
  541. indcrc:=cardinal(ppufile.getlongint);
  542. writeln(' (Crc: ',hexstr(ucrc,8),', IntfcCrc: ',hexstr(uintfcrc,8),', IndCrc: ',hexstr(indcrc,8),')');
  543. end;
  544. end;
  545. Procedure ReadDerefmap;
  546. var
  547. i,mapsize : longint;
  548. begin
  549. mapsize:=ppufile.getlongint;
  550. writeln('DerefMapsize: ',mapsize);
  551. for i:=0 to mapsize-1 do
  552. writeln('DerefMap[',i,'] = ',ppufile.getstring);
  553. end;
  554. Procedure ReadImportSymbols;
  555. var
  556. extlibname : string;
  557. j,
  558. extsymcnt : longint;
  559. extsymname : string;
  560. extsymmangledname : string;
  561. extsymordnr : longint;
  562. extsymisvar : boolean;
  563. begin
  564. while not ppufile.endofentry do
  565. begin
  566. extlibname:=ppufile.getstring;
  567. extsymcnt:=ppufile.getlongint;
  568. writeln('External Library: ',extlibname,' (',extsymcnt,' imports)');
  569. for j:=0 to extsymcnt-1 do
  570. begin
  571. extsymname:=ppufile.getstring;
  572. if ppuversion>130 then
  573. extsymmangledname:=ppufile.getstring
  574. else
  575. extsymmangledname:=extsymname;
  576. extsymordnr:=ppufile.getlongint;
  577. extsymisvar:=ppufile.getbyte<>0;
  578. writeln(' ',extsymname,' as ',extsymmangledname,
  579. '(OrdNr: ',extsymordnr,' IsVar: ',extsymisvar,')');
  580. end;
  581. end;
  582. end;
  583. Procedure ReadDerefdata;
  584. begin
  585. derefdatalen:=ppufile.entrysize;
  586. if derefdatalen=0 then
  587. begin
  588. WriteError('!! Error: derefdatalen=0');
  589. exit;
  590. end;
  591. Writeln('Derefdata length: ',derefdatalen);
  592. derefdata:=allocmem(derefdatalen);
  593. ppufile.getdata(derefdata^,derefdatalen);
  594. end;
  595. Procedure FreeDerefdata;
  596. begin
  597. if assigned(derefdata) then
  598. begin
  599. FreeMem(derefdata);
  600. derefdata:=nil;
  601. derefdatalen:=0;
  602. end;
  603. end;
  604. Procedure ReadWpoFileInfo;
  605. begin
  606. Writeln('Compiled with input whole-program optimisation from ',ppufile.getstring,' ',filetimestring(ppufile.getlongint));
  607. end;
  608. Procedure ReadAsmSymbols;
  609. type
  610. { Copied from aasmbase.pas }
  611. TAsmsymbind=(
  612. AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL,AB_WEAK_EXTERNAL,
  613. { global in the current program/library, but not visible outside it }
  614. AB_PRIVATE_EXTERN,AB_LAZY,AB_IMPORT);
  615. TAsmsymtype=(
  616. AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL,
  617. {
  618. the address of this code label is taken somewhere in the code
  619. so it must be taken care of it when creating pic
  620. }
  621. AT_ADDR
  622. );
  623. var
  624. s,
  625. bindstr,
  626. typestr : string;
  627. i : longint;
  628. begin
  629. writeln(space,'Number of AsmSymbols: ',ppufile.getlongint);
  630. i:=0;
  631. while (not ppufile.endofentry) and (not ppufile.error) do
  632. begin
  633. s:=ppufile.getstring;
  634. case tasmsymbind(ppufile.getbyte) of
  635. AB_EXTERNAL :
  636. bindstr:='External';
  637. AB_COMMON :
  638. bindstr:='Common';
  639. AB_LOCAL :
  640. bindstr:='Local';
  641. AB_GLOBAL :
  642. bindstr:='Global';
  643. AB_WEAK_EXTERNAL :
  644. bindstr:='Weak external';
  645. AB_PRIVATE_EXTERN :
  646. bindstr:='Private extern';
  647. AB_LAZY :
  648. bindstr:='Lazy';
  649. AB_IMPORT :
  650. bindstr:='Import';
  651. else
  652. begin
  653. bindstr:='<Error !!>';
  654. has_errors:=true;
  655. end;
  656. end;
  657. case tasmsymtype(ppufile.getbyte) of
  658. AT_FUNCTION :
  659. typestr:='Function';
  660. AT_DATA :
  661. typestr:='Data';
  662. AT_SECTION :
  663. typestr:='Section';
  664. AT_LABEL :
  665. typestr:='Label';
  666. AT_ADDR :
  667. typestr:='Label (with address taken)';
  668. else
  669. begin
  670. typestr:='<Error !!>';
  671. has_errors:=true;
  672. end;
  673. end;
  674. Writeln(space,' ',i,' : ',s,' [',bindstr,',',typestr,']');
  675. inc(i);
  676. end;
  677. end;
  678. function getexprint:Tconstexprint;
  679. begin
  680. getexprint.overflow:=false;
  681. getexprint.signed:=boolean(ppufile.getbyte);
  682. getexprint.svalue:=ppufile.getint64;
  683. end;
  684. Procedure ReadPosInfo;
  685. var
  686. info : byte;
  687. fileindex,line,column : longint;
  688. begin
  689. with ppufile do
  690. begin
  691. {
  692. info byte layout in bits:
  693. 0-1 - amount of bytes for fileindex
  694. 2-3 - amount of bytes for line
  695. 4-5 - amount of bytes for column
  696. }
  697. info:=getbyte;
  698. case (info and $03) of
  699. 0 : fileindex:=getbyte;
  700. 1 : fileindex:=getword;
  701. 2 : fileindex:=(getbyte shl 16) or getword;
  702. 3 : fileindex:=getlongint;
  703. end;
  704. case ((info shr 2) and $03) of
  705. 0 : line:=getbyte;
  706. 1 : line:=getword;
  707. 2 : line:=(getbyte shl 16) or getword;
  708. 3 : line:=getlongint;
  709. end;
  710. case ((info shr 4) and $03) of
  711. 0 : column:=getbyte;
  712. 1 : column:=getword;
  713. 2 : column:=(getbyte shl 16) or getword;
  714. 3 : column:=getlongint;
  715. end;
  716. Writeln(fileindex,' (',line,',',column,')');
  717. end;
  718. end;
  719. procedure readderef(const derefspace: string);
  720. var
  721. b : tdereftype;
  722. first : boolean;
  723. idx : longint;
  724. i,n : byte;
  725. pdata : pbyte;
  726. begin
  727. if not assigned(derefdata) then
  728. exit;
  729. first:=true;
  730. idx:=ppufile.getlongint;
  731. if (idx>derefdatalen) then
  732. begin
  733. writeln('!! Error: Deref idx ',idx,' > ',derefdatalen);
  734. has_errors:=true;
  735. exit;
  736. end;
  737. write(derefspace,'(',idx,') ');
  738. pdata:=@derefdata[idx];
  739. i:=0;
  740. n:=pdata[i];
  741. inc(i);
  742. if n<1 then
  743. begin
  744. WriteError('!! Error: Deref len < 1');
  745. exit;
  746. end;
  747. while (i<=n) do
  748. begin
  749. if not first then
  750. write(', ')
  751. else
  752. first:=false;
  753. b:=tdereftype(pdata[i]);
  754. inc(i);
  755. case b of
  756. deref_nil :
  757. write('Nil');
  758. deref_symid :
  759. begin
  760. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  761. inc(i,4);
  762. write('SymId ',idx);
  763. end;
  764. deref_defid :
  765. begin
  766. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  767. inc(i,4);
  768. write('DefId ',idx);
  769. end;
  770. deref_unit :
  771. begin
  772. idx:=pdata[i] shl 8 or pdata[i+1];
  773. inc(i,2);
  774. write('Unit ',idx);
  775. end;
  776. else
  777. begin
  778. writeln('!! unsupported dereftyp: ',ord(b));
  779. has_errors:=true;
  780. break;
  781. end;
  782. end;
  783. end;
  784. writeln;
  785. end;
  786. procedure readpropaccesslist(const s:string);
  787. { type tsltype is in symconst unit }
  788. const
  789. slstr : array[tsltype] of string[12] = (
  790. '',
  791. 'load',
  792. 'call',
  793. 'subscript',
  794. 'vec',
  795. 'typeconv',
  796. 'absolutetype'
  797. );
  798. var
  799. sl : tsltype;
  800. begin
  801. readderef('');
  802. repeat
  803. sl:=tsltype(ppufile.getbyte);
  804. if sl=sl_none then
  805. break;
  806. write(s,'(',slstr[sl],') ');
  807. case sl of
  808. sl_call,
  809. sl_load,
  810. sl_subscript :
  811. readderef('');
  812. sl_absolutetype,
  813. sl_typeconv :
  814. readderef('');
  815. sl_vec :
  816. begin
  817. writeln(ppufile.getlongint);
  818. readderef('');
  819. end;
  820. end;
  821. until false;
  822. end;
  823. (*
  824. talignmentinfo = packed record
  825. procalign,
  826. loopalign,
  827. jumpalign,
  828. constalignmin,
  829. constalignmax,
  830. varalignmin,
  831. varalignmax,
  832. localalignmin,
  833. localalignmax,
  834. recordalignmin,
  835. recordalignmax,
  836. maxCrecordalign : longint;
  837. end;
  838. tsettings = packed record
  839. alignment : talignmentinfo;
  840. globalswitches : tglobalswitches;
  841. moduleswitches : tmoduleswitches;
  842. localswitches : tlocalswitches;
  843. modeswitches : tmodeswitches;
  844. optimizerswitches : toptimizerswitches;
  845. { generate information necessary to perform these wpo's during a subsequent compilation }
  846. genwpoptimizerswitches: twpoptimizerswitches;
  847. { perform these wpo's using information generated during a previous compilation }
  848. dowpoptimizerswitches: twpoptimizerswitches;
  849. debugswitches : tdebugswitches;
  850. { 0: old behaviour for sets <=256 elements
  851. >0: round to this size }
  852. setalloc,
  853. packenum : shortint;
  854. packrecords : shortint;
  855. maxfpuregisters : shortint;
  856. cputype,
  857. optimizecputype : tcputype;
  858. fputype : tfputype;
  859. asmmode : tasmmode;
  860. interfacetype : tinterfacetypes;
  861. defproccall : tproccalloption;
  862. sourcecodepage : tcodepagestring;
  863. minfpconstprec : tfloattype;
  864. disabledircache : boolean;
  865. { CPU targets with microcontroller support can add a controller specific unit }
  866. {$if defined(ARM) or defined(AVR)}
  867. controllertype : tcontrollertype;
  868. {$endif defined(ARM) or defined(AVR)}
  869. { WARNING: this pointer cannot be written as such in record token }
  870. pmessage : pmessagestaterecord;
  871. end;
  872. *)
  873. procedure readprocinfooptions(space : string);
  874. (*
  875. tprocinfoflag=(
  876. { procedure has at least one assembler block }
  877. pi_has_assembler_block,
  878. { procedure does a call }
  879. pi_do_call,
  880. { procedure has a try statement = no register optimization }
  881. pi_uses_exceptions,
  882. { procedure is declared as @var(assembler), don't optimize}
  883. pi_is_assembler,
  884. { procedure contains data which needs to be finalized }
  885. pi_needs_implicit_finally,
  886. { procedure has the implicit try..finally generated }
  887. pi_has_implicit_finally,
  888. { procedure uses fpu}
  889. pi_uses_fpu,
  890. { procedure uses GOT for PIC code }
  891. pi_needs_got,
  892. { references var/proc/type/const in static symtable,
  893. i.e. not allowed for inlining from other units }
  894. pi_uses_static_symtable,
  895. { set if the procedure has to push parameters onto the stack }
  896. pi_has_stackparameter,
  897. { set if the procedure has at least one label }
  898. pi_has_label,
  899. { calls itself recursive }
  900. pi_is_recursive,
  901. { stack frame optimization not possible (only on x86 probably) }
  902. pi_needs_stackframe,
  903. { set if the procedure has at least one register saved on the stack }
  904. pi_has_saved_regs,
  905. { dfa was generated for this proc }
  906. pi_dfaavailable,
  907. { subroutine contains interprocedural used labels }
  908. pi_has_interproclabel
  909. ); *)
  910. type
  911. tprocinfoopt=record
  912. mask : tprocinfoflag;
  913. str : string[80];
  914. end;
  915. const
  916. procinfoopts=ord(high(tprocinfoflag)) - ord(low(tprocinfoflag));
  917. procinfoopt : array[0..procinfoopts] of tprocinfoopt=(
  918. (mask:pi_has_assembler_block;
  919. str:' has at least one assembler block'),
  920. (mask:pi_do_call;
  921. str:' does a call'),
  922. (mask:pi_uses_exceptions;
  923. str:' has a try statement = no register optimization '),
  924. (mask:pi_is_assembler;
  925. str:' is declared as @var(assembler), don''t optimize'),
  926. (mask:pi_needs_implicit_finally;
  927. str:' contains data which needs to be finalized '),
  928. (mask:pi_has_implicit_finally;
  929. str:' has the implicit try..finally generated '),
  930. (mask:pi_uses_fpu;
  931. str:' uses fpu'),
  932. (mask:pi_needs_got;
  933. str:' uses GOT for PIC code '),
  934. (mask:pi_uses_static_symtable;
  935. str:' references var/proc/type/const in static symtable'),
  936. (mask:pi_has_stackparameter;
  937. str:' set if the procedure has to push parameters onto the stack '),
  938. (mask:pi_has_label;
  939. str:' set if the procedure has at least one label '),
  940. (mask:pi_is_recursive;
  941. str:' calls itself recursive '),
  942. (mask:pi_needs_stackframe;
  943. str:' stack frame optimization not possible (only on x86 probably) '),
  944. (mask:pi_has_saved_regs;
  945. str:' set if the procedure has at least one register saved on the stack '),
  946. (mask:pi_dfaavailable;
  947. str:' dfa was generated for this proc '),
  948. (mask:pi_has_interproclabel;
  949. str:' subroutine contains interprocedural used labels '),
  950. (mask:pi_has_unwind_info;
  951. str:' unwinding info was generated for this proc ')
  952. );
  953. var
  954. procinfooptions : tprocinfoflags;
  955. i : longint;
  956. first : boolean;
  957. begin
  958. ppufile.getsmallset(procinfooptions);
  959. if procinfooptions<>[] then
  960. begin
  961. first:=true;
  962. for i:=0 to procinfoopts do
  963. if (procinfoopt[i].mask in procinfooptions) then
  964. begin
  965. if first then
  966. first:=false
  967. else
  968. write(', ');
  969. write(procinfoopt[i].str);
  970. end;
  971. end;
  972. writeln;
  973. end;
  974. procedure readsymoptions(space : string);
  975. type
  976. tsymopt=record
  977. mask : tsymoption;
  978. str : string[30];
  979. end;
  980. const
  981. symopts=ord(high(tsymoption)) - ord(low(tsymoption));
  982. { sp_none = 0 corresponds to nothing }
  983. symopt : array[1..symopts] of tsymopt=(
  984. (mask:sp_static; str:'Static'),
  985. (mask:sp_hint_deprecated; str:'Hint Deprecated'),
  986. (mask:sp_hint_platform; str:'Hint Platform'),
  987. (mask:sp_hint_library; str:'Hint Library'),
  988. (mask:sp_hint_unimplemented; str:'Hint Unimplemented'),
  989. (mask:sp_hint_experimental; str:'Hint Experimental'),
  990. (mask:sp_has_overloaded; str:'Has overloaded'),
  991. (mask:sp_internal; str:'Internal'),
  992. (mask:sp_implicitrename; str:'Implicit Rename'),
  993. (mask:sp_generic_para; str:'Generic Parameter'),
  994. (mask:sp_has_deprecated_msg; str:'Has Deprecated Message'),
  995. (mask:sp_generic_dummy; str:'Generic Dummy'),
  996. (mask:sp_explicitrename; str:'Explicit Rename')
  997. );
  998. var
  999. symoptions : tsymoptions;
  1000. i : longint;
  1001. first : boolean;
  1002. begin
  1003. ppufile.getsmallset(symoptions);
  1004. if symoptions<>[] then
  1005. begin
  1006. first:=true;
  1007. for i:=1to symopts do
  1008. if (symopt[i].mask in symoptions) then
  1009. begin
  1010. if first then
  1011. first:=false
  1012. else
  1013. write(', ');
  1014. write(symopt[i].str);
  1015. end;
  1016. end;
  1017. writeln;
  1018. if sp_has_deprecated_msg in symoptions then
  1019. writeln(space,'Deprecated : ', ppufile.getstring);
  1020. end;
  1021. procedure readcommonsym(const s:string);
  1022. begin
  1023. writeln(space,'** Symbol Id ',ppufile.getlongint,' **');
  1024. writeln(space,s,ppufile.getstring);
  1025. write (space,' File Pos : ');
  1026. readposinfo;
  1027. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  1028. write (space,' SymOptions : ');
  1029. readsymoptions(space+' ');
  1030. end;
  1031. var
  1032. { needed during tobjectdef parsing... }
  1033. current_defoptions : tdefoptions;
  1034. current_objectoptions : tobjectoptions;
  1035. procedure readcommondef(const s:string; out defoptions: tdefoptions);
  1036. type
  1037. tdefopt=record
  1038. mask : tdefoption;
  1039. str : string[30];
  1040. end;
  1041. tdefstateinfo=record
  1042. mask : tdefstate;
  1043. str : string[30];
  1044. end;
  1045. ptoken=^ttoken;
  1046. pmsgstate =^tmsgstate;
  1047. const
  1048. defopt : array[1..ord(high(tdefoption))] of tdefopt=(
  1049. (mask:df_unique; str:'Unique Type'),
  1050. (mask:df_generic; str:'Generic'),
  1051. (mask:df_specialization; str:'Specialization'),
  1052. (mask:df_copied_def; str:'Copied Typedef')
  1053. );
  1054. defstate : array[1..ord(high(tdefstate))] of tdefstateinfo=(
  1055. (mask:ds_vmt_written; str:'VMT Written'),
  1056. (mask:ds_rtti_table_used; str:'RTTITable Used'),
  1057. (mask:ds_init_table_used; str:'InitTable Used'),
  1058. (mask:ds_rtti_table_written; str:'RTTITable Written'),
  1059. (mask:ds_init_table_written; str:'InitTable Written'),
  1060. (mask:ds_dwarf_dbg_info_used; str:'Dwarf DbgInfo Used'),
  1061. (mask:ds_dwarf_dbg_info_written;str:'Dwarf DbgInfo Written')
  1062. );
  1063. var
  1064. defstates : tdefstates;
  1065. i, nb, msgvalue, mesgnb : longint;
  1066. first : boolean;
  1067. copy_size, min_size, tokenbufsize : longint;
  1068. tokenbuf : pbyte;
  1069. idtoken,
  1070. token : ttoken;
  1071. state : tmsgstate;
  1072. new_settings : Tsettings;
  1073. len : sizeint;
  1074. wstring : widestring;
  1075. astring : ansistring;
  1076. function readtoken: ttoken;
  1077. var
  1078. b,b2 : byte;
  1079. begin
  1080. b:=tokenbuf[i];
  1081. inc(i);
  1082. if (b and $80)<>0 then
  1083. begin
  1084. b2:=tokenbuf[i];
  1085. inc(i);
  1086. result:=ttoken(((b and $7f) shl 8) or b2);
  1087. end
  1088. else
  1089. result:=ttoken(b);
  1090. end;
  1091. function gettokenbufdword : dword;
  1092. var
  1093. var32 : dword;
  1094. begin
  1095. var32:=pdword(@tokenbuf[i])^;
  1096. inc(i,sizeof(dword));
  1097. if ppufile.change_endian then
  1098. var32:=swapendian(var32);
  1099. result:=var32;
  1100. end;
  1101. function gettokenbufword : word;
  1102. var
  1103. var16 : word;
  1104. begin
  1105. var16:=pword(@tokenbuf[i])^;
  1106. inc(i,sizeof(word));
  1107. if ppufile.change_endian then
  1108. var16:=swapendian(var16);
  1109. result:=var16;
  1110. end;
  1111. function gettokenbufsizeint : int64;
  1112. var
  1113. var64 : int64;
  1114. var32 : longint;
  1115. var16 : smallint;
  1116. begin
  1117. if CpuAddrBitSize[cpu]=64 then
  1118. begin
  1119. var64:=pint64(@tokenbuf[i])^;
  1120. inc(i,sizeof(int64));
  1121. if ppufile.change_endian then
  1122. var64:=swapendian(var64);
  1123. result:=var64;
  1124. end
  1125. else if CpuAddrBitSize[cpu]=32 then
  1126. begin
  1127. var32:=plongint(@tokenbuf[i])^;
  1128. inc(i,sizeof(longint));
  1129. if ppufile.change_endian then
  1130. var32:=swapendian(var32);
  1131. result:=var32;
  1132. end
  1133. else if CpuAddrBitSize[cpu]=16 then
  1134. begin
  1135. var16:=psmallint(@tokenbuf[i])^;
  1136. inc(i,sizeof(smallint));
  1137. if ppufile.change_endian then
  1138. var16:=swapendian(var16);
  1139. result:=var16;
  1140. end
  1141. else
  1142. begin
  1143. WriteError('Wrong CpuAddrBitSize');
  1144. result:=0;
  1145. end;
  1146. end;
  1147. begin
  1148. writeln(space,'** Definition Id ',ppufile.getlongint,' **');
  1149. writeln(space,s);
  1150. write (space,' Type symbol : ');
  1151. readderef('');
  1152. write (space,' DefOptions : ');
  1153. ppufile.getsmallset(defoptions);
  1154. if defoptions<>[] then
  1155. begin
  1156. first:=true;
  1157. for i:=1to high(defopt) do
  1158. if (defopt[i].mask in defoptions) then
  1159. begin
  1160. if first then
  1161. first:=false
  1162. else
  1163. write(', ');
  1164. write(defopt[i].str);
  1165. end;
  1166. end;
  1167. writeln;
  1168. write (space,' DefStates : ');
  1169. ppufile.getsmallset(defstates);
  1170. if defstates<>[] then
  1171. begin
  1172. first:=true;
  1173. for i:=1 to high(defstate) do
  1174. if (defstate[i].mask in defstates) then
  1175. begin
  1176. if first then
  1177. first:=false
  1178. else
  1179. write(', ');
  1180. write(defstate[i].str);
  1181. end;
  1182. end;
  1183. writeln;
  1184. if df_generic in defoptions then
  1185. begin
  1186. tokenbufsize:=ppufile.getlongint;
  1187. writeln(space,' Tokenbuffer size : ',tokenbufsize);
  1188. tokenbuf:=allocmem(tokenbufsize);
  1189. ppufile.getdata(tokenbuf^,tokenbufsize);
  1190. i:=0;
  1191. write(space,' Tokens: ');
  1192. while i<tokenbufsize do
  1193. begin
  1194. token:=readtoken;
  1195. if token<>_GENERICSPECIALTOKEN then
  1196. begin
  1197. if token <= high(ttoken) then
  1198. write(arraytokeninfo[token].str)
  1199. else
  1200. begin
  1201. HasMoreInfos;
  1202. write('Error in Token List');
  1203. break;
  1204. end;
  1205. idtoken:=readtoken;
  1206. end;
  1207. case token of
  1208. _CWCHAR,
  1209. _CWSTRING :
  1210. begin
  1211. len:=gettokenbufsizeint;
  1212. setlength(wstring,len);
  1213. move(tokenbuf[i],wstring[1],len*2);
  1214. write(' ',wstring);
  1215. inc(i,len*2);
  1216. end;
  1217. _CSTRING:
  1218. begin
  1219. len:=gettokenbufsizeint;
  1220. setlength(astring,len);
  1221. move(tokenbuf[i],astring[1],len);
  1222. write(' ',astring);
  1223. inc(i,len);
  1224. end;
  1225. _CCHAR,
  1226. _INTCONST,
  1227. _REALNUMBER :
  1228. begin
  1229. write(' ',pshortstring(@tokenbuf[i])^);
  1230. inc(i,tokenbuf[i]+1);
  1231. end;
  1232. _ID :
  1233. begin
  1234. write(' ',pshortstring(@tokenbuf[i])^);
  1235. inc(i,tokenbuf[i]+1);
  1236. end;
  1237. _GENERICSPECIALTOKEN:
  1238. begin
  1239. { Short version of column change,
  1240. byte or $80 used }
  1241. if (tokenbuf[i] and $80)<>0 then
  1242. begin
  1243. write('Col: ',tokenbuf[i] and $7f);
  1244. inc(i);
  1245. end
  1246. else
  1247. case tspecialgenerictoken(tokenbuf[i]) of
  1248. ST_LOADSETTINGS:
  1249. begin
  1250. inc(i);
  1251. write('Settings');
  1252. { This does not load pmessage pointer }
  1253. new_settings.pmessage:=nil;
  1254. { TSettings size depends in target...
  1255. We first read the size of the copied part }
  1256. { Still not cross endian ready :( }
  1257. copy_size:=gettokenbufsizeint;
  1258. if copy_size < sizeof(tsettings)-sizeof(pointer) then
  1259. min_size:=copy_size
  1260. else
  1261. min_size:= sizeof(tsettings)-sizeof(pointer);
  1262. move(tokenbuf[i],new_settings, min_size);
  1263. inc(i,copy_size);
  1264. end;
  1265. ST_LOADMESSAGES:
  1266. begin
  1267. inc(i);
  1268. write('Messages:');
  1269. mesgnb:=tokenbuf[i];
  1270. inc(i);
  1271. for nb:=1 to mesgnb do
  1272. begin
  1273. msgvalue:=gettokenbufsizeint;
  1274. inc(i,sizeof(sizeint));
  1275. state:=tmsgstate(gettokenbufsizeint);
  1276. end;
  1277. end;
  1278. ST_LINE:
  1279. begin
  1280. inc(i);
  1281. write('Line: ',gettokenbufdword);
  1282. end;
  1283. ST_COLUMN:
  1284. begin
  1285. inc(i);
  1286. write('Col: ',gettokenbufword);
  1287. end;
  1288. ST_FILEINDEX:
  1289. begin
  1290. inc(i);
  1291. write('File: ',gettokenbufword);
  1292. end;
  1293. end;
  1294. end;
  1295. end;
  1296. if i<tokenbufsize then
  1297. write(',');
  1298. end;
  1299. writeln;
  1300. freemem(tokenbuf);
  1301. end;
  1302. if df_specialization in defoptions then
  1303. begin
  1304. write (space,' Orig. GenericDef : ');
  1305. readderef('');
  1306. end;
  1307. current_defoptions:=defoptions;
  1308. end;
  1309. { Read abstract procdef and return if inline procdef }
  1310. { type tproccalloption is in globtype unit }
  1311. { type tproctypeoption is in globtype unit }
  1312. { type tprocoption is in globtype unit }
  1313. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions);
  1314. type
  1315. tproccallopt=record
  1316. mask : tproccalloption;
  1317. str : string[30];
  1318. end;
  1319. tproctypeopt=record
  1320. mask : tproctypeoption;
  1321. str : string[30];
  1322. end;
  1323. tprocopt=record
  1324. mask : tprocoption;
  1325. str : string[30];
  1326. end;
  1327. const
  1328. {proccalloptionStr is also in globtype unit }
  1329. proctypeopt : array[1..ord(high(tproctypeoption))] of tproctypeopt=(
  1330. (mask:potype_proginit; str:'ProgInit'),
  1331. (mask:potype_unitinit; str:'UnitInit'),
  1332. (mask:potype_unitfinalize; str:'UnitFinalize'),
  1333. (mask:potype_constructor; str:'Constructor'),
  1334. (mask:potype_destructor; str:'Destructor'),
  1335. (mask:potype_operator; str:'Operator'),
  1336. (mask:potype_procedure; str:'Procedure'),
  1337. (mask:potype_function; str:'Function'),
  1338. (mask:potype_class_constructor; str:'Class Constructor'),
  1339. (mask:potype_class_destructor; str:'Class Destructor'),
  1340. { Dispinterface property accessors }
  1341. (mask:potype_propgetter; str:'Property Getter'),
  1342. (mask:potype_propsetter; str:'Property Setter'),
  1343. (mask:potype_exceptfilter; str:'SEH filter')
  1344. );
  1345. procopt : array[1..ord(high(tprocoption))] of tprocopt=(
  1346. (mask:po_classmethod; str:'ClassMethod'),
  1347. (mask:po_virtualmethod; str:'VirtualMethod'),
  1348. (mask:po_abstractmethod; str:'AbstractMethod'),
  1349. (mask:po_finalmethod; str:'FinalMethod'),
  1350. (mask:po_staticmethod; str:'StaticMethod'),
  1351. (mask:po_overridingmethod;str:'OverridingMethod'),
  1352. (mask:po_methodpointer; str:'MethodPointer'),
  1353. (mask:po_interrupt; str:'Interrupt'),
  1354. (mask:po_iocheck; str:'IOCheck'),
  1355. (mask:po_assembler; str:'Assembler'),
  1356. (mask:po_msgstr; str:'MsgStr'),
  1357. (mask:po_msgint; str:'MsgInt'),
  1358. (mask:po_exports; str:'Exports'),
  1359. (mask:po_external; str:'External'),
  1360. (mask:po_overload; str:'Overload'),
  1361. (mask:po_varargs; str:'VarArgs'),
  1362. (mask:po_internconst; str:'InternConst'),
  1363. (mask:po_addressonly; str:'AddressOnly'),
  1364. (mask:po_public; str:'Public'),
  1365. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  1366. (mask:po_reintroduce; str:'ReIntroduce'),
  1367. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  1368. (mask:po_nostackframe; str:'NoStackFrame'),
  1369. (mask:po_has_mangledname; str:'HasMangledName'),
  1370. (mask:po_has_public_name; str:'HasPublicName'),
  1371. (mask:po_forward; str:'Forward'),
  1372. (mask:po_global; str:'Global'),
  1373. (mask:po_has_inlininginfo;str:'HasInliningInfo'),
  1374. (mask:po_syscall_legacy; str:'SyscallLegacy'),
  1375. (mask:po_syscall_sysv; str:'SyscallSysV'),
  1376. (mask:po_syscall_basesysv;str:'SyscallBaseSysV'),
  1377. (mask:po_syscall_sysvbase;str:'SyscallSysVBase'),
  1378. (mask:po_syscall_r12base; str:'SyscallR12Base'),
  1379. (mask:po_inline; str:'Inline'),
  1380. (mask:po_compilerproc; str:'CompilerProc'),
  1381. (mask:po_has_importdll; str:'HasImportDLL'),
  1382. (mask:po_has_importname; str:'HasImportName'),
  1383. (mask:po_kylixlocal; str:'KylixLocal'),
  1384. (mask:po_dispid; str:'DispId'),
  1385. (mask:po_weakexternal; str:'WeakExternal'),
  1386. (mask:po_objc; str:'ObjC'),
  1387. (mask:po_enumerator_movenext; str:'EnumeratorMoveNext'),
  1388. (mask:po_optional; str: 'Optional'),
  1389. (mask:po_delphi_nested_cc;str: 'Delphi-style nested frameptr'),
  1390. (mask:po_rtlproc; str: 'RTL procedure')
  1391. );
  1392. var
  1393. proctypeoption : tproctypeoption;
  1394. i : longint;
  1395. first : boolean;
  1396. tempbuf : array[0..255] of byte;
  1397. begin
  1398. write(space,' Return type : ');
  1399. readderef('');
  1400. writeln(space,' Fpu used : ',ppufile.getbyte);
  1401. proctypeoption:=tproctypeoption(ppufile.getbyte);
  1402. write(space,' TypeOption : ');
  1403. first:=true;
  1404. for i:=1 to high(proctypeopt) do
  1405. if (proctypeopt[i].mask=proctypeoption) then
  1406. begin
  1407. if first then
  1408. first:=false
  1409. else
  1410. write(', ');
  1411. write(proctypeopt[i].str);
  1412. end;
  1413. writeln;
  1414. proccalloption:=tproccalloption(ppufile.getbyte);
  1415. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  1416. ppufile.getnormalset(procoptions);
  1417. if procoptions<>[] then
  1418. begin
  1419. write(space,' Options : ');
  1420. first:=true;
  1421. for i:=1 to high(procopt) do
  1422. if (procopt[i].mask in procoptions) then
  1423. begin
  1424. if first then
  1425. first:=false
  1426. else
  1427. write(', ');
  1428. write(procopt[i].str);
  1429. end;
  1430. writeln;
  1431. end;
  1432. if (po_explicitparaloc in procoptions) then
  1433. begin
  1434. i:=ppufile.getbyte;
  1435. ppufile.getdata(tempbuf,i);
  1436. end;
  1437. end;
  1438. { type tvaroption is in unit symconst }
  1439. { register variable }
  1440. { type tvarregable is in unit symconst }
  1441. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions);
  1442. type
  1443. tvaropt=record
  1444. mask : tvaroption;
  1445. str : string[30];
  1446. end;
  1447. const
  1448. varopt : array[1..ord(high(tvaroption))] of tvaropt=(
  1449. (mask:vo_is_external; str:'External'),
  1450. (mask:vo_is_dll_var; str:'DLLVar'),
  1451. (mask:vo_is_thread_var; str:'ThreadVar'),
  1452. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  1453. (mask:vo_is_const; str:'Constant'),
  1454. (mask:vo_is_public; str:'Public'),
  1455. (mask:vo_is_high_para; str:'HighValue'),
  1456. (mask:vo_is_funcret; str:'Funcret'),
  1457. (mask:vo_is_self; str:'Self'),
  1458. (mask:vo_is_vmt; str:'VMT'),
  1459. (mask:vo_is_result; str:'Result'),
  1460. (mask:vo_is_parentfp; str:'ParentFP'),
  1461. (mask:vo_is_loop_counter; str:'LoopCounter'),
  1462. (mask:vo_is_hidden_para; str:'Hidden'),
  1463. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  1464. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  1465. (mask:vo_has_mangledname; str:'HasMangledName'),
  1466. (mask:vo_is_typed_const; str:'TypedConst'),
  1467. (mask:vo_is_range_check; str:'RangeCheckSwitch'),
  1468. (mask:vo_is_overflow_check; str:'OverflowCheckSwitch'),
  1469. (mask:vo_is_typinfo_para; str:'TypeInfo'),
  1470. (mask:vo_is_msgsel;str:'MsgSel'),
  1471. (mask:vo_is_weak_external;str:'WeakExternal'),
  1472. (mask:vo_is_first_field;str:'IsFirstField'),
  1473. (mask:vo_volatile;str:'Volatile'),
  1474. (mask:vo_has_section;str:'HasSection'),
  1475. (mask:vo_force_finalize;str:'ForceFinalize'),
  1476. (mask:vo_is_default_var;str:'DefaultIntrinsicVar')
  1477. );
  1478. var
  1479. i : longint;
  1480. first : boolean;
  1481. begin
  1482. readcommonsym(s);
  1483. writeln(space,' Spez : ',Varspez2Str(ppufile.getbyte));
  1484. writeln(space,' Regable : ',Varregable2Str(ppufile.getbyte));
  1485. writeln(space,' Addr Taken : ',(ppufile.getbyte<>0));
  1486. write (space,' Var Type : ');
  1487. readderef('');
  1488. ppufile.getsmallset(varoptions);
  1489. if varoptions<>[] then
  1490. begin
  1491. write(space,' Options : ');
  1492. first:=true;
  1493. for i:=1 to high(varopt) do
  1494. if (varopt[i].mask in varoptions) then
  1495. begin
  1496. if first then
  1497. first:=false
  1498. else
  1499. write(', ');
  1500. write(varopt[i].str);
  1501. if varopt[i].mask = vo_has_section then
  1502. writeln('Section name:',ppufile.getansistring);
  1503. end;
  1504. writeln;
  1505. end;
  1506. end;
  1507. procedure readobjectdefoptions;
  1508. type
  1509. tsymopt=record
  1510. mask : tobjectoption;
  1511. str : string[30];
  1512. end;
  1513. const
  1514. symopt : array[1..ord(high(tobjectoption))] of tsymopt=(
  1515. (mask:oo_is_forward; str:'IsForward'),
  1516. (mask:oo_is_abstract; str:'IsAbstract'),
  1517. (mask:oo_is_sealed; str:'IsSealed'),
  1518. (mask:oo_has_virtual; str:'HasVirtual'),
  1519. (mask:oo_has_private; str:'HasPrivate'),
  1520. (mask:oo_has_protected; str:'HasProtected'),
  1521. (mask:oo_has_strictprivate; str:'HasStrictPrivate'),
  1522. (mask:oo_has_strictprotected;str:'HasStrictProtected'),
  1523. (mask:oo_has_constructor; str:'HasConstructor'),
  1524. (mask:oo_has_destructor; str:'HasDestructor'),
  1525. (mask:oo_has_vmt; str:'HasVMT'),
  1526. (mask:oo_has_msgstr; str:'HasMsgStr'),
  1527. (mask:oo_has_msgint; str:'HasMsgInt'),
  1528. (mask:oo_can_have_published; str:'CanHavePublished'),
  1529. (mask:oo_has_default_property;str:'HasDefaultProperty'),
  1530. (mask:oo_has_valid_guid; str:'HasValidGUID'),
  1531. (mask:oo_has_enumerator_movenext; str:'HasEnumeratorMoveNext'),
  1532. (mask:oo_has_enumerator_current; str:'HasEnumeratorCurrent'),
  1533. (mask:oo_is_external; str:'External'),
  1534. (mask:oo_is_formal; str:'Formal'),
  1535. (mask:oo_is_classhelper; str:'Class Helper/Category'),
  1536. (mask:oo_has_class_constructor; str:'HasClassConstructor'),
  1537. (mask:oo_has_class_destructor; str:'HasClassDestructor')
  1538. );
  1539. var
  1540. i : longint;
  1541. first : boolean;
  1542. begin
  1543. ppufile.getsmallset(current_objectoptions);
  1544. if current_objectoptions<>[] then
  1545. begin
  1546. first:=true;
  1547. for i:=1 to high(symopt) do
  1548. if (symopt[i].mask in current_objectoptions) then
  1549. begin
  1550. if first then
  1551. first:=false
  1552. else
  1553. write(', ');
  1554. write(symopt[i].str);
  1555. end;
  1556. end;
  1557. writeln;
  1558. end;
  1559. procedure readarraydefoptions;
  1560. { type tarraydefoption is in unit symconst }
  1561. type
  1562. tsymopt=record
  1563. mask : tarraydefoption;
  1564. str : string[30];
  1565. end;
  1566. const
  1567. symopt : array[1..ord(high(tarraydefoption))] of tsymopt=(
  1568. (mask:ado_IsConvertedPointer;str:'ConvertedPointer'),
  1569. (mask:ado_IsDynamicArray; str:'IsDynamicArray'),
  1570. (mask:ado_IsVariant; str:'IsVariant'),
  1571. (mask:ado_IsConstructor; str:'IsConstructor'),
  1572. (mask:ado_IsArrayOfConst; str:'ArrayOfConst'),
  1573. (mask:ado_IsConstString; str:'ConstString'),
  1574. (mask:ado_IsBitPacked; str:'BitPacked')
  1575. );
  1576. var
  1577. symoptions : tarraydefoptions;
  1578. i : longint;
  1579. first : boolean;
  1580. begin
  1581. ppufile.getsmallset(symoptions);
  1582. if symoptions<>[] then
  1583. begin
  1584. first:=true;
  1585. for i:=1 to high(symopt) do
  1586. if (symopt[i].mask in symoptions) then
  1587. begin
  1588. if first then
  1589. first:=false
  1590. else
  1591. write(', ');
  1592. write(symopt[i].str);
  1593. end;
  1594. end;
  1595. writeln;
  1596. end;
  1597. (* options for properties
  1598. tpropertyoption=(ppo_none,
  1599. ppo_indexed,
  1600. ppo_defaultproperty,
  1601. ppo_stored,
  1602. ppo_hasparameters,
  1603. ppo_implements,
  1604. ppo_enumerator_current,
  1605. ppo_overrides,
  1606. ppo_dispid_write { no longer used }
  1607. );
  1608. tpropertyoptions=set of tpropertyoption;
  1609. *)
  1610. function readpropertyoptions:tpropertyoptions;
  1611. { type tarraydefoption is in unit symconst }
  1612. type
  1613. tpropopt=record
  1614. mask : tpropertyoption;
  1615. str : string[30];
  1616. end;
  1617. const
  1618. symopt : array[1..ord(high(tpropertyoption))] of tpropopt=(
  1619. (mask:ppo_indexed;str:'indexed'),
  1620. (mask:ppo_defaultproperty;str:'default'),
  1621. (mask:ppo_stored;str:'stored'),
  1622. (mask:ppo_hasparameters;str:'has parameters'),
  1623. (mask:ppo_implements;str:'implements'),
  1624. (mask:ppo_enumerator_current;str:'enumerator current'),
  1625. (mask:ppo_overrides;str:'overrides'),
  1626. (mask:ppo_dispid_write;str:'dispid write') { no longer used }
  1627. );
  1628. var
  1629. i : longint;
  1630. first : boolean;
  1631. begin
  1632. ppufile.getsmallset(result);
  1633. if result<>[] then
  1634. begin
  1635. first:=true;
  1636. for i:=1 to high(symopt) do
  1637. if (symopt[i].mask in result) then
  1638. begin
  1639. if first then
  1640. first:=false
  1641. else
  1642. write(', ');
  1643. write(symopt[i].str);
  1644. end;
  1645. end;
  1646. writeln;
  1647. end;
  1648. procedure readnodetree;
  1649. var
  1650. l : longint;
  1651. p : pointer;
  1652. begin
  1653. with ppufile do
  1654. begin
  1655. if space<>'' then
  1656. Writeln(space,'------ nodetree ------');
  1657. if readentry=ibnodetree then
  1658. begin
  1659. l:=entrysize;
  1660. Writeln(space,'Tree size : ',l);
  1661. { Read data to prevent error that entry is not completly read }
  1662. getmem(p,l);
  1663. getdata(p^,l);
  1664. freemem(p);
  1665. end
  1666. else
  1667. begin
  1668. WriteError('!! ibnodetree not found');
  1669. end;
  1670. end;
  1671. end;
  1672. procedure ReadCreatedObjTypes;
  1673. var
  1674. i,j,
  1675. len,
  1676. bssize: longint;
  1677. bs: pbyte;
  1678. begin
  1679. if ppufile.readentry<>ibcreatedobjtypes then
  1680. begin
  1681. writeln('!! ibcreatedobjtypes entry not found');
  1682. ppufile.skipdata(ppufile.entrysize);
  1683. has_errors:=true;
  1684. exit
  1685. end;
  1686. writeln;
  1687. writeln(space,'WPO info');
  1688. writeln(space,'--------');
  1689. len:=ppufile.getlongint;
  1690. writeln(space,'** Instantiated Object/Class types: ',len,' **');
  1691. space:=space+' ';
  1692. for i:=0 to len-1 do
  1693. readderef(space);
  1694. setlength(space,length(space)-2);
  1695. len:=ppufile.getlongint;
  1696. writeln(space,'** Instantiated ClassRef types: ',len,' **');
  1697. space:=space+' ';
  1698. for i:=0 to len-1 do
  1699. readderef(space);
  1700. setlength(space,length(space)-2);
  1701. len:=ppufile.getlongint;
  1702. writeln(space,'** Possibly instantiated ClassRef types : ',len,' **');
  1703. space:=space+' ';
  1704. for i:=0 to len-1 do
  1705. readderef(space);
  1706. setlength(space,length(space)-2);
  1707. len:=ppufile.getlongint;
  1708. writeln(space,'** Class types with called virtual methods info : ',len,' **');
  1709. space:=space+' ';
  1710. for i:=0 to len-1 do
  1711. begin
  1712. write(space,'Class def : ');
  1713. readderef('');
  1714. write(space+' ','Called vmtentries : ');
  1715. bssize:=ppufile.getlongint;
  1716. getmem(bs,bssize);
  1717. ppufile.readdata(bs^,bssize);
  1718. for j:=0 to bssize*8-1 do
  1719. if (((bs+j shr 3)^ shr (j and 7)) and 1) <> 0 then
  1720. write(j,', ');
  1721. writeln;
  1722. freemem(bs);
  1723. end;
  1724. setlength(space,length(space)-2);
  1725. end;
  1726. {****************************************************************************
  1727. Read Symbols Part
  1728. ****************************************************************************}
  1729. procedure readsymbols(const s:string);
  1730. type
  1731. pguid = ^tguid;
  1732. tguid = packed record
  1733. D1: LongWord;
  1734. D2: Word;
  1735. D3: Word;
  1736. D4: array[0..7] of Byte;
  1737. end;
  1738. var
  1739. b : byte;
  1740. pc : pchar;
  1741. ch : dword;
  1742. startnewline : boolean;
  1743. i,j,len : longint;
  1744. prettyname : ansistring;
  1745. guid : tguid;
  1746. realvalue : ppureal;
  1747. doublevalue : double;
  1748. singlevalue : single;
  1749. extended : TSplit80bitReal;
  1750. tempbuf : array[0..127] of char;
  1751. pw : pcompilerwidestring;
  1752. varoptions : tvaroptions;
  1753. propoptions : tpropertyoptions;
  1754. begin
  1755. with ppufile do
  1756. begin
  1757. if space<>'' then
  1758. Writeln(space,'------ ',s,' ------');
  1759. if readentry=ibstartsyms then
  1760. begin
  1761. Writeln(space,'Symtable datasize : ',getlongint);
  1762. Writeln(space,'Symtable alignment: ',getlongint);
  1763. end
  1764. else
  1765. Writeln('!! ibstartsym not found');
  1766. repeat
  1767. b:=readentry;
  1768. case b of
  1769. ibunitsym :
  1770. readcommonsym('Unit symbol ');
  1771. ibnamespacesym :
  1772. begin
  1773. readcommonsym('NameSpace symbol ');
  1774. write(space,' Hidden Unit : ');
  1775. readderef('');
  1776. end;
  1777. iblabelsym :
  1778. readcommonsym('Label symbol ');
  1779. ibtypesym :
  1780. begin
  1781. readcommonsym('Type symbol ');
  1782. write(space,' Result Type : ');
  1783. readderef('');
  1784. prettyname:=getansistring;
  1785. if prettyname<>'' then
  1786. begin
  1787. write(space,' Pretty Name : ');
  1788. Writeln(prettyname);
  1789. end;
  1790. end;
  1791. ibprocsym :
  1792. begin
  1793. readcommonsym('Procedure symbol ');
  1794. len:=ppufile.getword;
  1795. for i:=1 to len do
  1796. begin
  1797. write(space,' Definition : ');
  1798. readderef('');
  1799. end;
  1800. end;
  1801. ibconstsym :
  1802. begin
  1803. readcommonsym('Constant symbol ');
  1804. b:=getbyte;
  1805. case tconsttyp(b) of
  1806. constord :
  1807. begin
  1808. write (space,' OrdinalType : ');
  1809. readderef('');
  1810. writeln(space,' Value : ',constexp.tostr(getexprint));
  1811. end;
  1812. constpointer :
  1813. begin
  1814. write (space,' PointerType : ');
  1815. readderef('');
  1816. writeln(space,' Value : ',getaint)
  1817. end;
  1818. conststring,
  1819. constresourcestring :
  1820. begin
  1821. len:=getlongint;
  1822. getmem(pc,len+1);
  1823. getdata(pc^,len);
  1824. (pc+len)^:= #0;
  1825. writeln(space,' Length : ',len);
  1826. writeln(space,' Value : "',pc,'"');
  1827. freemem(pc,len+1);
  1828. end;
  1829. constreal :
  1830. begin
  1831. write(space,' Value : ');
  1832. if entryleft=sizeof(ppureal) then
  1833. begin
  1834. realvalue:=getrealsize(sizeof(ppureal));
  1835. writeln(realvalue);
  1836. end
  1837. else if entryleft=sizeof(double) then
  1838. begin
  1839. doublevalue:=getrealsize(sizeof(double));
  1840. writeln(doublevalue);
  1841. end
  1842. else if entryleft=sizeof(single) then
  1843. begin
  1844. singlevalue:=getrealsize(sizeof(single));
  1845. writeln(singlevalue);
  1846. end
  1847. else if entryleft=10 then
  1848. begin
  1849. getdata(extended,entryleft);
  1850. writeln(Real80bitToStr(extended));
  1851. end
  1852. else
  1853. begin
  1854. realvalue:=0.0;
  1855. writeln(realvalue,' Error reading real value');
  1856. has_errors:=true;
  1857. end;
  1858. end;
  1859. constset :
  1860. begin
  1861. write (space,' Set Type : ');
  1862. readderef('');
  1863. for i:=1to 4 do
  1864. begin
  1865. write (space,' Value : ');
  1866. for j:=1to 8 do
  1867. begin
  1868. if j>1 then
  1869. write(',');
  1870. write(hexstr(getbyte,2));
  1871. end;
  1872. writeln;
  1873. end;
  1874. end;
  1875. constnil:
  1876. writeln(space,' NIL pointer.');
  1877. constwstring :
  1878. begin
  1879. initwidestring(pw);
  1880. setlengthwidestring(pw,getlongint);
  1881. if widecharsize=2 then
  1882. { don't use getdata, because the compilerwidechars may have to
  1883. be byteswapped
  1884. }
  1885. begin
  1886. for i:=0 to pw^.len-1 do
  1887. pw^.data[i]:=ppufile.getword;
  1888. end
  1889. else if widecharsize=4 then
  1890. begin
  1891. for i:=0 to pw^.len-1 do
  1892. pw^.data[i]:=cardinal(ppufile.getlongint);
  1893. end
  1894. else
  1895. begin
  1896. WriteError('Unsupported tcompilerwidechar size');
  1897. end;
  1898. Writeln(space,'Wide string type');
  1899. startnewline:=true;
  1900. for i:=0 to pw^.len-1 do
  1901. begin
  1902. if startnewline then
  1903. begin
  1904. write(space);
  1905. startnewline:=false;
  1906. end;
  1907. ch:=pw^.data[i];
  1908. if widecharsize=2 then
  1909. write(hexstr(ch,4))
  1910. else
  1911. write(hexstr(ch,8));
  1912. if (i mod 8)= 0 then
  1913. startnewline:=true
  1914. else
  1915. write(', ');
  1916. end;
  1917. donewidestring(pw);
  1918. end;
  1919. constguid:
  1920. begin
  1921. getdata(guid,sizeof(guid));
  1922. write (space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-');
  1923. for i:=0 to 7 do
  1924. begin
  1925. write(hexstr(guid.d4[i],2));
  1926. if i=1 then write('-');
  1927. end;
  1928. writeln('}');
  1929. end
  1930. else
  1931. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  1932. end;
  1933. end;
  1934. ibabsolutevarsym :
  1935. begin
  1936. readabstractvarsym('Absolute variable symbol ',varoptions);
  1937. Write (space,' Relocated to ');
  1938. b:=getbyte;
  1939. case absolutetyp(b) of
  1940. tovar :
  1941. readpropaccesslist(space+' Sym : ');
  1942. toasm :
  1943. Writeln('Assembler name : ',getstring);
  1944. toaddr :
  1945. begin
  1946. Write('Address : ',getlongint);
  1947. if tsystemcpu(ppufile.header.cpu)=cpu_i386 then
  1948. WriteLn(' (Far: ',getbyte<>0,')');
  1949. end;
  1950. else
  1951. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  1952. end;
  1953. end;
  1954. ibfieldvarsym :
  1955. begin
  1956. readabstractvarsym('Field Variable symbol ',varoptions);
  1957. writeln(space,' Address : ',getaint);
  1958. end;
  1959. ibstaticvarsym :
  1960. begin
  1961. readabstractvarsym('Global Variable symbol ',varoptions);
  1962. write (space,' DefaultConst : ');
  1963. readderef('');
  1964. if (vo_has_mangledname in varoptions) then
  1965. writeln(space,' Mangledname : ',getstring);
  1966. end;
  1967. iblocalvarsym :
  1968. begin
  1969. readabstractvarsym('Local Variable symbol ',varoptions);
  1970. write (space,' DefaultConst : ');
  1971. readderef('');
  1972. end;
  1973. ibparavarsym :
  1974. begin
  1975. readabstractvarsym('Parameter Variable symbol ',varoptions);
  1976. write (space,' DefaultConst : ');
  1977. readderef('');
  1978. writeln(space,' ParaNr : ',getword);
  1979. writeln(space,' Univ : ',boolean(getbyte));
  1980. writeln(space,' VarState : ',getbyte);
  1981. if (vo_has_explicit_paraloc in varoptions) then
  1982. begin
  1983. i:=getbyte;
  1984. getdata(tempbuf,i);
  1985. end;
  1986. end;
  1987. ibenumsym :
  1988. begin
  1989. readcommonsym('Enumeration symbol ');
  1990. write (space,' Definition : ');
  1991. readderef('');
  1992. writeln(space,' Value : ',getlongint);
  1993. end;
  1994. ibsyssym :
  1995. begin
  1996. readcommonsym('Internal system symbol ');
  1997. writeln(space,' Internal Nr : ',getlongint);
  1998. end;
  1999. ibmacrosym :
  2000. begin
  2001. readcommonsym('Macro symbol ');
  2002. writeln(space,' Name: ',getstring);
  2003. writeln(space,' Defined: ',getbyte);
  2004. writeln(space,' Compiler var: ',getbyte);
  2005. len:=getlongint;
  2006. writeln(space,' Value length: ',len);
  2007. if len > 0 then
  2008. begin
  2009. getmem(pc,len+1);
  2010. getdata(pc^,len);
  2011. (pc+len)^:= #0;
  2012. writeln(space,' Value: "',pc,'"');
  2013. freemem(pc,len+1);
  2014. end;
  2015. end;
  2016. ibpropertysym :
  2017. begin
  2018. readcommonsym('Property ');
  2019. propoptions:=readpropertyoptions;
  2020. if ppo_overrides in propoptions then
  2021. begin
  2022. write (space,' OverrideProp : ');
  2023. readderef('');
  2024. end;
  2025. write (space,' Prop Type : ');
  2026. readderef('');
  2027. writeln(space,' Index : ',getlongint);
  2028. writeln(space,' Default : ',getlongint);
  2029. write (space,' Index Type : ');
  2030. readderef('');
  2031. { palt_none }
  2032. readpropaccesslist('');
  2033. write (space,' Readaccess : ');
  2034. readpropaccesslist(space+' Sym: ');
  2035. write (space,' Writeaccess : ');
  2036. readpropaccesslist(space+' Sym: ');
  2037. write (space,' Storedaccess : ');
  2038. readpropaccesslist(space+' Sym: ');
  2039. if [ppo_hasparameters,ppo_overrides]*propoptions=[ppo_hasparameters] then
  2040. begin
  2041. space:=' '+space;
  2042. readsymtable('parast');
  2043. delete(space,1,4);
  2044. end;
  2045. end;
  2046. iberror :
  2047. begin
  2048. WriteError('!! Error in PPU');
  2049. exit;
  2050. end;
  2051. ibendsyms :
  2052. break;
  2053. else
  2054. begin
  2055. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  2056. has_errors:=true;
  2057. end;
  2058. end;
  2059. if not EndOfEntry then
  2060. HasMoreInfos;
  2061. until false;
  2062. end;
  2063. end;
  2064. {****************************************************************************
  2065. Read defintions Part
  2066. ****************************************************************************}
  2067. procedure readdefinitions(const s:string);
  2068. { type tordtype is in symconst unit }
  2069. {
  2070. uvoid,
  2071. u8bit,u16bit,u32bit,u64bit,
  2072. s8bit,s16bit,s32bit,s64bit,
  2073. bool8bit,bool16bit,bool32bit,bool64bit,
  2074. uchar,uwidechar,scurrency
  2075. ); }
  2076. { type tobjecttyp is in symconst unit }
  2077. { type tvarianttype is in symconst unit }
  2078. var
  2079. b : byte;
  2080. l,j : longint;
  2081. calloption : tproccalloption;
  2082. procoptions : tprocoptions;
  2083. defoptions: tdefoptions;
  2084. begin
  2085. with ppufile do
  2086. begin
  2087. if space<>'' then
  2088. Writeln(space,'------ ',s,' ------');
  2089. if readentry<>ibstartdefs then
  2090. Writeln('!! ibstartdefs not found');
  2091. repeat
  2092. b:=readentry;
  2093. case b of
  2094. ibpointerdef :
  2095. begin
  2096. readcommondef('Pointer definition',defoptions);
  2097. write (space,' Pointed Type : ');
  2098. readderef('');
  2099. writeln(space,' Is Far : ',(getbyte<>0));
  2100. writeln(space,' Has Pointer Math : ',(getbyte<>0));
  2101. end;
  2102. iborddef :
  2103. begin
  2104. readcommondef('Ordinal definition',defoptions);
  2105. write (space,' Base type : ');
  2106. b:=getbyte;
  2107. case tordtype(b) of
  2108. uvoid : writeln('uvoid');
  2109. u8bit : writeln('u8bit');
  2110. u16bit : writeln('u16bit');
  2111. u32bit : writeln('s32bit');
  2112. u64bit : writeln('u64bit');
  2113. s8bit : writeln('s8bit');
  2114. s16bit : writeln('s16bit');
  2115. s32bit : writeln('s32bit');
  2116. s64bit : writeln('s64bit');
  2117. bool8bit : writeln('bool8bit');
  2118. bool16bit : writeln('bool16bit');
  2119. bool32bit : writeln('bool32bit');
  2120. bool64bit : writeln('bool64bit');
  2121. uchar : writeln('uchar');
  2122. uwidechar : writeln('uwidechar');
  2123. scurrency : writeln('ucurrency');
  2124. else writeln('!! Warning: Invalid base type ',b);
  2125. end;
  2126. writeln(space,' Range : ',constexp.tostr(getexprint),' to ',constexp.tostr(getexprint));
  2127. end;
  2128. ibfloatdef :
  2129. begin
  2130. readcommondef('Float definition',defoptions);
  2131. writeln(space,' Float type : ',getbyte);
  2132. end;
  2133. ibarraydef :
  2134. begin
  2135. readcommondef('Array definition',defoptions);
  2136. write (space,' Element type : ');
  2137. readderef('');
  2138. write (space,' Range Type : ');
  2139. readderef('');
  2140. writeln(space,' Range : ',getaint,' to ',getaint);
  2141. write (space,' Options : ');
  2142. readarraydefoptions;
  2143. readsymtable('symbols');
  2144. end;
  2145. ibprocdef :
  2146. begin
  2147. readcommondef('Procedure definition',defoptions);
  2148. read_abstract_proc_def(calloption,procoptions);
  2149. if (po_has_mangledname in procoptions) then
  2150. writeln(space,' Mangled name : ',getstring);
  2151. writeln(space,' Number : ',getword);
  2152. writeln(space,' Level : ',getbyte);
  2153. write (space,' Class : ');
  2154. readderef('');
  2155. write (space,' Procsym : ');
  2156. readderef('');
  2157. write (space,' File Pos : ');
  2158. readposinfo;
  2159. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  2160. write (space,' SymOptions : ');
  2161. readsymoptions(space+' ');
  2162. if tsystemcpu(ppufile.header.cpu)=cpu_powerpc then
  2163. begin
  2164. { library symbol for AmigaOS/MorphOS }
  2165. write (space,' Library symbol : ');
  2166. readderef('');
  2167. end;
  2168. if (po_has_importdll in procoptions) then
  2169. writeln(space,' Import DLL : ',getstring);
  2170. if (po_has_importname in procoptions) then
  2171. writeln(space,' Import Name : ',getstring);
  2172. writeln(space,' Import Nr : ',getword);
  2173. if (po_msgint in procoptions) then
  2174. writeln(space,' MsgInt : ',getlongint);
  2175. if (po_msgstr in procoptions) then
  2176. writeln(space,' MsgStr : ',getstring);
  2177. if (po_dispid in procoptions) then
  2178. writeln(space,' DispID: ',ppufile.getlongint);
  2179. if (po_has_inlininginfo in procoptions) then
  2180. begin
  2181. write (space,' FuncretSym : ');
  2182. readderef('');
  2183. readprocinfooptions(space);
  2184. end;
  2185. b:=ppufile.getbyte;
  2186. if b<>0 then
  2187. begin
  2188. write (space,' Alias names : ');
  2189. for j:=1 to b do
  2190. begin
  2191. write(ppufile.getstring);
  2192. if j<b then
  2193. write(', ');
  2194. end;
  2195. writeln;
  2196. end;
  2197. if not EndOfEntry then
  2198. HasMoreInfos;
  2199. space:=' '+space;
  2200. { parast }
  2201. readsymtable('parast');
  2202. { localst }
  2203. if (po_has_inlininginfo in procoptions) then
  2204. readsymtable('localst');
  2205. if (po_has_inlininginfo in procoptions) then
  2206. readnodetree;
  2207. delete(space,1,4);
  2208. end;
  2209. ibprocvardef :
  2210. begin
  2211. readcommondef('Procedural type (ProcVar) definition',defoptions);
  2212. read_abstract_proc_def(calloption,procoptions);
  2213. writeln(space,' Symtable level :',ppufile.getbyte);
  2214. if not EndOfEntry then
  2215. HasMoreInfos;
  2216. space:=' '+space;
  2217. { parast }
  2218. readsymtable('parast');
  2219. delete(space,1,4);
  2220. end;
  2221. ibshortstringdef :
  2222. begin
  2223. readcommondef('ShortString definition',defoptions);
  2224. writeln(space,' Length : ',getbyte);
  2225. end;
  2226. ibwidestringdef :
  2227. begin
  2228. readcommondef('WideString definition',defoptions);
  2229. writeln(space,' Length : ',getaint);
  2230. end;
  2231. ibunicodestringdef :
  2232. begin
  2233. readcommondef('UnicodeString definition',defoptions);
  2234. writeln(space,' Length : ',getaint);
  2235. end;
  2236. ibansistringdef :
  2237. begin
  2238. readcommondef('AnsiString definition',defoptions);
  2239. writeln(space,' Length : ',getaint);
  2240. end;
  2241. iblongstringdef :
  2242. begin
  2243. readcommondef('Longstring definition',defoptions);
  2244. writeln(space,' Length : ',getaint);
  2245. end;
  2246. ibrecorddef :
  2247. begin
  2248. readcommondef('Record definition',defoptions);
  2249. writeln(space,' Name of Record : ',getstring);
  2250. write (space,' Options : ');
  2251. readobjectdefoptions;
  2252. writeln(space,' FieldAlign : ',shortint(getbyte));
  2253. writeln(space,' RecordAlign : ',shortint(getbyte));
  2254. writeln(space,' PadAlign : ',shortint(getbyte));
  2255. writeln(space,'UseFieldAlignment : ',shortint(getbyte));
  2256. writeln(space,' DataSize : ',getasizeint);
  2257. writeln(space,' PaddingSize : ',getword);
  2258. if df_copied_def in current_defoptions then
  2259. begin
  2260. writeln(' Copy of def: ');
  2261. readderef('');
  2262. end;
  2263. if not EndOfEntry then
  2264. HasMoreInfos;
  2265. {read the record definitions and symbols}
  2266. if not(df_copied_def in current_defoptions) then
  2267. begin
  2268. space:=' '+space;
  2269. readrecsymtableoptions;
  2270. readsymtable('fields');
  2271. Delete(space,1,4);
  2272. end;
  2273. end;
  2274. ibobjectdef :
  2275. begin
  2276. readcommondef('Object/Class definition',defoptions);
  2277. writeln(space,' Name of Class : ',getstring);
  2278. write (space,' Options : ');
  2279. readobjectdefoptions;
  2280. b:=getbyte;
  2281. write (space,' Type : ');
  2282. case tobjecttyp(b) of
  2283. odt_class : writeln('class');
  2284. odt_object : writeln('object');
  2285. odt_interfacecom : writeln('interfacecom');
  2286. odt_interfacecorba : writeln('interfacecorba');
  2287. odt_cppclass : writeln('cppclass');
  2288. odt_dispinterface : writeln('dispinterface');
  2289. odt_objcclass : writeln('objcclass');
  2290. odt_objcprotocol : writeln('objcprotocol');
  2291. odt_helper : writeln('helper');
  2292. else writeln('!! Warning: Invalid object type ',b);
  2293. end;
  2294. writeln(space,' External name : ',getstring);
  2295. writeln(space,' Import lib : ',getstring);
  2296. writeln(space,' DataSize : ',getasizeint);
  2297. writeln(space,' PaddingSize : ',getword);
  2298. writeln(space,' FieldAlign : ',shortint(getbyte));
  2299. writeln(space,' RecordAlign : ',shortint(getbyte));
  2300. writeln(space,' Vmt offset : ',getlongint);
  2301. write (space, ' Ancestor Class : ');
  2302. readderef('');
  2303. if tobjecttyp(b) in [odt_interfacecom,odt_interfacecorba,odt_dispinterface] then
  2304. begin
  2305. { IIDGUID }
  2306. for j:=1to 16 do
  2307. getbyte;
  2308. writeln(space,' IID String : ',getstring);
  2309. end;
  2310. if (tobjecttyp(b)=odt_helper) or
  2311. (oo_is_classhelper in current_objectoptions) then
  2312. begin
  2313. write(space,' Helper parent : ');
  2314. readderef('');
  2315. end;
  2316. l:=getlongint;
  2317. writeln(space,' VMT entries: ',l);
  2318. for j:=1 to l do
  2319. begin
  2320. write(space,' ');
  2321. readderef('');
  2322. writeln(space,' Visibility: ',Visibility2Str(getbyte));
  2323. end;
  2324. if tobjecttyp(b) in [odt_class,odt_interfacecorba,odt_objcclass,odt_objcprotocol] then
  2325. begin
  2326. l:=getlongint;
  2327. writeln(space,' Impl Intf Count : ',l);
  2328. for j:=1 to l do
  2329. begin
  2330. write (space,' - Definition : ');
  2331. readderef('');
  2332. writeln(space,' IOffset : ',getlongint);
  2333. end;
  2334. end;
  2335. if df_copied_def in current_defoptions then
  2336. begin
  2337. writeln(' Copy of def: ');
  2338. readderef('');
  2339. end;
  2340. if not EndOfEntry then
  2341. HasMoreInfos;
  2342. if not(df_copied_def in current_defoptions) then
  2343. begin
  2344. {read the record definitions and symbols}
  2345. space:=' '+space;
  2346. readrecsymtableoptions;
  2347. readsymtable('fields');
  2348. Delete(space,1,4);
  2349. end;
  2350. end;
  2351. ibfiledef :
  2352. begin
  2353. ReadCommonDef('File definition',defoptions);
  2354. write (space,' Type : ');
  2355. case getbyte of
  2356. 0 : writeln('Text');
  2357. 1 : begin
  2358. writeln('Typed');
  2359. write (space,' File of Type : ');
  2360. readderef('');
  2361. end;
  2362. 2 : writeln('Untyped');
  2363. end;
  2364. end;
  2365. ibformaldef :
  2366. begin
  2367. readcommondef('Generic definition (void-typ)',defoptions);
  2368. writeln(space,' Is Typed : ',(getbyte<>0));
  2369. end;
  2370. ibundefineddef :
  2371. readcommondef('Undefined definition (generic parameter)',defoptions);
  2372. ibenumdef :
  2373. begin
  2374. readcommondef('Enumeration type definition',defoptions);
  2375. writeln(space,' Smallest element : ',getaint);
  2376. writeln(space,' Largest element : ',getaint);
  2377. writeln(space,' Size : ',getaint);
  2378. if df_copied_def in defoptions then
  2379. begin
  2380. write(space,'Base enumeration type : ');
  2381. readderef('');
  2382. end
  2383. else
  2384. begin
  2385. space:=' '+space;
  2386. readsymtable('elements');
  2387. delete(space,1,4);
  2388. end;
  2389. end;
  2390. ibclassrefdef :
  2391. begin
  2392. readcommondef('Class reference definition',defoptions);
  2393. write (space,' Pointed Type : ');
  2394. readderef('');
  2395. end;
  2396. ibsetdef :
  2397. begin
  2398. readcommondef('Set definition',defoptions);
  2399. write (space,' Element type : ');
  2400. readderef('');
  2401. writeln(space,' Size : ',getaint);
  2402. writeln(space,' Set Base : ',getaint);
  2403. writeln(space,' Set Max : ',getaint);
  2404. end;
  2405. ibvariantdef :
  2406. begin
  2407. readcommondef('Variant definition',defoptions);
  2408. write (space,' Varianttype : ');
  2409. b:=getbyte;
  2410. case tvarianttype(b) of
  2411. vt_normalvariant :
  2412. writeln('Normal');
  2413. vt_olevariant :
  2414. writeln('OLE');
  2415. else
  2416. writeln('!! Warning: Invalid varianttype ',b);
  2417. end;
  2418. end;
  2419. iberror :
  2420. begin
  2421. WriteError('!! Error in PPU');
  2422. exit;
  2423. end;
  2424. ibenddefs :
  2425. break;
  2426. else
  2427. begin
  2428. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  2429. has_errors:=true;
  2430. end;
  2431. end;
  2432. if not EndOfEntry then
  2433. HasMoreInfos;
  2434. until false;
  2435. end;
  2436. end;
  2437. procedure readmoduleoptions(space : string);
  2438. type
  2439. { tmoduleoption type is in unit fmodule }
  2440. tmoduleoption = (mo_none,
  2441. mo_hint_deprecated,
  2442. mo_hint_platform,
  2443. mo_hint_library,
  2444. mo_hint_unimplemented,
  2445. mo_hint_experimental,
  2446. mo_has_deprecated_msg
  2447. );
  2448. tmoduleoptions = set of tmoduleoption;
  2449. tmoduleopt=record
  2450. mask : tmoduleoption;
  2451. str : string[30];
  2452. end;
  2453. const
  2454. moduleopts=ord(high(tmoduleoption));
  2455. moduleopt : array[1..moduleopts] of tmoduleopt=(
  2456. (mask:mo_hint_deprecated; str:'Hint Deprecated'),
  2457. (mask:mo_hint_platform; str:'Hint Platform'),
  2458. (mask:mo_hint_library; str:'Hint Library'),
  2459. (mask:mo_hint_unimplemented; str:'Hint Unimplemented'),
  2460. (mask:mo_hint_experimental; str:'Hint Experimental'),
  2461. (mask:mo_has_deprecated_msg; str:'Has Deprecated Message')
  2462. );
  2463. var
  2464. moduleoptions : tmoduleoptions;
  2465. i : longint;
  2466. first : boolean;
  2467. begin
  2468. ppufile.getsmallset(moduleoptions);
  2469. if moduleoptions<>[] then
  2470. begin
  2471. first:=true;
  2472. for i:=1to moduleopts do
  2473. if (moduleopt[i].mask in moduleoptions) then
  2474. begin
  2475. if first then
  2476. first:=false
  2477. else
  2478. write(', ');
  2479. write(moduleopt[i].str);
  2480. end;
  2481. end;
  2482. writeln;
  2483. if mo_has_deprecated_msg in moduleoptions then
  2484. writeln(space,'Deprecated : ', ppufile.getstring);
  2485. end;
  2486. {****************************************************************************
  2487. Read General Part
  2488. ****************************************************************************}
  2489. procedure readinterface;
  2490. var
  2491. b : byte;
  2492. sourcenumber : longint;
  2493. begin
  2494. with ppufile do
  2495. begin
  2496. repeat
  2497. b:=readentry;
  2498. case b of
  2499. ibmodulename :
  2500. Writeln('Module Name: ',getstring);
  2501. ibmoduleoptions:
  2502. readmoduleoptions(' ');
  2503. ibsourcefiles :
  2504. begin
  2505. sourcenumber:=1;
  2506. while not EndOfEntry do
  2507. begin
  2508. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  2509. inc(sourcenumber);
  2510. end;
  2511. end;
  2512. {$IFDEF MACRO_DIFF_HINT}
  2513. ibusedmacros :
  2514. begin
  2515. while not EndOfEntry do
  2516. begin
  2517. Write('Conditional ',getstring);
  2518. b:=getbyte;
  2519. if boolean(b)=true then
  2520. write(' defined at startup')
  2521. else
  2522. write(' not defined at startup');
  2523. b:=getbyte;
  2524. if boolean(b)=true then
  2525. writeln(' was used')
  2526. else
  2527. writeln;
  2528. end;
  2529. end;
  2530. {$ENDIF}
  2531. ibloadunit :
  2532. ReadLoadUnit;
  2533. iblinkunitofiles :
  2534. ReadLinkContainer('Link unit object file: ');
  2535. iblinkunitstaticlibs :
  2536. ReadLinkContainer('Link unit static lib: ');
  2537. iblinkunitsharedlibs :
  2538. ReadLinkContainer('Link unit shared lib: ');
  2539. iblinkotherofiles :
  2540. ReadLinkContainer('Link other object file: ');
  2541. iblinkotherstaticlibs :
  2542. ReadLinkContainer('Link other static lib: ');
  2543. iblinkothersharedlibs :
  2544. ReadLinkContainer('Link other shared lib: ');
  2545. iblinkotherframeworks:
  2546. ReadLinkContainer('Link framework: ');
  2547. ibmainname:
  2548. Writeln('Specified main program symbol name: ',getstring);
  2549. ibImportSymbols :
  2550. ReadImportSymbols;
  2551. ibderefdata :
  2552. ReadDerefData;
  2553. ibderefmap :
  2554. ReadDerefMap;
  2555. ibwpofile :
  2556. ReadWpoFileInfo;
  2557. ibresources :
  2558. ReadLinkContainer('Resource file: ');
  2559. iberror :
  2560. begin
  2561. WriteError('Error in PPU');
  2562. exit;
  2563. end;
  2564. ibendinterface :
  2565. break;
  2566. else
  2567. begin
  2568. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  2569. has_errors:=true;
  2570. end;
  2571. end;
  2572. until false;
  2573. end;
  2574. end;
  2575. {****************************************************************************
  2576. Read Implementation Part
  2577. ****************************************************************************}
  2578. procedure readimplementation;
  2579. var
  2580. b : byte;
  2581. begin
  2582. with ppufile do
  2583. begin
  2584. repeat
  2585. b:=readentry;
  2586. case b of
  2587. ibasmsymbols :
  2588. ReadAsmSymbols;
  2589. ibloadunit :
  2590. ReadLoadUnit;
  2591. iberror :
  2592. begin
  2593. WriteError('Error in PPU');
  2594. exit;
  2595. end;
  2596. ibendimplementation :
  2597. break;
  2598. else
  2599. begin
  2600. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  2601. has_errors:=true;
  2602. end;
  2603. end;
  2604. until false;
  2605. end;
  2606. end;
  2607. procedure dofile (filename : string);
  2608. begin
  2609. { reset }
  2610. space:='';
  2611. { fix filename }
  2612. if pos('.',filename)=0 then
  2613. filename:=filename+'.ppu';
  2614. ppufile:=tppufile.create(filename);
  2615. if not ppufile.openfile then
  2616. begin
  2617. WriteError('IO-Error when opening : '+filename+', Skipping');
  2618. exit;
  2619. end;
  2620. { PPU File is open, check for PPU Id }
  2621. if not ppufile.CheckPPUID then
  2622. begin
  2623. writeln(Filename,' : Not a valid PPU file, Skipping');
  2624. has_errors:=true;
  2625. exit;
  2626. end;
  2627. { Check PPU Version }
  2628. ppuversion:=ppufile.GetPPUVersion;
  2629. Writeln('Analyzing ',filename,' (v',PPUVersion,')');
  2630. if PPUVersion<16 then
  2631. begin
  2632. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  2633. has_errors:=true;
  2634. exit;
  2635. end;
  2636. { Write PPU Header Information }
  2637. if (verbose and v_header)<>0 then
  2638. begin
  2639. Writeln;
  2640. Writeln('Header');
  2641. Writeln('-------');
  2642. with ppufile.header do
  2643. begin
  2644. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  2645. (ppufile.header.compiler shr 7) and $7f,'.',
  2646. ppufile.header.compiler and $7f);
  2647. WriteLn('Target processor : ',Cpu2Str(cpu));
  2648. WriteLn('Target operating system : ',Target2Str(target));
  2649. Writeln('Unit flags : ',PPUFlags2Str(flags));
  2650. Writeln('FileSize (w/o header) : ',size);
  2651. Writeln('Checksum : ',hexstr(checksum,8));
  2652. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  2653. Writeln('Indirect Checksum : ',hexstr(indirect_checksum,8));
  2654. Writeln('Definitions stored : ',tostr(deflistsize));
  2655. Writeln('Symbols stored : ',tostr(symlistsize));
  2656. end;
  2657. end;
  2658. {read the general stuff}
  2659. if (verbose and v_interface)<>0 then
  2660. begin
  2661. Writeln;
  2662. Writeln('Interface section');
  2663. Writeln('------------------');
  2664. readinterface;
  2665. end
  2666. else
  2667. ppufile.skipuntilentry(ibendinterface);
  2668. Writeln;
  2669. Writeln('Interface symtable');
  2670. Writeln('----------------------');
  2671. readsymtableoptions('interface');
  2672. {read the definitions}
  2673. if (verbose and v_defs)<>0 then
  2674. begin
  2675. Writeln;
  2676. Writeln('Interface definitions');
  2677. Writeln('----------------------');
  2678. readdefinitions('interface');
  2679. end
  2680. else
  2681. ppufile.skipuntilentry(ibenddefs);
  2682. {read the symbols}
  2683. if (verbose and v_syms)<>0 then
  2684. begin
  2685. Writeln;
  2686. Writeln('Interface Symbols');
  2687. Writeln('------------------');
  2688. readsymbols('interface');
  2689. end
  2690. else
  2691. ppufile.skipuntilentry(ibendsyms);
  2692. {read the macro symbols}
  2693. if (verbose and v_syms)<>0 then
  2694. begin
  2695. Writeln;
  2696. Writeln('Interface Macro Symbols');
  2697. Writeln('-----------------------');
  2698. end;
  2699. if ppufile.readentry<>ibexportedmacros then
  2700. begin
  2701. WriteError('!! Error in PPU');
  2702. exit;
  2703. end;
  2704. if boolean(ppufile.getbyte) then
  2705. begin
  2706. readsymtableoptions('interface macro');
  2707. {skip the definition section for macros (since they are never used) }
  2708. ppufile.skipuntilentry(ibenddefs);
  2709. {read the macro symbols}
  2710. if (verbose and v_syms)<>0 then
  2711. readsymbols('interface macro')
  2712. else
  2713. ppufile.skipuntilentry(ibendsyms);
  2714. end
  2715. else
  2716. Writeln('(no exported macros)');
  2717. {read the implementation stuff}
  2718. if (verbose and v_implementation)<>0 then
  2719. begin
  2720. Writeln;
  2721. Writeln('Implementation section');
  2722. Writeln('-----------------------');
  2723. readimplementation;
  2724. end
  2725. else
  2726. ppufile.skipuntilentry(ibendimplementation);
  2727. {read the static symtable}
  2728. Writeln;
  2729. Writeln('Implementation symtable');
  2730. Writeln('----------------------');
  2731. readsymtableoptions('implementation');
  2732. if (ppufile.header.flags and uf_local_symtable)<>0 then
  2733. begin
  2734. if (verbose and v_defs)<>0 then
  2735. begin
  2736. Writeln;
  2737. Writeln('Static definitions');
  2738. Writeln('----------------------');
  2739. readdefinitions('implementation');
  2740. end
  2741. else
  2742. ppufile.skipuntilentry(ibenddefs);
  2743. {read the symbols}
  2744. if (verbose and v_syms)<>0 then
  2745. begin
  2746. Writeln;
  2747. Writeln('Static Symbols');
  2748. Writeln('------------------');
  2749. readsymbols('implementation');
  2750. end
  2751. else
  2752. ppufile.skipuntilentry(ibendsyms);
  2753. end;
  2754. ReadCreatedObjTypes;
  2755. FreeDerefdata;
  2756. {shutdown ppufile}
  2757. ppufile.closefile;
  2758. ppufile.free;
  2759. Writeln;
  2760. end;
  2761. procedure help;
  2762. begin
  2763. writeln('usage: ppudump [options] <filename1> <filename2>...');
  2764. writeln;
  2765. writeln('[options] can be:');
  2766. writeln(' -M Exit with ExitCode=2 if more information is available');
  2767. writeln(' -V<verbose> Set verbosity to <verbose>');
  2768. writeln(' H - Show header info');
  2769. writeln(' I - Show interface');
  2770. writeln(' M - Show implementation');
  2771. writeln(' S - Show interface symbols');
  2772. writeln(' D - Show interface definitions');
  2773. // writeln(' B - Show browser info');
  2774. writeln(' A - Show all');
  2775. writeln(' -h, -? This helpscreen');
  2776. halt;
  2777. end;
  2778. var
  2779. startpara,
  2780. nrfile,i : longint;
  2781. para : string;
  2782. const
  2783. error_on_more : boolean = false;
  2784. begin
  2785. writeln(Title+' '+Version);
  2786. writeln(Copyright);
  2787. writeln;
  2788. if paramcount<1 then
  2789. begin
  2790. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  2791. halt(1);
  2792. end;
  2793. { turn verbose on by default }
  2794. verbose:=v_all;
  2795. { read options }
  2796. startpara:=1;
  2797. while copy(paramstr(startpara),1,1)='-' do
  2798. begin
  2799. para:=paramstr(startpara);
  2800. case upcase(para[2]) of
  2801. 'M' : error_on_more:=true;
  2802. 'V' : begin
  2803. verbose:=0;
  2804. for i:=3 to length(para) do
  2805. case upcase(para[i]) of
  2806. 'H' : verbose:=verbose or v_header;
  2807. 'I' : verbose:=verbose or v_interface;
  2808. 'M' : verbose:=verbose or v_implementation;
  2809. 'D' : verbose:=verbose or v_defs;
  2810. 'S' : verbose:=verbose or v_syms;
  2811. 'A' : verbose:=verbose or v_all;
  2812. end;
  2813. end;
  2814. 'H' : help;
  2815. '?' : help;
  2816. end;
  2817. inc(startpara);
  2818. end;
  2819. { process files }
  2820. for nrfile:=startpara to paramcount do
  2821. dofile (paramstr(nrfile));
  2822. if has_errors then
  2823. Halt(1);
  2824. if error_on_more and has_more_infos then
  2825. Halt(2);
  2826. end.