ppudump.pp 48 KB

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