ppudump.pp 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602
  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. );
  346. tprocoptions=set of tprocoption;
  347. type
  348. tproccallopt=record
  349. mask : tproccalloption;
  350. str : string[30];
  351. end;
  352. tproctypeopt=record
  353. mask : tproctypeoption;
  354. str : string[30];
  355. end;
  356. tprocopt=record
  357. mask : tprocoption;
  358. str : string[30];
  359. end;
  360. const
  361. proccallopts=12;
  362. proccallopt : array[1..proccallopts] of tproccallopt=(
  363. (mask:pocall_none; str:''),
  364. (mask:pocall_clearstack; str:'ClearStack'),
  365. (mask:pocall_leftright; str:'LeftRight'),
  366. (mask:pocall_cdecl; str:'Cdecl'),
  367. (mask:pocall_register; str:'Register'),
  368. (mask:pocall_stdcall; str:'StdCall'),
  369. (mask:pocall_safecall; str:'SafeCall'),
  370. (mask:pocall_palmossyscall;str:'PalmOSSysCall'),
  371. (mask:pocall_system; str:'System'),
  372. (mask:pocall_inline; str:'Inline'),
  373. (mask:pocall_internproc; str:'InternProc'),
  374. (mask:pocall_internconst; str:'InternConst')
  375. );
  376. proctypeopts=6;
  377. proctypeopt : array[1..proctypeopts] of tproctypeopt=(
  378. (mask:potype_proginit; str:'ProgInit'),
  379. (mask:potype_unitinit; str:'UnitInit'),
  380. (mask:potype_unitfinalize;str:'UnitFinalize'),
  381. (mask:potype_constructor; str:'Constructor'),
  382. (mask:potype_destructor; str:'Destructor'),
  383. (mask:potype_operator; str:'Operator')
  384. );
  385. procopts=16;
  386. procopt : array[1..procopts] of tprocopt=(
  387. (mask:po_classmethod; str:'ClassMethod'),
  388. (mask:po_virtualmethod; str:'VirtualMethod'),
  389. (mask:po_abstractmethod; str:'AbstractMethod'),
  390. (mask:po_staticmethod; str:'StaticMethod'),
  391. (mask:po_overridingmethod;str:'OverridingMethod'),
  392. (mask:po_methodpointer; str:'MethodPointer'),
  393. (mask:po_containsself; str:'ContainsSelf'),
  394. (mask:po_interrupt; str:'Interrupt'),
  395. (mask:po_iocheck; str:'IOCheck'),
  396. (mask:po_assembler; str:'Assembler'),
  397. (mask:po_msgstr; str:'MsgStr'),
  398. (mask:po_msgint; str:'MsgInt'),
  399. (mask:po_exports; str:'Exports'),
  400. (mask:po_external; str:'External'),
  401. (mask:po_savestdregs; str:'SaveStdRegs'),
  402. (mask:po_saveregisters; str:'SaveRegisters')
  403. );
  404. tvarspez : array[0..2] of string[5]=('Value','Const','Var ');
  405. var
  406. proctypeoption : tproctypeoption;
  407. proccalloptions : tproccalloptions;
  408. procoptions : tprocoptions;
  409. i,params : longint;
  410. first : boolean;
  411. begin
  412. write(space,' Return type : ');
  413. readtype;
  414. writeln(space,' Fpu used : ',ppufile.getbyte);
  415. proctypeoption:=tproctypeoption(ppufile.getlongint);
  416. if proctypeoption<>potype_none then
  417. begin
  418. write(space,' TypeOption : ');
  419. first:=true;
  420. for i:=1to proctypeopts do
  421. if (proctypeopt[i].mask=proctypeoption) then
  422. begin
  423. if first then
  424. first:=false
  425. else
  426. write(', ');
  427. write(proctypeopt[i].str);
  428. end;
  429. writeln;
  430. end;
  431. ppufile.getsmallset(proccalloptions);
  432. if proccalloptions<>[] then
  433. begin
  434. write(space,' CallOptions : ');
  435. first:=true;
  436. for i:=1to proccallopts do
  437. if (proccallopt[i].mask in proccalloptions) then
  438. begin
  439. if first then
  440. first:=false
  441. else
  442. write(', ');
  443. write(proccallopt[i].str);
  444. end;
  445. writeln;
  446. end;
  447. ppufile.getsmallset(procoptions);
  448. if procoptions<>[] then
  449. begin
  450. write(space,' Options : ');
  451. first:=true;
  452. for i:=1to procopts do
  453. if (procopt[i].mask in procoptions) then
  454. begin
  455. if first then
  456. first:=false
  457. else
  458. write(', ');
  459. write(procopt[i].str);
  460. end;
  461. writeln;
  462. end;
  463. params:=ppufile.getword;
  464. writeln(space,' Nr of parameters : ',params);
  465. if params>0 then
  466. begin
  467. repeat
  468. write(space,' - ',tvarspez[ppufile.getbyte],' : ');
  469. readtype;
  470. write(space,' Default : ');
  471. readsymref;
  472. dec(params);
  473. until params=0;
  474. end;
  475. end;
  476. procedure readcommonsym(const s:string);
  477. type
  478. tsymoption=(sp_none,
  479. sp_public,
  480. sp_private,
  481. sp_published,
  482. sp_protected,
  483. sp_forwarddef,
  484. sp_static,
  485. sp_primary_typesym { this is for typesym, to know who is the primary symbol of a def }
  486. );
  487. tsymoptions=set of tsymoption;
  488. tsymopt=record
  489. mask : tsymoption;
  490. str : string[30];
  491. end;
  492. const
  493. symopts=7;
  494. symopt : array[1..symopts] of tsymopt=(
  495. (mask:sp_public; str:'Public'),
  496. (mask:sp_private; str:'Private'),
  497. (mask:sp_published; str:'Published'),
  498. (mask:sp_protected; str:'Protected'),
  499. (mask:sp_forwarddef; str:'ForwardDef'),
  500. (mask:sp_static; str:'Static'),
  501. (mask:sp_primary_typesym;str:'PrimaryTypeSym')
  502. );
  503. var
  504. symoptions : tsymoptions;
  505. i : longint;
  506. first : boolean;
  507. begin
  508. writeln(space,'** Symbol Nr. ',ppufile.getword,' **');
  509. writeln(space,s,ppufile.getstring);
  510. ppufile.getsmallset(symoptions);
  511. if symoptions<>[] then
  512. begin
  513. write(space,' File Pos: ');
  514. readposinfo;
  515. write(space,' SymOptions: ');
  516. first:=true;
  517. for i:=1to symopts do
  518. if (symopt[i].mask in symoptions) then
  519. begin
  520. if first then
  521. first:=false
  522. else
  523. write(', ');
  524. write(symopt[i].str);
  525. end;
  526. writeln;
  527. end;
  528. end;
  529. procedure readcommondef(const s:string);
  530. begin
  531. writeln(space,'** Definition Nr. ',ppufile.getword,' **');
  532. writeln(space,s);
  533. write (space,' Type symbol : ');
  534. readsymref;
  535. end;
  536. {****************************************************************************
  537. Read Symbols Part
  538. ****************************************************************************}
  539. procedure readsymbols;
  540. Const
  541. vo_is_C_var = 2;
  542. Type
  543. absolutetyp = (tovar,toasm,toaddr);
  544. tconsttyp = (constnone,
  545. constord,conststring,constreal,constbool,
  546. constint,constchar,constset,constpointer,constnil,
  547. constresourcestring
  548. );
  549. var
  550. b : byte;
  551. pc : pchar;
  552. totalsyms,
  553. symcnt,
  554. i,j,len : longint;
  555. l1,l2 : longint;
  556. begin
  557. symcnt:=1;
  558. with ppufile do
  559. begin
  560. if space<>'' then
  561. Writeln(space,'-----------------------------');
  562. if readentry=ibstartsyms then
  563. begin
  564. totalsyms:=getlongint;
  565. Writeln(space,'Number of symbols : ',totalsyms);
  566. Writeln(space,'Symtable datasize : ',getlongint);
  567. Writeln(space,'Symtable alignment: ',getlongint);
  568. end
  569. else
  570. begin
  571. totalsyms:=-1;
  572. Writeln('!! ibstartsym not found');
  573. end;
  574. repeat
  575. b:=readentry;
  576. if not (b in [iberror,ibendsyms]) then
  577. inc(symcnt);
  578. case b of
  579. ibunitsym :
  580. readcommonsym('Unit symbol ');
  581. iblabelsym :
  582. readcommonsym('Label symbol ');
  583. ibtypesym :
  584. begin
  585. readcommonsym('Type symbol ');
  586. write(space,' Result Type: ');
  587. readtype;
  588. end;
  589. ibprocsym :
  590. begin
  591. readcommonsym('Procedure symbol ');
  592. write(space,' Definition: ');
  593. readdefref;
  594. end;
  595. ibconstsym :
  596. begin
  597. readcommonsym('Constant symbol ');
  598. b:=getbyte;
  599. case tconsttyp(b) of
  600. constord :
  601. begin
  602. write (space,'OrdinalType: ');
  603. readtype;
  604. writeln (space,' Value: ',getlongint)
  605. end;
  606. constpointer :
  607. begin
  608. write (space,' Pointer Type: ');
  609. readtype;
  610. writeln (space,' Value: ',getlongint)
  611. end;
  612. conststring,
  613. constresourcestring :
  614. begin
  615. len:=getlongint;
  616. getmem(pc,len+1);
  617. getdata(pc^,len);
  618. writeln(space,' Length: ',len);
  619. writeln(space,' Value: "',pc,'"');
  620. freemem(pc,len+1);
  621. if tconsttyp(b)=constresourcestring then
  622. writeln(space,' Index: ',getlongint);
  623. end;
  624. constreal :
  625. writeln(space,' Value: ',getreal);
  626. constbool :
  627. if getlongint<>0 then
  628. writeln (space,' Value : True')
  629. else
  630. writeln (space,' Value: False');
  631. constint :
  632. begin
  633. l1:=getlongint;
  634. l2:=getlongint;
  635. writeln(space,' Value: ',int64(l2 shl 32) or l1);
  636. end;
  637. constchar :
  638. writeln(space,' Value: "'+chr(getlongint)+'"');
  639. constset :
  640. begin
  641. write (space,' Set Type: ');
  642. readtype;
  643. for i:=1to 4 do
  644. begin
  645. write (space,' Value: ');
  646. for j:=1to 8 do
  647. begin
  648. if j>1 then
  649. write(',');
  650. write(hexb(getbyte));
  651. end;
  652. writeln;
  653. end;
  654. end;
  655. else
  656. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  657. end;
  658. end;
  659. ibvarsym :
  660. begin
  661. readcommonsym('Variable symbol ');
  662. writeln(space,' Type: ',getbyte);
  663. if read_member then
  664. writeln(space,' Address: ',getlongint);
  665. write (space,' Var Type: ');
  666. readtype;
  667. i:=getlongint;
  668. writeln(space,' Options: ',i);
  669. if (i and vo_is_C_var)<>0 then
  670. writeln(space,' Mangledname: ',getstring);
  671. end;
  672. ibenumsym :
  673. begin
  674. readcommonsym('Enumeration symbol ');
  675. write (space,' Definition: ');
  676. readdefref;
  677. writeln(space,' Value: ',getlongint);
  678. end;
  679. ibsyssym :
  680. begin
  681. readcommonsym('Internal system symbol ');
  682. writeln(space,' Internal Nr: ',getlongint);
  683. end;
  684. ibtypedconstsym :
  685. begin
  686. readcommonsym('Typed constant ');
  687. write (space,' Constant Type: ');
  688. readtype;
  689. writeln(space,' Label: ',getstring);
  690. writeln(space,' ReallyConst: ',(getbyte<>0));
  691. end;
  692. ibabsolutesym :
  693. begin
  694. readcommonsym('Absolute variable symbol ');
  695. writeln(space,' Type: ',getbyte);
  696. if read_member then
  697. writeln(space,' Address: ',getlongint);
  698. write (space,' Var Type: ');
  699. readtype;
  700. writeln(space,' Options: ',getlongint);
  701. Write (space,' Relocated to ');
  702. b:=getbyte;
  703. case absolutetyp(b) of
  704. tovar :
  705. Writeln('Name : ',getstring);
  706. toasm :
  707. Writeln('Assembler name : ',getstring);
  708. toaddr :
  709. begin
  710. Write('Address : ',getlongint);
  711. WriteLn(' (Far: ',getbyte<>0,')');
  712. end;
  713. else
  714. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  715. end;
  716. end;
  717. ibpropertysym :
  718. begin
  719. readcommonsym('Property ');
  720. i:=getlongint;
  721. writeln(space,' PropOptions: ',i);
  722. if (i and 32)>0 then
  723. begin
  724. write (space,'OverrideProp: ');
  725. readsymref;
  726. end
  727. else
  728. begin
  729. write (space,' Prop Type: ');
  730. readtype;
  731. writeln(space,' Index: ',getlongint);
  732. writeln(space,' Default: ',getlongint);
  733. write (space,' Index Type: ');
  734. readtype;
  735. write (space,' Readaccess: ');
  736. readsymlist(space+' Sym: ');
  737. write (space,' Writeaccess: ');
  738. readsymlist(space+' Sym: ');
  739. write (space,'Storedaccess: ');
  740. readsymlist(space+' Sym: ');
  741. end;
  742. end;
  743. ibfuncretsym :
  744. begin
  745. readcommonsym('Func return value ');
  746. write (space,' Return Type: ');
  747. readtype;
  748. writeln(space,' Address: ',getlongint);
  749. end;
  750. iberror :
  751. begin
  752. Writeln('!! Error in PPU');
  753. exit;
  754. end;
  755. ibendsyms :
  756. break;
  757. else
  758. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  759. end;
  760. if not EndOfEntry then
  761. Writeln('!! Entry has more information stored');
  762. until false;
  763. if (totalsyms<>-1) and (symcnt-1<>totalsyms) then
  764. Writeln('!! Only read ',symcnt-1,' of ',totalsyms,' symbols');
  765. end;
  766. end;
  767. {****************************************************************************
  768. Read defintions Part
  769. ****************************************************************************}
  770. procedure readdefinitions(start_read : boolean);
  771. type
  772. tsettype = (normset,smallset,varset);
  773. tbasetype = (
  774. uauto,uvoid,uchar,
  775. u8bit,u16bit,u32bit,
  776. s8bit,s16bit,s32bit,
  777. bool8bit,bool16bit,bool32bit,
  778. u64bit,s64bit,uwidechar
  779. );
  780. tobjectdeftype = (odt_none,
  781. odt_class,
  782. odt_object,
  783. odt_interfacecom,
  784. odt_interfacecorba,
  785. odt_cppclass
  786. );
  787. var
  788. b : byte;
  789. oldread_member : boolean;
  790. totaldefs,l,j,
  791. defcnt : longint;
  792. begin
  793. defcnt:=0;
  794. with ppufile do
  795. begin
  796. if space<>'' then
  797. Writeln(space,'-----------------------------');
  798. if not start_read then
  799. if readentry=ibstartdefs then
  800. begin
  801. totaldefs:=getlongint;
  802. Writeln(space,'Number of definitions: ',totaldefs);
  803. end
  804. else
  805. begin
  806. totaldefs:=-1;
  807. Writeln('!! ibstartdef not found');
  808. end;
  809. repeat
  810. b:=readentry;
  811. if not (b in [iberror,ibenddefs]) then
  812. inc(defcnt);
  813. case b of
  814. ibpointerdef :
  815. begin
  816. readcommondef('Pointer definition');
  817. write (space,' Pointed Type : ');
  818. readtype;
  819. writeln(space,' Is Far : ',(getbyte<>0));
  820. end;
  821. iborddef :
  822. begin
  823. readcommondef('Ordinal definition');
  824. write (space,' Base type : ');
  825. b:=getbyte;
  826. case tbasetype(b) of
  827. uauto : writeln('uauto');
  828. uvoid : writeln('uvoid');
  829. uchar : writeln('uchar');
  830. u8bit : writeln('u8bit');
  831. u16bit : writeln('u16bit');
  832. u32bit : writeln('s32bit');
  833. s8bit : writeln('s8bit');
  834. s16bit : writeln('s16bit');
  835. s32bit : writeln('s32bit');
  836. bool8bit : writeln('bool8bit');
  837. bool16bit : writeln('bool16bit');
  838. bool32bit : writeln('bool32bit');
  839. u64bit : writeln('u64bit');
  840. s64bit : writeln('s64bit');
  841. uwidechar : writeln('uwidechar');
  842. else writeln('!! Warning: Invalid base type ',b);
  843. end;
  844. writeln(space,' Range : ',getlongint,' to ',getlongint);
  845. end;
  846. ibfloatdef :
  847. begin
  848. readcommondef('Float definition');
  849. writeln(space,' Float type : ',getbyte);
  850. end;
  851. ibarraydef :
  852. begin
  853. readcommondef('Array definition');
  854. write (space,' Element type : ');
  855. readtype;
  856. write (space,' Range Type : ');
  857. readtype;
  858. writeln(space,' Range : ',getlongint,' to ',getlongint);
  859. writeln(space,' Is Constructor : ',(getbyte<>0));
  860. end;
  861. ibprocdef :
  862. begin
  863. readcommondef('Procedure definition');
  864. read_abstract_proc_def;
  865. writeln(space,' Used Register : ',getbyte);
  866. writeln(space,' Mangled name : ',getstring);
  867. writeln(space,' Number : ',getlongint);
  868. write (space,' Next : ');
  869. readdefref;
  870. write (space,' Class : ');
  871. readdefref;
  872. write (space,' File Pos : ');
  873. readposinfo;
  874. space:=' '+space;
  875. { parast }
  876. readdefinitions(false);
  877. readsymbols;
  878. { localst }
  879. {readdefinitions(false);
  880. readsymbols;}
  881. delete(space,1,4);
  882. end;
  883. ibprocvardef :
  884. begin
  885. readcommondef('Procedural type (ProcVar) definition');
  886. read_abstract_proc_def;
  887. end;
  888. ibshortstringdef :
  889. begin
  890. readcommondef('ShortString definition');
  891. writeln(space,' Length : ',getbyte);
  892. end;
  893. ibwidestringdef :
  894. begin
  895. readcommondef('WideString definition');
  896. writeln(space,' Length : ',getlongint);
  897. end;
  898. ibansistringdef :
  899. begin
  900. readcommondef('AnsiString definition');
  901. writeln(space,' Length : ',getlongint);
  902. end;
  903. iblongstringdef :
  904. begin
  905. readcommondef('Longstring definition');
  906. writeln(space,' Length : ',getlongint);
  907. end;
  908. ibrecorddef :
  909. begin
  910. readcommondef('Record definition');
  911. writeln(space,' Size : ',getlongint);
  912. {read the record definitions and symbols}
  913. space:=' '+space;
  914. oldread_member:=read_member;
  915. read_member:=true;
  916. readdefinitions(false);
  917. readsymbols;
  918. read_member:=oldread_member;
  919. Delete(space,1,4);
  920. end;
  921. ibobjectdef :
  922. begin
  923. readcommondef('Object/Class definition');
  924. b:=getbyte;
  925. write (space,' Type : ');
  926. case tobjectdeftype(b) of
  927. odt_class : writeln('class');
  928. odt_object : writeln('object');
  929. odt_interfacecom : writeln('interfacecom');
  930. odt_interfacecorba : writeln('interfacecorba');
  931. odt_cppclass : writeln('cppclass');
  932. else writeln('!! Warning: Invalid object type ',b);
  933. end;
  934. writeln(space,' Size : ',getlongint);
  935. writeln(space,' Vmt offset : ',getlongint);
  936. writeln(space,' Name of Class : ',getstring);
  937. write(space, ' Ancestor Class : ');
  938. readdefref;
  939. writeln(space,' Options : ',getlongint);
  940. writeln(space,' Has RTTI : ',(getbyte<>0));
  941. if tobjectdeftype(b) in [odt_interfacecom,odt_interfacecorba] then
  942. begin
  943. writeln(space,' GUID Valid : ',(getbyte<>0));
  944. { IIDGUID }
  945. for j:=1to 16 do
  946. getbyte;
  947. writeln(space,' IID String : ',getstring);
  948. writeln(space,' Last VTable idx : ',getlongint);
  949. end;
  950. if tobjectdeftype(b) in [odt_class,odt_interfacecorba] then
  951. begin
  952. l:=getlongint;
  953. writeln(space,' Impl Intf Count : ',l);
  954. for j:=1 to l do
  955. begin
  956. write (space,' - Definition : ');
  957. readdefref;
  958. writeln(space,' IOffset : ',getlongint);
  959. end;
  960. end;
  961. {read the record definitions and symbols}
  962. space:=' '+space;
  963. oldread_member:=read_member;
  964. read_member:=true;
  965. readdefinitions(false);
  966. readsymbols;
  967. read_member:=oldread_member;
  968. Delete(space,1,4);
  969. end;
  970. ibfiledef :
  971. begin
  972. ReadCommonDef('File definition');
  973. write (space,' Type : ');
  974. case getbyte of
  975. 0 : writeln('Text');
  976. 1 : begin
  977. writeln('Typed');
  978. write (space,' File of Type : ');
  979. Readtype;
  980. end;
  981. 2 : writeln('Untyped');
  982. end;
  983. end;
  984. ibformaldef :
  985. readcommondef('Generic Definition (void-typ)');
  986. ibenumdef :
  987. begin
  988. readcommondef('Enumeration type definition');
  989. write(space,'Base enumeration type : ');
  990. readdefref;
  991. writeln(space,' Smallest element : ',getlongint);
  992. writeln(space,' Largest element : ',getlongint);
  993. writeln(space,' Size : ',getlongint);
  994. end;
  995. ibclassrefdef :
  996. begin
  997. readcommondef('Class reference definition');
  998. write (space,' Pointed Type : ');
  999. readtype;
  1000. end;
  1001. ibsetdef :
  1002. begin
  1003. readcommondef('Set definition');
  1004. write (space,' Element type : ');
  1005. readtype;
  1006. b:=getbyte;
  1007. case tsettype(b) of
  1008. smallset : writeln(space,' Set with 32 Elements');
  1009. normset : writeln(space,' Set with 256 Elements');
  1010. varset : writeln(space,' Set with ',getlongint,' Elements');
  1011. else writeln('!! Warning: Invalid set type ',b);
  1012. end;
  1013. end;
  1014. ibvariantdef :
  1015. begin
  1016. readcommondef('Variant definition');
  1017. end;
  1018. iberror :
  1019. begin
  1020. Writeln('!! Error in PPU');
  1021. exit;
  1022. end;
  1023. ibenddefs :
  1024. break;
  1025. else
  1026. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  1027. end;
  1028. if not EndOfEntry then
  1029. Writeln('!! Entry has more information stored');
  1030. until false;
  1031. if (totaldefs<>-1) and (defcnt<>totaldefs) then
  1032. Writeln('!! Only read ',defcnt,' of ',totaldefs,' definitions');
  1033. end;
  1034. end;
  1035. {****************************************************************************
  1036. Read General Part
  1037. ****************************************************************************}
  1038. procedure readinterface;
  1039. var
  1040. b : byte;
  1041. sourcenumber,
  1042. unitnumber : word;
  1043. ucrc,uintfcrc : longint;
  1044. begin
  1045. with ppufile do
  1046. begin
  1047. repeat
  1048. b:=readentry;
  1049. case b of
  1050. ibmodulename :
  1051. Writeln('Module Name: ',getstring);
  1052. ibsourcefiles :
  1053. begin
  1054. sourcenumber:=1;
  1055. while not EndOfEntry do
  1056. begin
  1057. Writeln('Source file ',sourcenumber,' : ',getstring);
  1058. inc(sourcenumber);
  1059. end;
  1060. end;
  1061. ibusedmacros :
  1062. begin
  1063. while not EndOfEntry do
  1064. begin
  1065. Write('Conditional ',getstring);
  1066. b:=getbyte;
  1067. if boolean(b)=true then
  1068. write(' defined at startup')
  1069. else
  1070. write(' not defined at startup');
  1071. b:=getbyte;
  1072. if boolean(b)=true then
  1073. writeln(' was used')
  1074. else
  1075. writeln;
  1076. end;
  1077. end;
  1078. ibloadunit :
  1079. begin
  1080. unitnumber:=1;
  1081. while not EndOfEntry do
  1082. begin
  1083. write('Uses unit: ',getstring,' (Number: ',unitnumber,')');
  1084. ucrc:=getlongint;
  1085. uintfcrc:=getlongint;
  1086. write(' (Crc: ',ucrc,', IntfcCrc: ',uintfcrc,')');
  1087. if getbyte<>0 then
  1088. writeln(' (interface)')
  1089. else
  1090. writeln(' (implementation)');
  1091. inc(unitnumber);
  1092. end;
  1093. end;
  1094. iblinkunitofiles :
  1095. ReadLinkContainer('Link unit object file: ');
  1096. iblinkunitstaticlibs :
  1097. ReadLinkContainer('Link unit static lib: ');
  1098. iblinkunitsharedlibs :
  1099. ReadLinkContainer('Link unit shared lib: ');
  1100. iblinkotherofiles :
  1101. ReadLinkContainer('Link other object file: ');
  1102. iblinkotherstaticlibs :
  1103. ReadLinkContainer('Link other static lib: ');
  1104. iblinkothersharedlibs :
  1105. ReadLinkContainer('Link other shared lib: ');
  1106. iberror :
  1107. begin
  1108. Writeln('Error in PPU');
  1109. exit;
  1110. end;
  1111. ibendinterface :
  1112. break;
  1113. else
  1114. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  1115. end;
  1116. until false;
  1117. end;
  1118. end;
  1119. {****************************************************************************
  1120. Read Implementation Part
  1121. ****************************************************************************}
  1122. procedure readimplementation;
  1123. var
  1124. b : byte;
  1125. begin
  1126. with ppufile do
  1127. begin
  1128. repeat
  1129. b:=readentry;
  1130. case b of
  1131. iberror :
  1132. begin
  1133. Writeln('Error in PPU');
  1134. exit;
  1135. end;
  1136. ibendimplementation :
  1137. break;
  1138. else
  1139. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  1140. end;
  1141. until false;
  1142. end;
  1143. end;
  1144. {****************************************************************************
  1145. Read Browser Part
  1146. ****************************************************************************}
  1147. procedure readbrowser;
  1148. var
  1149. b : byte;
  1150. const indent : string = '';
  1151. begin
  1152. Writeln(indent,'Start of symtable browser');
  1153. indent:=indent+'**';
  1154. with ppufile do
  1155. begin
  1156. repeat
  1157. b:=readentry;
  1158. case b of
  1159. ibbeginsymtablebrowser :
  1160. { here we must read object and record symtables !! }
  1161. begin
  1162. indent:=indent+' ';
  1163. Writeln(indent,'Record/Object symtable');
  1164. readbrowser;
  1165. Indent:=Copy(Indent,1,Length(Indent)-2);
  1166. end;
  1167. ibsymref : begin
  1168. readsymref;
  1169. readref;
  1170. end;
  1171. ibdefref : begin
  1172. readdefref;
  1173. readref;
  1174. if (ppufile.header.flags and uf_local_browser)<>0 then
  1175. begin
  1176. { parast and localst }
  1177. indent:=indent+' ';
  1178. Writeln(indent,'Parasymtable for function');
  1179. readdefinitions(false);
  1180. readsymbols;
  1181. b:=ppufile.readentry;
  1182. if b=ibbeginsymtablebrowser then
  1183. readbrowser;
  1184. Writeln(indent,'Localsymtable for function');
  1185. readdefinitions(false);
  1186. readsymbols;
  1187. b:=ppufile.readentry;
  1188. if b=ibbeginsymtablebrowser then
  1189. readbrowser;
  1190. Indent:=Copy(Indent,1,Length(Indent)-2);
  1191. end;
  1192. end;
  1193. iberror : begin
  1194. Writeln('Error in PPU');
  1195. exit;
  1196. end;
  1197. ibendsymtablebrowser : break;
  1198. else
  1199. begin
  1200. WriteLn('!! Skipping unsupported PPU Entry in Browser: ',b);
  1201. Halt;
  1202. end;
  1203. end;
  1204. until false;
  1205. end;
  1206. Indent:=Copy(Indent,1,Length(Indent)-2);
  1207. Writeln(Indent,'End of symtable browser');
  1208. end;
  1209. procedure dofile (filename : string);
  1210. var
  1211. b,unitindex : byte;
  1212. begin
  1213. { reset }
  1214. space:='';
  1215. { fix filename }
  1216. if pos('.',filename)=0 then
  1217. filename:=filename+'.ppu';
  1218. ppufile:=tppufile.create(filename);
  1219. if not ppufile.openfile then
  1220. begin
  1221. writeln ('IO-Error when opening : ',filename,', Skipping');
  1222. exit;
  1223. end;
  1224. { PPU File is open, check for PPU Id }
  1225. if not ppufile.CheckPPUID then
  1226. begin
  1227. writeln(Filename,' : Not a valid PPU file, Skipping');
  1228. exit;
  1229. end;
  1230. { Check PPU Version }
  1231. Writeln('Analyzing ',filename,' (v',ppufile.GetPPUVersion,')');
  1232. if ppufile.GetPPUVersion<16 then
  1233. begin
  1234. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  1235. exit;
  1236. end;
  1237. { Write PPU Header Information }
  1238. if (verbose and v_header)<>0 then
  1239. begin
  1240. Writeln;
  1241. Writeln('Header');
  1242. Writeln('-------');
  1243. with ppufile.header do
  1244. begin
  1245. Writeln('Compiler version : ',hi(ppufile.header.compiler and $ff),'.',lo(ppufile.header.compiler));
  1246. WriteLn('Target processor : ',Cpu2Str(cpu));
  1247. WriteLn('Target operating system : ',Target2Str(target));
  1248. Writeln('Unit flags : ',PPUFlags2Str(flags));
  1249. Writeln('FileSize (w/o header) : ',size);
  1250. Writeln('Checksum : ',hexstr(checksum,8));
  1251. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  1252. end;
  1253. end;
  1254. {read the general stuff}
  1255. if (verbose and v_interface)<>0 then
  1256. begin
  1257. Writeln;
  1258. Writeln('Interface section');
  1259. Writeln('------------------');
  1260. readinterface;
  1261. end
  1262. else
  1263. ppufile.skipuntilentry(ibendinterface);
  1264. {read the definitions}
  1265. if (verbose and v_defs)<>0 then
  1266. begin
  1267. Writeln;
  1268. Writeln('Interface definitions');
  1269. Writeln('----------------------');
  1270. readdefinitions(false);
  1271. end
  1272. else
  1273. ppufile.skipuntilentry(ibenddefs);
  1274. {read the symbols}
  1275. if (verbose and v_syms)<>0 then
  1276. begin
  1277. Writeln;
  1278. Writeln('Interface Symbols');
  1279. Writeln('------------------');
  1280. readsymbols;
  1281. end
  1282. else
  1283. ppufile.skipuntilentry(ibendsyms);
  1284. {read the implementation stuff}
  1285. { Not used at the moment (PFV)
  1286. if (verbose and v_implementation)<>0 then
  1287. begin
  1288. Writeln;
  1289. Writeln('Implementation section');
  1290. Writeln('-----------------------');
  1291. readimplementation;
  1292. end
  1293. else}
  1294. ppufile.skipuntilentry(ibendimplementation);
  1295. {read the static browser units stuff}
  1296. if (ppufile.header.flags and uf_local_browser)<>0 then
  1297. begin
  1298. if (verbose and v_defs)<>0 then
  1299. begin
  1300. Writeln;
  1301. Writeln('Static definitions');
  1302. Writeln('----------------------');
  1303. readdefinitions(false);
  1304. end
  1305. else
  1306. ppufile.skipuntilentry(ibenddefs);
  1307. {read the symbols}
  1308. if (verbose and v_syms)<>0 then
  1309. begin
  1310. Writeln;
  1311. Writeln('Static Symbols');
  1312. Writeln('------------------');
  1313. readsymbols;
  1314. end;
  1315. end;
  1316. {read the browser units stuff}
  1317. if (ppufile.header.flags and uf_has_browser)<>0 then
  1318. begin
  1319. if (verbose and v_browser)<>0 then
  1320. begin
  1321. Writeln;
  1322. Writeln('Browser section');
  1323. Writeln('---------------');
  1324. UnitIndex:=0;
  1325. repeat
  1326. b:=ppufile.readentry;
  1327. if b = ibendbrowser then break;
  1328. if b=ibbeginsymtablebrowser then
  1329. begin
  1330. Writeln('Unit ',UnitIndex);
  1331. readbrowser;
  1332. Inc(UnitIndex);
  1333. end
  1334. else
  1335. Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
  1336. until false;
  1337. end;
  1338. end;
  1339. {read the static browser units stuff}
  1340. if (ppufile.header.flags and uf_local_browser)<>0 then
  1341. begin
  1342. if (verbose and v_browser)<>0 then
  1343. begin
  1344. Writeln;
  1345. Writeln('Static browser section');
  1346. Writeln('---------------');
  1347. b:=ppufile.readentry;
  1348. if b=ibbeginsymtablebrowser then
  1349. begin
  1350. Writeln('Unit ',UnitIndex);
  1351. readbrowser;
  1352. Inc(UnitIndex);
  1353. end
  1354. else
  1355. Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
  1356. end;
  1357. end;
  1358. {shutdown ppufile}
  1359. ppufile.closefile;
  1360. ppufile.free;
  1361. Writeln;
  1362. end;
  1363. procedure help;
  1364. begin
  1365. writeln('usage: ppudump [options] <filename1> <filename2>...');
  1366. writeln;
  1367. writeln('[options] can be:');
  1368. writeln(' -V<verbose> Set verbosity to <verbose>');
  1369. writeln(' H - Show header info');
  1370. writeln(' I - Show interface');
  1371. writeln(' M - Show implementation');
  1372. writeln(' S - Show interface symbols');
  1373. writeln(' D - Show interface definitions');
  1374. writeln(' B - Show browser info');
  1375. writeln(' A - Show all');
  1376. writeln(' -? This helpscreen');
  1377. halt;
  1378. end;
  1379. var
  1380. startpara,
  1381. nrfile,i : longint;
  1382. para : string;
  1383. begin
  1384. writeln(Title+' '+Version);
  1385. writeln(Copyright);
  1386. writeln;
  1387. if paramcount<1 then
  1388. begin
  1389. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  1390. halt(1);
  1391. end;
  1392. { turn verbose on by default }
  1393. verbose:=v_all;
  1394. { read options }
  1395. startpara:=1;
  1396. while copy(paramstr(startpara),1,1)='-' do
  1397. begin
  1398. para:=paramstr(startpara);
  1399. case upcase(para[2]) of
  1400. 'V' : begin
  1401. verbose:=0;
  1402. for i:=3to length(para) do
  1403. case upcase(para[i]) of
  1404. 'H' : verbose:=verbose or v_header;
  1405. 'I' : verbose:=verbose or v_interface;
  1406. 'M' : verbose:=verbose or v_implementation;
  1407. 'D' : verbose:=verbose or v_defs;
  1408. 'S' : verbose:=verbose or v_syms;
  1409. 'B' : verbose:=verbose or v_browser;
  1410. 'A' : verbose:=verbose or v_all;
  1411. end;
  1412. end;
  1413. '?' : help;
  1414. end;
  1415. inc(startpara);
  1416. end;
  1417. { process files }
  1418. for nrfile:=startpara to paramcount do
  1419. dofile (paramstr(nrfile));
  1420. if has_errors then
  1421. Halt(1);
  1422. end.
  1423. {
  1424. $Log$
  1425. Revision 1.3 2001-05-09 14:11:10 jonas
  1426. * range check error fixes from Peter
  1427. Revision 1.2 2001/05/06 14:49:19 peter
  1428. * ppu object to class rewrite
  1429. * move ppu read and write stuff to fppu
  1430. Revision 1.1 2001/04/25 22:40:07 peter
  1431. * compiler dependent utils in utils/ subdir
  1432. Revision 1.5 2001/04/10 21:21:41 peter
  1433. * variantdef support
  1434. * propertysym fixed
  1435. Revision 1.4 2001/04/04 22:42:59 peter
  1436. * updated for new objectdef with interfaces
  1437. Revision 1.3 2000/09/09 19:46:40 peter
  1438. * show dataalignment
  1439. Revision 1.2 2000/08/13 12:58:06 peter
  1440. * updated for ppu additions
  1441. Revision 1.1 2000/07/13 10:16:22 michael
  1442. + Initial import
  1443. Revision 1.15 2000/07/04 19:05:54 peter
  1444. * be optimistic: version 1.00 for some utils
  1445. Revision 1.14 2000/02/09 16:44:14 peter
  1446. * log truncated
  1447. Revision 1.13 2000/01/23 16:34:36 peter
  1448. * updated for new aktlocalindex
  1449. Revision 1.12 2000/01/07 16:46:03 daniel
  1450. * copyright 2000
  1451. Revision 1.11 1999/11/30 10:35:37 peter
  1452. * support new readtype
  1453. Revision 1.10 1999/11/08 14:06:45 florian
  1454. + indexref of propertysym is handle too now
  1455. Revision 1.9 1999/08/31 16:07:37 pierre
  1456. + support for writeusedmacros
  1457. Revision 1.8 1999/08/15 10:47:14 peter
  1458. * updates for new options
  1459. Revision 1.7 1999/08/13 21:25:35 peter
  1460. * updated flags
  1461. Revision 1.6 1999/07/27 23:45:29 peter
  1462. * updated for typesym writing
  1463. }