ppudump.pp 61 KB

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