ppudump.pp 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by the FPC Development Team
  4. Dumps the contents of a FPC unit file (PPU File)
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************}
  17. {$ifdef TP}
  18. {$N+,E+}
  19. {$endif}
  20. program pppdump;
  21. uses
  22. {$ifdef go32v2}
  23. dpmiexcp,
  24. {$endif go32v2}
  25. ppu;
  26. const
  27. Version = 'Version 1.10';
  28. Title = 'PPU-Analyser';
  29. Copyright = 'Copyright (c) 1998-2001 by the Free Pascal Development Team';
  30. { verbosity }
  31. v_none = $0;
  32. v_header = $1;
  33. v_defs = $2;
  34. v_syms = $4;
  35. v_interface = $8;
  36. v_implementation = $10;
  37. v_browser = $20;
  38. v_all = $ff;
  39. var
  40. ppufile : tppufile;
  41. space : string;
  42. read_member : boolean;
  43. unitindex : longint;
  44. verbose : longint;
  45. {****************************************************************************
  46. Helper Routines
  47. ****************************************************************************}
  48. const has_errors : boolean = false;
  49. Procedure Error(const S : string);
  50. Begin
  51. Writeln(S);
  52. has_errors:=true;
  53. End;
  54. Function Target2Str(w:longint):string;
  55. type
  56. { taken from systems.pas }
  57. ttarget =
  58. (
  59. target_none, { 0 }
  60. target_i386_GO32V1, { 1 }
  61. target_i386_GO32V2, { 2 }
  62. target_i386_linux, { 3 }
  63. target_i386_OS2, { 4 }
  64. target_i386_Win32, { 5 }
  65. target_i386_freebsd, { 6 }
  66. target_m68k_Amiga, { 7 }
  67. target_m68k_Atari, { 8 }
  68. target_m68k_Mac, { 9 }
  69. target_m68k_linux, { 10 }
  70. target_m68k_PalmOS, { 11 }
  71. target_alpha_linux, { 12 }
  72. target_powerpc_linux, { 13 }
  73. target_powerpc_macos, { 14 }
  74. target_i386_sunos, { 15 }
  75. target_i386_beos, { 16 }
  76. target_i386_netbsd, { 17 }
  77. target_m68k_netbsd, { 18 }
  78. target_i386_Netware { 19 }
  79. );
  80. const
  81. Targets : array[ttarget] of string[12]=(
  82. { 0 } 'none',
  83. { 1 } 'GO32V1',
  84. { 2 } 'GO32V2',
  85. { 3 } 'Linux-i386',
  86. { 4 } 'OS/2',
  87. { 5 } 'Win32',
  88. { 6 } 'FreeBSD-i386',
  89. { 7 } 'Amiga',
  90. { 8 } 'Atari',
  91. { 9 } 'MacOS-m68k',
  92. { 10 } 'Linux-m68k',
  93. { 11 } 'PalmOS-m68k',
  94. { 12 } 'Linux-alpha',
  95. { 13 } 'Linux-ppc',
  96. { 14 } 'MacOS-ppc',
  97. { 15 } 'Solaris-i386',
  98. { 16 } 'BeOS-i386',
  99. { 17 } 'NetBSD-i386',
  100. { 18 } 'NetBSD-m68k',
  101. { 19 } 'Netware'
  102. );
  103. begin
  104. if w<=ord(high(ttarget)) then
  105. Target2Str:=Targets[ttarget(w)]
  106. else
  107. Target2Str:='<Unknown>';
  108. end;
  109. Function Cpu2Str(w:longint):string;
  110. type
  111. { Copied from systems.pas }
  112. ttargetcpu=
  113. (
  114. no_cpu, { 0 }
  115. i386, { 1 }
  116. m68k, { 2 }
  117. alpha, { 3 }
  118. powerpc { 4 }
  119. );
  120. const
  121. CpuTxt : array[ttargetcpu] of string[7]=
  122. ('none','i386','m68k','alpha','powerpc');
  123. begin
  124. if w<=ord(high(ttargetcpu)) then
  125. Cpu2Str:=CpuTxt[ttargetcpu(w)]
  126. else
  127. Cpu2Str:='<Unknown>';
  128. end;
  129. function PPUFlags2Str(flags:longint):string;
  130. type
  131. tflagopt=record
  132. mask : longint;
  133. str : string[30];
  134. end;
  135. const
  136. flagopts=14;
  137. flagopt : array[1..flagopts] of tflagopt=(
  138. (mask: $1 ;str:'init'),
  139. (mask: $2 ;str:'final'),
  140. (mask: $4 ;str:'big_endian'),
  141. (mask: $8 ;str:'dbx'),
  142. (mask: $10 ;str:'browser'),
  143. (mask: $20 ;str:'in_library'),
  144. (mask: $40 ;str:'smart_linked'),
  145. (mask: $80 ;str:'static_linked'),
  146. (mask: $100 ;str:'shared_linked'),
  147. (mask: $200 ;str:'local_browser'),
  148. (mask: $400 ;str:'no_link'),
  149. (mask: $800 ;str:'has_resources'),
  150. (mask: $1000 ;str:'little_endian'),
  151. (mask: $2000 ;str:'release')
  152. );
  153. var
  154. i : longint;
  155. first : boolean;
  156. s : string;
  157. begin
  158. s:='';
  159. if flags<>0 then
  160. begin
  161. first:=true;
  162. for i:=1to flagopts do
  163. if (flags and flagopt[i].mask)<>0 then
  164. begin
  165. if first then
  166. first:=false
  167. else
  168. s:=s+', ';
  169. s:=s+flagopt[i].str;
  170. end;
  171. end
  172. else
  173. s:='none';
  174. PPUFlags2Str:=s;
  175. end;
  176. const
  177. HexTbl : array[0..15] of char='0123456789ABCDEF';
  178. function HexB(b:byte):string;
  179. begin
  180. HexB[0]:=#2;
  181. HexB[1]:=HexTbl[b shr 4];
  182. HexB[2]:=HexTbl[b and $f];
  183. end;
  184. function hexstr(val : cardinal;cnt : byte) : string;
  185. const
  186. HexTbl : array[0..15] of char='0123456789ABCDEF';
  187. var
  188. i : longint;
  189. begin
  190. hexstr[0]:=char(cnt);
  191. for i:=cnt downto 1 do
  192. begin
  193. hexstr[i]:=hextbl[val and $f];
  194. val:=val shr 4;
  195. end;
  196. end;
  197. {****************************************************************************
  198. Read Routines
  199. ****************************************************************************}
  200. Procedure ReadLinkContainer(const prefix:string);
  201. {
  202. Read a serie of strings and write to the screen starting every line
  203. with prefix
  204. }
  205. function maskstr(m:longint):string;
  206. const
  207. { link options }
  208. link_none = $0;
  209. link_allways = $1;
  210. link_static = $2;
  211. link_smart = $4;
  212. link_shared = $8;
  213. var
  214. s : string;
  215. begin
  216. s:='';
  217. if (m and link_allways)<>0 then
  218. s:=s+'always ';
  219. if (m and link_static)<>0 then
  220. s:=s+'static ';
  221. if (m and link_smart)<>0 then
  222. s:=s+'smart ';
  223. if (m and link_shared)<>0 then
  224. s:=s+'shared ';
  225. maskstr:=s;
  226. end;
  227. var
  228. s : string;
  229. m : longint;
  230. begin
  231. while not ppufile.endofentry do
  232. begin
  233. s:=ppufile.getstring;
  234. m:=ppufile.getlongint;
  235. WriteLn(prefix,s,' (',maskstr(m),')');
  236. end;
  237. end;
  238. Procedure ReadContainer(const prefix:string);
  239. {
  240. Read a serie of strings and write to the screen starting every line
  241. with prefix
  242. }
  243. begin
  244. while not ppufile.endofentry do
  245. WriteLn(prefix,ppufile.getstring);
  246. end;
  247. Procedure ReadRef;
  248. begin
  249. if (verbose and v_browser)=0 then
  250. exit;
  251. while (not ppufile.endofentry) and (not ppufile.error) do
  252. Writeln(space,' - Refered : ',ppufile.getword,', (',ppufile.getlongint,',',ppufile.getword,')');
  253. end;
  254. Procedure ReadPosInfo;
  255. begin
  256. Writeln(ppufile.getword,' (',ppufile.getlongint,',',ppufile.getword,')');
  257. end;
  258. function readderef(const s:string;skipnil:boolean):boolean;
  259. type
  260. tdereftype = (derefnil,derefaktrecordindex,derefaktstaticindex,
  261. derefunit,derefrecord,derefindex,
  262. dereflocal,derefpara,derefaktlocalindex);
  263. var
  264. b : tdereftype;
  265. begin
  266. readderef:=true;
  267. repeat
  268. b:=tdereftype(ppufile.getbyte);
  269. case b of
  270. derefnil :
  271. begin
  272. if not skipnil then
  273. writeln('nil');
  274. readderef:=false;
  275. break;
  276. end;
  277. derefaktrecordindex :
  278. begin
  279. writeln('AktRecord ',s,' ',ppufile.getword);
  280. break;
  281. end;
  282. derefaktstaticindex :
  283. begin
  284. writeln('AktStatic ',s,' ',ppufile.getword);
  285. break;
  286. end;
  287. derefaktlocalindex :
  288. begin
  289. writeln('AktLocal ',s,' ',ppufile.getword);
  290. break;
  291. end;
  292. derefunit :
  293. begin
  294. writeln('Unit ',ppufile.getword);
  295. break;
  296. end;
  297. derefrecord :
  298. begin
  299. write('RecordDef ',ppufile.getword,', ');
  300. end;
  301. derefpara :
  302. begin
  303. write('Parameter of procdef ',ppufile.getword,', ');
  304. end;
  305. dereflocal :
  306. begin
  307. write('Local of procdef ',ppufile.getword,', ');
  308. end;
  309. derefindex :
  310. begin
  311. write(s,' ',ppufile.getword,', ');
  312. end;
  313. else
  314. begin
  315. writeln('!! unsupported dereftyp: ',ord(b));
  316. break;
  317. end;
  318. end;
  319. until false;
  320. end;
  321. function readdefref:boolean;
  322. begin
  323. readdefref:=readderef('Definition',false);
  324. end;
  325. function readsymref:boolean;
  326. begin
  327. readsymref:=readderef('Symbol',false);
  328. end;
  329. procedure readtype;
  330. var
  331. b1,b2 : boolean;
  332. begin
  333. b1:=readderef('Definition',true);
  334. b2:=readderef('Symbol',true);
  335. if not(b1 or b2) then
  336. Writeln('nil')
  337. else
  338. if (b1 and b2) then
  339. Writeln('!! Type has both definition and symbol stored');
  340. end;
  341. procedure readsymlist(const s:string);
  342. type
  343. tsltype = (sl_none,
  344. sl_load,
  345. sl_call,
  346. sl_subscript,
  347. sl_vec
  348. );
  349. const
  350. slstr : array[tsltype] of string[9] = ('',
  351. 'load',
  352. 'call',
  353. 'subscript',
  354. 'vec'
  355. );
  356. var
  357. sl : tsltype;
  358. begin
  359. readdefref;
  360. repeat
  361. sl:=tsltype(ppufile.getbyte);
  362. if sl=sl_none then
  363. break;
  364. write(s,'(',slstr[sl],') ');
  365. case sl of
  366. sl_call,
  367. sl_load,
  368. sl_subscript :
  369. readsymref;
  370. sl_vec :
  371. writeln(ppufile.getlongint);
  372. end;
  373. until false;
  374. end;
  375. { Read abstract procdef and return if inline procdef }
  376. type
  377. tproccalloption=(pocall_none,
  378. pocall_cdecl, { procedure uses C styled calling }
  379. pocall_cppdecl, { C++ calling conventions }
  380. pocall_compilerproc, { Procedure is used for internal compiler calls }
  381. pocall_far16, { Far16 for OS/2 }
  382. pocall_fpccall, { FPC default calling }
  383. pocall_inline, { Procedure is an assembler macro }
  384. pocall_internconst, { procedure has constant evaluator intern }
  385. pocall_internproc, { Procedure has compiler magic}
  386. pocall_palmossyscall, { procedure is a PalmOS system call }
  387. pocall_pascal, { pascal standard left to right }
  388. pocall_register, { procedure uses register (fastcall) calling }
  389. pocall_safecall, { safe call calling conventions }
  390. pocall_stdcall, { procedure uses stdcall call }
  391. pocall_system { system call }
  392. );
  393. tproccalloptions=set of tproccalloption;
  394. tproctypeoption=(potype_none,
  395. potype_proginit, { Program initialization }
  396. potype_unitinit, { unit initialization }
  397. potype_unitfinalize, { unit finalization }
  398. potype_constructor, { Procedure is a constructor }
  399. potype_destructor, { Procedure is a destructor }
  400. potype_operator { Procedure defines an operator }
  401. );
  402. tproctypeoptions=set of tproctypeoption;
  403. tprocoption=(po_none,
  404. po_classmethod, { class method }
  405. po_virtualmethod, { Procedure is a virtual method }
  406. po_abstractmethod, { Procedure is an abstract method }
  407. po_staticmethod, { static method }
  408. po_overridingmethod, { method with override directive }
  409. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  410. po_containsself, { self is passed explicit to the compiler }
  411. po_interrupt, { Procedure is an interrupt handler }
  412. po_iocheck, { IO checking should be done after a call to the procedure }
  413. po_assembler, { Procedure is written in assembler }
  414. po_msgstr, { method for string message handling }
  415. po_msgint, { method for int message handling }
  416. po_exports, { Procedure has export directive (needed for OS/2) }
  417. po_external, { Procedure is external (in other object or lib)}
  418. po_savestdregs, { save std regs cdecl and stdcall need that ! }
  419. po_saveregisters, { save all registers }
  420. po_overload, { procedure is declared with overload directive }
  421. po_varargs { printf like arguments }
  422. );
  423. tprocoptions=set of tprocoption;
  424. function read_abstract_proc_def:tproccalloption;
  425. type
  426. tproccallopt=record
  427. mask : tproccalloption;
  428. str : string[30];
  429. end;
  430. tproctypeopt=record
  431. mask : tproctypeoption;
  432. str : string[30];
  433. end;
  434. tprocopt=record
  435. mask : tprocoption;
  436. str : string[30];
  437. end;
  438. const
  439. proccalloptionStr : array[tproccalloption] of string[14]=('',
  440. 'CDecl',
  441. 'CPPDecl',
  442. 'CompilerProc',
  443. 'Far16',
  444. 'FPCCall',
  445. 'Inline',
  446. 'InternConst',
  447. 'InternProc',
  448. 'PalmOSSysCall',
  449. 'Pascal',
  450. 'Register',
  451. 'SafeCall',
  452. 'StdCall',
  453. 'System'
  454. );
  455. proctypeopts=6;
  456. proctypeopt : array[1..proctypeopts] of tproctypeopt=(
  457. (mask:potype_proginit; str:'ProgInit'),
  458. (mask:potype_unitinit; str:'UnitInit'),
  459. (mask:potype_unitfinalize;str:'UnitFinalize'),
  460. (mask:potype_constructor; str:'Constructor'),
  461. (mask:potype_destructor; str:'Destructor'),
  462. (mask:potype_operator; str:'Operator')
  463. );
  464. procopts=18;
  465. procopt : array[1..procopts] of tprocopt=(
  466. (mask:po_classmethod; str:'ClassMethod'),
  467. (mask:po_virtualmethod; str:'VirtualMethod'),
  468. (mask:po_abstractmethod; str:'AbstractMethod'),
  469. (mask:po_staticmethod; str:'StaticMethod'),
  470. (mask:po_overridingmethod;str:'OverridingMethod'),
  471. (mask:po_methodpointer; str:'MethodPointer'),
  472. (mask:po_containsself; str:'ContainsSelf'),
  473. (mask:po_interrupt; str:'Interrupt'),
  474. (mask:po_iocheck; str:'IOCheck'),
  475. (mask:po_assembler; str:'Assembler'),
  476. (mask:po_msgstr; str:'MsgStr'),
  477. (mask:po_msgint; str:'MsgInt'),
  478. (mask:po_exports; str:'Exports'),
  479. (mask:po_external; str:'External'),
  480. (mask:po_savestdregs; str:'SaveStdRegs'),
  481. (mask:po_saveregisters; str:'SaveRegisters'),
  482. (mask:po_overload; str:'Overload'),
  483. (mask:po_varargs; str:'VarArgs')
  484. );
  485. tvarspez : array[0..3] of string[5]=('Value','Const','Var ','Out ');
  486. var
  487. proctypeoption : tproctypeoption;
  488. proccalloption : tproccalloption;
  489. procoptions : tprocoptions;
  490. i,params : longint;
  491. first : boolean;
  492. begin
  493. write(space,' Return type : ');
  494. readtype;
  495. writeln(space,' Fpu used : ',ppufile.getbyte);
  496. proctypeoption:=tproctypeoption(ppufile.getbyte);
  497. if proctypeoption<>potype_none then
  498. begin
  499. write(space,' TypeOption : ');
  500. first:=true;
  501. for i:=1to proctypeopts do
  502. if (proctypeopt[i].mask=proctypeoption) then
  503. begin
  504. if first then
  505. first:=false
  506. else
  507. write(', ');
  508. write(proctypeopt[i].str);
  509. end;
  510. writeln;
  511. end;
  512. proccalloption:=tproccalloption(ppufile.getbyte);
  513. read_abstract_proc_def:=proccalloption;
  514. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  515. ppufile.getsmallset(procoptions);
  516. if procoptions<>[] then
  517. begin
  518. write(space,' Options : ');
  519. first:=true;
  520. for i:=1to procopts do
  521. if (procopt[i].mask in procoptions) then
  522. begin
  523. if first then
  524. first:=false
  525. else
  526. write(', ');
  527. write(procopt[i].str);
  528. end;
  529. writeln;
  530. end;
  531. params:=ppufile.getword;
  532. writeln(space,' Nr of parameters : ',params);
  533. if params>0 then
  534. begin
  535. repeat
  536. write(space,' - ',tvarspez[ppufile.getbyte],' : ');
  537. readtype;
  538. write(space,' Default : ');
  539. readsymref;
  540. dec(params);
  541. until params=0;
  542. end;
  543. end;
  544. procedure readcommonsym(const s:string);
  545. type
  546. tsymoption=(sp_none,
  547. sp_public,
  548. sp_private,
  549. sp_published,
  550. sp_protected,
  551. sp_forwarddef,
  552. sp_static,
  553. sp_primary_typesym { this is for typesym, to know who is the primary symbol of a def }
  554. );
  555. tsymoptions=set of tsymoption;
  556. tsymopt=record
  557. mask : tsymoption;
  558. str : string[30];
  559. end;
  560. const
  561. symopts=7;
  562. symopt : array[1..symopts] of tsymopt=(
  563. (mask:sp_public; str:'Public'),
  564. (mask:sp_private; str:'Private'),
  565. (mask:sp_published; str:'Published'),
  566. (mask:sp_protected; str:'Protected'),
  567. (mask:sp_forwarddef; str:'ForwardDef'),
  568. (mask:sp_static; str:'Static'),
  569. (mask:sp_primary_typesym;str:'PrimaryTypeSym')
  570. );
  571. var
  572. symoptions : tsymoptions;
  573. i : longint;
  574. first : boolean;
  575. begin
  576. writeln(space,'** Symbol Nr. ',ppufile.getword,' **');
  577. writeln(space,s,ppufile.getstring);
  578. ppufile.getsmallset(symoptions);
  579. if symoptions<>[] then
  580. begin
  581. write(space,' File Pos: ');
  582. readposinfo;
  583. write(space,' SymOptions: ');
  584. first:=true;
  585. for i:=1to symopts do
  586. if (symopt[i].mask in symoptions) then
  587. begin
  588. if first then
  589. first:=false
  590. else
  591. write(', ');
  592. write(symopt[i].str);
  593. end;
  594. writeln;
  595. end;
  596. end;
  597. procedure readcommondef(const s:string);
  598. type
  599. tdefoption=(df_none,
  600. df_has_inittable, { init data has been generated }
  601. df_has_rttitable { rtti data has been generated }
  602. );
  603. tdefoptions=set of tdefoption;
  604. var
  605. defopts : tdefoptions;
  606. begin
  607. writeln(space,'** Definition Nr. ',ppufile.getword,' **');
  608. writeln(space,s);
  609. write (space,' Type symbol : ');
  610. readsymref;
  611. ppufile.getsmallset(defopts);
  612. if df_has_rttitable in defopts then
  613. begin
  614. write (space,' RTTI symbol : ');
  615. readsymref;
  616. end;
  617. if df_has_inittable in defopts then
  618. begin
  619. write (space,' Init symbol : ');
  620. readsymref;
  621. end;
  622. end;
  623. {****************************************************************************
  624. Read Symbols Part
  625. ****************************************************************************}
  626. procedure readsymbols;
  627. Const
  628. vo_is_C_var = 2;
  629. Type
  630. absolutetyp = (tovar,toasm,toaddr);
  631. tconsttyp = (constnone,
  632. constord,conststring,constreal,constbool,
  633. constint,constchar,constset,constpointer,constnil,
  634. constresourcestring
  635. );
  636. var
  637. b : byte;
  638. pc : pchar;
  639. totalsyms,
  640. symcnt,
  641. i,j,len : longint;
  642. l1,l2 : longint;
  643. begin
  644. symcnt:=1;
  645. with ppufile do
  646. begin
  647. if space<>'' then
  648. Writeln(space,'-----------------------------');
  649. if readentry=ibstartsyms then
  650. begin
  651. totalsyms:=getlongint;
  652. Writeln(space,'Number of symbols : ',totalsyms);
  653. Writeln(space,'Symtable datasize : ',getlongint);
  654. Writeln(space,'Symtable alignment: ',getlongint);
  655. end
  656. else
  657. begin
  658. totalsyms:=-1;
  659. Writeln('!! ibstartsym not found');
  660. end;
  661. repeat
  662. b:=readentry;
  663. if not (b in [iberror,ibendsyms]) then
  664. inc(symcnt);
  665. case b of
  666. ibunitsym :
  667. readcommonsym('Unit symbol ');
  668. iblabelsym :
  669. readcommonsym('Label symbol ');
  670. ibtypesym :
  671. begin
  672. readcommonsym('Type symbol ');
  673. write(space,' Result Type: ');
  674. readtype;
  675. end;
  676. ibprocsym :
  677. begin
  678. readcommonsym('Procedure symbol ');
  679. repeat
  680. write(space,' Definition: ');
  681. until not readdefref;
  682. end;
  683. ibconstsym :
  684. begin
  685. readcommonsym('Constant symbol ');
  686. b:=getbyte;
  687. case tconsttyp(b) of
  688. constord :
  689. begin
  690. write (space,'OrdinalType: ');
  691. readtype;
  692. writeln (space,' Value: ',getlongint)
  693. end;
  694. constpointer :
  695. begin
  696. write (space,' Pointer Type: ');
  697. readtype;
  698. writeln (space,' Value: ',getlongint)
  699. end;
  700. conststring,
  701. constresourcestring :
  702. begin
  703. len:=getlongint;
  704. getmem(pc,len+1);
  705. getdata(pc^,len);
  706. writeln(space,' Length: ',len);
  707. writeln(space,' Value: "',pc,'"');
  708. freemem(pc,len+1);
  709. if tconsttyp(b)=constresourcestring then
  710. writeln(space,' Index: ',getlongint);
  711. end;
  712. constreal :
  713. writeln(space,' Value: ',getreal);
  714. constbool :
  715. if getlongint<>0 then
  716. writeln (space,' Value : True')
  717. else
  718. writeln (space,' Value: False');
  719. constint :
  720. begin
  721. l1:=getlongint;
  722. l2:=getlongint;
  723. writeln(space,' Value: ',int64(l2 shl 32) or l1);
  724. end;
  725. constchar :
  726. writeln(space,' Value: "'+chr(getlongint)+'"');
  727. constset :
  728. begin
  729. write (space,' Set Type: ');
  730. readtype;
  731. for i:=1to 4 do
  732. begin
  733. write (space,' Value: ');
  734. for j:=1to 8 do
  735. begin
  736. if j>1 then
  737. write(',');
  738. write(hexb(getbyte));
  739. end;
  740. writeln;
  741. end;
  742. end;
  743. else
  744. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  745. end;
  746. end;
  747. ibvarsym :
  748. begin
  749. readcommonsym('Variable symbol ');
  750. writeln(space,' Type: ',getbyte);
  751. if read_member then
  752. writeln(space,' Address: ',getlongint);
  753. write (space,' Var Type: ');
  754. readtype;
  755. i:=getlongint;
  756. writeln(space,' Options: ',i);
  757. if (i and vo_is_C_var)<>0 then
  758. writeln(space,' Mangledname: ',getstring);
  759. end;
  760. ibenumsym :
  761. begin
  762. readcommonsym('Enumeration symbol ');
  763. write (space,' Definition: ');
  764. readdefref;
  765. writeln(space,' Value: ',getlongint);
  766. end;
  767. ibsyssym :
  768. begin
  769. readcommonsym('Internal system symbol ');
  770. writeln(space,' Internal Nr: ',getlongint);
  771. end;
  772. ibrttisym :
  773. begin
  774. readcommonsym('RTTI symbol ');
  775. writeln(space,' RTTI Type: ',getbyte);
  776. end;
  777. ibtypedconstsym :
  778. begin
  779. readcommonsym('Typed constant ');
  780. write (space,' Constant Type: ');
  781. readtype;
  782. writeln(space,' Label: ',getstring);
  783. writeln(space,' ReallyConst: ',(getbyte<>0));
  784. end;
  785. ibabsolutesym :
  786. begin
  787. readcommonsym('Absolute variable symbol ');
  788. writeln(space,' Type: ',getbyte);
  789. if read_member then
  790. writeln(space,' Address: ',getlongint);
  791. write (space,' Var Type: ');
  792. readtype;
  793. writeln(space,' Options: ',getlongint);
  794. Write (space,' Relocated to ');
  795. b:=getbyte;
  796. case absolutetyp(b) of
  797. tovar :
  798. Writeln('Name : ',getstring);
  799. toasm :
  800. Writeln('Assembler name : ',getstring);
  801. toaddr :
  802. begin
  803. Write('Address : ',getlongint);
  804. WriteLn(' (Far: ',getbyte<>0,')');
  805. end;
  806. else
  807. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  808. end;
  809. end;
  810. ibpropertysym :
  811. begin
  812. readcommonsym('Property ');
  813. i:=getlongint;
  814. writeln(space,' PropOptions: ',i);
  815. if (i and 32)>0 then
  816. begin
  817. write (space,'OverrideProp: ');
  818. readsymref;
  819. end
  820. else
  821. begin
  822. write (space,' Prop Type: ');
  823. readtype;
  824. writeln(space,' Index: ',getlongint);
  825. writeln(space,' Default: ',getlongint);
  826. write (space,' Index Type: ');
  827. readtype;
  828. write (space,' Readaccess: ');
  829. readsymlist(space+' Sym: ');
  830. write (space,' Writeaccess: ');
  831. readsymlist(space+' Sym: ');
  832. write (space,'Storedaccess: ');
  833. readsymlist(space+' Sym: ');
  834. end;
  835. end;
  836. ibfuncretsym :
  837. begin
  838. readcommonsym('Func return value ');
  839. write (space,' Return Type: ');
  840. readtype;
  841. writeln(space,' Address: ',getlongint);
  842. end;
  843. iberror :
  844. begin
  845. Writeln('!! Error in PPU');
  846. exit;
  847. end;
  848. ibendsyms :
  849. break;
  850. else
  851. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  852. end;
  853. if not EndOfEntry then
  854. Writeln('!! Entry has more information stored');
  855. until false;
  856. if (totalsyms<>-1) and (symcnt-1<>totalsyms) then
  857. Writeln('!! Only read ',symcnt-1,' of ',totalsyms,' symbols');
  858. end;
  859. end;
  860. {****************************************************************************
  861. Read defintions Part
  862. ****************************************************************************}
  863. procedure readdefinitions(start_read : boolean);
  864. type
  865. tsettype = (normset,smallset,varset);
  866. tbasetype = (
  867. uauto,uvoid,uchar,
  868. u8bit,u16bit,u32bit,
  869. s8bit,s16bit,s32bit,
  870. bool8bit,bool16bit,bool32bit,
  871. u64bit,s64bit,uwidechar
  872. );
  873. tobjectdeftype = (odt_none,
  874. odt_class,
  875. odt_object,
  876. odt_interfacecom,
  877. odt_interfacecorba,
  878. odt_cppclass
  879. );
  880. var
  881. b : byte;
  882. oldread_member : boolean;
  883. totaldefs,l,j,
  884. defcnt : longint;
  885. calloption : tproccalloption;
  886. begin
  887. defcnt:=0;
  888. with ppufile do
  889. begin
  890. if space<>'' then
  891. Writeln(space,'-----------------------------');
  892. if not start_read then
  893. if readentry=ibstartdefs then
  894. begin
  895. totaldefs:=getlongint;
  896. Writeln(space,'Number of definitions: ',totaldefs);
  897. end
  898. else
  899. begin
  900. totaldefs:=-1;
  901. Writeln('!! ibstartdef not found');
  902. end;
  903. repeat
  904. b:=readentry;
  905. if not (b in [iberror,ibenddefs]) then
  906. inc(defcnt);
  907. case b of
  908. ibpointerdef :
  909. begin
  910. readcommondef('Pointer definition');
  911. write (space,' Pointed Type : ');
  912. readtype;
  913. writeln(space,' Is Far : ',(getbyte<>0));
  914. end;
  915. iborddef :
  916. begin
  917. readcommondef('Ordinal definition');
  918. write (space,' Base type : ');
  919. b:=getbyte;
  920. case tbasetype(b) of
  921. uauto : writeln('uauto');
  922. uvoid : writeln('uvoid');
  923. uchar : writeln('uchar');
  924. u8bit : writeln('u8bit');
  925. u16bit : writeln('u16bit');
  926. u32bit : writeln('s32bit');
  927. s8bit : writeln('s8bit');
  928. s16bit : writeln('s16bit');
  929. s32bit : writeln('s32bit');
  930. bool8bit : writeln('bool8bit');
  931. bool16bit : writeln('bool16bit');
  932. bool32bit : writeln('bool32bit');
  933. u64bit : writeln('u64bit');
  934. s64bit : writeln('s64bit');
  935. uwidechar : writeln('uwidechar');
  936. else writeln('!! Warning: Invalid base type ',b);
  937. end;
  938. writeln(space,' Range : ',getlongint,' to ',getlongint);
  939. end;
  940. ibfloatdef :
  941. begin
  942. readcommondef('Float definition');
  943. writeln(space,' Float type : ',getbyte);
  944. end;
  945. ibarraydef :
  946. begin
  947. readcommondef('Array definition');
  948. write (space,' Element type : ');
  949. readtype;
  950. write (space,' Range Type : ');
  951. readtype;
  952. writeln(space,' Range : ',getlongint,' to ',getlongint);
  953. writeln(space,' Is Constructor : ',(getbyte<>0));
  954. writeln(space,' Is Dynamic : ',(getbyte<>0));
  955. end;
  956. ibprocdef :
  957. begin
  958. readcommondef('Procedure definition');
  959. calloption:=read_abstract_proc_def;
  960. writeln(space,' Used Register : ',getbyte);
  961. writeln(space,' Mangled name : ',getstring);
  962. writeln(space,' Number : ',getlongint);
  963. write (space,' Class : ');
  964. readdefref;
  965. write (space,' Procsym : ');
  966. readsymref;
  967. write (space,' File Pos : ');
  968. readposinfo;
  969. if (calloption=pocall_inline) then
  970. begin
  971. write (space,' FuncretSym : ');
  972. readdefref;
  973. end;
  974. space:=' '+space;
  975. { parast }
  976. readdefinitions(false);
  977. readsymbols;
  978. { localst }
  979. if (calloption=pocall_inline) or
  980. ((ppufile.header.flags and uf_local_browser) <> 0) then
  981. begin
  982. readdefinitions(false);
  983. readsymbols;
  984. end;
  985. delete(space,1,4);
  986. end;
  987. ibprocvardef :
  988. begin
  989. readcommondef('Procedural type (ProcVar) definition');
  990. read_abstract_proc_def;
  991. end;
  992. ibshortstringdef :
  993. begin
  994. readcommondef('ShortString definition');
  995. writeln(space,' Length : ',getbyte);
  996. end;
  997. ibwidestringdef :
  998. begin
  999. readcommondef('WideString definition');
  1000. writeln(space,' Length : ',getlongint);
  1001. end;
  1002. ibansistringdef :
  1003. begin
  1004. readcommondef('AnsiString definition');
  1005. writeln(space,' Length : ',getlongint);
  1006. end;
  1007. iblongstringdef :
  1008. begin
  1009. readcommondef('Longstring definition');
  1010. writeln(space,' Length : ',getlongint);
  1011. end;
  1012. ibrecorddef :
  1013. begin
  1014. readcommondef('Record definition');
  1015. writeln(space,' Size : ',getlongint);
  1016. {read the record definitions and symbols}
  1017. space:=' '+space;
  1018. oldread_member:=read_member;
  1019. read_member:=true;
  1020. readdefinitions(false);
  1021. readsymbols;
  1022. read_member:=oldread_member;
  1023. Delete(space,1,4);
  1024. end;
  1025. ibobjectdef :
  1026. begin
  1027. readcommondef('Object/Class definition');
  1028. b:=getbyte;
  1029. write (space,' Type : ');
  1030. case tobjectdeftype(b) of
  1031. odt_class : writeln('class');
  1032. odt_object : writeln('object');
  1033. odt_interfacecom : writeln('interfacecom');
  1034. odt_interfacecorba : writeln('interfacecorba');
  1035. odt_cppclass : writeln('cppclass');
  1036. else writeln('!! Warning: Invalid object type ',b);
  1037. end;
  1038. writeln(space,' Size : ',getlongint);
  1039. writeln(space,' Vmt offset : ',getlongint);
  1040. writeln(space,' Name of Class : ',getstring);
  1041. write(space, ' Ancestor Class : ');
  1042. readdefref;
  1043. writeln(space,' Options : ',getlongint);
  1044. if tobjectdeftype(b) in [odt_interfacecom,odt_interfacecorba] then
  1045. begin
  1046. writeln(space,' GUID Valid : ',(getbyte<>0));
  1047. { IIDGUID }
  1048. for j:=1to 16 do
  1049. getbyte;
  1050. writeln(space,' IID String : ',getstring);
  1051. writeln(space,' Last VTable idx : ',getlongint);
  1052. end;
  1053. if tobjectdeftype(b) in [odt_class,odt_interfacecorba] then
  1054. begin
  1055. l:=getlongint;
  1056. writeln(space,' Impl Intf Count : ',l);
  1057. for j:=1 to l do
  1058. begin
  1059. write (space,' - Definition : ');
  1060. readdefref;
  1061. writeln(space,' IOffset : ',getlongint);
  1062. end;
  1063. end;
  1064. {read the record definitions and symbols}
  1065. space:=' '+space;
  1066. oldread_member:=read_member;
  1067. read_member:=true;
  1068. readdefinitions(false);
  1069. readsymbols;
  1070. read_member:=oldread_member;
  1071. Delete(space,1,4);
  1072. end;
  1073. ibfiledef :
  1074. begin
  1075. ReadCommonDef('File definition');
  1076. write (space,' Type : ');
  1077. case getbyte of
  1078. 0 : writeln('Text');
  1079. 1 : begin
  1080. writeln('Typed');
  1081. write (space,' File of Type : ');
  1082. Readtype;
  1083. end;
  1084. 2 : writeln('Untyped');
  1085. end;
  1086. end;
  1087. ibformaldef :
  1088. readcommondef('Generic Definition (void-typ)');
  1089. ibenumdef :
  1090. begin
  1091. readcommondef('Enumeration type definition');
  1092. write(space,'Base enumeration type : ');
  1093. readdefref;
  1094. writeln(space,' Smallest element : ',getlongint);
  1095. writeln(space,' Largest element : ',getlongint);
  1096. writeln(space,' Size : ',getlongint);
  1097. end;
  1098. ibclassrefdef :
  1099. begin
  1100. readcommondef('Class reference definition');
  1101. write (space,' Pointed Type : ');
  1102. readtype;
  1103. end;
  1104. ibsetdef :
  1105. begin
  1106. readcommondef('Set definition');
  1107. write (space,' Element type : ');
  1108. readtype;
  1109. b:=getbyte;
  1110. case tsettype(b) of
  1111. smallset : writeln(space,' Set with 32 Elements');
  1112. normset : writeln(space,' Set with 256 Elements');
  1113. varset : writeln(space,' Set with ',getlongint,' Elements');
  1114. else writeln('!! Warning: Invalid set type ',b);
  1115. end;
  1116. end;
  1117. ibvariantdef :
  1118. begin
  1119. readcommondef('Variant definition');
  1120. end;
  1121. iberror :
  1122. begin
  1123. Writeln('!! Error in PPU');
  1124. exit;
  1125. end;
  1126. ibenddefs :
  1127. break;
  1128. else
  1129. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  1130. end;
  1131. if not EndOfEntry then
  1132. Writeln('!! Entry has more information stored');
  1133. until false;
  1134. if (totaldefs<>-1) and (defcnt<>totaldefs) then
  1135. Writeln('!! Only read ',defcnt,' of ',totaldefs,' definitions');
  1136. end;
  1137. end;
  1138. {****************************************************************************
  1139. Read General Part
  1140. ****************************************************************************}
  1141. procedure readinterface;
  1142. var
  1143. b : byte;
  1144. sourcenumber,
  1145. unitnumber : word;
  1146. ucrc,uintfcrc : longint;
  1147. begin
  1148. with ppufile do
  1149. begin
  1150. repeat
  1151. b:=readentry;
  1152. case b of
  1153. ibmodulename :
  1154. Writeln('Module Name: ',getstring);
  1155. ibsourcefiles :
  1156. begin
  1157. sourcenumber:=1;
  1158. while not EndOfEntry do
  1159. begin
  1160. Writeln('Source file ',sourcenumber,' : ',getstring);
  1161. inc(sourcenumber);
  1162. end;
  1163. end;
  1164. ibusedmacros :
  1165. begin
  1166. while not EndOfEntry do
  1167. begin
  1168. Write('Conditional ',getstring);
  1169. b:=getbyte;
  1170. if boolean(b)=true then
  1171. write(' defined at startup')
  1172. else
  1173. write(' not defined at startup');
  1174. b:=getbyte;
  1175. if boolean(b)=true then
  1176. writeln(' was used')
  1177. else
  1178. writeln;
  1179. end;
  1180. end;
  1181. ibloadunit :
  1182. begin
  1183. unitnumber:=1;
  1184. while not EndOfEntry do
  1185. begin
  1186. write('Uses unit: ',getstring,' (Number: ',unitnumber,')');
  1187. ucrc:=getlongint;
  1188. uintfcrc:=getlongint;
  1189. write(' (Crc: ',hexstr(ucrc,8),', IntfcCrc: ',hexstr(uintfcrc,8),')');
  1190. if getbyte<>0 then
  1191. writeln(' (interface)')
  1192. else
  1193. writeln(' (implementation)');
  1194. inc(unitnumber);
  1195. end;
  1196. end;
  1197. iblinkunitofiles :
  1198. ReadLinkContainer('Link unit object file: ');
  1199. iblinkunitstaticlibs :
  1200. ReadLinkContainer('Link unit static lib: ');
  1201. iblinkunitsharedlibs :
  1202. ReadLinkContainer('Link unit shared lib: ');
  1203. iblinkotherofiles :
  1204. ReadLinkContainer('Link other object file: ');
  1205. iblinkotherstaticlibs :
  1206. ReadLinkContainer('Link other static lib: ');
  1207. iblinkothersharedlibs :
  1208. ReadLinkContainer('Link other shared lib: ');
  1209. iberror :
  1210. begin
  1211. Writeln('Error in PPU');
  1212. exit;
  1213. end;
  1214. ibendinterface :
  1215. break;
  1216. else
  1217. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  1218. end;
  1219. until false;
  1220. end;
  1221. end;
  1222. {****************************************************************************
  1223. Read Implementation Part
  1224. ****************************************************************************}
  1225. procedure readimplementation;
  1226. var
  1227. b : byte;
  1228. begin
  1229. with ppufile do
  1230. begin
  1231. repeat
  1232. b:=readentry;
  1233. case b of
  1234. iberror :
  1235. begin
  1236. Writeln('Error in PPU');
  1237. exit;
  1238. end;
  1239. ibendimplementation :
  1240. break;
  1241. else
  1242. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  1243. end;
  1244. until false;
  1245. end;
  1246. end;
  1247. {****************************************************************************
  1248. Read Browser Part
  1249. ****************************************************************************}
  1250. procedure readbrowser;
  1251. var
  1252. b : byte;
  1253. const indent : string = '';
  1254. begin
  1255. Writeln(indent,'Start of symtable browser');
  1256. indent:=indent+'**';
  1257. with ppufile do
  1258. begin
  1259. repeat
  1260. b:=readentry;
  1261. case b of
  1262. ibbeginsymtablebrowser :
  1263. begin
  1264. { here we must read object and record symtables !! }
  1265. indent:=indent+' ';
  1266. Writeln(indent,'Record/Object symtable');
  1267. readbrowser;
  1268. Indent:=Copy(Indent,1,Length(Indent)-2);
  1269. end;
  1270. ibsymref :
  1271. begin
  1272. readsymref;
  1273. readref;
  1274. end;
  1275. ibdefref :
  1276. begin
  1277. readdefref;
  1278. readref;
  1279. if ((ppufile.header.flags and uf_local_browser)<>0) and
  1280. (UnitIndex=0) then
  1281. begin
  1282. { parast and localst }
  1283. indent:=indent+' ';
  1284. b:=ppufile.readentry;
  1285. if b=ibbeginsymtablebrowser then
  1286. readbrowser;
  1287. b:=ppufile.readentry;
  1288. if b=ibbeginsymtablebrowser then
  1289. readbrowser;
  1290. Indent:=Copy(Indent,1,Length(Indent)-2);
  1291. end;
  1292. end;
  1293. iberror :
  1294. begin
  1295. Writeln('Error in PPU');
  1296. exit;
  1297. end;
  1298. ibendsymtablebrowser :
  1299. break;
  1300. else
  1301. begin
  1302. WriteLn('!! Skipping unsupported PPU Entry in Browser: ',b);
  1303. Halt;
  1304. end;
  1305. end;
  1306. until false;
  1307. end;
  1308. Indent:=Copy(Indent,1,Length(Indent)-2);
  1309. Writeln(Indent,'End of symtable browser');
  1310. end;
  1311. procedure dofile (filename : string);
  1312. var
  1313. b : byte;
  1314. begin
  1315. { reset }
  1316. space:='';
  1317. { fix filename }
  1318. if pos('.',filename)=0 then
  1319. filename:=filename+'.ppu';
  1320. ppufile:=tppufile.create(filename);
  1321. if not ppufile.openfile then
  1322. begin
  1323. writeln ('IO-Error when opening : ',filename,', Skipping');
  1324. exit;
  1325. end;
  1326. { PPU File is open, check for PPU Id }
  1327. if not ppufile.CheckPPUID then
  1328. begin
  1329. writeln(Filename,' : Not a valid PPU file, Skipping');
  1330. exit;
  1331. end;
  1332. { Check PPU Version }
  1333. Writeln('Analyzing ',filename,' (v',ppufile.GetPPUVersion,')');
  1334. if ppufile.GetPPUVersion<16 then
  1335. begin
  1336. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  1337. exit;
  1338. end;
  1339. { Write PPU Header Information }
  1340. if (verbose and v_header)<>0 then
  1341. begin
  1342. Writeln;
  1343. Writeln('Header');
  1344. Writeln('-------');
  1345. with ppufile.header do
  1346. begin
  1347. Writeln('Compiler version : ',hi(ppufile.header.compiler and $ff),'.',lo(ppufile.header.compiler));
  1348. WriteLn('Target processor : ',Cpu2Str(cpu));
  1349. WriteLn('Target operating system : ',Target2Str(target));
  1350. Writeln('Unit flags : ',PPUFlags2Str(flags));
  1351. Writeln('FileSize (w/o header) : ',size);
  1352. Writeln('Checksum : ',hexstr(checksum,8));
  1353. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  1354. end;
  1355. end;
  1356. {read the general stuff}
  1357. if (verbose and v_interface)<>0 then
  1358. begin
  1359. Writeln;
  1360. Writeln('Interface section');
  1361. Writeln('------------------');
  1362. readinterface;
  1363. end
  1364. else
  1365. ppufile.skipuntilentry(ibendinterface);
  1366. {read the definitions}
  1367. if (verbose and v_defs)<>0 then
  1368. begin
  1369. Writeln;
  1370. Writeln('Interface definitions');
  1371. Writeln('----------------------');
  1372. readdefinitions(false);
  1373. end
  1374. else
  1375. ppufile.skipuntilentry(ibenddefs);
  1376. {read the symbols}
  1377. if (verbose and v_syms)<>0 then
  1378. begin
  1379. Writeln;
  1380. Writeln('Interface Symbols');
  1381. Writeln('------------------');
  1382. readsymbols;
  1383. end
  1384. else
  1385. ppufile.skipuntilentry(ibendsyms);
  1386. {read the implementation stuff}
  1387. { Not used at the moment (PFV)
  1388. if (verbose and v_implementation)<>0 then
  1389. begin
  1390. Writeln;
  1391. Writeln('Implementation section');
  1392. Writeln('-----------------------');
  1393. readimplementation;
  1394. end
  1395. else}
  1396. ppufile.skipuntilentry(ibendimplementation);
  1397. {read the static browser units stuff}
  1398. if (ppufile.header.flags and uf_local_browser)<>0 then
  1399. begin
  1400. if (verbose and v_defs)<>0 then
  1401. begin
  1402. Writeln;
  1403. Writeln('Static definitions');
  1404. Writeln('----------------------');
  1405. readdefinitions(false);
  1406. end
  1407. else
  1408. ppufile.skipuntilentry(ibenddefs);
  1409. {read the symbols}
  1410. if (verbose and v_syms)<>0 then
  1411. begin
  1412. Writeln;
  1413. Writeln('Static Symbols');
  1414. Writeln('------------------');
  1415. readsymbols;
  1416. end;
  1417. end;
  1418. {read the browser units stuff}
  1419. if (ppufile.header.flags and uf_has_browser)<>0 then
  1420. begin
  1421. if (verbose and v_browser)<>0 then
  1422. begin
  1423. Writeln;
  1424. Writeln('Browser section');
  1425. Writeln('---------------');
  1426. UnitIndex:=0;
  1427. repeat
  1428. b:=ppufile.readentry;
  1429. if b = ibendbrowser then break;
  1430. if b=ibbeginsymtablebrowser then
  1431. begin
  1432. Writeln('Unit ',UnitIndex);
  1433. readbrowser;
  1434. Inc(UnitIndex);
  1435. end
  1436. else
  1437. Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
  1438. until false;
  1439. end;
  1440. end;
  1441. {read the static browser units stuff}
  1442. if (ppufile.header.flags and uf_local_browser)<>0 then
  1443. begin
  1444. if (verbose and v_browser)<>0 then
  1445. begin
  1446. Writeln;
  1447. Writeln('Static browser section');
  1448. Writeln('---------------');
  1449. UnitIndex:=0;
  1450. b:=ppufile.readentry;
  1451. if b=ibbeginsymtablebrowser then
  1452. readbrowser
  1453. else
  1454. Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
  1455. end;
  1456. end;
  1457. {shutdown ppufile}
  1458. ppufile.closefile;
  1459. ppufile.free;
  1460. Writeln;
  1461. end;
  1462. procedure help;
  1463. begin
  1464. writeln('usage: ppudump [options] <filename1> <filename2>...');
  1465. writeln;
  1466. writeln('[options] can be:');
  1467. writeln(' -V<verbose> Set verbosity to <verbose>');
  1468. writeln(' H - Show header info');
  1469. writeln(' I - Show interface');
  1470. writeln(' M - Show implementation');
  1471. writeln(' S - Show interface symbols');
  1472. writeln(' D - Show interface definitions');
  1473. writeln(' B - Show browser info');
  1474. writeln(' A - Show all');
  1475. writeln(' -? This helpscreen');
  1476. halt;
  1477. end;
  1478. var
  1479. startpara,
  1480. nrfile,i : longint;
  1481. para : string;
  1482. begin
  1483. writeln(Title+' '+Version);
  1484. writeln(Copyright);
  1485. writeln;
  1486. if paramcount<1 then
  1487. begin
  1488. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  1489. halt(1);
  1490. end;
  1491. { turn verbose on by default }
  1492. verbose:=v_all;
  1493. { read options }
  1494. startpara:=1;
  1495. while copy(paramstr(startpara),1,1)='-' do
  1496. begin
  1497. para:=paramstr(startpara);
  1498. case upcase(para[2]) of
  1499. 'V' : begin
  1500. verbose:=0;
  1501. for i:=3to length(para) do
  1502. case upcase(para[i]) of
  1503. 'H' : verbose:=verbose or v_header;
  1504. 'I' : verbose:=verbose or v_interface;
  1505. 'M' : verbose:=verbose or v_implementation;
  1506. 'D' : verbose:=verbose or v_defs;
  1507. 'S' : verbose:=verbose or v_syms;
  1508. 'B' : verbose:=verbose or v_browser;
  1509. 'A' : verbose:=verbose or v_all;
  1510. end;
  1511. end;
  1512. '?' : help;
  1513. end;
  1514. inc(startpara);
  1515. end;
  1516. { process files }
  1517. for nrfile:=startpara to paramcount do
  1518. dofile (paramstr(nrfile));
  1519. if has_errors then
  1520. Halt(1);
  1521. end.
  1522. {
  1523. $Log$
  1524. Revision 1.9 2001-11-02 22:58:12 peter
  1525. * procsym definition rewrite
  1526. Revision 1.8 2001/09/22 04:52:27 carl
  1527. * updated targets
  1528. Revision 1.7 2001/08/30 20:55:02 peter
  1529. * rttisym support
  1530. Revision 1.6 2001/08/19 09:39:29 peter
  1531. * local browser support fixed
  1532. Revision 1.5 2001/06/29 19:42:18 peter
  1533. * new flags added
  1534. Revision 1.4 2001/06/04 11:53:15 peter
  1535. + varargs directive
  1536. Revision 1.3 2001/05/09 14:11:10 jonas
  1537. * range check error fixes from Peter
  1538. Revision 1.2 2001/05/06 14:49:19 peter
  1539. * ppu object to class rewrite
  1540. * move ppu read and write stuff to fppu
  1541. Revision 1.1 2001/04/25 22:40:07 peter
  1542. * compiler dependent utils in utils/ subdir
  1543. Revision 1.5 2001/04/10 21:21:41 peter
  1544. * variantdef support
  1545. * propertysym fixed
  1546. Revision 1.4 2001/04/04 22:42:59 peter
  1547. * updated for new objectdef with interfaces
  1548. Revision 1.3 2000/09/09 19:46:40 peter
  1549. * show dataalignment
  1550. Revision 1.2 2000/08/13 12:58:06 peter
  1551. * updated for ppu additions
  1552. Revision 1.1 2000/07/13 10:16:22 michael
  1553. + Initial import
  1554. Revision 1.15 2000/07/04 19:05:54 peter
  1555. * be optimistic: version 1.00 for some utils
  1556. Revision 1.14 2000/02/09 16:44:14 peter
  1557. * log truncated
  1558. Revision 1.13 2000/01/23 16:34:36 peter
  1559. * updated for new aktlocalindex
  1560. Revision 1.12 2000/01/07 16:46:03 daniel
  1561. * copyright 2000
  1562. Revision 1.11 1999/11/30 10:35:37 peter
  1563. * support new readtype
  1564. Revision 1.10 1999/11/08 14:06:45 florian
  1565. + indexref of propertysym is handle too now
  1566. Revision 1.9 1999/08/31 16:07:37 pierre
  1567. + support for writeusedmacros
  1568. Revision 1.8 1999/08/15 10:47:14 peter
  1569. * updates for new options
  1570. Revision 1.7 1999/08/13 21:25:35 peter
  1571. * updated flags
  1572. Revision 1.6 1999/07/27 23:45:29 peter
  1573. * updated for typesym writing
  1574. }