ppudump.pp 60 KB

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