ppudump.pp 46 KB

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