ppudump.pp 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189
  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. {$ifdef TP}
  17. {$N+,E+}
  18. {$endif}
  19. program pppdump;
  20. uses
  21. dos,
  22. ppu;
  23. const
  24. Version = 'Version 2.0.0';
  25. Title = 'PPU-Analyser';
  26. Copyright = 'Copyright (c) 1998-2005 by the Free Pascal Development Team';
  27. { verbosity }
  28. v_none = $0;
  29. v_header = $1;
  30. v_defs = $2;
  31. v_syms = $4;
  32. v_interface = $8;
  33. v_implementation = $10;
  34. v_browser = $20;
  35. v_all = $ff;
  36. type
  37. tprocinfoflag=(
  38. {# procedure uses asm }
  39. pi_uses_asm,
  40. {# procedure does a call }
  41. pi_do_call,
  42. {# procedure has a try statement = no register optimization }
  43. pi_uses_exceptions,
  44. {# procedure is declared as @var(assembler), don't optimize}
  45. pi_is_assembler,
  46. {# procedure contains data which needs to be finalized }
  47. pi_needs_implicit_finally
  48. );
  49. tprocinfoflags=set of tprocinfoflag;
  50. { Copied from systems.pas }
  51. tsystemcpu=
  52. (
  53. cpu_no, { 0 }
  54. cpu_i386, { 1 }
  55. cpu_m68k, { 2 }
  56. cpu_alpha, { 3 }
  57. cpu_powerpc, { 4 }
  58. cpu_sparc, { 5 }
  59. cpu_vm, { 6 }
  60. cpu_iA64, { 7 }
  61. cpu_x86_64, { 8 }
  62. cpu_mips, { 9 }
  63. cpu_arm { 10 }
  64. );
  65. var
  66. ppufile : tppufile;
  67. space : string;
  68. unitindex : longint;
  69. verbose : longint;
  70. derefdata : pbyte;
  71. derefdatalen : longint;
  72. {****************************************************************************
  73. Helper Routines
  74. ****************************************************************************}
  75. const has_errors : boolean = false;
  76. Procedure Error(const S : string);
  77. Begin
  78. Writeln(S);
  79. has_errors:=true;
  80. End;
  81. function ToStr(w:longint):String;
  82. begin
  83. Str(w,ToStr);
  84. end;
  85. Function Target2Str(w:longint):string;
  86. type
  87. { taken from systems.pas }
  88. ttarget =
  89. (
  90. target_none, { 0 }
  91. target_i386_GO32V1, { 1 }
  92. target_i386_GO32V2, { 2 }
  93. target_i386_linux, { 3 }
  94. target_i386_OS2, { 4 }
  95. target_i386_Win32, { 5 }
  96. target_i386_freebsd, { 6 }
  97. target_m68k_Amiga, { 7 }
  98. target_m68k_Atari, { 8 }
  99. target_m68k_Mac, { 9 }
  100. target_m68k_linux, { 10 }
  101. target_m68k_PalmOS, { 11 }
  102. target_alpha_linux, { 12 }
  103. target_powerpc_linux, { 13 }
  104. target_powerpc_macos, { 14 }
  105. target_i386_sunos, { 15 }
  106. target_i386_beos, { 16 }
  107. target_i386_netbsd, { 17 }
  108. target_m68k_netbsd, { 18 }
  109. target_i386_Netware, { 19 }
  110. target_i386_qnx, { 20 }
  111. target_i386_wdosx, { 21 }
  112. target_sparc_sunos, { 22 }
  113. target_sparc_linux, { 23 }
  114. target_i386_openbsd, { 24 }
  115. target_m68k_openbsd, { 25 }
  116. system_x86_64_linux, { 26 }
  117. system_powerpc_macosx, { 27 }
  118. target_i386_emx, { 28 }
  119. target_powerpc_netbsd, { 29 }
  120. target_powerpc_openbsd, { 30 }
  121. target_arm_linux, { 31 }
  122. target_i386_watcom, { 32 }
  123. target_powerpc_MorphOS, { 33 }
  124. target_x86_64_freebsd, { 34 }
  125. target_i386_netwlibc, { 35 }
  126. system_powerpc_Amiga, { 36 }
  127. system_x86_64_win64, { 37 }
  128. system_arm_wince, { 38 }
  129. system_ia64_win64, { 39 }
  130. system_i386_wince, { 40 }
  131. system_x86_6432_linux, { 41 }
  132. system_arm_gba { 42 }
  133. );
  134. const
  135. Targets : array[ttarget] of string[17]=(
  136. { 0 } 'none',
  137. { 1 } 'GO32V1',
  138. { 2 } 'GO32V2',
  139. { 3 } 'Linux-i386',
  140. { 4 } 'OS/2',
  141. { 5 } 'Win32',
  142. { 6 } 'FreeBSD-i386',
  143. { 7 } 'Amiga',
  144. { 8 } 'Atari',
  145. { 9 } 'MacOS-m68k',
  146. { 10 } 'Linux-m68k',
  147. { 11 } 'PalmOS-m68k',
  148. { 12 } 'Linux-alpha',
  149. { 13 } 'Linux-ppc',
  150. { 14 } 'MacOS-ppc',
  151. { 15 } 'Solaris-i386',
  152. { 16 } 'BeOS-i386',
  153. { 17 } 'NetBSD-i386',
  154. { 18 } 'NetBSD-m68k',
  155. { 19 } 'Netware-i386-clib',
  156. { 20 } 'Qnx-i386',
  157. { 21 } 'WDOSX-i386',
  158. { 22 } 'Solaris-sparc',
  159. { 23 } 'Linux-sparc',
  160. { 24 } 'OpenBSD-i386',
  161. { 25 } 'OpenBSD-m68k',
  162. { 26 } 'Linux-x86-64',
  163. { 27 } 'MacOSX-ppc',
  164. { 28 } 'OS/2 via EMX',
  165. { 29 } 'NetBSD-powerpc',
  166. { 30 } 'OpenBSD-powerpc',
  167. { 31 } 'Linux-arm',
  168. { 32 } 'Watcom-i386',
  169. { 33 } 'MorphOS-powerpc',
  170. { 34 } 'FreeBSD-x86-64',
  171. { 35 } 'Netware-i386-libc',
  172. { 36 } 'Amiga-PowerPC',
  173. { 37 } 'Win64-x64',
  174. { 38 } 'WinCE-ARM',
  175. { 39 } 'Win64-iA64',
  176. { 40 } 'WinCE-i386',
  177. { 41 } 'Linux-x64',
  178. { 42 } 'GBA-ARM'
  179. );
  180. begin
  181. if w<=ord(high(ttarget)) then
  182. Target2Str:=Targets[ttarget(w)]
  183. else
  184. Target2Str:='<!! Unknown target value '+tostr(w)+'>';
  185. end;
  186. Function Cpu2Str(w:longint):string;
  187. const
  188. CpuTxt : array[tsystemcpu] of string[8]=
  189. ('none','i386','m68k','alpha','powerpc','sparc','vis','ia64','x86_64','mips','arm');
  190. begin
  191. if w<=ord(high(tsystemcpu)) then
  192. Cpu2Str:=CpuTxt[tsystemcpu(w)]
  193. else
  194. Cpu2Str:='<!! Unknown cpu value '+tostr(w)+'>';
  195. end;
  196. Function Varspez2Str(w:longint):string;
  197. const
  198. varspezstr : array[0..4] of string[6]=('Value','Const','Var','Out','Hidden');
  199. begin
  200. if w<=ord(high(varspezstr)) then
  201. Varspez2Str:=varspezstr[w]
  202. else
  203. Varspez2Str:='<!! Unknown varspez value '+tostr(w)+'>';
  204. end;
  205. Function VarRegable2Str(w:longint):string;
  206. const
  207. varregableStr : array[0..3] of string[6]=('None','IntReg','FPUReg','MMReg');
  208. begin
  209. if w<=ord(high(varregablestr)) then
  210. Varregable2Str:=varregablestr[w]
  211. else
  212. Varregable2Str:='<!! Unknown regable value '+tostr(w)+'>';
  213. end;
  214. function PPUFlags2Str(flags:longint):string;
  215. type
  216. tflagopt=record
  217. mask : longint;
  218. str : string[30];
  219. end;
  220. const
  221. flagopts=19;
  222. flagopt : array[1..flagopts] of tflagopt=(
  223. (mask: $1 ;str:'init'),
  224. (mask: $2 ;str:'final'),
  225. (mask: $4 ;str:'big_endian'),
  226. (mask: $8 ;str:'dbx'),
  227. (mask: $10 ;str:'browser'),
  228. (mask: $20 ;str:'in_library'),
  229. (mask: $40 ;str:'smart_linked'),
  230. (mask: $80 ;str:'static_linked'),
  231. (mask: $100 ;str:'shared_linked'),
  232. (mask: $200 ;str:'local_browser'),
  233. (mask: $400 ;str:'no_link'),
  234. (mask: $800 ;str:'has_resources'),
  235. (mask: $1000 ;str:'little_endian'),
  236. (mask: $2000 ;str:'release'),
  237. (mask: $4000 ;str:'local_threadvars'),
  238. (mask: $8000 ;str:'fpu_emulation_on'),
  239. (mask: $10000 ;str:'has_debug_info'),
  240. (mask: $20000 ;str:'local_symtable'),
  241. (mask: $40000 ;str:'uses_variants')
  242. );
  243. var
  244. i : longint;
  245. first : boolean;
  246. s : string;
  247. begin
  248. s:='';
  249. if flags<>0 then
  250. begin
  251. first:=true;
  252. for i:=1to flagopts do
  253. if (flags and flagopt[i].mask)<>0 then
  254. begin
  255. if first then
  256. first:=false
  257. else
  258. s:=s+', ';
  259. s:=s+flagopt[i].str;
  260. end;
  261. end
  262. else
  263. s:='none';
  264. PPUFlags2Str:=s;
  265. end;
  266. const
  267. HexTbl : array[0..15] of char='0123456789ABCDEF';
  268. function HexB(b:byte):string;
  269. begin
  270. HexB[0]:=#2;
  271. HexB[1]:=HexTbl[b shr 4];
  272. HexB[2]:=HexTbl[b and $f];
  273. end;
  274. function hexstr(val : cardinal;cnt : byte) : string;
  275. const
  276. HexTbl : array[0..15] of char='0123456789ABCDEF';
  277. var
  278. i : longint;
  279. begin
  280. hexstr[0]:=char(cnt);
  281. for i:=cnt downto 1 do
  282. begin
  283. hexstr[i]:=hextbl[val and $f];
  284. val:=val shr 4;
  285. end;
  286. end;
  287. Function L0(l:longint):string;
  288. {
  289. return the string of value l, if l<10 then insert a zero, so
  290. the string is always at least 2 chars '01','02',etc
  291. }
  292. var
  293. s : string;
  294. begin
  295. Str(l,s);
  296. if l<10 then
  297. s:='0'+s;
  298. L0:=s;
  299. end;
  300. function filetimestring( t : longint) : string;
  301. {
  302. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  303. }
  304. var
  305. DT : DateTime;
  306. begin
  307. if t=-1 then
  308. begin
  309. FileTimeString:='Not Found';
  310. exit;
  311. end;
  312. unpacktime(t,DT);
  313. filetimestring:=L0(dt.Year)+'/'+L0(dt.Month)+'/'+L0(dt.Day)+' '+L0(dt.Hour)+':'+L0(dt.min)+':'+L0(dt.sec);
  314. end;
  315. {****************************************************************************
  316. Read Routines
  317. ****************************************************************************}
  318. Procedure ReadLinkContainer(const prefix:string);
  319. {
  320. Read a serie of strings and write to the screen starting every line
  321. with prefix
  322. }
  323. function maskstr(m:longint):string;
  324. const
  325. { link options }
  326. link_none = $0;
  327. link_allways = $1;
  328. link_static = $2;
  329. link_smart = $4;
  330. link_shared = $8;
  331. var
  332. s : string;
  333. begin
  334. s:='';
  335. if (m and link_allways)<>0 then
  336. s:=s+'always ';
  337. if (m and link_static)<>0 then
  338. s:=s+'static ';
  339. if (m and link_smart)<>0 then
  340. s:=s+'smart ';
  341. if (m and link_shared)<>0 then
  342. s:=s+'shared ';
  343. maskstr:=s;
  344. end;
  345. var
  346. s : string;
  347. m : longint;
  348. begin
  349. while not ppufile.endofentry do
  350. begin
  351. s:=ppufile.getstring;
  352. m:=ppufile.getlongint;
  353. WriteLn(prefix,s,' (',maskstr(m),')');
  354. end;
  355. end;
  356. Procedure ReadContainer(const prefix:string);
  357. {
  358. Read a serie of strings and write to the screen starting every line
  359. with prefix
  360. }
  361. begin
  362. while not ppufile.endofentry do
  363. WriteLn(prefix,ppufile.getstring);
  364. end;
  365. procedure ReadLoadUnit;
  366. var
  367. ucrc,uintfcrc : cardinal;
  368. begin
  369. while not ppufile.EndOfEntry do
  370. begin
  371. write('Uses unit: ',ppufile.getstring);
  372. ucrc:=cardinal(ppufile.getlongint);
  373. uintfcrc:=cardinal(ppufile.getlongint);
  374. writeln(' (Crc: ',hexstr(ucrc,8),', IntfcCrc: ',hexstr(uintfcrc,8),')');
  375. end;
  376. end;
  377. Procedure ReadDerefmap;
  378. var
  379. i,mapsize : longint;
  380. begin
  381. mapsize:=ppufile.getword;
  382. writeln('DerefMapsize: ',mapsize);
  383. for i:=0 to mapsize-1 do
  384. writeln('DerefMap[',i,'] = ',ppufile.getstring);
  385. end;
  386. Procedure ReadDerefdata;
  387. begin
  388. derefdatalen:=ppufile.entrysize;
  389. if derefdatalen=0 then
  390. begin
  391. writeln('!! Error: derefdatalen=0');
  392. exit;
  393. end;
  394. Writeln('Derefdata length: ',derefdatalen);
  395. derefdata:=allocmem(derefdatalen);
  396. ppufile.getdata(derefdata^,derefdatalen);
  397. end;
  398. Procedure ReadRef;
  399. begin
  400. if (verbose and v_browser)=0 then
  401. exit;
  402. while (not ppufile.endofentry) and (not ppufile.error) do
  403. Writeln(space,' - Refered : ',ppufile.getword,', (',ppufile.getlongint,',',ppufile.getword,')');
  404. end;
  405. Procedure ReadAsmSymbols;
  406. type
  407. { Copied from aasmbase.pas }
  408. TAsmsymbind=(AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL);
  409. TAsmsymtype=(AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION);
  410. var
  411. s,
  412. bindstr,
  413. typestr : string;
  414. i : longint;
  415. begin
  416. writeln(space,'Number of AsmSymbols: ',ppufile.getlongint);
  417. i:=0;
  418. while (not ppufile.endofentry) and (not ppufile.error) do
  419. begin
  420. s:=ppufile.getstring;
  421. case tasmsymbind(ppufile.getbyte) of
  422. AB_EXTERNAL :
  423. bindstr:='External';
  424. AB_COMMON :
  425. bindstr:='Common';
  426. AB_LOCAL :
  427. bindstr:='Local';
  428. AB_GLOBAL :
  429. bindstr:='Global';
  430. else
  431. bindstr:='<Error !!>'
  432. end;
  433. case tasmsymtype(ppufile.getbyte) of
  434. AT_FUNCTION :
  435. typestr:='Function';
  436. AT_DATA :
  437. typestr:='Data';
  438. AT_SECTION :
  439. typestr:='Section';
  440. else
  441. typestr:='<Error !!>'
  442. end;
  443. Writeln(space,' ',i,' : ',s,' [',bindstr,',',typestr,']');
  444. inc(i);
  445. end;
  446. end;
  447. Procedure ReadPosInfo;
  448. var
  449. info : byte;
  450. fileindex,line,column : longint;
  451. begin
  452. with ppufile do
  453. begin
  454. {
  455. info byte layout in bits:
  456. 0-1 - amount of bytes for fileindex
  457. 2-3 - amount of bytes for line
  458. 4-5 - amount of bytes for column
  459. }
  460. info:=getbyte;
  461. case (info and $03) of
  462. 0 : fileindex:=getbyte;
  463. 1 : fileindex:=getword;
  464. 2 : fileindex:=(getbyte shl 16) or getword;
  465. 3 : fileindex:=getlongint;
  466. end;
  467. case ((info shr 2) and $03) of
  468. 0 : line:=getbyte;
  469. 1 : line:=getword;
  470. 2 : line:=(getbyte shl 16) or getword;
  471. 3 : line:=getlongint;
  472. end;
  473. case ((info shr 4) and $03) of
  474. 0 : column:=getbyte;
  475. 1 : column:=getword;
  476. 2 : column:=(getbyte shl 16) or getword;
  477. 3 : column:=getlongint;
  478. end;
  479. Writeln(fileindex,' (',line,',',column,')');
  480. end;
  481. end;
  482. procedure readderef;
  483. type
  484. tdereftype = (deref_nil,
  485. deref_sym,
  486. deref_def,
  487. deref_aktrecord,
  488. deref_aktstatic,
  489. deref_aktglobal,
  490. deref_aktlocal,
  491. deref_aktpara,
  492. deref_unit,
  493. deref_record,
  494. deref_local,
  495. deref_para,
  496. deref_parent_object
  497. );
  498. var
  499. b : tdereftype;
  500. first : boolean;
  501. idx : longint;
  502. i,n : byte;
  503. pdata : pbyte;
  504. begin
  505. if not assigned(derefdata) then
  506. exit;
  507. first:=true;
  508. idx:=ppufile.getlongint;
  509. if (idx>derefdatalen) then
  510. begin
  511. writeln('!! Error: Deref idx ',idx,' > ',derefdatalen);
  512. exit;
  513. end;
  514. write('(',idx,') ');
  515. pdata:=@derefdata[idx];
  516. i:=0;
  517. n:=pdata[i];
  518. inc(i);
  519. if n<1 then
  520. begin
  521. writeln('!! Error: Deref len < 1');
  522. exit;
  523. end;
  524. while (i<n) do
  525. begin
  526. if not first then
  527. write(', ')
  528. else
  529. first:=false;
  530. b:=tdereftype(pdata[i]);
  531. inc(i);
  532. case b of
  533. deref_nil :
  534. write('Nil');
  535. deref_def :
  536. begin
  537. idx:=pdata[i] shl 8;
  538. idx:=idx or pdata[i+1];
  539. inc(i,2);
  540. write('Definition ',idx);
  541. end;
  542. deref_sym :
  543. begin
  544. idx:=pdata[i] shl 8;
  545. idx:=idx or pdata[i+1];
  546. inc(i,2);
  547. write('Symbol ',idx);
  548. end;
  549. deref_aktrecord :
  550. write('AktRecord');
  551. deref_aktstatic :
  552. write('AktStatic');
  553. deref_aktglobal :
  554. write('AktGlobal');
  555. deref_aktlocal :
  556. write('AktLocal');
  557. deref_aktpara :
  558. write('AktPara');
  559. deref_unit :
  560. begin
  561. idx:=pdata[i] shl 8;
  562. idx:=idx or pdata[i+1];
  563. inc(i,2);
  564. write('Unit ',idx);
  565. end;
  566. deref_record :
  567. write('RecordDef');
  568. deref_para :
  569. write('Parameter of procdef');
  570. deref_local :
  571. write('Local of procdef');
  572. deref_parent_object :
  573. write('Parent object');
  574. else
  575. begin
  576. writeln('!! unsupported dereftyp: ',ord(b));
  577. break;
  578. end;
  579. end;
  580. end;
  581. writeln;
  582. end;
  583. procedure readtype;
  584. begin
  585. readderef;
  586. end;
  587. procedure readsymlist(const s:string);
  588. type
  589. tsltype = (sl_none,
  590. sl_load,
  591. sl_call,
  592. sl_subscript,
  593. sl_vec
  594. );
  595. const
  596. slstr : array[tsltype] of string[9] = ('',
  597. 'load',
  598. 'call',
  599. 'subscript',
  600. 'vec'
  601. );
  602. var
  603. sl : tsltype;
  604. begin
  605. readderef;
  606. repeat
  607. sl:=tsltype(ppufile.getbyte);
  608. if sl=sl_none then
  609. break;
  610. write(s,'(',slstr[sl],') ');
  611. case sl of
  612. sl_call,
  613. sl_load,
  614. sl_subscript :
  615. readderef;
  616. sl_vec :
  617. writeln(ppufile.getlongint);
  618. end;
  619. until false;
  620. end;
  621. procedure readsymoptions;
  622. type
  623. tsymoption=(sp_none,
  624. sp_public,
  625. sp_private,
  626. sp_published,
  627. sp_protected,
  628. sp_static,
  629. sp_hint_deprecated,
  630. sp_hint_platform,
  631. sp_hint_library,
  632. sp_hint_unimplemented,
  633. sp_has_overloaded,
  634. sp_internal { internal symbol, not reported as unused }
  635. );
  636. tsymoptions=set of tsymoption;
  637. tsymopt=record
  638. mask : tsymoption;
  639. str : string[30];
  640. end;
  641. const
  642. symopts=11;
  643. symopt : array[1..symopts] of tsymopt=(
  644. (mask:sp_public; str:'Public'),
  645. (mask:sp_private; str:'Private'),
  646. (mask:sp_published; str:'Published'),
  647. (mask:sp_protected; str:'Protected'),
  648. (mask:sp_static; str:'Static'),
  649. (mask:sp_hint_deprecated;str:'Hint Deprecated'),
  650. (mask:sp_hint_deprecated;str:'Hint Platform'),
  651. (mask:sp_hint_deprecated;str:'Hint Library'),
  652. (mask:sp_hint_deprecated;str:'Hint Unimplemented'),
  653. (mask:sp_has_overloaded; str:'Has overloaded'),
  654. (mask:sp_internal; str:'Internal')
  655. );
  656. var
  657. symoptions : tsymoptions;
  658. i : longint;
  659. first : boolean;
  660. begin
  661. ppufile.getsmallset(symoptions);
  662. if symoptions<>[] then
  663. begin
  664. first:=true;
  665. for i:=1to symopts do
  666. if (symopt[i].mask in symoptions) then
  667. begin
  668. if first then
  669. first:=false
  670. else
  671. write(', ');
  672. write(symopt[i].str);
  673. end;
  674. end;
  675. writeln;
  676. end;
  677. procedure readcommonsym(const s:string);
  678. begin
  679. writeln(space,'** Symbol Nr. ',ppufile.getword,' **');
  680. writeln(space,s,ppufile.getstring);
  681. write(space,' File Pos : ');
  682. readposinfo;
  683. write(space,' SymOptions : ');
  684. readsymoptions;
  685. end;
  686. procedure readcommondef(const s:string);
  687. type
  688. tdefoption=(df_none,
  689. df_has_inittable, { init data has been generated }
  690. df_has_rttitable, { rtti data has been generated }
  691. df_unique
  692. );
  693. tdefoptions=set of tdefoption;
  694. var
  695. defopts : tdefoptions;
  696. begin
  697. writeln(space,'** Definition Nr. ',ppufile.getword,' **');
  698. writeln(space,s);
  699. write (space,' Type symbol : ');
  700. readderef;
  701. ppufile.getsmallset(defopts);
  702. if df_unique in defopts then
  703. writeln (space,' Unique type symbol');
  704. if df_has_rttitable in defopts then
  705. begin
  706. write (space,' RTTI symbol : ');
  707. readderef;
  708. end;
  709. if df_has_inittable in defopts then
  710. begin
  711. write (space,' Init symbol : ');
  712. readderef;
  713. end;
  714. end;
  715. { Read abstract procdef and return if inline procdef }
  716. type
  717. tproccalloption=(pocall_none,
  718. { procedure uses C styled calling }
  719. pocall_cdecl,
  720. { C++ calling conventions }
  721. pocall_cppdecl,
  722. { Far16 for OS/2 }
  723. pocall_far16,
  724. { Old style FPC default calling }
  725. pocall_oldfpccall,
  726. { Procedure has compiler magic}
  727. pocall_internproc,
  728. { procedure is a system call, applies e.g. to MorphOS and PalmOS }
  729. pocall_syscall,
  730. { pascal standard left to right }
  731. pocall_pascal,
  732. { procedure uses register (fastcall) calling }
  733. pocall_register,
  734. { safe call calling conventions }
  735. pocall_safecall,
  736. { procedure uses stdcall call }
  737. pocall_stdcall,
  738. { Special calling convention for cpus without a floating point
  739. unit. Floating point numbers are passed in integer registers
  740. instead of floating point registers. Depending on the other
  741. available calling conventions available for the cpu
  742. this replaces either pocall_fastcall or pocall_stdcall.
  743. }
  744. pocall_softfloat,
  745. { Metrowerks Pascal. Special case on Mac OS (X): passes all }
  746. { constant records by reference. }
  747. pocall_mwpascal
  748. );
  749. tproccalloptions=set of tproccalloption;
  750. tproctypeoption=(potype_none,
  751. potype_proginit, { Program initialization }
  752. potype_unitinit, { unit initialization }
  753. potype_unitfinalize, { unit finalization }
  754. potype_constructor, { Procedure is a constructor }
  755. potype_destructor, { Procedure is a destructor }
  756. potype_operator, { Procedure defines an operator }
  757. potype_procedure,
  758. potype_function
  759. );
  760. tproctypeoptions=set of tproctypeoption;
  761. tprocoption=(po_none,
  762. po_classmethod, { class method }
  763. po_virtualmethod, { Procedure is a virtual method }
  764. po_abstractmethod, { Procedure is an abstract method }
  765. po_staticmethod, { static method }
  766. po_overridingmethod, { method with override directive }
  767. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  768. po_interrupt, { Procedure is an interrupt handler }
  769. po_iocheck, { IO checking should be done after a call to the procedure }
  770. po_assembler, { Procedure is written in assembler }
  771. po_msgstr, { method for string message handling }
  772. po_msgint, { method for int message handling }
  773. po_exports, { Procedure has export directive (needed for OS/2) }
  774. po_external, { Procedure is external (in other object or lib)}
  775. po_overload, { procedure is declared with overload directive }
  776. po_varargs, { printf like arguments }
  777. po_internconst, { procedure has constant evaluator intern }
  778. { flag that only the address of a method is returned and not a full methodpointer }
  779. po_addressonly,
  780. { procedure is exported }
  781. po_public,
  782. { calling convention is specified explicitly }
  783. po_hascallingconvention,
  784. { reintroduce flag }
  785. po_reintroduce,
  786. { location of parameters is given explicitly as it is necessary for some syscall
  787. conventions like that one of MorphOS }
  788. po_explicitparaloc,
  789. { no stackframe will be generated, used by lowlevel assembler like get_frame }
  790. po_nostackframe,
  791. po_has_mangledname,
  792. po_has_public_name,
  793. po_forward,
  794. po_global,
  795. po_has_inlininginfo,
  796. { The different kind of syscalls on MorphOS }
  797. po_syscall_legacy,
  798. po_syscall_sysv,
  799. po_syscall_basesysv,
  800. po_syscall_sysvbase,
  801. po_syscall_r12base,
  802. po_local,
  803. { Procedure can be inlined }
  804. po_inline,
  805. { Procedure is used for internal compiler calls }
  806. po_compilerproc
  807. );
  808. tprocoptions=set of tprocoption;
  809. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions);
  810. type
  811. tproccallopt=record
  812. mask : tproccalloption;
  813. str : string[30];
  814. end;
  815. tproctypeopt=record
  816. mask : tproctypeoption;
  817. str : string[30];
  818. end;
  819. tprocopt=record
  820. mask : tprocoption;
  821. str : string[30];
  822. end;
  823. const
  824. proccalloptionStr : array[tproccalloption] of string[14]=('',
  825. 'CDecl',
  826. 'CPPDecl',
  827. 'Far16',
  828. 'OldFPCCall',
  829. 'InternProc',
  830. 'SysCall',
  831. 'Pascal',
  832. 'Register',
  833. 'SafeCall',
  834. 'StdCall',
  835. 'SoftFloat',
  836. 'MWPascal'
  837. );
  838. proctypeopts=8;
  839. proctypeopt : array[1..proctypeopts] of tproctypeopt=(
  840. (mask:potype_proginit; str:'ProgInit'),
  841. (mask:potype_unitinit; str:'UnitInit'),
  842. (mask:potype_unitfinalize;str:'UnitFinalize'),
  843. (mask:potype_constructor; str:'Constructor'),
  844. (mask:potype_destructor; str:'Destructor'),
  845. (mask:potype_operator; str:'Operator'),
  846. (mask:potype_function; str:'Function'),
  847. (mask:potype_procedure; str:'Procedure')
  848. );
  849. procopts=35;
  850. procopt : array[1..procopts] of tprocopt=(
  851. (mask:po_classmethod; str:'ClassMethod'),
  852. (mask:po_virtualmethod; str:'VirtualMethod'),
  853. (mask:po_abstractmethod; str:'AbstractMethod'),
  854. (mask:po_staticmethod; str:'StaticMethod'),
  855. (mask:po_overridingmethod;str:'OverridingMethod'),
  856. (mask:po_methodpointer; str:'MethodPointer'),
  857. (mask:po_interrupt; str:'Interrupt'),
  858. (mask:po_iocheck; str:'IOCheck'),
  859. (mask:po_assembler; str:'Assembler'),
  860. (mask:po_msgstr; str:'MsgStr'),
  861. (mask:po_msgint; str:'MsgInt'),
  862. (mask:po_exports; str:'Exports'),
  863. (mask:po_external; str:'External'),
  864. (mask:po_overload; str:'Overload'),
  865. (mask:po_varargs; str:'VarArgs'),
  866. (mask:po_internconst; str:'InternConst'),
  867. (mask:po_addressonly; str:'AddressOnly'),
  868. (mask:po_public; str:'Public'),
  869. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  870. (mask:po_reintroduce; str:'ReIntroduce'),
  871. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  872. (mask:po_nostackframe; str:'NoStackFrame'),
  873. (mask:po_has_mangledname; str:'HasMangledName'),
  874. (mask:po_has_public_name; str:'HasPublicName'),
  875. (mask:po_forward; str:'Forward'),
  876. (mask:po_global; str:'Global'),
  877. (mask:po_has_inlininginfo;str:'HasInliningInfo'),
  878. (mask:po_syscall_legacy; str:'SyscallLegacy'),
  879. (mask:po_syscall_sysv; str:'SyscallSysV'),
  880. (mask:po_syscall_basesysv;str:'SyscallBaseSysV'),
  881. (mask:po_syscall_sysvbase;str:'SyscallSysVBase'),
  882. (mask:po_syscall_r12base; str:'SyscallR12Base'),
  883. (mask:po_local; str:'Local'),
  884. (mask:po_inline; str:'Inline'),
  885. (mask:po_compilerproc; str:'CompilerProc')
  886. );
  887. var
  888. proctypeoption : tproctypeoption;
  889. i : longint;
  890. first : boolean;
  891. tempbuf : array[0..255] of byte;
  892. begin
  893. write(space,' Return type : ');
  894. readtype;
  895. writeln(space,' Fpu used : ',ppufile.getbyte);
  896. proctypeoption:=tproctypeoption(ppufile.getbyte);
  897. write(space,' TypeOption : ');
  898. first:=true;
  899. for i:=1 to proctypeopts do
  900. if (proctypeopt[i].mask=proctypeoption) then
  901. begin
  902. if first then
  903. first:=false
  904. else
  905. write(', ');
  906. write(proctypeopt[i].str);
  907. end;
  908. writeln;
  909. proccalloption:=tproccalloption(ppufile.getbyte);
  910. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  911. ppufile.getnormalset(procoptions);
  912. if procoptions<>[] then
  913. begin
  914. write(space,' Options : ');
  915. first:=true;
  916. for i:=1to procopts do
  917. if (procopt[i].mask in procoptions) then
  918. begin
  919. if first then
  920. first:=false
  921. else
  922. write(', ');
  923. write(procopt[i].str);
  924. end;
  925. writeln;
  926. end;
  927. if (po_explicitparaloc in procoptions) then
  928. begin
  929. i:=ppufile.getbyte;
  930. ppufile.getdata(tempbuf,i);
  931. end;
  932. end;
  933. type
  934. { options for variables }
  935. tvaroption=(vo_none,
  936. vo_is_C_var,
  937. vo_is_external,
  938. vo_is_dll_var,
  939. vo_is_thread_var,
  940. vo_has_local_copy,
  941. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  942. vo_is_exported,
  943. vo_is_high_para,
  944. vo_is_funcret,
  945. vo_is_self,
  946. vo_is_vmt,
  947. vo_is_result, { special result variable }
  948. vo_is_parentfp,
  949. vo_is_loop_counter, { used to detect assignments to loop counter }
  950. vo_is_hidden_para,
  951. vo_has_explicit_paraloc,
  952. vo_is_syscall_lib,
  953. vo_has_mangledname
  954. );
  955. tvaroptions=set of tvaroption;
  956. { register variable }
  957. tvarregable=(vr_none,
  958. vr_intreg,
  959. vr_fpureg,
  960. vr_mmreg
  961. );
  962. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions);
  963. type
  964. tvaropt=record
  965. mask : tvaroption;
  966. str : string[30];
  967. end;
  968. const
  969. varopts=18;
  970. varopt : array[1..varopts] of tvaropt=(
  971. (mask:vo_is_C_var; str:'CVar'),
  972. (mask:vo_is_external; str:'External'),
  973. (mask:vo_is_dll_var; str:'DLLVar'),
  974. (mask:vo_is_thread_var; str:'ThreadVar'),
  975. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  976. (mask:vo_is_const; str:'Constant'),
  977. (mask:vo_is_exported; str:'Exported'),
  978. (mask:vo_is_high_para; str:'HighValue'),
  979. (mask:vo_is_funcret; str:'Funcret'),
  980. (mask:vo_is_self; str:'Self'),
  981. (mask:vo_is_vmt; str:'VMT'),
  982. (mask:vo_is_result; str:'Result'),
  983. (mask:vo_is_parentfp; str:'ParentFP'),
  984. (mask:vo_is_loop_counter; str:'LoopCounter'),
  985. (mask:vo_is_hidden_para; str:'Hidden'),
  986. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  987. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  988. (mask:vo_has_mangledname; str:'HasMangledName')
  989. );
  990. var
  991. i : longint;
  992. first : boolean;
  993. begin
  994. readcommonsym(s);
  995. writeln(space,' Spez : ',Varspez2Str(ppufile.getbyte));
  996. writeln(space,' Regable : ',Varregable2Str(ppufile.getbyte));
  997. write (space,' Var Type : ');
  998. readtype;
  999. ppufile.getsmallset(varoptions);
  1000. if varoptions<>[] then
  1001. begin
  1002. write(space,' Options : ');
  1003. first:=true;
  1004. for i:=1to varopts do
  1005. if (varopt[i].mask in varoptions) then
  1006. begin
  1007. if first then
  1008. first:=false
  1009. else
  1010. write(', ');
  1011. write(varopt[i].str);
  1012. end;
  1013. writeln;
  1014. end;
  1015. end;
  1016. procedure readnodetree;
  1017. var
  1018. l : longint;
  1019. p : pointer;
  1020. begin
  1021. with ppufile do
  1022. begin
  1023. if space<>'' then
  1024. Writeln(space,'------ nodetree ------');
  1025. if readentry=ibnodetree then
  1026. begin
  1027. l:=entrysize;
  1028. Writeln(space,'Tree size : ',l);
  1029. { Read data to prevent error that entry is not completly read }
  1030. getmem(p,l);
  1031. getdata(p^,l);
  1032. freemem(p);
  1033. end
  1034. else
  1035. begin
  1036. Writeln('!! ibnodetree not found');
  1037. end;
  1038. end;
  1039. end;
  1040. {****************************************************************************
  1041. Read Symbols Part
  1042. ****************************************************************************}
  1043. procedure readsymbols(const s:string);
  1044. type
  1045. pguid = ^tguid;
  1046. tguid = packed record
  1047. D1: LongWord;
  1048. D2: Word;
  1049. D3: Word;
  1050. D4: array[0..7] of Byte;
  1051. end;
  1052. absolutetyp = (tovar,toasm,toaddr);
  1053. tconsttyp = (constnone,
  1054. constord,conststring,constreal,
  1055. constset,constpointer,constnil,
  1056. constresourcestring,constwstring,constguid
  1057. );
  1058. var
  1059. b : byte;
  1060. pc : pchar;
  1061. totalsyms,
  1062. symcnt,
  1063. i,j,len : longint;
  1064. guid : tguid;
  1065. tempbuf : array[0..127] of char;
  1066. varoptions : tvaroptions;
  1067. begin
  1068. symcnt:=1;
  1069. with ppufile do
  1070. begin
  1071. if space<>'' then
  1072. Writeln(space,'------ ',s,' ------');
  1073. if readentry=ibstartsyms then
  1074. begin
  1075. totalsyms:=getlongint;
  1076. Writeln(space,'Number of symbols : ',totalsyms);
  1077. Writeln(space,'Symtable datasize : ',getlongint);
  1078. Writeln(space,'Symtable alignment: ',getlongint);
  1079. end
  1080. else
  1081. begin
  1082. totalsyms:=-1;
  1083. Writeln('!! ibstartsym not found');
  1084. end;
  1085. repeat
  1086. b:=readentry;
  1087. if not (b in [iberror,ibendsyms]) then
  1088. inc(symcnt);
  1089. case b of
  1090. ibunitsym :
  1091. readcommonsym('Unit symbol ');
  1092. iblabelsym :
  1093. readcommonsym('Label symbol ');
  1094. ibtypesym :
  1095. begin
  1096. readcommonsym('Type symbol ');
  1097. write(space,' Result Type : ');
  1098. readtype;
  1099. end;
  1100. ibprocsym :
  1101. begin
  1102. readcommonsym('Procedure symbol ');
  1103. len:=ppufile.getword;
  1104. for i:=1 to len do
  1105. begin
  1106. write(space,' Definition : ');
  1107. readderef;
  1108. end;
  1109. end;
  1110. ibconstsym :
  1111. begin
  1112. readcommonsym('Constant symbol ');
  1113. b:=getbyte;
  1114. case tconsttyp(b) of
  1115. constord :
  1116. begin
  1117. write (space,' OrdinalType : ');
  1118. readtype;
  1119. writeln(space,' Value : ',getint64);
  1120. end;
  1121. constpointer :
  1122. begin
  1123. write (space,' PointerType : ');
  1124. readtype;
  1125. writeln(space,' Value : ',getlongint)
  1126. end;
  1127. conststring,
  1128. constresourcestring :
  1129. begin
  1130. len:=getlongint;
  1131. getmem(pc,len+1);
  1132. getdata(pc^,len);
  1133. (pc+len)^:= #0;
  1134. writeln(space,' Length : ',len);
  1135. writeln(space,' Value : "',pc,'"');
  1136. freemem(pc,len+1);
  1137. if tconsttyp(b)=constresourcestring then
  1138. writeln(space,' Index : ',getlongint);
  1139. end;
  1140. constreal :
  1141. writeln(space,' Value : ',getreal);
  1142. constset :
  1143. begin
  1144. write (space,' Set Type : ');
  1145. readtype;
  1146. for i:=1to 4 do
  1147. begin
  1148. write (space,' Value : ');
  1149. for j:=1to 8 do
  1150. begin
  1151. if j>1 then
  1152. write(',');
  1153. write(hexb(getbyte));
  1154. end;
  1155. writeln;
  1156. end;
  1157. end;
  1158. constwstring:
  1159. begin
  1160. end;
  1161. constguid:
  1162. begin
  1163. getdata(guid,sizeof(guid));
  1164. write (space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-');
  1165. for i:=0 to 7 do
  1166. begin
  1167. write(hexstr(guid.d4[i],2));
  1168. if i=1 then write('-');
  1169. end;
  1170. writeln('}');
  1171. end
  1172. else
  1173. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  1174. end;
  1175. end;
  1176. ibabsolutevarsym :
  1177. begin
  1178. readabstractvarsym('Absolute variable symbol ',varoptions);
  1179. Write (space,' Relocated to ');
  1180. b:=getbyte;
  1181. case absolutetyp(b) of
  1182. tovar :
  1183. readsymlist(space+' Sym : ');
  1184. toasm :
  1185. Writeln('Assembler name : ',getstring);
  1186. toaddr :
  1187. begin
  1188. Write('Address : ',getlongint);
  1189. if tsystemcpu(ppufile.header.cpu)=cpu_i386 then
  1190. WriteLn(' (Far: ',getbyte<>0,')');
  1191. end;
  1192. else
  1193. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  1194. end;
  1195. end;
  1196. ibfieldvarsym :
  1197. begin
  1198. readabstractvarsym('Field Variable symbol ',varoptions);
  1199. writeln(space,' Address : ',getlongint);
  1200. end;
  1201. ibglobalvarsym :
  1202. begin
  1203. readabstractvarsym('Global Variable symbol ',varoptions);
  1204. write (space,' DefaultConst : ');
  1205. readderef;
  1206. if (vo_has_mangledname in varoptions) then
  1207. writeln(space,' Mangledname : ',getstring);
  1208. end;
  1209. iblocalvarsym :
  1210. begin
  1211. readabstractvarsym('Local Variable symbol ',varoptions);
  1212. write (space,' DefaultConst : ');
  1213. readderef;
  1214. end;
  1215. ibparavarsym :
  1216. begin
  1217. readabstractvarsym('Parameter Variable symbol ',varoptions);
  1218. write (space,' DefaultConst : ');
  1219. readderef;
  1220. writeln(space,' ParaNr : ',getword);
  1221. if (vo_has_explicit_paraloc in varoptions) then
  1222. begin
  1223. i:=getbyte;
  1224. getdata(tempbuf,i);
  1225. end;
  1226. end;
  1227. ibenumsym :
  1228. begin
  1229. readcommonsym('Enumeration symbol ');
  1230. write (space,' Definition : ');
  1231. readderef;
  1232. writeln(space,' Value : ',getlongint);
  1233. end;
  1234. ibsyssym :
  1235. begin
  1236. readcommonsym('Internal system symbol ');
  1237. writeln(space,' Internal Nr : ',getlongint);
  1238. end;
  1239. ibrttisym :
  1240. begin
  1241. readcommonsym('RTTI symbol ');
  1242. writeln(space,' RTTI Type : ',getbyte);
  1243. end;
  1244. ibmacrosym :
  1245. begin
  1246. readcommonsym('Macro symbol ');
  1247. writeln(space,' Name: ',getstring);
  1248. writeln(space,' Defined: ',getbyte);
  1249. writeln(space,' Compiler var: ',getbyte);
  1250. len:=getlongint;
  1251. writeln(space,' Value length: ',len);
  1252. if len > 0 then
  1253. begin
  1254. getmem(pc,len+1);
  1255. getdata(pc^,len);
  1256. (pc+len)^:= #0;
  1257. writeln(space,' Value: "',pc,'"');
  1258. freemem(pc,len+1);
  1259. end;
  1260. end;
  1261. ibtypedconstsym :
  1262. begin
  1263. readcommonsym('Typed constant ');
  1264. write (space,' Constant Type : ');
  1265. readtype;
  1266. writeln(space,' ReallyConst : ',(getbyte<>0));
  1267. end;
  1268. ibpropertysym :
  1269. begin
  1270. readcommonsym('Property ');
  1271. i:=getlongint;
  1272. writeln(space,' PropOptions : ',i);
  1273. if (i and 32)>0 then
  1274. begin
  1275. write (space,' OverrideProp : ');
  1276. readderef;
  1277. end
  1278. else
  1279. begin
  1280. write (space,' Prop Type : ');
  1281. readtype;
  1282. writeln(space,' Index : ',getlongint);
  1283. writeln(space,' Default : ',getlongint);
  1284. write (space,' Index Type : ');
  1285. readtype;
  1286. write (space,' Readaccess : ');
  1287. readsymlist(space+' Sym: ');
  1288. write (space,' Writeaccess : ');
  1289. readsymlist(space+' Sym: ');
  1290. write (space,' Storedaccess : ');
  1291. readsymlist(space+' Sym: ');
  1292. end;
  1293. end;
  1294. iberror :
  1295. begin
  1296. Writeln('!! Error in PPU');
  1297. exit;
  1298. end;
  1299. ibendsyms :
  1300. break;
  1301. else
  1302. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  1303. end;
  1304. if not EndOfEntry then
  1305. Writeln('!! Entry has more information stored');
  1306. until false;
  1307. if (totalsyms<>-1) and (symcnt-1<>totalsyms) then
  1308. Writeln('!! Only read ',symcnt-1,' of ',totalsyms,' symbols');
  1309. end;
  1310. end;
  1311. {****************************************************************************
  1312. Read defintions Part
  1313. ****************************************************************************}
  1314. procedure readdefinitions(const s:string;start_read : boolean);
  1315. type
  1316. tsettype = (normset,smallset,varset);
  1317. tbasetype = (
  1318. uvoid,
  1319. u8bit,u16bit,u32bit,u64bit,
  1320. s8bit,s16bit,s32bit,s64bit,
  1321. bool8bit,bool16bit,bool32bit,
  1322. uchar,uwidechar,scurrency
  1323. );
  1324. tobjectdeftype = (odt_none,
  1325. odt_class,
  1326. odt_object,
  1327. odt_interfacecom,
  1328. odt_interfacecorba,
  1329. odt_cppclass
  1330. );
  1331. tvarianttype = (
  1332. vt_normalvariant,vt_olevariant
  1333. );
  1334. var
  1335. b : byte;
  1336. totaldefs,l,j,
  1337. defcnt : longint;
  1338. calloption : tproccalloption;
  1339. procoptions : tprocoptions;
  1340. procinfooptions : tprocinfoflag;
  1341. begin
  1342. defcnt:=0;
  1343. with ppufile do
  1344. begin
  1345. if space<>'' then
  1346. Writeln(space,'------ ',s,' ------');
  1347. if not start_read then
  1348. if readentry=ibstartdefs then
  1349. begin
  1350. totaldefs:=getlongint;
  1351. Writeln(space,'Number of definitions: ',totaldefs);
  1352. end
  1353. else
  1354. begin
  1355. totaldefs:=-1;
  1356. Writeln('!! ibstartdef not found');
  1357. end;
  1358. repeat
  1359. b:=readentry;
  1360. if not (b in [iberror,ibenddefs]) then
  1361. inc(defcnt);
  1362. case b of
  1363. ibpointerdef :
  1364. begin
  1365. readcommondef('Pointer definition');
  1366. write (space,' Pointed Type : ');
  1367. readtype;
  1368. writeln(space,' Is Far : ',(getbyte<>0));
  1369. end;
  1370. iborddef :
  1371. begin
  1372. readcommondef('Ordinal definition');
  1373. write (space,' Base type : ');
  1374. b:=getbyte;
  1375. case tbasetype(b) of
  1376. uvoid : writeln('uvoid');
  1377. u8bit : writeln('u8bit');
  1378. u16bit : writeln('u16bit');
  1379. u32bit : writeln('s32bit');
  1380. u64bit : writeln('u64bit');
  1381. s8bit : writeln('s8bit');
  1382. s16bit : writeln('s16bit');
  1383. s32bit : writeln('s32bit');
  1384. s64bit : writeln('s64bit');
  1385. bool8bit : writeln('bool8bit');
  1386. bool16bit : writeln('bool16bit');
  1387. bool32bit : writeln('bool32bit');
  1388. uchar : writeln('uchar');
  1389. uwidechar : writeln('uwidechar');
  1390. scurrency : writeln('ucurrency');
  1391. else writeln('!! Warning: Invalid base type ',b);
  1392. end;
  1393. writeln(space,' Range : ',getint64,' to ',getint64);
  1394. end;
  1395. ibfloatdef :
  1396. begin
  1397. readcommondef('Float definition');
  1398. writeln(space,' Float type : ',getbyte);
  1399. end;
  1400. ibarraydef :
  1401. begin
  1402. readcommondef('Array definition');
  1403. write (space,' Element type : ');
  1404. readtype;
  1405. write (space,' Range Type : ');
  1406. readtype;
  1407. writeln(space,' Range : ',getlongint,' to ',getlongint);
  1408. writeln(space,' Is Constructor : ',(getbyte<>0));
  1409. writeln(space,' Is Dynamic : ',(getbyte<>0));
  1410. end;
  1411. ibprocdef :
  1412. begin
  1413. readcommondef('Procedure definition');
  1414. read_abstract_proc_def(calloption,procoptions);
  1415. if (po_has_mangledname in procoptions) then
  1416. writeln(space,' Mangled name : ',getstring);
  1417. writeln(space,' Number : ',getword);
  1418. writeln(space,' Level : ',getbyte);
  1419. write (space,' Class : ');
  1420. readderef;
  1421. write (space,' Procsym : ');
  1422. readderef;
  1423. write (space,' File Pos : ');
  1424. readposinfo;
  1425. write (space,' SymOptions : ');
  1426. readsymoptions;
  1427. if tsystemcpu(ppufile.header.cpu)=cpu_powerpc then
  1428. begin
  1429. { library symbol for AmigaOS/MorphOS }
  1430. write (space,' Library symbol : ');
  1431. readderef;
  1432. end;
  1433. if (po_inline in procoptions) then
  1434. begin
  1435. write (space,' FuncretSym : ');
  1436. readderef;
  1437. ppufile.getsmallset(procinfooptions);
  1438. writeln(space,' ProcInfoOptions : ',dword(procinfooptions));
  1439. b := ppufile.getbyte;
  1440. writeln(space,' Inline node tree : ',b);
  1441. end;
  1442. if not EndOfEntry then
  1443. Writeln('!! Entry has more information stored');
  1444. space:=' '+space;
  1445. { parast }
  1446. readdefinitions('parast',false);
  1447. readsymbols('parast');
  1448. { localst }
  1449. if (po_has_inlininginfo in procoptions) or
  1450. ((ppufile.header.flags and uf_local_browser)<>0) then
  1451. begin
  1452. readdefinitions('localst',false);
  1453. readsymbols('localst');
  1454. end;
  1455. if (po_has_inlininginfo in procoptions) then
  1456. readnodetree;
  1457. delete(space,1,4);
  1458. end;
  1459. ibprocvardef :
  1460. begin
  1461. readcommondef('Procedural type (ProcVar) definition');
  1462. read_abstract_proc_def(calloption,procoptions);
  1463. if not EndOfEntry then
  1464. Writeln('!! Entry has more information stored');
  1465. space:=' '+space;
  1466. { parast }
  1467. readdefinitions('parast',false);
  1468. readsymbols('parast');
  1469. delete(space,1,4);
  1470. end;
  1471. ibshortstringdef :
  1472. begin
  1473. readcommondef('ShortString definition');
  1474. writeln(space,' Length : ',getbyte);
  1475. end;
  1476. ibwidestringdef :
  1477. begin
  1478. readcommondef('WideString definition');
  1479. writeln(space,' Length : ',getlongint);
  1480. end;
  1481. ibansistringdef :
  1482. begin
  1483. readcommondef('AnsiString definition');
  1484. writeln(space,' Length : ',getlongint);
  1485. end;
  1486. iblongstringdef :
  1487. begin
  1488. readcommondef('Longstring definition');
  1489. writeln(space,' Length : ',getlongint);
  1490. end;
  1491. ibrecorddef :
  1492. begin
  1493. readcommondef('Record definition');
  1494. writeln(space,' DataSize : ',getlongint);
  1495. writeln(space,' FieldAlign : ',getbyte);
  1496. writeln(space,' RecordAlign : ',getbyte);
  1497. writeln(space,' PadAlign : ',getbyte);
  1498. if not EndOfEntry then
  1499. Writeln('!! Entry has more information stored');
  1500. {read the record definitions and symbols}
  1501. space:=' '+space;
  1502. readdefinitions('fields',false);
  1503. readsymbols('fields');
  1504. Delete(space,1,4);
  1505. end;
  1506. ibobjectdef :
  1507. begin
  1508. readcommondef('Object/Class definition');
  1509. b:=getbyte;
  1510. write (space,' Type : ');
  1511. case tobjectdeftype(b) of
  1512. odt_class : writeln('class');
  1513. odt_object : writeln('object');
  1514. odt_interfacecom : writeln('interfacecom');
  1515. odt_interfacecorba : writeln('interfacecorba');
  1516. odt_cppclass : writeln('cppclass');
  1517. else writeln('!! Warning: Invalid object type ',b);
  1518. end;
  1519. writeln(space,' Name of Class : ',getstring);
  1520. writeln(space,' DataSize : ',getlongint);
  1521. writeln(space,' FieldAlign : ',getbyte);
  1522. writeln(space,' RecordAlign : ',getbyte);
  1523. writeln(space,' Vmt offset : ',getlongint);
  1524. write(space, ' Ancestor Class : ');
  1525. readderef;
  1526. writeln(space,' Options : ',getlongint);
  1527. if tobjectdeftype(b) in [odt_interfacecom,odt_interfacecorba] then
  1528. begin
  1529. { IIDGUID }
  1530. for j:=1to 16 do
  1531. getbyte;
  1532. writeln(space,' IID String : ',getstring);
  1533. writeln(space,' Last VTable idx : ',getlongint);
  1534. end;
  1535. if tobjectdeftype(b) in [odt_class,odt_interfacecorba] then
  1536. begin
  1537. l:=getlongint;
  1538. writeln(space,' Impl Intf Count : ',l);
  1539. for j:=1 to l do
  1540. begin
  1541. write (space,' - Definition : ');
  1542. readderef;
  1543. writeln(space,' IOffset : ',getlongint);
  1544. end;
  1545. end;
  1546. if not EndOfEntry then
  1547. Writeln('!! Entry has more information stored');
  1548. {read the record definitions and symbols}
  1549. space:=' '+space;
  1550. readdefinitions('fields',false);
  1551. readsymbols('fields');
  1552. Delete(space,1,4);
  1553. end;
  1554. ibfiledef :
  1555. begin
  1556. ReadCommonDef('File definition');
  1557. write (space,' Type : ');
  1558. case getbyte of
  1559. 0 : writeln('Text');
  1560. 1 : begin
  1561. writeln('Typed');
  1562. write (space,' File of Type : ');
  1563. Readtype;
  1564. end;
  1565. 2 : writeln('Untyped');
  1566. end;
  1567. end;
  1568. ibformaldef :
  1569. readcommondef('Generic Definition (void-typ)');
  1570. ibenumdef :
  1571. begin
  1572. readcommondef('Enumeration type definition');
  1573. write(space,'Base enumeration type : ');
  1574. readderef;
  1575. writeln(space,' Smallest element : ',getlongint);
  1576. writeln(space,' Largest element : ',getlongint);
  1577. writeln(space,' Size : ',getlongint);
  1578. end;
  1579. ibclassrefdef :
  1580. begin
  1581. readcommondef('Class reference definition');
  1582. write (space,' Pointed Type : ');
  1583. readtype;
  1584. end;
  1585. ibsetdef :
  1586. begin
  1587. readcommondef('Set definition');
  1588. write (space,' Element type : ');
  1589. readtype;
  1590. b:=getbyte;
  1591. case tsettype(b) of
  1592. smallset : writeln(space,' Set with 32 Elements');
  1593. normset : writeln(space,' Set with 256 Elements');
  1594. varset : writeln(space,' Set with ',getlongint,' Elements');
  1595. else writeln('!! Warning: Invalid set type ',b);
  1596. end;
  1597. end;
  1598. ibvariantdef :
  1599. begin
  1600. readcommondef('Variant definition');
  1601. write (space,' Varianttype : ');
  1602. b:=getbyte;
  1603. case tvarianttype(b) of
  1604. vt_normalvariant :
  1605. writeln('Normal');
  1606. vt_olevariant :
  1607. writeln('OLE');
  1608. else
  1609. writeln('!! Warning: Invalid varianttype ',b);
  1610. end;
  1611. end;
  1612. iberror :
  1613. begin
  1614. Writeln('!! Error in PPU');
  1615. exit;
  1616. end;
  1617. ibenddefs :
  1618. break;
  1619. else
  1620. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  1621. end;
  1622. if not EndOfEntry then
  1623. Writeln('!! Entry has more information stored');
  1624. until false;
  1625. if (totaldefs<>-1) and (defcnt<>totaldefs) then
  1626. Writeln('!! Only read ',defcnt,' of ',totaldefs,' definitions');
  1627. end;
  1628. end;
  1629. {****************************************************************************
  1630. Read General Part
  1631. ****************************************************************************}
  1632. procedure readinterface;
  1633. var
  1634. b : byte;
  1635. sourcenumber : longint;
  1636. begin
  1637. with ppufile do
  1638. begin
  1639. repeat
  1640. b:=readentry;
  1641. case b of
  1642. ibmodulename :
  1643. Writeln('Module Name: ',getstring);
  1644. ibsourcefiles :
  1645. begin
  1646. sourcenumber:=1;
  1647. while not EndOfEntry do
  1648. begin
  1649. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  1650. inc(sourcenumber);
  1651. end;
  1652. end;
  1653. {$IFDEF MACRO_DIFF_HINT}
  1654. ibusedmacros :
  1655. begin
  1656. while not EndOfEntry do
  1657. begin
  1658. Write('Conditional ',getstring);
  1659. b:=getbyte;
  1660. if boolean(b)=true then
  1661. write(' defined at startup')
  1662. else
  1663. write(' not defined at startup');
  1664. b:=getbyte;
  1665. if boolean(b)=true then
  1666. writeln(' was used')
  1667. else
  1668. writeln;
  1669. end;
  1670. end;
  1671. {$ENDIF}
  1672. ibloadunit :
  1673. ReadLoadUnit;
  1674. iblinkunitofiles :
  1675. ReadLinkContainer('Link unit object file: ');
  1676. iblinkunitstaticlibs :
  1677. ReadLinkContainer('Link unit static lib: ');
  1678. iblinkunitsharedlibs :
  1679. ReadLinkContainer('Link unit shared lib: ');
  1680. iblinkotherofiles :
  1681. ReadLinkContainer('Link other object file: ');
  1682. iblinkotherstaticlibs :
  1683. ReadLinkContainer('Link other static lib: ');
  1684. iblinkothersharedlibs :
  1685. ReadLinkContainer('Link other shared lib: ');
  1686. ibderefdata :
  1687. ReadDerefData;
  1688. ibderefmap :
  1689. ReadDerefMap;
  1690. iberror :
  1691. begin
  1692. Writeln('Error in PPU');
  1693. exit;
  1694. end;
  1695. ibendinterface :
  1696. break;
  1697. else
  1698. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  1699. end;
  1700. until false;
  1701. end;
  1702. end;
  1703. {****************************************************************************
  1704. Read Implementation Part
  1705. ****************************************************************************}
  1706. procedure readimplementation;
  1707. var
  1708. b : byte;
  1709. begin
  1710. with ppufile do
  1711. begin
  1712. repeat
  1713. b:=readentry;
  1714. case b of
  1715. ibasmsymbols :
  1716. ReadAsmSymbols;
  1717. ibloadunit :
  1718. ReadLoadUnit;
  1719. iberror :
  1720. begin
  1721. Writeln('Error in PPU');
  1722. exit;
  1723. end;
  1724. ibendimplementation :
  1725. break;
  1726. else
  1727. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  1728. end;
  1729. until false;
  1730. end;
  1731. end;
  1732. {****************************************************************************
  1733. Read Browser Part
  1734. ****************************************************************************}
  1735. procedure readbrowser;
  1736. var
  1737. b : byte;
  1738. const indent : string = '';
  1739. begin
  1740. Writeln(indent,'Start of symtable browser');
  1741. indent:=indent+'**';
  1742. with ppufile do
  1743. begin
  1744. repeat
  1745. b:=readentry;
  1746. case b of
  1747. ibbeginsymtablebrowser :
  1748. begin
  1749. { here we must read object and record symtables !! }
  1750. indent:=indent+' ';
  1751. Writeln(indent,'Record/Object symtable');
  1752. readbrowser;
  1753. Indent:=Copy(Indent,1,Length(Indent)-2);
  1754. end;
  1755. ibsymref :
  1756. begin
  1757. readderef;
  1758. readref;
  1759. end;
  1760. ibdefref :
  1761. begin
  1762. readderef;
  1763. readref;
  1764. if ((ppufile.header.flags and uf_local_browser)<>0) and
  1765. (UnitIndex=0) then
  1766. begin
  1767. { parast and localst }
  1768. indent:=indent+' ';
  1769. b:=ppufile.readentry;
  1770. if b=ibbeginsymtablebrowser then
  1771. readbrowser;
  1772. b:=ppufile.readentry;
  1773. if b=ibbeginsymtablebrowser then
  1774. readbrowser;
  1775. Indent:=Copy(Indent,1,Length(Indent)-2);
  1776. end;
  1777. end;
  1778. iberror :
  1779. begin
  1780. Writeln('Error in PPU');
  1781. exit;
  1782. end;
  1783. ibendsymtablebrowser :
  1784. break;
  1785. else
  1786. begin
  1787. WriteLn('!! Skipping unsupported PPU Entry in Browser: ',b);
  1788. Halt;
  1789. end;
  1790. end;
  1791. until false;
  1792. end;
  1793. Indent:=Copy(Indent,1,Length(Indent)-2);
  1794. Writeln(Indent,'End of symtable browser');
  1795. end;
  1796. procedure dofile (filename : string);
  1797. var
  1798. b : byte;
  1799. begin
  1800. { reset }
  1801. space:='';
  1802. { fix filename }
  1803. if pos('.',filename)=0 then
  1804. filename:=filename+'.ppu';
  1805. ppufile:=tppufile.create(filename);
  1806. if not ppufile.openfile then
  1807. begin
  1808. writeln ('IO-Error when opening : ',filename,', Skipping');
  1809. exit;
  1810. end;
  1811. { PPU File is open, check for PPU Id }
  1812. if not ppufile.CheckPPUID then
  1813. begin
  1814. writeln(Filename,' : Not a valid PPU file, Skipping');
  1815. exit;
  1816. end;
  1817. { Check PPU Version }
  1818. Writeln('Analyzing ',filename,' (v',ppufile.GetPPUVersion,')');
  1819. if ppufile.GetPPUVersion<16 then
  1820. begin
  1821. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  1822. exit;
  1823. end;
  1824. { Write PPU Header Information }
  1825. if (verbose and v_header)<>0 then
  1826. begin
  1827. Writeln;
  1828. Writeln('Header');
  1829. Writeln('-------');
  1830. with ppufile.header do
  1831. begin
  1832. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  1833. (ppufile.header.compiler shr 7) and $7f,'.',
  1834. ppufile.header.compiler and $7f);
  1835. WriteLn('Target processor : ',Cpu2Str(cpu));
  1836. WriteLn('Target operating system : ',Target2Str(target));
  1837. Writeln('Unit flags : ',PPUFlags2Str(flags));
  1838. Writeln('FileSize (w/o header) : ',size);
  1839. Writeln('Checksum : ',hexstr(checksum,8));
  1840. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  1841. end;
  1842. end;
  1843. {read the general stuff}
  1844. if (verbose and v_interface)<>0 then
  1845. begin
  1846. Writeln;
  1847. Writeln('Interface section');
  1848. Writeln('------------------');
  1849. readinterface;
  1850. end
  1851. else
  1852. ppufile.skipuntilentry(ibendinterface);
  1853. {read the definitions}
  1854. if (verbose and v_defs)<>0 then
  1855. begin
  1856. Writeln;
  1857. Writeln('Interface definitions');
  1858. Writeln('----------------------');
  1859. readdefinitions('interface',false);
  1860. end
  1861. else
  1862. ppufile.skipuntilentry(ibenddefs);
  1863. {read the symbols}
  1864. if (verbose and v_syms)<>0 then
  1865. begin
  1866. Writeln;
  1867. Writeln('Interface Symbols');
  1868. Writeln('------------------');
  1869. readsymbols('interface');
  1870. end
  1871. else
  1872. ppufile.skipuntilentry(ibendsyms);
  1873. {read the macro symbols}
  1874. if (verbose and v_syms)<>0 then
  1875. begin
  1876. Writeln;
  1877. Writeln('Interface Macro Symbols');
  1878. Writeln('-----------------------');
  1879. end;
  1880. if ppufile.readentry<>ibexportedmacros then
  1881. begin
  1882. Writeln('!! Error in PPU');
  1883. exit;
  1884. end;
  1885. if boolean(ppufile.getbyte) then
  1886. begin
  1887. {skip the definition section for macros (since they are never used) }
  1888. ppufile.skipuntilentry(ibenddefs);
  1889. {read the macro symbols}
  1890. if (verbose and v_syms)<>0 then
  1891. readsymbols('interface macro')
  1892. else
  1893. ppufile.skipuntilentry(ibendsyms);
  1894. end
  1895. else
  1896. Writeln('(no exported macros)');
  1897. {read the implementation stuff}
  1898. if (verbose and v_implementation)<>0 then
  1899. begin
  1900. Writeln;
  1901. Writeln('Implementation section');
  1902. Writeln('-----------------------');
  1903. readimplementation;
  1904. end
  1905. else
  1906. ppufile.skipuntilentry(ibendimplementation);
  1907. {read the static browser units stuff}
  1908. if (ppufile.header.flags and uf_local_symtable)<>0 then
  1909. begin
  1910. if (verbose and v_defs)<>0 then
  1911. begin
  1912. Writeln;
  1913. Writeln('Static definitions');
  1914. Writeln('----------------------');
  1915. readdefinitions('implementation',false);
  1916. end
  1917. else
  1918. ppufile.skipuntilentry(ibenddefs);
  1919. {read the symbols}
  1920. if (verbose and v_syms)<>0 then
  1921. begin
  1922. Writeln;
  1923. Writeln('Static Symbols');
  1924. Writeln('------------------');
  1925. readsymbols('implementation');
  1926. end
  1927. else
  1928. ppufile.skipuntilentry(ibendsyms);
  1929. end;
  1930. {read the browser units stuff}
  1931. if (ppufile.header.flags and uf_has_browser)<>0 then
  1932. begin
  1933. if (verbose and v_browser)<>0 then
  1934. begin
  1935. Writeln;
  1936. Writeln('Browser section');
  1937. Writeln('---------------');
  1938. UnitIndex:=0;
  1939. repeat
  1940. b:=ppufile.readentry;
  1941. if b = ibendbrowser then break;
  1942. if b=ibbeginsymtablebrowser then
  1943. begin
  1944. Writeln('Unit ',UnitIndex);
  1945. readbrowser;
  1946. Inc(UnitIndex);
  1947. end
  1948. else
  1949. Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
  1950. until false;
  1951. end;
  1952. end;
  1953. {read the static browser units stuff}
  1954. if (ppufile.header.flags and uf_local_browser)<>0 then
  1955. begin
  1956. if (verbose and v_browser)<>0 then
  1957. begin
  1958. Writeln;
  1959. Writeln('Static browser section');
  1960. Writeln('---------------');
  1961. UnitIndex:=0;
  1962. b:=ppufile.readentry;
  1963. if b=ibbeginsymtablebrowser then
  1964. readbrowser
  1965. else
  1966. Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
  1967. end;
  1968. end;
  1969. {shutdown ppufile}
  1970. ppufile.closefile;
  1971. ppufile.free;
  1972. Writeln;
  1973. end;
  1974. procedure help;
  1975. begin
  1976. writeln('usage: ppudump [options] <filename1> <filename2>...');
  1977. writeln;
  1978. writeln('[options] can be:');
  1979. writeln(' -V<verbose> Set verbosity to <verbose>');
  1980. writeln(' H - Show header info');
  1981. writeln(' I - Show interface');
  1982. writeln(' M - Show implementation');
  1983. writeln(' S - Show interface symbols');
  1984. writeln(' D - Show interface definitions');
  1985. writeln(' B - Show browser info');
  1986. writeln(' A - Show all');
  1987. writeln(' -h, -? This helpscreen');
  1988. halt;
  1989. end;
  1990. var
  1991. startpara,
  1992. nrfile,i : longint;
  1993. para : string;
  1994. begin
  1995. writeln(Title+' '+Version);
  1996. writeln(Copyright);
  1997. writeln;
  1998. if paramcount<1 then
  1999. begin
  2000. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  2001. halt(1);
  2002. end;
  2003. { turn verbose on by default }
  2004. verbose:=v_all;
  2005. { read options }
  2006. startpara:=1;
  2007. while copy(paramstr(startpara),1,1)='-' do
  2008. begin
  2009. para:=paramstr(startpara);
  2010. case upcase(para[2]) of
  2011. 'V' : begin
  2012. verbose:=0;
  2013. for i:=3 to length(para) do
  2014. case upcase(para[i]) of
  2015. 'H' : verbose:=verbose or v_header;
  2016. 'I' : verbose:=verbose or v_interface;
  2017. 'M' : verbose:=verbose or v_implementation;
  2018. 'D' : verbose:=verbose or v_defs;
  2019. 'S' : verbose:=verbose or v_syms;
  2020. 'B' : verbose:=verbose or v_browser;
  2021. 'A' : verbose:=verbose or v_all;
  2022. end;
  2023. end;
  2024. 'H' : help;
  2025. '?' : help;
  2026. end;
  2027. inc(startpara);
  2028. end;
  2029. { process files }
  2030. for nrfile:=startpara to paramcount do
  2031. dofile (paramstr(nrfile));
  2032. if has_errors then
  2033. Halt(1);
  2034. end.