2
0

ppudump.pp 45 KB

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