ppudump.pp 60 KB

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