ppudump.pp 48 KB

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