ppudump.pp 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459
  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. uses
  20. { do NOT add symconst or globtype to make merging easier }
  21. { do include symconst and globtype now before splitting 2.5 PM 2011-06-15 }
  22. SysUtils,
  23. constexp,
  24. symconst,
  25. ppu,
  26. globals,
  27. globtype,
  28. tokens;
  29. const
  30. Version = 'Version 2.5.1';
  31. Title = 'PPU-Analyser';
  32. Copyright = 'Copyright (c) 1998-2010 by the Free Pascal Development Team';
  33. { verbosity }
  34. v_none = $0;
  35. v_header = $1;
  36. v_defs = $2;
  37. v_syms = $4;
  38. v_interface = $8;
  39. v_implementation = $10;
  40. // v_browser = $20;
  41. v_all = $ff;
  42. {$i systems.inc }
  43. { List of all supported cpus }
  44. const
  45. CpuTxt : array[tsystemcpu] of string[9]=
  46. (
  47. { 0 } 'none',
  48. { 1 } 'i386',
  49. { 2 } 'm68k',
  50. { 3 } 'alpha',
  51. { 4 } 'powerpc',
  52. { 5 } 'sparc',
  53. { 6 } 'vis',
  54. { 7 } 'ia64',
  55. { 8 } 'x86_64',
  56. { 9 } 'mips',
  57. { 10 } 'arm',
  58. { 11 } 'powerpc64',
  59. { 12 } 'avr',
  60. { 13 } 'mipsel'
  61. );
  62. { List of all supported system-cpu couples }
  63. const
  64. Targets : array[tsystem] of string[18]=(
  65. { 0 } 'none',
  66. { 1 } 'GO32V1 (obsolete)',
  67. { 2 } 'GO32V2',
  68. { 3 } 'Linux-i386',
  69. { 4 } 'OS/2',
  70. { 5 } 'Win32',
  71. { 6 } 'FreeBSD-i386',
  72. { 7 } 'Amiga',
  73. { 8 } 'Atari',
  74. { 9 } 'MacOS-m68k',
  75. { 10 } 'Linux-m68k',
  76. { 11 } 'PalmOS-m68k',
  77. { 12 } 'Linux-alpha',
  78. { 13 } 'Linux-ppc',
  79. { 14 } 'MacOS-ppc',
  80. { 15 } 'Solaris-i386',
  81. { 16 } 'BeOS-i386',
  82. { 17 } 'NetBSD-i386',
  83. { 18 } 'NetBSD-m68k',
  84. { 19 } 'Netware-i386-clib',
  85. { 20 } 'Qnx-i386',
  86. { 21 } 'WDOSX-i386',
  87. { 22 } 'Solaris-sparc',
  88. { 23 } 'Linux-sparc',
  89. { 24 } 'OpenBSD-i386',
  90. { 25 } 'OpenBSD-m68k',
  91. { 26 } 'Linux-x86-64',
  92. { 27 } 'MacOSX-ppc',
  93. { 28 } 'OS/2 via EMX',
  94. { 29 } 'NetBSD-powerpc',
  95. { 30 } 'OpenBSD-powerpc',
  96. { 31 } 'Linux-arm',
  97. { 32 } 'Watcom-i386',
  98. { 33 } 'MorphOS-powerpc',
  99. { 34 } 'FreeBSD-x86-64',
  100. { 35 } 'Netware-i386-libc',
  101. { 36 } 'Amiga-PowerPC',
  102. { 37 } 'Win64-x64',
  103. { 38 } 'WinCE-ARM',
  104. { 39 } 'Win64-iA64',
  105. { 40 } 'WinCE-i386',
  106. { 41 } 'Linux-x64',
  107. { 42 } 'GBA-arm',
  108. { 43 } 'Linux-powerpc64',
  109. { 44 } 'Darwin-i386',
  110. { 45 } 'PalmOS-arm',
  111. { 46 } 'MacOSX-powerpc64',
  112. { 47 } 'NDS-arm',
  113. { 48 } 'Embedded-i386',
  114. { 49 } 'Embedded-m68k',
  115. { 50 } 'Embedded-alpha',
  116. { 51 } 'Embedded-powerpc',
  117. { 52 } 'Embedded-sparc',
  118. { 53 } 'Embedded-vm',
  119. { 54 } 'Embedded-iA64',
  120. { 55 } 'Embedded-x64',
  121. { 56 } 'Embedded-mips',
  122. { 57 } 'Embedded-arm',
  123. { 58 } 'Embedded-powerpc64',
  124. { 59 } 'Symbian-i386',
  125. { 60 } 'Symbian-arm',
  126. { 61 } 'MacOSX-x64',
  127. { 62 } 'Embedded-avr',
  128. { 63 } 'Haiku-i386',
  129. { 64 } 'Darwin-ARM',
  130. { 65 } 'Solaris-x86-64',
  131. { 66 } 'Linux-MIPS',
  132. { 67 } 'Linux-MIPSel',
  133. { 68 } 'NativeNT-i386',
  134. { 69 } 'iPhoneSim-i386',
  135. { 70 } 'Wii-powerpc'
  136. );
  137. type
  138. tspecialgenerictoken = (ST_LOADSETTINGS,ST_LINE,ST_COLUMN,ST_FILEINDEX);
  139. var
  140. ppufile : tppufile;
  141. space : string;
  142. verbose : longint;
  143. derefdata : pbyte;
  144. derefdatalen : longint;
  145. {****************************************************************************
  146. Helper Routines
  147. ****************************************************************************}
  148. const has_errors : boolean = false;
  149. Procedure Error(const S : string);
  150. Begin
  151. Writeln(S);
  152. has_errors:=true;
  153. End;
  154. function ToStr(w:longint):String;
  155. begin
  156. Str(w,ToStr);
  157. end;
  158. Function Target2Str(w:longint):string;
  159. begin
  160. if w<=ord(high(tsystem)) then
  161. Target2Str:=Targets[tsystem(w)]
  162. else
  163. Target2Str:='<!! Unknown target value '+tostr(w)+'>';
  164. end;
  165. Function Cpu2Str(w:longint):string;
  166. begin
  167. if w<=ord(high(tsystemcpu)) then
  168. Cpu2Str:=CpuTxt[tsystemcpu(w)]
  169. else
  170. Cpu2Str:='<!! Unknown cpu value '+tostr(w)+'>';
  171. end;
  172. Function Varspez2Str(w:longint):string;
  173. const
  174. { in symconst unit
  175. tvarspez = (vs_value,vs_const,vs_var,vs_out,vs_constref); }
  176. varspezstr : array[tvarspez] of string[6]=('Value','Const','Var','Out','Hidden');
  177. begin
  178. if w<=ord(high(varspezstr)) then
  179. Varspez2Str:=varspezstr[tvarspez(w)]
  180. else
  181. Varspez2Str:='<!! Unknown varspez value '+tostr(w)+'>';
  182. end;
  183. Function VarRegable2Str(w:longint):string;
  184. { tvarregable type is defined in symconst unit }
  185. const
  186. varregableStr : array[tvarregable] of string[6]=('None','IntReg','FPUReg','MMReg','Addr');
  187. begin
  188. if w<=ord(high(varregablestr)) then
  189. Varregable2Str:=varregablestr[tvarregable(w)]
  190. else
  191. Varregable2Str:='<!! Unknown regable value '+tostr(w)+'>';
  192. end;
  193. Function Visibility2Str(w:longint):string;
  194. const
  195. { tvisibility type is defined in symconst unit }
  196. visibilityName : array[tvisibility] of string[16] = (
  197. 'hidden','strict private','private','strict protected','protected',
  198. 'public','published'
  199. );
  200. begin
  201. if w<=ord(high(visibilityName)) then
  202. result:=visibilityName[tvisibility(w)]
  203. else
  204. result:='<!! Unknown visibility value '+tostr(w)+'>';
  205. end;
  206. function PPUFlags2Str(flags:longint):string;
  207. type
  208. tflagopt=record
  209. mask : longint;
  210. str : string[30];
  211. end;
  212. const
  213. flagopts=23;
  214. flagopt : array[1..flagopts] of tflagopt=(
  215. (mask: $1 ;str:'init'),
  216. (mask: $2 ;str:'final'),
  217. (mask: $4 ;str:'big_endian'),
  218. (mask: $8 ;str:'dbx'),
  219. // (mask: $10 ;str:'browser'),
  220. (mask: $20 ;str:'in_library'),
  221. (mask: $40 ;str:'smart_linked'),
  222. (mask: $80 ;str:'static_linked'),
  223. (mask: $100 ;str:'shared_linked'),
  224. // (mask: $200 ;str:'local_browser'),
  225. (mask: $400 ;str:'no_link'),
  226. (mask: $800 ;str:'has_resources'),
  227. (mask: $1000 ;str:'little_endian'),
  228. (mask: $2000 ;str:'release'),
  229. (mask: $4000 ;str:'local_threadvars'),
  230. (mask: $8000 ;str:'fpu_emulation_on'),
  231. (mask: $210000 ;str:'has_debug_info'),
  232. (mask: $10000 ;str:'stabs_debug_info'),
  233. (mask: $200000 ;str:'dwarf_debug_info'),
  234. (mask: $20000 ;str:'local_symtable'),
  235. (mask: $40000 ;str:'uses_variants'),
  236. (mask: $80000 ;str:'has_resourcefiles'),
  237. (mask: $100000 ;str:'has_exports'),
  238. (mask: $400000 ;str:'has_wideinits'),
  239. (mask: $800000 ;str:'has_classinits')
  240. );
  241. var
  242. i : longint;
  243. first : boolean;
  244. s : string;
  245. begin
  246. s:='';
  247. if flags<>0 then
  248. begin
  249. first:=true;
  250. for i:=1to flagopts do
  251. if (flags and flagopt[i].mask)<>0 then
  252. begin
  253. if first then
  254. first:=false
  255. else
  256. s:=s+', ';
  257. s:=s+flagopt[i].str;
  258. end;
  259. end
  260. else
  261. s:='none';
  262. PPUFlags2Str:=s;
  263. end;
  264. Function L0(l:longint):string;
  265. {
  266. return the string of value l, if l<10 then insert a zero, so
  267. the string is always at least 2 chars '01','02',etc
  268. }
  269. var
  270. s : string;
  271. begin
  272. Str(l,s);
  273. if l<10 then
  274. s:='0'+s;
  275. L0:=s;
  276. end;
  277. function filetimestring( t : longint) : string;
  278. {
  279. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  280. }
  281. var
  282. DT : TDateTime;
  283. hsec : word;
  284. Year,Month,Day: Word;
  285. hour,min,sec : word;
  286. begin
  287. if t=-1 then
  288. begin
  289. Result := 'Not Found';
  290. exit;
  291. end;
  292. DT := FileDateToDateTime(t);
  293. DecodeTime(DT,hour,min,sec,hsec);
  294. DecodeDate(DT,year,month,day);
  295. Result := L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  296. end;
  297. {****************************************************************************
  298. Read Routines
  299. ****************************************************************************}
  300. procedure readsymtableoptions(const s: string);
  301. type
  302. tsymtblopt=record
  303. mask : tsymtableoption;
  304. str : string[30];
  305. end;
  306. const
  307. symtblopts=ord(high(tsymtableoption)) + 1;
  308. symtblopt : array[1..symtblopts] of tsymtblopt=(
  309. (mask:sto_has_helper; str:'Has helper')
  310. );
  311. var
  312. options : tsymtableoptions;
  313. first : boolean;
  314. i : integer;
  315. begin
  316. if ppufile.readentry<>ibsymtableoptions then
  317. exit;
  318. ppufile.getsmallset(options);
  319. if space<>'' then
  320. writeln(space,'------ ',s,' ------');
  321. write(space,'Symtable options: ');
  322. if options<>[] then
  323. begin
  324. first:=true;
  325. for i:=1 to symtblopts do
  326. if (symtblopt[i].mask in options) then
  327. begin
  328. if first then
  329. first:=false
  330. else
  331. write(', ');
  332. write(symtblopt[i].str);
  333. end;
  334. end
  335. else
  336. write('none');
  337. writeln;
  338. end;
  339. Procedure ReadLinkContainer(const prefix:string);
  340. {
  341. Read a serie of strings and write to the screen starting every line
  342. with prefix
  343. }
  344. function maskstr(m:longint):string;
  345. { link options are in globtype unit
  346. const
  347. link_none = $0;
  348. link_always = $1;
  349. link_static = $2;
  350. link_smart = $4;
  351. link_shared = $8; }
  352. var
  353. s : string;
  354. begin
  355. s:='';
  356. if (m and link_always)<>0 then
  357. s:=s+'always ';
  358. if (m and link_static)<>0 then
  359. s:=s+'static ';
  360. if (m and link_smart)<>0 then
  361. s:=s+'smart ';
  362. if (m and link_shared)<>0 then
  363. s:=s+'shared ';
  364. maskstr:=s;
  365. end;
  366. var
  367. s : string;
  368. m : longint;
  369. begin
  370. while not ppufile.endofentry do
  371. begin
  372. s:=ppufile.getstring;
  373. m:=ppufile.getlongint;
  374. WriteLn(prefix,s,' (',maskstr(m),')');
  375. end;
  376. end;
  377. Procedure ReadContainer(const prefix:string);
  378. {
  379. Read a serie of strings and write to the screen starting every line
  380. with prefix
  381. }
  382. begin
  383. while not ppufile.endofentry do
  384. WriteLn(prefix,ppufile.getstring);
  385. end;
  386. procedure ReadLoadUnit;
  387. var
  388. ucrc,uintfcrc, indcrc : cardinal;
  389. begin
  390. while not ppufile.EndOfEntry do
  391. begin
  392. write('Uses unit: ',ppufile.getstring);
  393. ucrc:=cardinal(ppufile.getlongint);
  394. uintfcrc:=cardinal(ppufile.getlongint);
  395. indcrc:=cardinal(ppufile.getlongint);
  396. writeln(' (Crc: ',hexstr(ucrc,8),', IntfcCrc: ',hexstr(uintfcrc,8),', IndCrc: ',hexstr(indcrc,8),')');
  397. end;
  398. end;
  399. Procedure ReadDerefmap;
  400. var
  401. i,mapsize : longint;
  402. begin
  403. mapsize:=ppufile.getlongint;
  404. writeln('DerefMapsize: ',mapsize);
  405. for i:=0 to mapsize-1 do
  406. writeln('DerefMap[',i,'] = ',ppufile.getstring);
  407. end;
  408. Procedure ReadImportSymbols;
  409. var
  410. extlibname : string;
  411. j,
  412. extsymcnt : longint;
  413. extsymname : string;
  414. extsymordnr : longint;
  415. extsymisvar : boolean;
  416. begin
  417. while not ppufile.endofentry do
  418. begin
  419. extlibname:=ppufile.getstring;
  420. extsymcnt:=ppufile.getlongint;
  421. writeln('External Library: ',extlibname,' (',extsymcnt,' imports)');
  422. for j:=0 to extsymcnt-1 do
  423. begin
  424. extsymname:=ppufile.getstring;
  425. extsymordnr:=ppufile.getlongint;
  426. extsymisvar:=ppufile.getbyte<>0;
  427. writeln(' ',extsymname,' (OrdNr: ',extsymordnr,' IsVar: ',extsymisvar,')');
  428. end;
  429. end;
  430. end;
  431. Procedure ReadDerefdata;
  432. begin
  433. derefdatalen:=ppufile.entrysize;
  434. if derefdatalen=0 then
  435. begin
  436. writeln('!! Error: derefdatalen=0');
  437. exit;
  438. end;
  439. Writeln('Derefdata length: ',derefdatalen);
  440. derefdata:=allocmem(derefdatalen);
  441. ppufile.getdata(derefdata^,derefdatalen);
  442. end;
  443. Procedure ReadWpoFileInfo;
  444. begin
  445. Writeln('Compiled with input whole-program optimisation from ',ppufile.getstring,' ',filetimestring(ppufile.getlongint));
  446. end;
  447. Procedure ReadAsmSymbols;
  448. type
  449. { Copied from aasmbase.pas }
  450. TAsmsymbind=(
  451. AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL,AB_WEAK_EXTERNAL,
  452. { global in the current program/library, but not visible outside it }
  453. AB_PRIVATE_EXTERN,AB_LAZY,AB_IMPORT);
  454. TAsmsymtype=(
  455. AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL,
  456. {
  457. the address of this code label is taken somewhere in the code
  458. so it must be taken care of it when creating pic
  459. }
  460. AT_ADDR
  461. );
  462. var
  463. s,
  464. bindstr,
  465. typestr : string;
  466. i : longint;
  467. begin
  468. writeln(space,'Number of AsmSymbols: ',ppufile.getlongint);
  469. i:=0;
  470. while (not ppufile.endofentry) and (not ppufile.error) do
  471. begin
  472. s:=ppufile.getstring;
  473. case tasmsymbind(ppufile.getbyte) of
  474. AB_EXTERNAL :
  475. bindstr:='External';
  476. AB_COMMON :
  477. bindstr:='Common';
  478. AB_LOCAL :
  479. bindstr:='Local';
  480. AB_GLOBAL :
  481. bindstr:='Global';
  482. AB_WEAK_EXTERNAL :
  483. bindstr:='Weak external';
  484. AB_PRIVATE_EXTERN :
  485. bindstr:='Private extern';
  486. AB_LAZY :
  487. bindstr:='Lazy';
  488. AB_IMPORT :
  489. bindstr:='Import';
  490. else
  491. bindstr:='<Error !!>'
  492. end;
  493. case tasmsymtype(ppufile.getbyte) of
  494. AT_FUNCTION :
  495. typestr:='Function';
  496. AT_DATA :
  497. typestr:='Data';
  498. AT_SECTION :
  499. typestr:='Section';
  500. AT_LABEL :
  501. typestr:='Label';
  502. AT_ADDR :
  503. typestr:='Label (with address taken)';
  504. else
  505. typestr:='<Error !!>'
  506. end;
  507. Writeln(space,' ',i,' : ',s,' [',bindstr,',',typestr,']');
  508. inc(i);
  509. end;
  510. end;
  511. function getexprint:Tconstexprint;
  512. begin
  513. getexprint.overflow:=false;
  514. getexprint.signed:=boolean(ppufile.getbyte);
  515. getexprint.svalue:=ppufile.getint64;
  516. end;
  517. Procedure ReadPosInfo;
  518. var
  519. info : byte;
  520. fileindex,line,column : longint;
  521. begin
  522. with ppufile do
  523. begin
  524. {
  525. info byte layout in bits:
  526. 0-1 - amount of bytes for fileindex
  527. 2-3 - amount of bytes for line
  528. 4-5 - amount of bytes for column
  529. }
  530. info:=getbyte;
  531. case (info and $03) of
  532. 0 : fileindex:=getbyte;
  533. 1 : fileindex:=getword;
  534. 2 : fileindex:=(getbyte shl 16) or getword;
  535. 3 : fileindex:=getlongint;
  536. end;
  537. case ((info shr 2) and $03) of
  538. 0 : line:=getbyte;
  539. 1 : line:=getword;
  540. 2 : line:=(getbyte shl 16) or getword;
  541. 3 : line:=getlongint;
  542. end;
  543. case ((info shr 4) and $03) of
  544. 0 : column:=getbyte;
  545. 1 : column:=getword;
  546. 2 : column:=(getbyte shl 16) or getword;
  547. 3 : column:=getlongint;
  548. end;
  549. Writeln(fileindex,' (',line,',',column,')');
  550. end;
  551. end;
  552. procedure readderef(const derefspace: string);
  553. type
  554. tdereftype = (deref_nil,
  555. deref_unit,
  556. deref_symid,
  557. deref_defid
  558. );
  559. var
  560. b : tdereftype;
  561. first : boolean;
  562. idx : longint;
  563. i,n : byte;
  564. pdata : pbyte;
  565. begin
  566. if not assigned(derefdata) then
  567. exit;
  568. first:=true;
  569. idx:=ppufile.getlongint;
  570. if (idx>derefdatalen) then
  571. begin
  572. writeln('!! Error: Deref idx ',idx,' > ',derefdatalen);
  573. exit;
  574. end;
  575. write(derefspace,'(',idx,') ');
  576. pdata:=@derefdata[idx];
  577. i:=0;
  578. n:=pdata[i];
  579. inc(i);
  580. if n<1 then
  581. begin
  582. writeln('!! Error: Deref len < 1');
  583. exit;
  584. end;
  585. while (i<=n) do
  586. begin
  587. if not first then
  588. write(', ')
  589. else
  590. first:=false;
  591. b:=tdereftype(pdata[i]);
  592. inc(i);
  593. case b of
  594. deref_nil :
  595. write('Nil');
  596. deref_symid :
  597. begin
  598. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  599. inc(i,4);
  600. write('SymId ',idx);
  601. end;
  602. deref_defid :
  603. begin
  604. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  605. inc(i,4);
  606. write('DefId ',idx);
  607. end;
  608. deref_unit :
  609. begin
  610. idx:=pdata[i] shl 8 or pdata[i+1];
  611. inc(i,2);
  612. write('Unit ',idx);
  613. end;
  614. else
  615. begin
  616. writeln('!! unsupported dereftyp: ',ord(b));
  617. break;
  618. end;
  619. end;
  620. end;
  621. writeln;
  622. end;
  623. procedure readpropaccesslist(const s:string);
  624. { type tsltype is in symconst unit }
  625. const
  626. slstr : array[tsltype] of string[12] = (
  627. '',
  628. 'load',
  629. 'call',
  630. 'subscript',
  631. 'vec',
  632. 'typeconv',
  633. 'absolutetype'
  634. );
  635. var
  636. sl : tsltype;
  637. begin
  638. readderef('');
  639. repeat
  640. sl:=tsltype(ppufile.getbyte);
  641. if sl=sl_none then
  642. break;
  643. write(s,'(',slstr[sl],') ');
  644. case sl of
  645. sl_call,
  646. sl_load,
  647. sl_subscript :
  648. readderef('');
  649. sl_absolutetype,
  650. sl_typeconv :
  651. readderef('');
  652. sl_vec :
  653. begin
  654. writeln(ppufile.getlongint);
  655. readderef('');
  656. end;
  657. end;
  658. until false;
  659. end;
  660. procedure readsymoptions(space : string);
  661. type
  662. tsymopt=record
  663. mask : tsymoption;
  664. str : string[30];
  665. end;
  666. const
  667. symopts=ord(high(tsymoption)) - ord(low(tsymoption));
  668. { sp_none = 0 corresponds to nothing }
  669. symopt : array[1..symopts] of tsymopt=(
  670. (mask:sp_static; str:'Static'),
  671. (mask:sp_hint_deprecated; str:'Hint Deprecated'),
  672. (mask:sp_hint_platform; str:'Hint Platform'),
  673. (mask:sp_hint_library; str:'Hint Library'),
  674. (mask:sp_hint_unimplemented; str:'Hint Unimplemented'),
  675. (mask:sp_hint_experimental; str:'Hint Experimental'),
  676. (mask:sp_has_overloaded; str:'Has overloaded'),
  677. (mask:sp_internal; str:'Internal'),
  678. (mask:sp_implicitrename; str:'Implicit Rename'),
  679. (mask:sp_generic_para; str:'Generic Parameter'),
  680. (mask:sp_has_deprecated_msg; str:'Has Deprecated Message')
  681. );
  682. var
  683. symoptions : tsymoptions;
  684. i : longint;
  685. first : boolean;
  686. begin
  687. ppufile.getsmallset(symoptions);
  688. if symoptions<>[] then
  689. begin
  690. first:=true;
  691. for i:=1to symopts do
  692. if (symopt[i].mask in symoptions) then
  693. begin
  694. if first then
  695. first:=false
  696. else
  697. write(', ');
  698. write(symopt[i].str);
  699. end;
  700. end;
  701. writeln;
  702. if sp_has_deprecated_msg in symoptions then
  703. writeln(space,'Deprecated : ', ppufile.getstring);
  704. end;
  705. procedure readcommonsym(const s:string);
  706. begin
  707. writeln(space,'** Symbol Id ',ppufile.getlongint,' **');
  708. writeln(space,s,ppufile.getstring);
  709. write (space,' File Pos : ');
  710. readposinfo;
  711. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  712. write (space,' SymOptions : ');
  713. readsymoptions(space+' ');
  714. end;
  715. var
  716. { needed during tobjectdef parsing... }
  717. current_defoptions : tdefoptions;
  718. current_objectoptions : tobjectoptions;
  719. procedure readcommondef(const s:string; out defoptions: tdefoptions);
  720. type
  721. tdefopt=record
  722. mask : tdefoption;
  723. str : string[30];
  724. end;
  725. tdefstateinfo=record
  726. mask : tdefstate;
  727. str : string[30];
  728. end;
  729. ptoken=^ttoken;
  730. const
  731. defopt : array[1..ord(high(tdefoption))] of tdefopt=(
  732. (mask:df_unique; str:'Unique Type'),
  733. (mask:df_generic; str:'Generic'),
  734. (mask:df_specialization; str:'Specialization'),
  735. (mask:df_copied_def; str:'Copied Typedef')
  736. );
  737. defstate : array[1..ord(high(tdefstate))] of tdefstateinfo=(
  738. (mask:ds_vmt_written; str:'VMT Written'),
  739. (mask:ds_rtti_table_used; str:'RTTITable Used'),
  740. (mask:ds_init_table_used; str:'InitTable Used'),
  741. (mask:ds_rtti_table_written; str:'RTTITable Written'),
  742. (mask:ds_init_table_written; str:'InitTable Written'),
  743. (mask:ds_dwarf_dbg_info_used; str:'Dwarf DbgInfo Used'),
  744. (mask:ds_dwarf_dbg_info_written;str:'Dwarf DbgInfo Written')
  745. );
  746. var
  747. defstates : tdefstates;
  748. i : longint;
  749. first : boolean;
  750. tokenbufsize : longint;
  751. tokenbuf : pbyte;
  752. idtoken,
  753. token : ttoken;
  754. len : sizeint;
  755. wstring : widestring;
  756. astring : ansistring;
  757. function readtoken: ttoken;
  758. var
  759. b,b2 : byte;
  760. begin
  761. b:=tokenbuf[i];
  762. inc(i);
  763. if (b and $80)<>0 then
  764. begin
  765. b2:=tokenbuf[i];
  766. inc(i);
  767. result:=ttoken(((b and $7f) shl 8) or b2);
  768. end
  769. else
  770. result:=ttoken(b);
  771. end;
  772. begin
  773. writeln(space,'** Definition Id ',ppufile.getlongint,' **');
  774. writeln(space,s);
  775. write (space,' Type symbol : ');
  776. readderef('');
  777. write (space,' DefOptions : ');
  778. ppufile.getsmallset(defoptions);
  779. if defoptions<>[] then
  780. begin
  781. first:=true;
  782. for i:=1to high(defopt) do
  783. if (defopt[i].mask in defoptions) then
  784. begin
  785. if first then
  786. first:=false
  787. else
  788. write(', ');
  789. write(defopt[i].str);
  790. end;
  791. end;
  792. writeln;
  793. write (space,' DefStates : ');
  794. ppufile.getsmallset(defstates);
  795. if defstates<>[] then
  796. begin
  797. first:=true;
  798. for i:=1 to high(defstate) do
  799. if (defstate[i].mask in defstates) then
  800. begin
  801. if first then
  802. first:=false
  803. else
  804. write(', ');
  805. write(defstate[i].str);
  806. end;
  807. end;
  808. writeln;
  809. if df_generic in defoptions then
  810. begin
  811. tokenbufsize:=ppufile.getlongint;
  812. writeln(space,' Tokenbuffer size : ',tokenbufsize);
  813. tokenbuf:=allocmem(tokenbufsize);
  814. ppufile.getdata(tokenbuf^,tokenbufsize);
  815. i:=0;
  816. write(space,' Tokens: ');
  817. while i<tokenbufsize do
  818. begin
  819. token:=readtoken;
  820. if token<>_GENERICSPECIALTOKEN then
  821. begin
  822. write(arraytokeninfo[token].str);
  823. idtoken:=readtoken;
  824. end;
  825. case token of
  826. _CWCHAR,
  827. _CWSTRING :
  828. begin
  829. len:=psizeint(@tokenbuf[i])^;
  830. inc(i,sizeof(sizeint));
  831. setlength(wstring,len);
  832. move(tokenbuf[i],wstring[1],len*2);
  833. write(' ',wstring);
  834. inc(i,len*2);
  835. end;
  836. _CSTRING:
  837. begin
  838. len:=psizeint(@tokenbuf[i])^;
  839. inc(i,sizeof(sizeint));
  840. setlength(astring,len);
  841. move(tokenbuf[i],astring[1],len);
  842. write(' ',astring);
  843. inc(i,len);
  844. end;
  845. _CCHAR,
  846. _INTCONST,
  847. _REALNUMBER :
  848. begin
  849. write(' ',pshortstring(@tokenbuf[i])^);
  850. inc(i,tokenbuf[i]+1);
  851. end;
  852. _ID :
  853. begin
  854. write(' ',pshortstring(@tokenbuf[i])^);
  855. inc(i,tokenbuf[i]+1);
  856. {
  857. replaytokenbuf.read(orgpattern[0],1);
  858. replaytokenbuf.read(orgpattern[1],length(orgpattern));
  859. pattern:=upper(orgpattern);
  860. }
  861. end;
  862. _GENERICSPECIALTOKEN:
  863. begin
  864. if (tokenbuf[i] and $80)<>0 then
  865. begin
  866. write('Col: ',tokenbuf[i] and $7f);
  867. inc(i);
  868. end
  869. else
  870. case tspecialgenerictoken(tokenbuf[i]) of
  871. ST_LOADSETTINGS:
  872. begin
  873. inc(i);
  874. write('Settings');
  875. inc(i,sizeof(tsettings));
  876. end;
  877. ST_LINE:
  878. begin
  879. inc(i);
  880. write('Line: ',pdword(@tokenbuf[i])^);
  881. inc(i,4);
  882. end;
  883. ST_COLUMN:
  884. begin
  885. inc(i);
  886. write('Col: ',pword(@tokenbuf[i])^);
  887. inc(i,2);
  888. end;
  889. ST_FILEINDEX:
  890. begin
  891. inc(i);
  892. write('File: ',pword(@tokenbuf[i])^);
  893. inc(i,2);
  894. end;
  895. end;
  896. {
  897. replaytokenbuf.read(specialtoken,1);
  898. case specialtoken of
  899. ST_LOADSETTINGS:
  900. begin
  901. replaytokenbuf.read(current_settings,sizeof(current_settings));
  902. end
  903. else
  904. internalerror(2006103010);
  905. end;
  906. continue;
  907. }
  908. end;
  909. end;
  910. if i<tokenbufsize then
  911. write(',');
  912. end;
  913. writeln;
  914. freemem(tokenbuf);
  915. end;
  916. if df_specialization in defoptions then
  917. begin
  918. write (space,' Orig. GenericDef : ');
  919. readderef('');
  920. end;
  921. current_defoptions:=defoptions;
  922. end;
  923. { Read abstract procdef and return if inline procdef }
  924. { type tproccalloption is in globtype unit }
  925. { type tproctypeoption is in globtype unit }
  926. { type tprocoption is in globtype unit }
  927. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions);
  928. type
  929. tproccallopt=record
  930. mask : tproccalloption;
  931. str : string[30];
  932. end;
  933. tproctypeopt=record
  934. mask : tproctypeoption;
  935. str : string[30];
  936. end;
  937. tprocopt=record
  938. mask : tprocoption;
  939. str : string[30];
  940. end;
  941. const
  942. {proccalloptionStr is also in globtype unit }
  943. proctypeopt : array[1..ord(high(tproctypeoption))] of tproctypeopt=(
  944. (mask:potype_proginit; str:'ProgInit'),
  945. (mask:potype_unitinit; str:'UnitInit'),
  946. (mask:potype_unitfinalize; str:'UnitFinalize'),
  947. (mask:potype_constructor; str:'Constructor'),
  948. (mask:potype_destructor; str:'Destructor'),
  949. (mask:potype_operator; str:'Operator'),
  950. (mask:potype_procedure; str:'Procedure'),
  951. (mask:potype_function; str:'Function'),
  952. (mask:potype_class_constructor; str:'Class Constructor'),
  953. (mask:potype_class_destructor; str:'Class Destructor'),
  954. { Dispinterface property accessors }
  955. (mask:potype_propgetter; str:'Property Getter'),
  956. (mask:potype_propsetter; str:'Property Setter')
  957. );
  958. procopt : array[1..ord(high(tprocoption))] of tprocopt=(
  959. (mask:po_classmethod; str:'ClassMethod'),
  960. (mask:po_virtualmethod; str:'VirtualMethod'),
  961. (mask:po_abstractmethod; str:'AbstractMethod'),
  962. (mask:po_finalmethod; str:'FinalMethod'),
  963. (mask:po_staticmethod; str:'StaticMethod'),
  964. (mask:po_overridingmethod;str:'OverridingMethod'),
  965. (mask:po_methodpointer; str:'MethodPointer'),
  966. (mask:po_interrupt; str:'Interrupt'),
  967. (mask:po_iocheck; str:'IOCheck'),
  968. (mask:po_assembler; str:'Assembler'),
  969. (mask:po_msgstr; str:'MsgStr'),
  970. (mask:po_msgint; str:'MsgInt'),
  971. (mask:po_exports; str:'Exports'),
  972. (mask:po_external; str:'External'),
  973. (mask:po_overload; str:'Overload'),
  974. (mask:po_varargs; str:'VarArgs'),
  975. (mask:po_internconst; str:'InternConst'),
  976. (mask:po_addressonly; str:'AddressOnly'),
  977. (mask:po_public; str:'Public'),
  978. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  979. (mask:po_reintroduce; str:'ReIntroduce'),
  980. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  981. (mask:po_nostackframe; str:'NoStackFrame'),
  982. (mask:po_has_mangledname; str:'HasMangledName'),
  983. (mask:po_has_public_name; str:'HasPublicName'),
  984. (mask:po_forward; str:'Forward'),
  985. (mask:po_global; str:'Global'),
  986. (mask:po_has_inlininginfo;str:'HasInliningInfo'),
  987. (mask:po_syscall_legacy; str:'SyscallLegacy'),
  988. (mask:po_syscall_sysv; str:'SyscallSysV'),
  989. (mask:po_syscall_basesysv;str:'SyscallBaseSysV'),
  990. (mask:po_syscall_sysvbase;str:'SyscallSysVBase'),
  991. (mask:po_syscall_r12base; str:'SyscallR12Base'),
  992. (mask:po_inline; str:'Inline'),
  993. (mask:po_compilerproc; str:'CompilerProc'),
  994. (mask:po_has_importdll; str:'HasImportDLL'),
  995. (mask:po_has_importname; str:'HasImportName'),
  996. (mask:po_kylixlocal; str:'KylixLocal'),
  997. (mask:po_dispid; str:'DispId'),
  998. (mask:po_weakexternal; str:'WeakExternal'),
  999. (mask:po_objc; str:'ObjC'),
  1000. (mask:po_enumerator_movenext; str:'EnumeratorMoveNext'),
  1001. (mask:po_optional; str: 'Optional'),
  1002. (mask:po_delphi_nested_cc;str: 'Delphi-style nested frameptr')
  1003. );
  1004. var
  1005. proctypeoption : tproctypeoption;
  1006. i : longint;
  1007. first : boolean;
  1008. tempbuf : array[0..255] of byte;
  1009. begin
  1010. write(space,' Return type : ');
  1011. readderef('');
  1012. writeln(space,' Fpu used : ',ppufile.getbyte);
  1013. proctypeoption:=tproctypeoption(ppufile.getbyte);
  1014. write(space,' TypeOption : ');
  1015. first:=true;
  1016. for i:=1 to high(proctypeopt) do
  1017. if (proctypeopt[i].mask=proctypeoption) then
  1018. begin
  1019. if first then
  1020. first:=false
  1021. else
  1022. write(', ');
  1023. write(proctypeopt[i].str);
  1024. end;
  1025. writeln;
  1026. proccalloption:=tproccalloption(ppufile.getbyte);
  1027. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  1028. ppufile.getnormalset(procoptions);
  1029. if procoptions<>[] then
  1030. begin
  1031. write(space,' Options : ');
  1032. first:=true;
  1033. for i:=1 to high(procopt) do
  1034. if (procopt[i].mask in procoptions) then
  1035. begin
  1036. if first then
  1037. first:=false
  1038. else
  1039. write(', ');
  1040. write(procopt[i].str);
  1041. end;
  1042. writeln;
  1043. end;
  1044. if (po_explicitparaloc in procoptions) then
  1045. begin
  1046. i:=ppufile.getbyte;
  1047. ppufile.getdata(tempbuf,i);
  1048. end;
  1049. end;
  1050. { type tvaroption is in unit symconst }
  1051. { register variable }
  1052. { type tvarregable is in unit symconst }
  1053. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions);
  1054. type
  1055. tvaropt=record
  1056. mask : tvaroption;
  1057. str : string[30];
  1058. end;
  1059. const
  1060. varopt : array[1..ord(high(tvaroption))] of tvaropt=(
  1061. (mask:vo_is_external; str:'External'),
  1062. (mask:vo_is_dll_var; str:'DLLVar'),
  1063. (mask:vo_is_thread_var; str:'ThreadVar'),
  1064. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  1065. (mask:vo_is_const; str:'Constant'),
  1066. (mask:vo_is_public; str:'Public'),
  1067. (mask:vo_is_high_para; str:'HighValue'),
  1068. (mask:vo_is_funcret; str:'Funcret'),
  1069. (mask:vo_is_self; str:'Self'),
  1070. (mask:vo_is_vmt; str:'VMT'),
  1071. (mask:vo_is_result; str:'Result'),
  1072. (mask:vo_is_parentfp; str:'ParentFP'),
  1073. (mask:vo_is_loop_counter; str:'LoopCounter'),
  1074. (mask:vo_is_hidden_para; str:'Hidden'),
  1075. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  1076. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  1077. (mask:vo_has_mangledname; str:'HasMangledName'),
  1078. (mask:vo_is_typed_const; str:'TypedConst'),
  1079. (mask:vo_is_range_check; str:'RangeCheckSwitch'),
  1080. (mask:vo_is_overflow_check; str:'OverflowCheckSwitch'),
  1081. (mask:vo_is_typinfo_para; str:'TypeInfo'),
  1082. (mask:vo_is_msgsel;str:'MsgSel'),
  1083. (mask:vo_is_weak_external;str:'WeakExternal'),
  1084. (mask:vo_is_first_field;str:'IsFirstField'),
  1085. (mask:vo_volatile;str:'Volatile'),
  1086. (mask:vo_has_section;str:'HasSection')
  1087. );
  1088. var
  1089. i : longint;
  1090. first : boolean;
  1091. begin
  1092. readcommonsym(s);
  1093. writeln(space,' Spez : ',Varspez2Str(ppufile.getbyte));
  1094. writeln(space,' Regable : ',Varregable2Str(ppufile.getbyte));
  1095. writeln(space,' Addr Taken : ',(ppufile.getbyte<>0));
  1096. write (space,' Var Type : ');
  1097. readderef('');
  1098. ppufile.getsmallset(varoptions);
  1099. if varoptions<>[] then
  1100. begin
  1101. write(space,' Options : ');
  1102. first:=true;
  1103. for i:=1 to high(varopt) do
  1104. if (varopt[i].mask in varoptions) then
  1105. begin
  1106. if first then
  1107. first:=false
  1108. else
  1109. write(', ');
  1110. write(varopt[i].str);
  1111. if varopt[i].mask = vo_has_section then
  1112. writeln('Section name:',ppufile.getansistring);
  1113. end;
  1114. writeln;
  1115. end;
  1116. end;
  1117. procedure readobjectdefoptions;
  1118. type
  1119. tsymopt=record
  1120. mask : tobjectoption;
  1121. str : string[30];
  1122. end;
  1123. const
  1124. symopt : array[1..ord(high(tobjectoption))] of tsymopt=(
  1125. (mask:oo_is_forward; str:'IsForward'),
  1126. (mask:oo_is_abstract; str:'IsAbstract'),
  1127. (mask:oo_is_sealed; str:'IsSealed'),
  1128. (mask:oo_has_virtual; str:'HasVirtual'),
  1129. (mask:oo_has_private; str:'HasPrivate'),
  1130. (mask:oo_has_protected; str:'HasProtected'),
  1131. (mask:oo_has_strictprivate; str:'HasStrictPrivate'),
  1132. (mask:oo_has_strictprotected;str:'HasStrictProtected'),
  1133. (mask:oo_has_constructor; str:'HasConstructor'),
  1134. (mask:oo_has_destructor; str:'HasDestructor'),
  1135. (mask:oo_has_vmt; str:'HasVMT'),
  1136. (mask:oo_has_msgstr; str:'HasMsgStr'),
  1137. (mask:oo_has_msgint; str:'HasMsgInt'),
  1138. (mask:oo_can_have_published; str:'CanHavePublished'),
  1139. (mask:oo_has_default_property;str:'HasDefaultProperty'),
  1140. (mask:oo_has_valid_guid; str:'HasValidGUID'),
  1141. (mask:oo_has_enumerator_movenext; str:'HasEnumeratorMoveNext'),
  1142. (mask:oo_has_enumerator_current; str:'HasEnumeratorCurrent'),
  1143. (mask:oo_is_external; str:'External'),
  1144. (mask:oo_is_formal; str:'Formal'),
  1145. (mask:oo_is_classhelper; str:'Class Helper/Category'),
  1146. (mask:oo_has_class_constructor; str:'HasClassConstructor'),
  1147. (mask:oo_has_class_destructor; str:'HasClassDestructor')
  1148. );
  1149. var
  1150. i : longint;
  1151. first : boolean;
  1152. begin
  1153. ppufile.getsmallset(current_objectoptions);
  1154. if current_objectoptions<>[] then
  1155. begin
  1156. first:=true;
  1157. for i:=1 to high(symopt) do
  1158. if (symopt[i].mask in current_objectoptions) then
  1159. begin
  1160. if first then
  1161. first:=false
  1162. else
  1163. write(', ');
  1164. write(symopt[i].str);
  1165. end;
  1166. end;
  1167. writeln;
  1168. end;
  1169. procedure readarraydefoptions;
  1170. { type tarraydefoption is in unit symconst }
  1171. type
  1172. tsymopt=record
  1173. mask : tarraydefoption;
  1174. str : string[30];
  1175. end;
  1176. const
  1177. symopt : array[1..ord(high(tarraydefoption))] of tsymopt=(
  1178. (mask:ado_IsConvertedPointer;str:'ConvertedPointer'),
  1179. (mask:ado_IsDynamicArray; str:'IsDynamicArray'),
  1180. (mask:ado_IsVariant; str:'IsVariant'),
  1181. (mask:ado_IsConstructor; str:'IsConstructor'),
  1182. (mask:ado_IsArrayOfConst; str:'ArrayOfConst'),
  1183. (mask:ado_IsConstString; str:'ConstString'),
  1184. (mask:ado_IsBitPacked; str:'BitPacked')
  1185. );
  1186. var
  1187. symoptions : tarraydefoptions;
  1188. i : longint;
  1189. first : boolean;
  1190. begin
  1191. ppufile.getsmallset(symoptions);
  1192. if symoptions<>[] then
  1193. begin
  1194. first:=true;
  1195. for i:=1 to high(symopt) do
  1196. if (symopt[i].mask in symoptions) then
  1197. begin
  1198. if first then
  1199. first:=false
  1200. else
  1201. write(', ');
  1202. write(symopt[i].str);
  1203. end;
  1204. end;
  1205. writeln;
  1206. end;
  1207. procedure readnodetree;
  1208. var
  1209. l : longint;
  1210. p : pointer;
  1211. begin
  1212. with ppufile do
  1213. begin
  1214. if space<>'' then
  1215. Writeln(space,'------ nodetree ------');
  1216. if readentry=ibnodetree then
  1217. begin
  1218. l:=entrysize;
  1219. Writeln(space,'Tree size : ',l);
  1220. { Read data to prevent error that entry is not completly read }
  1221. getmem(p,l);
  1222. getdata(p^,l);
  1223. freemem(p);
  1224. end
  1225. else
  1226. begin
  1227. Writeln('!! ibnodetree not found');
  1228. end;
  1229. end;
  1230. end;
  1231. procedure ReadCreatedObjTypes;
  1232. var
  1233. i,j,
  1234. len,
  1235. bssize: longint;
  1236. bs: pbyte;
  1237. begin
  1238. if ppufile.readentry<>ibcreatedobjtypes then
  1239. begin
  1240. writeln('!! ibcreatedobjtypes entry not found');
  1241. ppufile.skipdata(ppufile.entrysize);
  1242. exit
  1243. end;
  1244. writeln;
  1245. writeln(space,'WPO info');
  1246. writeln(space,'--------');
  1247. len:=ppufile.getlongint;
  1248. writeln(space,'** Instantiated Object/Class types: ',len,' **');
  1249. space:=space+' ';
  1250. for i:=0 to len-1 do
  1251. readderef(space);
  1252. setlength(space,length(space)-2);
  1253. len:=ppufile.getlongint;
  1254. writeln(space,'** Instantiated ClassRef types: ',len,' **');
  1255. space:=space+' ';
  1256. for i:=0 to len-1 do
  1257. readderef(space);
  1258. setlength(space,length(space)-2);
  1259. len:=ppufile.getlongint;
  1260. writeln(space,'** Possibly instantiated ClassRef types : ',len,' **');
  1261. space:=space+' ';
  1262. for i:=0 to len-1 do
  1263. readderef(space);
  1264. setlength(space,length(space)-2);
  1265. len:=ppufile.getlongint;
  1266. writeln(space,'** Class types with called virtual methods info : ',len,' **');
  1267. space:=space+' ';
  1268. for i:=0 to len-1 do
  1269. begin
  1270. write(space,'Class def : ');
  1271. readderef('');
  1272. write(space+' ','Called vmtentries : ');
  1273. bssize:=ppufile.getlongint;
  1274. getmem(bs,bssize);
  1275. ppufile.readdata(bs^,bssize);
  1276. for j:=0 to bssize*8-1 do
  1277. if (((bs+j shr 3)^ shr (j and 7)) and 1) <> 0 then
  1278. write(j,', ');
  1279. writeln;
  1280. freemem(bs);
  1281. end;
  1282. setlength(space,length(space)-2);
  1283. end;
  1284. {****************************************************************************
  1285. Read Symbols Part
  1286. ****************************************************************************}
  1287. procedure readsymbols(const s:string);
  1288. type
  1289. pguid = ^tguid;
  1290. tguid = packed record
  1291. D1: LongWord;
  1292. D2: Word;
  1293. D3: Word;
  1294. D4: array[0..7] of Byte;
  1295. end;
  1296. absolutetyp = (tovar,toasm,toaddr);
  1297. tconsttyp = (constnone,
  1298. constord,conststring,constreal,
  1299. constset,constpointer,constnil,
  1300. constresourcestring,constwstring,constguid
  1301. );
  1302. var
  1303. b : byte;
  1304. pc : pchar;
  1305. i,j,len : longint;
  1306. guid : tguid;
  1307. tempbuf : array[0..127] of char;
  1308. varoptions : tvaroptions;
  1309. begin
  1310. with ppufile do
  1311. begin
  1312. if space<>'' then
  1313. Writeln(space,'------ ',s,' ------');
  1314. if readentry=ibstartsyms then
  1315. begin
  1316. Writeln(space,'Symtable datasize : ',getlongint);
  1317. Writeln(space,'Symtable alignment: ',getlongint);
  1318. end
  1319. else
  1320. Writeln('!! ibstartsym not found');
  1321. repeat
  1322. b:=readentry;
  1323. case b of
  1324. ibunitsym :
  1325. readcommonsym('Unit symbol ');
  1326. iblabelsym :
  1327. readcommonsym('Label symbol ');
  1328. ibtypesym :
  1329. begin
  1330. readcommonsym('Type symbol ');
  1331. write(space,' Result Type : ');
  1332. readderef('');
  1333. end;
  1334. ibprocsym :
  1335. begin
  1336. readcommonsym('Procedure symbol ');
  1337. len:=ppufile.getword;
  1338. for i:=1 to len do
  1339. begin
  1340. write(space,' Definition : ');
  1341. readderef('');
  1342. end;
  1343. end;
  1344. ibconstsym :
  1345. begin
  1346. readcommonsym('Constant symbol ');
  1347. b:=getbyte;
  1348. case tconsttyp(b) of
  1349. constord :
  1350. begin
  1351. write (space,' OrdinalType : ');
  1352. readderef('');
  1353. writeln(space,' Value : ',constexp.tostr(getexprint));
  1354. end;
  1355. constpointer :
  1356. begin
  1357. write (space,' PointerType : ');
  1358. readderef('');
  1359. writeln(space,' Value : ',getlongint)
  1360. end;
  1361. conststring,
  1362. constresourcestring :
  1363. begin
  1364. len:=getlongint;
  1365. getmem(pc,len+1);
  1366. getdata(pc^,len);
  1367. (pc+len)^:= #0;
  1368. writeln(space,' Length : ',len);
  1369. writeln(space,' Value : "',pc,'"');
  1370. freemem(pc,len+1);
  1371. end;
  1372. constreal :
  1373. writeln(space,' Value : ',getreal);
  1374. constset :
  1375. begin
  1376. write (space,' Set Type : ');
  1377. readderef('');
  1378. for i:=1to 4 do
  1379. begin
  1380. write (space,' Value : ');
  1381. for j:=1to 8 do
  1382. begin
  1383. if j>1 then
  1384. write(',');
  1385. write(hexstr(getbyte,2));
  1386. end;
  1387. writeln;
  1388. end;
  1389. end;
  1390. constwstring:
  1391. begin
  1392. end;
  1393. constguid:
  1394. begin
  1395. getdata(guid,sizeof(guid));
  1396. write (space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-');
  1397. for i:=0 to 7 do
  1398. begin
  1399. write(hexstr(guid.d4[i],2));
  1400. if i=1 then write('-');
  1401. end;
  1402. writeln('}');
  1403. end
  1404. else
  1405. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  1406. end;
  1407. end;
  1408. ibabsolutevarsym :
  1409. begin
  1410. readabstractvarsym('Absolute variable symbol ',varoptions);
  1411. Write (space,' Relocated to ');
  1412. b:=getbyte;
  1413. case absolutetyp(b) of
  1414. tovar :
  1415. readpropaccesslist(space+' Sym : ');
  1416. toasm :
  1417. Writeln('Assembler name : ',getstring);
  1418. toaddr :
  1419. begin
  1420. Write('Address : ',getlongint);
  1421. if tsystemcpu(ppufile.header.cpu)=cpu_i386 then
  1422. WriteLn(' (Far: ',getbyte<>0,')');
  1423. end;
  1424. else
  1425. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  1426. end;
  1427. end;
  1428. ibfieldvarsym :
  1429. begin
  1430. readabstractvarsym('Field Variable symbol ',varoptions);
  1431. writeln(space,' Address : ',getaint);
  1432. end;
  1433. ibstaticvarsym :
  1434. begin
  1435. readabstractvarsym('Global Variable symbol ',varoptions);
  1436. write (space,' DefaultConst : ');
  1437. readderef('');
  1438. if (vo_has_mangledname in varoptions) then
  1439. writeln(space,' Mangledname : ',getstring);
  1440. end;
  1441. iblocalvarsym :
  1442. begin
  1443. readabstractvarsym('Local Variable symbol ',varoptions);
  1444. write (space,' DefaultConst : ');
  1445. readderef('');
  1446. end;
  1447. ibparavarsym :
  1448. begin
  1449. readabstractvarsym('Parameter Variable symbol ',varoptions);
  1450. write (space,' DefaultConst : ');
  1451. readderef('');
  1452. writeln(space,' ParaNr : ',getword);
  1453. writeln(space,' Univ : ',boolean(getbyte));
  1454. writeln(space,' VarState : ',getbyte);
  1455. if (vo_has_explicit_paraloc in varoptions) then
  1456. begin
  1457. i:=getbyte;
  1458. getdata(tempbuf,i);
  1459. end;
  1460. end;
  1461. ibenumsym :
  1462. begin
  1463. readcommonsym('Enumeration symbol ');
  1464. write (space,' Definition : ');
  1465. readderef('');
  1466. writeln(space,' Value : ',getlongint);
  1467. end;
  1468. ibsyssym :
  1469. begin
  1470. readcommonsym('Internal system symbol ');
  1471. writeln(space,' Internal Nr : ',getlongint);
  1472. end;
  1473. ibmacrosym :
  1474. begin
  1475. readcommonsym('Macro symbol ');
  1476. writeln(space,' Name: ',getstring);
  1477. writeln(space,' Defined: ',getbyte);
  1478. writeln(space,' Compiler var: ',getbyte);
  1479. len:=getlongint;
  1480. writeln(space,' Value length: ',len);
  1481. if len > 0 then
  1482. begin
  1483. getmem(pc,len+1);
  1484. getdata(pc^,len);
  1485. (pc+len)^:= #0;
  1486. writeln(space,' Value: "',pc,'"');
  1487. freemem(pc,len+1);
  1488. end;
  1489. end;
  1490. ibpropertysym :
  1491. begin
  1492. readcommonsym('Property ');
  1493. i:=getlongint;
  1494. writeln(space,' PropOptions : ',i);
  1495. write (space,' OverrideProp : ');
  1496. readderef('');
  1497. write (space,' Prop Type : ');
  1498. readderef('');
  1499. writeln(space,' Index : ',getlongint);
  1500. writeln(space,' Default : ',getlongint);
  1501. write (space,' Index Type : ');
  1502. readderef('');
  1503. { palt_none }
  1504. readpropaccesslist('');
  1505. write (space,' Readaccess : ');
  1506. readpropaccesslist(space+' Sym: ');
  1507. write (space,' Writeaccess : ');
  1508. readpropaccesslist(space+' Sym: ');
  1509. write (space,' Storedaccess : ');
  1510. readpropaccesslist(space+' Sym: ');
  1511. end;
  1512. iberror :
  1513. begin
  1514. Writeln('!! Error in PPU');
  1515. exit;
  1516. end;
  1517. ibendsyms :
  1518. break;
  1519. else
  1520. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  1521. end;
  1522. if not EndOfEntry then
  1523. Writeln('!! Entry has more information stored');
  1524. until false;
  1525. end;
  1526. end;
  1527. {****************************************************************************
  1528. Read defintions Part
  1529. ****************************************************************************}
  1530. procedure readdefinitions(const s:string);
  1531. { type tordtype is in symconst unit }
  1532. {
  1533. uvoid,
  1534. u8bit,u16bit,u32bit,u64bit,
  1535. s8bit,s16bit,s32bit,s64bit,
  1536. bool8bit,bool16bit,bool32bit,bool64bit,
  1537. uchar,uwidechar,scurrency
  1538. ); }
  1539. { type tobjecttyp is in symconst unit }
  1540. { type tvarianttype is in symconst unit }
  1541. var
  1542. b : byte;
  1543. l,j : longint;
  1544. calloption : tproccalloption;
  1545. procoptions : tprocoptions;
  1546. procinfooptions : tprocinfoflag;
  1547. defoptions: tdefoptions;
  1548. begin
  1549. with ppufile do
  1550. begin
  1551. if space<>'' then
  1552. Writeln(space,'------ ',s,' ------');
  1553. if readentry<>ibstartdefs then
  1554. Writeln('!! ibstartdefs not found');
  1555. repeat
  1556. b:=readentry;
  1557. case b of
  1558. ibpointerdef :
  1559. begin
  1560. readcommondef('Pointer definition',defoptions);
  1561. write (space,' Pointed Type : ');
  1562. readderef('');
  1563. writeln(space,' Is Far : ',(getbyte<>0));
  1564. writeln(space,' Has Pointer Math : ',(getbyte<>0));
  1565. end;
  1566. iborddef :
  1567. begin
  1568. readcommondef('Ordinal definition',defoptions);
  1569. write (space,' Base type : ');
  1570. b:=getbyte;
  1571. case tordtype(b) of
  1572. uvoid : writeln('uvoid');
  1573. u8bit : writeln('u8bit');
  1574. u16bit : writeln('u16bit');
  1575. u32bit : writeln('s32bit');
  1576. u64bit : writeln('u64bit');
  1577. s8bit : writeln('s8bit');
  1578. s16bit : writeln('s16bit');
  1579. s32bit : writeln('s32bit');
  1580. s64bit : writeln('s64bit');
  1581. bool8bit : writeln('bool8bit');
  1582. bool16bit : writeln('bool16bit');
  1583. bool32bit : writeln('bool32bit');
  1584. bool64bit : writeln('bool64bit');
  1585. uchar : writeln('uchar');
  1586. uwidechar : writeln('uwidechar');
  1587. scurrency : writeln('ucurrency');
  1588. else writeln('!! Warning: Invalid base type ',b);
  1589. end;
  1590. writeln(space,' Range : ',constexp.tostr(getexprint),' to ',constexp.tostr(getexprint));
  1591. end;
  1592. ibfloatdef :
  1593. begin
  1594. readcommondef('Float definition',defoptions);
  1595. writeln(space,' Float type : ',getbyte);
  1596. end;
  1597. ibarraydef :
  1598. begin
  1599. readcommondef('Array definition',defoptions);
  1600. write (space,' Element type : ');
  1601. readderef('');
  1602. write (space,' Range Type : ');
  1603. readderef('');
  1604. writeln(space,' Range : ',getaint,' to ',getaint);
  1605. write (space,' Options : ');
  1606. readarraydefoptions;
  1607. readsymtableoptions('symbols');
  1608. readdefinitions('symbols');
  1609. readsymbols('symbols');
  1610. end;
  1611. ibprocdef :
  1612. begin
  1613. readcommondef('Procedure definition',defoptions);
  1614. read_abstract_proc_def(calloption,procoptions);
  1615. if (po_has_mangledname in procoptions) then
  1616. writeln(space,' Mangled name : ',getstring);
  1617. writeln(space,' Number : ',getword);
  1618. writeln(space,' Level : ',getbyte);
  1619. write (space,' Class : ');
  1620. readderef('');
  1621. write (space,' Procsym : ');
  1622. readderef('');
  1623. write (space,' File Pos : ');
  1624. readposinfo;
  1625. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  1626. write (space,' SymOptions : ');
  1627. readsymoptions(space+' ');
  1628. if tsystemcpu(ppufile.header.cpu)=cpu_powerpc then
  1629. begin
  1630. { library symbol for AmigaOS/MorphOS }
  1631. write (space,' Library symbol : ');
  1632. readderef('');
  1633. end;
  1634. if (po_has_importdll in procoptions) then
  1635. writeln(space,' Import DLL : ',getstring);
  1636. if (po_has_importname in procoptions) then
  1637. writeln(space,' Import Name : ',getstring);
  1638. writeln(space,' Import Nr : ',getword);
  1639. if (po_msgint in procoptions) then
  1640. writeln(space,' MsgInt : ',getlongint);
  1641. if (po_msgstr in procoptions) then
  1642. writeln(space,' MsgStr : ',getstring);
  1643. if (po_dispid in procoptions) then
  1644. writeln(space,' DispID: ',ppufile.getlongint);
  1645. if (po_has_inlininginfo in procoptions) then
  1646. begin
  1647. write (space,' FuncretSym : ');
  1648. readderef('');
  1649. ppufile.getsmallset(procinfooptions);
  1650. writeln(space,' ProcInfoOptions : ',dword(procinfooptions));
  1651. end;
  1652. b:=ppufile.getbyte;
  1653. if b<>0 then
  1654. begin
  1655. write (space,' Alias names : ');
  1656. for j:=1 to b do
  1657. begin
  1658. write(ppufile.getstring);
  1659. if j<b then
  1660. write(', ');
  1661. end;
  1662. writeln;
  1663. end;
  1664. if not EndOfEntry then
  1665. Writeln('!! Entry has more information stored');
  1666. space:=' '+space;
  1667. { parast }
  1668. readsymtableoptions('parast');
  1669. readdefinitions('parast');
  1670. readsymbols('parast');
  1671. { localst }
  1672. if (po_has_inlininginfo in procoptions) then
  1673. begin
  1674. readsymtableoptions('localst');
  1675. readdefinitions('localst');
  1676. readsymbols('localst');
  1677. end;
  1678. if (po_has_inlininginfo in procoptions) then
  1679. readnodetree;
  1680. delete(space,1,4);
  1681. end;
  1682. ibprocvardef :
  1683. begin
  1684. readcommondef('Procedural type (ProcVar) definition',defoptions);
  1685. read_abstract_proc_def(calloption,procoptions);
  1686. writeln(space,' Symtable level :',ppufile.getbyte);
  1687. if not EndOfEntry then
  1688. Writeln('!! Entry has more information stored');
  1689. space:=' '+space;
  1690. { parast }
  1691. readsymtableoptions('parast');
  1692. readdefinitions('parast');
  1693. readsymbols('parast');
  1694. delete(space,1,4);
  1695. end;
  1696. ibshortstringdef :
  1697. begin
  1698. readcommondef('ShortString definition',defoptions);
  1699. writeln(space,' Length : ',getbyte);
  1700. end;
  1701. ibwidestringdef :
  1702. begin
  1703. readcommondef('WideString definition',defoptions);
  1704. writeln(space,' Length : ',getlongint);
  1705. end;
  1706. ibunicodestringdef :
  1707. begin
  1708. readcommondef('UnicodeString definition',defoptions);
  1709. writeln(space,' Length : ',getlongint);
  1710. end;
  1711. ibansistringdef :
  1712. begin
  1713. readcommondef('AnsiString definition',defoptions);
  1714. writeln(space,' Length : ',getlongint);
  1715. end;
  1716. iblongstringdef :
  1717. begin
  1718. readcommondef('Longstring definition',defoptions);
  1719. writeln(space,' Length : ',getlongint);
  1720. end;
  1721. ibrecorddef :
  1722. begin
  1723. readcommondef('Record definition',defoptions);
  1724. writeln(space,' Name of Record : ',getstring);
  1725. write (space,' Options : ');
  1726. readobjectdefoptions;
  1727. writeln(space,' FieldAlign : ',getbyte);
  1728. writeln(space,' RecordAlign : ',getbyte);
  1729. writeln(space,' PadAlign : ',getbyte);
  1730. writeln(space,'UseFieldAlignment : ',getbyte);
  1731. writeln(space,' DataSize : ',getaint);
  1732. if not EndOfEntry then
  1733. Writeln('!! Entry has more information stored');
  1734. {read the record definitions and symbols}
  1735. space:=' '+space;
  1736. readsymtableoptions('fields');
  1737. readdefinitions('fields');
  1738. readsymbols('fields');
  1739. Delete(space,1,4);
  1740. end;
  1741. ibobjectdef :
  1742. begin
  1743. readcommondef('Object/Class definition',defoptions);
  1744. writeln(space,' Name of Class : ',getstring);
  1745. write (space,' Options : ');
  1746. readobjectdefoptions;
  1747. b:=getbyte;
  1748. write (space,' Type : ');
  1749. case tobjecttyp(b) of
  1750. odt_class : writeln('class');
  1751. odt_object : writeln('object');
  1752. odt_interfacecom : writeln('interfacecom');
  1753. odt_interfacecorba : writeln('interfacecorba');
  1754. odt_cppclass : writeln('cppclass');
  1755. odt_dispinterface : writeln('dispinterface');
  1756. odt_objcclass : writeln('objcclass');
  1757. odt_objcprotocol : writeln('objcprotocol');
  1758. odt_helper : writeln('helper');
  1759. else writeln('!! Warning: Invalid object type ',b);
  1760. end;
  1761. writeln(space,' External name : ',getstring);
  1762. writeln(space,' Import lib : ',getstring);
  1763. writeln(space,' DataSize : ',getaint);
  1764. writeln(space,' FieldAlign : ',getbyte);
  1765. writeln(space,' RecordAlign : ',getbyte);
  1766. writeln(space,' Vmt offset : ',getlongint);
  1767. write (space, ' Ancestor Class : ');
  1768. readderef('');
  1769. if tobjecttyp(b) in [odt_interfacecom,odt_interfacecorba,odt_dispinterface] then
  1770. begin
  1771. { IIDGUID }
  1772. for j:=1to 16 do
  1773. getbyte;
  1774. writeln(space,' IID String : ',getstring);
  1775. end;
  1776. if (tobjecttyp(b)=odt_helper) or
  1777. (oo_is_classhelper in current_objectoptions) then
  1778. begin
  1779. write(space,' Helper parent : ');
  1780. readderef('');
  1781. end;
  1782. l:=getlongint;
  1783. writeln(space,' VMT entries: ',l);
  1784. for j:=1 to l do
  1785. begin
  1786. write(space,' ');
  1787. readderef('');
  1788. writeln(space,' Visibility: ',Visibility2Str(getbyte));
  1789. end;
  1790. if tobjecttyp(b) in [odt_class,odt_interfacecorba,odt_objcclass,odt_objcprotocol] then
  1791. begin
  1792. l:=getlongint;
  1793. writeln(space,' Impl Intf Count : ',l);
  1794. for j:=1 to l do
  1795. begin
  1796. write (space,' - Definition : ');
  1797. readderef('');
  1798. writeln(space,' IOffset : ',getlongint);
  1799. end;
  1800. end;
  1801. if df_copied_def in current_defoptions then
  1802. begin
  1803. writeln(' Copy of def: ');
  1804. readderef('');
  1805. end;
  1806. if not EndOfEntry then
  1807. Writeln('!! Entry has more information stored');
  1808. if not(df_copied_def in current_defoptions) then
  1809. begin
  1810. {read the record definitions and symbols}
  1811. space:=' '+space;
  1812. readsymtableoptions('fields');
  1813. readdefinitions('fields');
  1814. readsymbols('fields');
  1815. Delete(space,1,4);
  1816. end;
  1817. end;
  1818. ibfiledef :
  1819. begin
  1820. ReadCommonDef('File definition',defoptions);
  1821. write (space,' Type : ');
  1822. case getbyte of
  1823. 0 : writeln('Text');
  1824. 1 : begin
  1825. writeln('Typed');
  1826. write (space,' File of Type : ');
  1827. readderef('');
  1828. end;
  1829. 2 : writeln('Untyped');
  1830. end;
  1831. end;
  1832. ibformaldef :
  1833. begin
  1834. readcommondef('Generic definition (void-typ)',defoptions);
  1835. writeln(space,' Is Typed : ',(getbyte<>0));
  1836. end;
  1837. ibundefineddef :
  1838. readcommondef('Undefined definition (generic parameter)',defoptions);
  1839. ibenumdef :
  1840. begin
  1841. readcommondef('Enumeration type definition',defoptions);
  1842. writeln(space,' Smallest element : ',getaint);
  1843. writeln(space,' Largest element : ',getaint);
  1844. writeln(space,' Size : ',getaint);
  1845. if df_copied_def in defoptions then
  1846. begin
  1847. write(space,'Base enumeration type : ');
  1848. readderef('');
  1849. end
  1850. else
  1851. begin
  1852. space:=' '+space;
  1853. readsymtableoptions('elements');
  1854. readdefinitions('elements');
  1855. readsymbols('elements');
  1856. delete(space,1,4);
  1857. end;
  1858. end;
  1859. ibclassrefdef :
  1860. begin
  1861. readcommondef('Class reference definition',defoptions);
  1862. write (space,' Pointed Type : ');
  1863. readderef('');
  1864. end;
  1865. ibsetdef :
  1866. begin
  1867. readcommondef('Set definition',defoptions);
  1868. write (space,' Element type : ');
  1869. readderef('');
  1870. writeln(space,' Size : ',getaint);
  1871. writeln(space,' Set Base : ',getaint);
  1872. writeln(space,' Set Max : ',getaint);
  1873. end;
  1874. ibvariantdef :
  1875. begin
  1876. readcommondef('Variant definition',defoptions);
  1877. write (space,' Varianttype : ');
  1878. b:=getbyte;
  1879. case tvarianttype(b) of
  1880. vt_normalvariant :
  1881. writeln('Normal');
  1882. vt_olevariant :
  1883. writeln('OLE');
  1884. else
  1885. writeln('!! Warning: Invalid varianttype ',b);
  1886. end;
  1887. end;
  1888. iberror :
  1889. begin
  1890. Writeln('!! Error in PPU');
  1891. exit;
  1892. end;
  1893. ibenddefs :
  1894. break;
  1895. else
  1896. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  1897. end;
  1898. if not EndOfEntry then
  1899. Writeln('!! Entry has more information stored');
  1900. until false;
  1901. end;
  1902. end;
  1903. procedure readmoduleoptions(space : string);
  1904. type
  1905. { tmoduleoption type is in unit fmodule }
  1906. tmoduleoption = (mo_none,
  1907. mo_hint_deprecated,
  1908. mo_hint_platform,
  1909. mo_hint_library,
  1910. mo_hint_unimplemented,
  1911. mo_hint_experimental,
  1912. mo_has_deprecated_msg
  1913. );
  1914. tmoduleoptions = set of tmoduleoption;
  1915. tmoduleopt=record
  1916. mask : tmoduleoption;
  1917. str : string[30];
  1918. end;
  1919. const
  1920. moduleopts=ord(high(tmoduleoption));
  1921. moduleopt : array[1..moduleopts] of tmoduleopt=(
  1922. (mask:mo_hint_deprecated; str:'Hint Deprecated'),
  1923. (mask:mo_hint_platform; str:'Hint Platform'),
  1924. (mask:mo_hint_library; str:'Hint Library'),
  1925. (mask:mo_hint_unimplemented; str:'Hint Unimplemented'),
  1926. (mask:mo_hint_experimental; str:'Hint Experimental'),
  1927. (mask:mo_has_deprecated_msg; str:'Has Deprecated Message')
  1928. );
  1929. var
  1930. moduleoptions : tmoduleoptions;
  1931. i : longint;
  1932. first : boolean;
  1933. begin
  1934. ppufile.getsmallset(moduleoptions);
  1935. if moduleoptions<>[] then
  1936. begin
  1937. first:=true;
  1938. for i:=1to moduleopts do
  1939. if (moduleopt[i].mask in moduleoptions) then
  1940. begin
  1941. if first then
  1942. first:=false
  1943. else
  1944. write(', ');
  1945. write(moduleopt[i].str);
  1946. end;
  1947. end;
  1948. writeln;
  1949. if mo_has_deprecated_msg in moduleoptions then
  1950. writeln(space,'Deprecated : ', ppufile.getstring);
  1951. end;
  1952. {****************************************************************************
  1953. Read General Part
  1954. ****************************************************************************}
  1955. procedure readinterface;
  1956. var
  1957. b : byte;
  1958. sourcenumber : longint;
  1959. begin
  1960. with ppufile do
  1961. begin
  1962. repeat
  1963. b:=readentry;
  1964. case b of
  1965. ibmodulename :
  1966. Writeln('Module Name: ',getstring);
  1967. ibmoduleoptions:
  1968. readmoduleoptions(' ');
  1969. ibsourcefiles :
  1970. begin
  1971. sourcenumber:=1;
  1972. while not EndOfEntry do
  1973. begin
  1974. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  1975. inc(sourcenumber);
  1976. end;
  1977. end;
  1978. {$IFDEF MACRO_DIFF_HINT}
  1979. ibusedmacros :
  1980. begin
  1981. while not EndOfEntry do
  1982. begin
  1983. Write('Conditional ',getstring);
  1984. b:=getbyte;
  1985. if boolean(b)=true then
  1986. write(' defined at startup')
  1987. else
  1988. write(' not defined at startup');
  1989. b:=getbyte;
  1990. if boolean(b)=true then
  1991. writeln(' was used')
  1992. else
  1993. writeln;
  1994. end;
  1995. end;
  1996. {$ENDIF}
  1997. ibloadunit :
  1998. ReadLoadUnit;
  1999. iblinkunitofiles :
  2000. ReadLinkContainer('Link unit object file: ');
  2001. iblinkunitstaticlibs :
  2002. ReadLinkContainer('Link unit static lib: ');
  2003. iblinkunitsharedlibs :
  2004. ReadLinkContainer('Link unit shared lib: ');
  2005. iblinkotherofiles :
  2006. ReadLinkContainer('Link other object file: ');
  2007. iblinkotherstaticlibs :
  2008. ReadLinkContainer('Link other static lib: ');
  2009. iblinkothersharedlibs :
  2010. ReadLinkContainer('Link other shared lib: ');
  2011. iblinkotherframeworks:
  2012. ReadLinkContainer('Link framework: ');
  2013. ibmainname:
  2014. Writeln('Specified main program symbol name: ',getstring);
  2015. ibImportSymbols :
  2016. ReadImportSymbols;
  2017. ibderefdata :
  2018. ReadDerefData;
  2019. ibderefmap :
  2020. ReadDerefMap;
  2021. ibwpofile :
  2022. ReadWpoFileInfo;
  2023. ibresources :
  2024. ReadLinkContainer('Resource file: ');
  2025. iberror :
  2026. begin
  2027. Writeln('Error in PPU');
  2028. exit;
  2029. end;
  2030. ibendinterface :
  2031. break;
  2032. else
  2033. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  2034. end;
  2035. until false;
  2036. end;
  2037. end;
  2038. {****************************************************************************
  2039. Read Implementation Part
  2040. ****************************************************************************}
  2041. procedure readimplementation;
  2042. var
  2043. b : byte;
  2044. begin
  2045. with ppufile do
  2046. begin
  2047. repeat
  2048. b:=readentry;
  2049. case b of
  2050. ibasmsymbols :
  2051. ReadAsmSymbols;
  2052. ibloadunit :
  2053. ReadLoadUnit;
  2054. iberror :
  2055. begin
  2056. Writeln('Error in PPU');
  2057. exit;
  2058. end;
  2059. ibendimplementation :
  2060. break;
  2061. else
  2062. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  2063. end;
  2064. until false;
  2065. end;
  2066. end;
  2067. procedure dofile (filename : string);
  2068. begin
  2069. { reset }
  2070. space:='';
  2071. { fix filename }
  2072. if pos('.',filename)=0 then
  2073. filename:=filename+'.ppu';
  2074. ppufile:=tppufile.create(filename);
  2075. if not ppufile.openfile then
  2076. begin
  2077. writeln ('IO-Error when opening : ',filename,', Skipping');
  2078. exit;
  2079. end;
  2080. { PPU File is open, check for PPU Id }
  2081. if not ppufile.CheckPPUID then
  2082. begin
  2083. writeln(Filename,' : Not a valid PPU file, Skipping');
  2084. exit;
  2085. end;
  2086. { Check PPU Version }
  2087. Writeln('Analyzing ',filename,' (v',ppufile.GetPPUVersion,')');
  2088. if ppufile.GetPPUVersion<16 then
  2089. begin
  2090. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  2091. exit;
  2092. end;
  2093. { Write PPU Header Information }
  2094. if (verbose and v_header)<>0 then
  2095. begin
  2096. Writeln;
  2097. Writeln('Header');
  2098. Writeln('-------');
  2099. with ppufile.header do
  2100. begin
  2101. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  2102. (ppufile.header.compiler shr 7) and $7f,'.',
  2103. ppufile.header.compiler and $7f);
  2104. WriteLn('Target processor : ',Cpu2Str(cpu));
  2105. WriteLn('Target operating system : ',Target2Str(target));
  2106. Writeln('Unit flags : ',PPUFlags2Str(flags));
  2107. Writeln('FileSize (w/o header) : ',size);
  2108. Writeln('Checksum : ',hexstr(checksum,8));
  2109. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  2110. Writeln('Indirect Checksum : ',hexstr(indirect_checksum,8));
  2111. Writeln('Definitions stored : ',tostr(deflistsize));
  2112. Writeln('Symbols stored : ',tostr(symlistsize));
  2113. end;
  2114. end;
  2115. {read the general stuff}
  2116. if (verbose and v_interface)<>0 then
  2117. begin
  2118. Writeln;
  2119. Writeln('Interface section');
  2120. Writeln('------------------');
  2121. readinterface;
  2122. end
  2123. else
  2124. ppufile.skipuntilentry(ibendinterface);
  2125. Writeln;
  2126. Writeln('Interface symtable');
  2127. Writeln('----------------------');
  2128. readsymtableoptions('interface');
  2129. {read the definitions}
  2130. if (verbose and v_defs)<>0 then
  2131. begin
  2132. Writeln;
  2133. Writeln('Interface definitions');
  2134. Writeln('----------------------');
  2135. readdefinitions('interface');
  2136. end
  2137. else
  2138. ppufile.skipuntilentry(ibenddefs);
  2139. {read the symbols}
  2140. if (verbose and v_syms)<>0 then
  2141. begin
  2142. Writeln;
  2143. Writeln('Interface Symbols');
  2144. Writeln('------------------');
  2145. readsymbols('interface');
  2146. end
  2147. else
  2148. ppufile.skipuntilentry(ibendsyms);
  2149. {read the macro symbols}
  2150. if (verbose and v_syms)<>0 then
  2151. begin
  2152. Writeln;
  2153. Writeln('Interface Macro Symbols');
  2154. Writeln('-----------------------');
  2155. end;
  2156. if ppufile.readentry<>ibexportedmacros then
  2157. begin
  2158. Writeln('!! Error in PPU');
  2159. exit;
  2160. end;
  2161. if boolean(ppufile.getbyte) then
  2162. begin
  2163. readsymtableoptions('interface macro');
  2164. {skip the definition section for macros (since they are never used) }
  2165. ppufile.skipuntilentry(ibenddefs);
  2166. {read the macro symbols}
  2167. if (verbose and v_syms)<>0 then
  2168. readsymbols('interface macro')
  2169. else
  2170. ppufile.skipuntilentry(ibendsyms);
  2171. end
  2172. else
  2173. Writeln('(no exported macros)');
  2174. {read the implementation stuff}
  2175. if (verbose and v_implementation)<>0 then
  2176. begin
  2177. Writeln;
  2178. Writeln('Implementation section');
  2179. Writeln('-----------------------');
  2180. readimplementation;
  2181. end
  2182. else
  2183. ppufile.skipuntilentry(ibendimplementation);
  2184. {read the static symtable}
  2185. Writeln;
  2186. Writeln('Implementation symtable');
  2187. Writeln('----------------------');
  2188. readsymtableoptions('implementation');
  2189. if (ppufile.header.flags and uf_local_symtable)<>0 then
  2190. begin
  2191. if (verbose and v_defs)<>0 then
  2192. begin
  2193. Writeln;
  2194. Writeln('Static definitions');
  2195. Writeln('----------------------');
  2196. readdefinitions('implementation');
  2197. end
  2198. else
  2199. ppufile.skipuntilentry(ibenddefs);
  2200. {read the symbols}
  2201. if (verbose and v_syms)<>0 then
  2202. begin
  2203. Writeln;
  2204. Writeln('Static Symbols');
  2205. Writeln('------------------');
  2206. readsymbols('implementation');
  2207. end
  2208. else
  2209. ppufile.skipuntilentry(ibendsyms);
  2210. end;
  2211. ReadCreatedObjTypes;
  2212. {shutdown ppufile}
  2213. ppufile.closefile;
  2214. ppufile.free;
  2215. Writeln;
  2216. end;
  2217. procedure help;
  2218. begin
  2219. writeln('usage: ppudump [options] <filename1> <filename2>...');
  2220. writeln;
  2221. writeln('[options] can be:');
  2222. writeln(' -V<verbose> Set verbosity to <verbose>');
  2223. writeln(' H - Show header info');
  2224. writeln(' I - Show interface');
  2225. writeln(' M - Show implementation');
  2226. writeln(' S - Show interface symbols');
  2227. writeln(' D - Show interface definitions');
  2228. // writeln(' B - Show browser info');
  2229. writeln(' A - Show all');
  2230. writeln(' -h, -? This helpscreen');
  2231. halt;
  2232. end;
  2233. var
  2234. startpara,
  2235. nrfile,i : longint;
  2236. para : string;
  2237. begin
  2238. writeln(Title+' '+Version);
  2239. writeln(Copyright);
  2240. writeln;
  2241. if paramcount<1 then
  2242. begin
  2243. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  2244. halt(1);
  2245. end;
  2246. { turn verbose on by default }
  2247. verbose:=v_all;
  2248. { read options }
  2249. startpara:=1;
  2250. while copy(paramstr(startpara),1,1)='-' do
  2251. begin
  2252. para:=paramstr(startpara);
  2253. case upcase(para[2]) of
  2254. 'V' : begin
  2255. verbose:=0;
  2256. for i:=3 to length(para) do
  2257. case upcase(para[i]) of
  2258. 'H' : verbose:=verbose or v_header;
  2259. 'I' : verbose:=verbose or v_interface;
  2260. 'M' : verbose:=verbose or v_implementation;
  2261. 'D' : verbose:=verbose or v_defs;
  2262. 'S' : verbose:=verbose or v_syms;
  2263. 'A' : verbose:=verbose or v_all;
  2264. end;
  2265. end;
  2266. 'H' : help;
  2267. '?' : help;
  2268. end;
  2269. inc(startpara);
  2270. end;
  2271. { process files }
  2272. for nrfile:=startpara to paramcount do
  2273. dofile (paramstr(nrfile));
  2274. if has_errors then
  2275. Halt(1);
  2276. end.