ppudump.pp 45 KB

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