ppudump.pp 48 KB

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