ppudump.pp 46 KB

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