ppudump.pp 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157
  1. {
  2. Copyright (c) 1998-2002 by the FPC Development Team
  3. Dumps the contents of a FPC unit file (PPU File)
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************}
  16. {$ifdef TP}
  17. {$N+,E+}
  18. {$endif}
  19. program pppdump;
  20. uses
  21. dos,
  22. ppu;
  23. const
  24. Version = 'Version 1.9.8';
  25. Title = 'PPU-Analyser';
  26. Copyright = 'Copyright (c) 1998-2005 by the Free Pascal Development Team';
  27. { verbosity }
  28. v_none = $0;
  29. v_header = $1;
  30. v_defs = $2;
  31. v_syms = $4;
  32. v_interface = $8;
  33. v_implementation = $10;
  34. v_browser = $20;
  35. v_all = $ff;
  36. type
  37. tprocinfoflag=(
  38. {# procedure uses asm }
  39. pi_uses_asm,
  40. {# procedure does a call }
  41. pi_do_call,
  42. {# procedure has a try statement = no register optimization }
  43. pi_uses_exceptions,
  44. {# procedure is declared as @var(assembler), don't optimize}
  45. pi_is_assembler,
  46. {# procedure contains data which needs to be finalized }
  47. pi_needs_implicit_finally
  48. );
  49. tprocinfoflags=set of tprocinfoflag;
  50. { Copied from systems.pas }
  51. tsystemcpu=
  52. (
  53. cpu_no, { 0 }
  54. cpu_i386, { 1 }
  55. cpu_m68k, { 2 }
  56. cpu_alpha, { 3 }
  57. cpu_powerpc, { 4 }
  58. cpu_sparc, { 5 }
  59. cpu_vm, { 6 }
  60. cpu_iA64, { 7 }
  61. cpu_x86_64, { 8 }
  62. cpu_mips, { 9 }
  63. cpu_arm { 10 }
  64. );
  65. var
  66. ppufile : tppufile;
  67. space : string;
  68. unitindex : longint;
  69. verbose : longint;
  70. derefdata : pbyte;
  71. derefdatalen : longint;
  72. {****************************************************************************
  73. Helper Routines
  74. ****************************************************************************}
  75. const has_errors : boolean = false;
  76. Procedure Error(const S : string);
  77. Begin
  78. Writeln(S);
  79. has_errors:=true;
  80. End;
  81. function ToStr(w:longint):String;
  82. begin
  83. Str(w,ToStr);
  84. end;
  85. Function Target2Str(w:longint):string;
  86. type
  87. { taken from systems.pas }
  88. ttarget =
  89. (
  90. target_none, { 0 }
  91. target_i386_GO32V1, { 1 }
  92. target_i386_GO32V2, { 2 }
  93. target_i386_linux, { 3 }
  94. target_i386_OS2, { 4 }
  95. target_i386_Win32, { 5 }
  96. target_i386_freebsd, { 6 }
  97. target_m68k_Amiga, { 7 }
  98. target_m68k_Atari, { 8 }
  99. target_m68k_Mac, { 9 }
  100. target_m68k_linux, { 10 }
  101. target_m68k_PalmOS, { 11 }
  102. target_alpha_linux, { 12 }
  103. target_powerpc_linux, { 13 }
  104. target_powerpc_macos, { 14 }
  105. target_i386_sunos, { 15 }
  106. target_i386_beos, { 16 }
  107. target_i386_netbsd, { 17 }
  108. target_m68k_netbsd, { 18 }
  109. target_i386_Netware, { 19 }
  110. target_i386_qnx, { 20 }
  111. target_i386_wdosx, { 21 }
  112. target_sparc_sunos, { 22 }
  113. target_sparc_linux, { 23 }
  114. target_i386_openbsd, { 24 }
  115. target_m68k_openbsd, { 25 }
  116. system_x86_64_linux, { 26 }
  117. system_powerpc_macosx, { 27 }
  118. target_i386_emx, { 28 }
  119. target_powerpc_netbsd, { 29 }
  120. target_powerpc_openbsd, { 30 }
  121. target_arm_linux, { 31 }
  122. target_i386_watcom, { 32 }
  123. target_powerpc_MorphOS, { 33 }
  124. target_x86_64_freebsd, { 34 }
  125. target_i386_netwlibc { 35 }
  126. );
  127. const
  128. Targets : array[ttarget] of string[17]=(
  129. { 0 } 'none',
  130. { 1 } 'GO32V1',
  131. { 2 } 'GO32V2',
  132. { 3 } 'Linux-i386',
  133. { 4 } 'OS/2',
  134. { 5 } 'Win32',
  135. { 6 } 'FreeBSD-i386',
  136. { 7 } 'Amiga',
  137. { 8 } 'Atari',
  138. { 9 } 'MacOS-m68k',
  139. { 10 } 'Linux-m68k',
  140. { 11 } 'PalmOS-m68k',
  141. { 12 } 'Linux-alpha',
  142. { 13 } 'Linux-ppc',
  143. { 14 } 'MacOS-ppc',
  144. { 15 } 'Solaris-i386',
  145. { 16 } 'BeOS-i386',
  146. { 17 } 'NetBSD-i386',
  147. { 18 } 'NetBSD-m68k',
  148. { 19 } 'Netware-i386-clib',
  149. { 20 } 'Qnx-i386',
  150. { 21 } 'WDOSX-i386',
  151. { 22 } 'Solaris-sparc',
  152. { 23 } 'Linux-sparc',
  153. { 24 } 'OpenBSD-i386',
  154. { 25 } 'OpenBSD-m68k',
  155. { 26 } 'Linux-x86-64',
  156. { 27 } 'MacOSX-ppc',
  157. { 28 } 'OS/2 via EMX',
  158. { 29 } 'NetBSD-powerpc',
  159. { 30 } 'OpenBSD-powerpc',
  160. { 31 } 'Linux-arm',
  161. { 32 } 'Watcom-i386',
  162. { 33 } 'MorphOS-powerpc',
  163. { 34 } 'FreeBSD-x86-64',
  164. { 35 } 'Netware-i386-libc'
  165. );
  166. begin
  167. if w<=ord(high(ttarget)) then
  168. Target2Str:=Targets[ttarget(w)]
  169. else
  170. Target2Str:='<!! Unknown target value '+tostr(w)+'>';
  171. end;
  172. Function Cpu2Str(w:longint):string;
  173. const
  174. CpuTxt : array[tsystemcpu] of string[8]=
  175. ('none','i386','m68k','alpha','powerpc','sparc','vis','ia64','x86_64','mips','arm');
  176. begin
  177. if w<=ord(high(tsystemcpu)) then
  178. Cpu2Str:=CpuTxt[tsystemcpu(w)]
  179. else
  180. Cpu2Str:='<!! Unknown cpu value '+tostr(w)+'>';
  181. end;
  182. Function Varspez2Str(w:longint):string;
  183. const
  184. varspezstr : array[0..4] of string[6]=('Value','Const','Var','Out','Hidden');
  185. begin
  186. if w<=ord(high(varspezstr)) then
  187. Varspez2Str:=varspezstr[w]
  188. else
  189. Varspez2Str:='<!! Unknown varspez value '+tostr(w)+'>';
  190. end;
  191. Function VarRegable2Str(w:longint):string;
  192. const
  193. varregableStr : array[0..3] of string[6]=('None','IntReg','FPUReg','MMReg');
  194. begin
  195. if w<=ord(high(varregablestr)) then
  196. Varregable2Str:=varregablestr[w]
  197. else
  198. Varregable2Str:='<!! Unknown regable value '+tostr(w)+'>';
  199. end;
  200. function PPUFlags2Str(flags:longint):string;
  201. type
  202. tflagopt=record
  203. mask : longint;
  204. str : string[30];
  205. end;
  206. const
  207. flagopts=19;
  208. flagopt : array[1..flagopts] of tflagopt=(
  209. (mask: $1 ;str:'init'),
  210. (mask: $2 ;str:'final'),
  211. (mask: $4 ;str:'big_endian'),
  212. (mask: $8 ;str:'dbx'),
  213. (mask: $10 ;str:'browser'),
  214. (mask: $20 ;str:'in_library'),
  215. (mask: $40 ;str:'smart_linked'),
  216. (mask: $80 ;str:'static_linked'),
  217. (mask: $100 ;str:'shared_linked'),
  218. (mask: $200 ;str:'local_browser'),
  219. (mask: $400 ;str:'no_link'),
  220. (mask: $800 ;str:'has_resources'),
  221. (mask: $1000 ;str:'little_endian'),
  222. (mask: $2000 ;str:'release'),
  223. (mask: $4000 ;str:'local_threadvars'),
  224. (mask: $8000 ;str:'fpu_emulation_on'),
  225. (mask: $10000 ;str:'has_debug_info'),
  226. (mask: $20000 ;str:'local_symtable'),
  227. (mask: $40000 ;str:'uses_variants')
  228. );
  229. var
  230. i : longint;
  231. first : boolean;
  232. s : string;
  233. begin
  234. s:='';
  235. if flags<>0 then
  236. begin
  237. first:=true;
  238. for i:=1to flagopts do
  239. if (flags and flagopt[i].mask)<>0 then
  240. begin
  241. if first then
  242. first:=false
  243. else
  244. s:=s+', ';
  245. s:=s+flagopt[i].str;
  246. end;
  247. end
  248. else
  249. s:='none';
  250. PPUFlags2Str:=s;
  251. end;
  252. const
  253. HexTbl : array[0..15] of char='0123456789ABCDEF';
  254. function HexB(b:byte):string;
  255. begin
  256. HexB[0]:=#2;
  257. HexB[1]:=HexTbl[b shr 4];
  258. HexB[2]:=HexTbl[b and $f];
  259. end;
  260. function hexstr(val : cardinal;cnt : byte) : string;
  261. const
  262. HexTbl : array[0..15] of char='0123456789ABCDEF';
  263. var
  264. i : longint;
  265. begin
  266. hexstr[0]:=char(cnt);
  267. for i:=cnt downto 1 do
  268. begin
  269. hexstr[i]:=hextbl[val and $f];
  270. val:=val shr 4;
  271. end;
  272. end;
  273. Function L0(l:longint):string;
  274. {
  275. return the string of value l, if l<10 then insert a zero, so
  276. the string is always at least 2 chars '01','02',etc
  277. }
  278. var
  279. s : string;
  280. begin
  281. Str(l,s);
  282. if l<10 then
  283. s:='0'+s;
  284. L0:=s;
  285. end;
  286. function filetimestring( t : longint) : string;
  287. {
  288. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  289. }
  290. var
  291. DT : DateTime;
  292. begin
  293. if t=-1 then
  294. begin
  295. FileTimeString:='Not Found';
  296. exit;
  297. end;
  298. unpacktime(t,DT);
  299. filetimestring:=L0(dt.Year)+'/'+L0(dt.Month)+'/'+L0(dt.Day)+' '+L0(dt.Hour)+':'+L0(dt.min)+':'+L0(dt.sec);
  300. end;
  301. {****************************************************************************
  302. Read Routines
  303. ****************************************************************************}
  304. Procedure ReadLinkContainer(const prefix:string);
  305. {
  306. Read a serie of strings and write to the screen starting every line
  307. with prefix
  308. }
  309. function maskstr(m:longint):string;
  310. const
  311. { link options }
  312. link_none = $0;
  313. link_allways = $1;
  314. link_static = $2;
  315. link_smart = $4;
  316. link_shared = $8;
  317. var
  318. s : string;
  319. begin
  320. s:='';
  321. if (m and link_allways)<>0 then
  322. s:=s+'always ';
  323. if (m and link_static)<>0 then
  324. s:=s+'static ';
  325. if (m and link_smart)<>0 then
  326. s:=s+'smart ';
  327. if (m and link_shared)<>0 then
  328. s:=s+'shared ';
  329. maskstr:=s;
  330. end;
  331. var
  332. s : string;
  333. m : longint;
  334. begin
  335. while not ppufile.endofentry do
  336. begin
  337. s:=ppufile.getstring;
  338. m:=ppufile.getlongint;
  339. WriteLn(prefix,s,' (',maskstr(m),')');
  340. end;
  341. end;
  342. Procedure ReadContainer(const prefix:string);
  343. {
  344. Read a serie of strings and write to the screen starting every line
  345. with prefix
  346. }
  347. begin
  348. while not ppufile.endofentry do
  349. WriteLn(prefix,ppufile.getstring);
  350. end;
  351. procedure ReadLoadUnit;
  352. var
  353. ucrc,uintfcrc : cardinal;
  354. begin
  355. while not ppufile.EndOfEntry do
  356. begin
  357. write('Uses unit: ',ppufile.getstring);
  358. ucrc:=cardinal(ppufile.getlongint);
  359. uintfcrc:=cardinal(ppufile.getlongint);
  360. writeln(' (Crc: ',hexstr(ucrc,8),', IntfcCrc: ',hexstr(uintfcrc,8),')');
  361. end;
  362. end;
  363. Procedure ReadDerefmap;
  364. var
  365. i,mapsize : longint;
  366. begin
  367. mapsize:=ppufile.getword;
  368. writeln('DerefMapsize: ',mapsize);
  369. for i:=0 to mapsize-1 do
  370. writeln('DerefMap[',i,'] = ',ppufile.getstring);
  371. end;
  372. Procedure ReadDerefdata;
  373. begin
  374. derefdatalen:=ppufile.entrysize;
  375. if derefdatalen=0 then
  376. begin
  377. writeln('!! Error: derefdatalen=0');
  378. exit;
  379. end;
  380. Writeln('Derefdata length: ',derefdatalen);
  381. derefdata:=allocmem(derefdatalen);
  382. ppufile.getdata(derefdata^,derefdatalen);
  383. end;
  384. Procedure ReadRef;
  385. begin
  386. if (verbose and v_browser)=0 then
  387. exit;
  388. while (not ppufile.endofentry) and (not ppufile.error) do
  389. Writeln(space,' - Refered : ',ppufile.getword,', (',ppufile.getlongint,',',ppufile.getword,')');
  390. end;
  391. Procedure ReadAsmSymbols;
  392. type
  393. { Copied from aasmbase.pas }
  394. TAsmsymbind=(AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL);
  395. TAsmsymtype=(AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION);
  396. var
  397. s,
  398. bindstr,
  399. typestr : string;
  400. i : longint;
  401. begin
  402. writeln(space,'Number of AsmSymbols: ',ppufile.getlongint);
  403. i:=0;
  404. while (not ppufile.endofentry) and (not ppufile.error) do
  405. begin
  406. s:=ppufile.getstring;
  407. case tasmsymbind(ppufile.getbyte) of
  408. AB_EXTERNAL :
  409. bindstr:='External';
  410. AB_COMMON :
  411. bindstr:='Common';
  412. AB_LOCAL :
  413. bindstr:='Local';
  414. AB_GLOBAL :
  415. bindstr:='Global';
  416. else
  417. bindstr:='<Error !!>'
  418. end;
  419. case tasmsymtype(ppufile.getbyte) of
  420. AT_FUNCTION :
  421. typestr:='Function';
  422. AT_DATA :
  423. typestr:='Data';
  424. AT_SECTION :
  425. typestr:='Section';
  426. else
  427. typestr:='<Error !!>'
  428. end;
  429. Writeln(space,' ',i,' : ',s,' [',bindstr,',',typestr,']');
  430. inc(i);
  431. end;
  432. end;
  433. Procedure ReadPosInfo;
  434. var
  435. info : byte;
  436. fileindex,line,column : longint;
  437. begin
  438. with ppufile do
  439. begin
  440. {
  441. info byte layout in bits:
  442. 0-1 - amount of bytes for fileindex
  443. 2-3 - amount of bytes for line
  444. 4-5 - amount of bytes for column
  445. }
  446. info:=getbyte;
  447. case (info and $03) of
  448. 0 : fileindex:=getbyte;
  449. 1 : fileindex:=getword;
  450. 2 : fileindex:=(getbyte shl 16) or getword;
  451. 3 : fileindex:=getlongint;
  452. end;
  453. case ((info shr 2) and $03) of
  454. 0 : line:=getbyte;
  455. 1 : line:=getword;
  456. 2 : line:=(getbyte shl 16) or getword;
  457. 3 : line:=getlongint;
  458. end;
  459. case ((info shr 4) and $03) of
  460. 0 : column:=getbyte;
  461. 1 : column:=getword;
  462. 2 : column:=(getbyte shl 16) or getword;
  463. 3 : column:=getlongint;
  464. end;
  465. Writeln(fileindex,' (',line,',',column,')');
  466. end;
  467. end;
  468. procedure readderef;
  469. type
  470. tdereftype = (deref_nil,
  471. deref_sym,
  472. deref_def,
  473. deref_aktrecord,
  474. deref_aktstatic,
  475. deref_aktglobal,
  476. deref_aktlocal,
  477. deref_aktpara,
  478. deref_unit,
  479. deref_record,
  480. deref_local,
  481. deref_para,
  482. deref_parent_object
  483. );
  484. var
  485. b : tdereftype;
  486. first : boolean;
  487. idx : longint;
  488. i,n : byte;
  489. pdata : pbyte;
  490. begin
  491. if not assigned(derefdata) then
  492. exit;
  493. first:=true;
  494. idx:=ppufile.getlongint;
  495. if (idx>derefdatalen) then
  496. begin
  497. writeln('!! Error: Deref idx ',idx,' > ',derefdatalen);
  498. exit;
  499. end;
  500. write('(',idx,') ');
  501. pdata:=@derefdata[idx];
  502. i:=0;
  503. n:=pdata[i];
  504. inc(i);
  505. if n<1 then
  506. begin
  507. writeln('!! Error: Deref len < 1');
  508. exit;
  509. end;
  510. while (i<n) do
  511. begin
  512. if not first then
  513. write(', ')
  514. else
  515. first:=false;
  516. b:=tdereftype(pdata[i]);
  517. inc(i);
  518. case b of
  519. deref_nil :
  520. write('Nil');
  521. deref_def :
  522. begin
  523. idx:=pdata[i] shl 8;
  524. idx:=idx or pdata[i+1];
  525. inc(i,2);
  526. write('Definition ',idx);
  527. end;
  528. deref_sym :
  529. begin
  530. idx:=pdata[i] shl 8;
  531. idx:=idx or pdata[i+1];
  532. inc(i,2);
  533. write('Symbol ',idx);
  534. end;
  535. deref_aktrecord :
  536. write('AktRecord');
  537. deref_aktstatic :
  538. write('AktStatic');
  539. deref_aktglobal :
  540. write('AktGlobal');
  541. deref_aktlocal :
  542. write('AktLocal');
  543. deref_aktpara :
  544. write('AktPara');
  545. deref_unit :
  546. begin
  547. idx:=pdata[i] shl 8;
  548. idx:=idx or pdata[i+1];
  549. inc(i,2);
  550. write('Unit ',idx);
  551. end;
  552. deref_record :
  553. write('RecordDef');
  554. deref_para :
  555. write('Parameter of procdef');
  556. deref_local :
  557. write('Local of procdef');
  558. deref_parent_object :
  559. write('Parent object');
  560. else
  561. begin
  562. writeln('!! unsupported dereftyp: ',ord(b));
  563. break;
  564. end;
  565. end;
  566. end;
  567. writeln;
  568. end;
  569. procedure readtype;
  570. begin
  571. readderef;
  572. end;
  573. procedure readsymlist(const s:string);
  574. type
  575. tsltype = (sl_none,
  576. sl_load,
  577. sl_call,
  578. sl_subscript,
  579. sl_vec
  580. );
  581. const
  582. slstr : array[tsltype] of string[9] = ('',
  583. 'load',
  584. 'call',
  585. 'subscript',
  586. 'vec'
  587. );
  588. var
  589. sl : tsltype;
  590. begin
  591. readderef;
  592. repeat
  593. sl:=tsltype(ppufile.getbyte);
  594. if sl=sl_none then
  595. break;
  596. write(s,'(',slstr[sl],') ');
  597. case sl of
  598. sl_call,
  599. sl_load,
  600. sl_subscript :
  601. readderef;
  602. sl_vec :
  603. writeln(ppufile.getlongint);
  604. end;
  605. until false;
  606. end;
  607. procedure readsymoptions;
  608. type
  609. tsymoption=(sp_none,
  610. sp_public,
  611. sp_private,
  612. sp_published,
  613. sp_protected,
  614. sp_static,
  615. sp_hint_deprecated,
  616. sp_hint_platform,
  617. sp_hint_library,
  618. sp_hint_unimplemented,
  619. sp_has_overloaded,
  620. sp_internal { internal symbol, not reported as unused }
  621. );
  622. tsymoptions=set of tsymoption;
  623. tsymopt=record
  624. mask : tsymoption;
  625. str : string[30];
  626. end;
  627. const
  628. symopts=11;
  629. symopt : array[1..symopts] of tsymopt=(
  630. (mask:sp_public; str:'Public'),
  631. (mask:sp_private; str:'Private'),
  632. (mask:sp_published; str:'Published'),
  633. (mask:sp_protected; str:'Protected'),
  634. (mask:sp_static; str:'Static'),
  635. (mask:sp_hint_deprecated;str:'Hint Deprecated'),
  636. (mask:sp_hint_deprecated;str:'Hint Platform'),
  637. (mask:sp_hint_deprecated;str:'Hint Library'),
  638. (mask:sp_hint_deprecated;str:'Hint Unimplemented'),
  639. (mask:sp_has_overloaded; str:'Has overloaded'),
  640. (mask:sp_internal; str:'Internal')
  641. );
  642. var
  643. symoptions : tsymoptions;
  644. i : longint;
  645. first : boolean;
  646. begin
  647. ppufile.getsmallset(symoptions);
  648. if symoptions<>[] then
  649. begin
  650. first:=true;
  651. for i:=1to symopts do
  652. if (symopt[i].mask in symoptions) then
  653. begin
  654. if first then
  655. first:=false
  656. else
  657. write(', ');
  658. write(symopt[i].str);
  659. end;
  660. end;
  661. writeln;
  662. end;
  663. procedure readcommonsym(const s:string);
  664. begin
  665. writeln(space,'** Symbol Nr. ',ppufile.getword,' **');
  666. writeln(space,s,ppufile.getstring);
  667. write(space,' File Pos : ');
  668. readposinfo;
  669. write(space,' SymOptions : ');
  670. readsymoptions;
  671. end;
  672. procedure readcommondef(const s:string);
  673. type
  674. tdefoption=(df_none,
  675. df_has_inittable, { init data has been generated }
  676. df_has_rttitable, { rtti data has been generated }
  677. df_unique
  678. );
  679. tdefoptions=set of tdefoption;
  680. var
  681. defopts : tdefoptions;
  682. begin
  683. writeln(space,'** Definition Nr. ',ppufile.getword,' **');
  684. writeln(space,s);
  685. write (space,' Type symbol : ');
  686. readderef;
  687. ppufile.getsmallset(defopts);
  688. if df_unique in defopts then
  689. writeln (space,' Unique type symbol');
  690. if df_has_rttitable in defopts then
  691. begin
  692. write (space,' RTTI symbol : ');
  693. readderef;
  694. end;
  695. if df_has_inittable in defopts then
  696. begin
  697. write (space,' Init symbol : ');
  698. readderef;
  699. end;
  700. end;
  701. { Read abstract procdef and return if inline procdef }
  702. type
  703. tproccalloption=(pocall_none,
  704. { procedure uses C styled calling }
  705. pocall_cdecl,
  706. { C++ calling conventions }
  707. pocall_cppdecl,
  708. { Procedure is used for internal compiler calls }
  709. pocall_compilerproc,
  710. { Far16 for OS/2 }
  711. pocall_far16,
  712. { Old style FPC default calling }
  713. pocall_oldfpccall,
  714. { Procedure is an assembler macro }
  715. pocall_inline,
  716. { Procedure has compiler magic}
  717. pocall_internproc,
  718. { procedure is a system call, applies e.g. to MorphOS and PalmOS }
  719. pocall_syscall,
  720. { pascal standard left to right }
  721. pocall_pascal,
  722. { procedure uses register (fastcall) calling }
  723. pocall_register,
  724. { safe call calling conventions }
  725. pocall_safecall,
  726. { procedure uses stdcall call }
  727. pocall_stdcall,
  728. { Special calling convention for cpus without a floating point
  729. unit. Floating point numbers are passed in integer registers
  730. instead of floating point registers. Depending on the other
  731. available calling conventions available for the cpu
  732. this replaces either pocall_fastcall or pocall_stdcall.
  733. }
  734. pocall_softfloat,
  735. { Metrowerks Pascal. Special case on Mac OS (X): passes all }
  736. { constant records by reference. }
  737. pocall_mwpascal
  738. );
  739. tproccalloptions=set of tproccalloption;
  740. tproctypeoption=(potype_none,
  741. potype_proginit, { Program initialization }
  742. potype_unitinit, { unit initialization }
  743. potype_unitfinalize, { unit finalization }
  744. potype_constructor, { Procedure is a constructor }
  745. potype_destructor, { Procedure is a destructor }
  746. potype_operator { Procedure defines an operator }
  747. );
  748. tproctypeoptions=set of tproctypeoption;
  749. tprocoption=(po_none,
  750. po_classmethod, { class method }
  751. po_virtualmethod, { Procedure is a virtual method }
  752. po_abstractmethod, { Procedure is an abstract method }
  753. po_staticmethod, { static method }
  754. po_overridingmethod, { method with override directive }
  755. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  756. po_interrupt, { Procedure is an interrupt handler }
  757. po_iocheck, { IO checking should be done after a call to the procedure }
  758. po_assembler, { Procedure is written in assembler }
  759. po_msgstr, { method for string message handling }
  760. po_msgint, { method for int message handling }
  761. po_exports, { Procedure has export directive (needed for OS/2) }
  762. po_external, { Procedure is external (in other object or lib)}
  763. po_overload, { procedure is declared with overload directive }
  764. po_varargs, { printf like arguments }
  765. po_internconst, { procedure has constant evaluator intern }
  766. { flag that only the address of a method is returned and not a full methodpointer }
  767. po_addressonly,
  768. { procedure is exported }
  769. po_public,
  770. { calling convention is specified explicitly }
  771. po_hascallingconvention,
  772. { reintroduce flag }
  773. po_reintroduce,
  774. { location of parameters is given explicitly as it is necessary for some syscall
  775. conventions like that one of MorphOS }
  776. po_explicitparaloc,
  777. { no stackframe will be generated, used by lowlevel assembler like get_frame }
  778. po_nostackframe,
  779. po_has_mangledname,
  780. po_has_public_name,
  781. po_forward,
  782. po_global
  783. );
  784. tprocoptions=set of tprocoption;
  785. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions);
  786. type
  787. tproccallopt=record
  788. mask : tproccalloption;
  789. str : string[30];
  790. end;
  791. tproctypeopt=record
  792. mask : tproctypeoption;
  793. str : string[30];
  794. end;
  795. tprocopt=record
  796. mask : tprocoption;
  797. str : string[30];
  798. end;
  799. const
  800. proccalloptionStr : array[tproccalloption] of string[14]=('',
  801. 'CDecl',
  802. 'CPPDecl',
  803. 'CompilerProc',
  804. 'Far16',
  805. 'OldFPCCall',
  806. 'Inline',
  807. 'InternProc',
  808. 'SysCall',
  809. 'Pascal',
  810. 'Register',
  811. 'SafeCall',
  812. 'StdCall',
  813. 'SoftFloat',
  814. 'MWPascal'
  815. );
  816. proctypeopts=6;
  817. proctypeopt : array[1..proctypeopts] of tproctypeopt=(
  818. (mask:potype_proginit; str:'ProgInit'),
  819. (mask:potype_unitinit; str:'UnitInit'),
  820. (mask:potype_unitfinalize;str:'UnitFinalize'),
  821. (mask:potype_constructor; str:'Constructor'),
  822. (mask:potype_destructor; str:'Destructor'),
  823. (mask:potype_operator; str:'Operator')
  824. );
  825. procopts=26;
  826. procopt : array[1..procopts] of tprocopt=(
  827. (mask:po_classmethod; str:'ClassMethod'),
  828. (mask:po_virtualmethod; str:'VirtualMethod'),
  829. (mask:po_abstractmethod; str:'AbstractMethod'),
  830. (mask:po_staticmethod; str:'StaticMethod'),
  831. (mask:po_overridingmethod;str:'OverridingMethod'),
  832. (mask:po_methodpointer; str:'MethodPointer'),
  833. (mask:po_interrupt; str:'Interrupt'),
  834. (mask:po_iocheck; str:'IOCheck'),
  835. (mask:po_assembler; str:'Assembler'),
  836. (mask:po_msgstr; str:'MsgStr'),
  837. (mask:po_msgint; str:'MsgInt'),
  838. (mask:po_exports; str:'Exports'),
  839. (mask:po_external; str:'External'),
  840. (mask:po_overload; str:'Overload'),
  841. (mask:po_varargs; str:'VarArgs'),
  842. (mask:po_internconst; str:'InternConst'),
  843. (mask:po_addressonly; str:'AddressOnly'),
  844. (mask:po_public; str:'Public'),
  845. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  846. (mask:po_reintroduce; str:'ReIntroduce'),
  847. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  848. (mask:po_nostackframe; str:'NoStackFrame'),
  849. (mask:po_has_mangledname; str:'HasMangledName'),
  850. (mask:po_has_public_name; str:'HasPublicName'),
  851. (mask:po_forward; str:'Forward'),
  852. (mask:po_global; str:'Global')
  853. );
  854. var
  855. proctypeoption : tproctypeoption;
  856. i : longint;
  857. first : boolean;
  858. tempbuf : array[0..255] of byte;
  859. begin
  860. write(space,' Return type : ');
  861. readtype;
  862. writeln(space,' Fpu used : ',ppufile.getbyte);
  863. proctypeoption:=tproctypeoption(ppufile.getbyte);
  864. if proctypeoption<>potype_none then
  865. begin
  866. write(space,' TypeOption : ');
  867. first:=true;
  868. for i:=1 to proctypeopts do
  869. if (proctypeopt[i].mask=proctypeoption) then
  870. begin
  871. if first then
  872. first:=false
  873. else
  874. write(', ');
  875. write(proctypeopt[i].str);
  876. end;
  877. writeln;
  878. end;
  879. proccalloption:=tproccalloption(ppufile.getbyte);
  880. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  881. ppufile.getsmallset(procoptions);
  882. if procoptions<>[] then
  883. begin
  884. write(space,' Options : ');
  885. first:=true;
  886. for i:=1to procopts do
  887. if (procopt[i].mask in procoptions) then
  888. begin
  889. if first then
  890. first:=false
  891. else
  892. write(', ');
  893. write(procopt[i].str);
  894. end;
  895. writeln;
  896. end;
  897. if (po_explicitparaloc in procoptions) then
  898. begin
  899. i:=ppufile.getbyte;
  900. ppufile.getdata(tempbuf,i);
  901. end;
  902. end;
  903. type
  904. { options for variables }
  905. tvaroption=(vo_none,
  906. vo_is_C_var,
  907. vo_is_external,
  908. vo_is_dll_var,
  909. vo_is_thread_var,
  910. vo_has_local_copy,
  911. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  912. vo_is_exported,
  913. vo_is_high_para,
  914. vo_is_funcret,
  915. vo_is_self,
  916. vo_is_vmt,
  917. vo_is_result, { special result variable }
  918. vo_is_parentfp,
  919. vo_is_loop_counter, { used to detect assignments to loop counter }
  920. vo_is_hidden_para,
  921. vo_has_explicit_paraloc,
  922. vo_is_syscall_lib,
  923. vo_has_mangledname
  924. );
  925. tvaroptions=set of tvaroption;
  926. { register variable }
  927. tvarregable=(vr_none,
  928. vr_intreg,
  929. vr_fpureg,
  930. vr_mmreg
  931. );
  932. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions);
  933. type
  934. tvaropt=record
  935. mask : tvaroption;
  936. str : string[30];
  937. end;
  938. const
  939. varopts=18;
  940. varopt : array[1..varopts] of tvaropt=(
  941. (mask:vo_is_C_var; str:'CVar'),
  942. (mask:vo_is_external; str:'External'),
  943. (mask:vo_is_dll_var; str:'DLLVar'),
  944. (mask:vo_is_thread_var; str:'ThreadVar'),
  945. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  946. (mask:vo_is_const; str:'Constant'),
  947. (mask:vo_is_exported; str:'Exported'),
  948. (mask:vo_is_high_para; str:'HighValue'),
  949. (mask:vo_is_funcret; str:'Funcret'),
  950. (mask:vo_is_self; str:'Self'),
  951. (mask:vo_is_vmt; str:'VMT'),
  952. (mask:vo_is_result; str:'Result'),
  953. (mask:vo_is_parentfp; str:'ParentFP'),
  954. (mask:vo_is_loop_counter; str:'LoopCounter'),
  955. (mask:vo_is_hidden_para; str:'Hidden'),
  956. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  957. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  958. (mask:vo_has_mangledname; str:'HasMangledName')
  959. );
  960. var
  961. i : longint;
  962. first : boolean;
  963. begin
  964. readcommonsym(s);
  965. writeln(space,' Spez : ',Varspez2Str(ppufile.getbyte));
  966. writeln(space,' Regable : ',Varregable2Str(ppufile.getbyte));
  967. write (space,' Var Type : ');
  968. readtype;
  969. ppufile.getsmallset(varoptions);
  970. if varoptions<>[] then
  971. begin
  972. write(space,' Options : ');
  973. first:=true;
  974. for i:=1to varopts do
  975. if (varopt[i].mask in varoptions) then
  976. begin
  977. if first then
  978. first:=false
  979. else
  980. write(', ');
  981. write(varopt[i].str);
  982. end;
  983. writeln;
  984. end;
  985. end;
  986. procedure readnodetree;
  987. var
  988. l : longint;
  989. p : pointer;
  990. begin
  991. with ppufile do
  992. begin
  993. if space<>'' then
  994. Writeln(space,'------ nodetree ------');
  995. if readentry=ibnodetree then
  996. begin
  997. l:=entrysize;
  998. Writeln(space,'Tree size : ',l);
  999. { Read data to prevent error that entry is not completly read }
  1000. getmem(p,l);
  1001. getdata(p^,l);
  1002. freemem(p);
  1003. end
  1004. else
  1005. begin
  1006. Writeln('!! ibnodetree not found');
  1007. end;
  1008. end;
  1009. end;
  1010. {****************************************************************************
  1011. Read Symbols Part
  1012. ****************************************************************************}
  1013. procedure readsymbols(const s:string);
  1014. type
  1015. pguid = ^tguid;
  1016. tguid = packed record
  1017. D1: LongWord;
  1018. D2: Word;
  1019. D3: Word;
  1020. D4: array[0..7] of Byte;
  1021. end;
  1022. absolutetyp = (tovar,toasm,toaddr);
  1023. tconsttyp = (constnone,
  1024. constord,conststring,constreal,
  1025. constset,constpointer,constnil,
  1026. constresourcestring,constwstring,constguid
  1027. );
  1028. var
  1029. b : byte;
  1030. pc : pchar;
  1031. totalsyms,
  1032. symcnt,
  1033. i,j,len : longint;
  1034. guid : tguid;
  1035. tempbuf : array[0..127] of char;
  1036. varoptions : tvaroptions;
  1037. begin
  1038. symcnt:=1;
  1039. with ppufile do
  1040. begin
  1041. if space<>'' then
  1042. Writeln(space,'------ ',s,' ------');
  1043. if readentry=ibstartsyms then
  1044. begin
  1045. totalsyms:=getlongint;
  1046. Writeln(space,'Number of symbols : ',totalsyms);
  1047. Writeln(space,'Symtable datasize : ',getlongint);
  1048. Writeln(space,'Symtable alignment: ',getlongint);
  1049. end
  1050. else
  1051. begin
  1052. totalsyms:=-1;
  1053. Writeln('!! ibstartsym not found');
  1054. end;
  1055. repeat
  1056. b:=readentry;
  1057. if not (b in [iberror,ibendsyms]) then
  1058. inc(symcnt);
  1059. case b of
  1060. ibunitsym :
  1061. readcommonsym('Unit symbol ');
  1062. iblabelsym :
  1063. readcommonsym('Label symbol ');
  1064. ibtypesym :
  1065. begin
  1066. readcommonsym('Type symbol ');
  1067. write(space,' Result Type : ');
  1068. readtype;
  1069. end;
  1070. ibprocsym :
  1071. begin
  1072. readcommonsym('Procedure symbol ');
  1073. len:=ppufile.getword;
  1074. for i:=1 to len do
  1075. begin
  1076. write(space,' Definition : ');
  1077. readderef;
  1078. end;
  1079. end;
  1080. ibconstsym :
  1081. begin
  1082. readcommonsym('Constant symbol ');
  1083. b:=getbyte;
  1084. case tconsttyp(b) of
  1085. constord :
  1086. begin
  1087. write (space,' OrdinalType : ');
  1088. readtype;
  1089. writeln(space,' Value : ',getint64);
  1090. end;
  1091. constpointer :
  1092. begin
  1093. write (space,' PointerType : ');
  1094. readtype;
  1095. writeln(space,' Value : ',getlongint)
  1096. end;
  1097. conststring,
  1098. constresourcestring :
  1099. begin
  1100. len:=getlongint;
  1101. getmem(pc,len+1);
  1102. getdata(pc^,len);
  1103. (pc+len)^:= #0;
  1104. writeln(space,' Length : ',len);
  1105. writeln(space,' Value : "',pc,'"');
  1106. freemem(pc,len+1);
  1107. if tconsttyp(b)=constresourcestring then
  1108. writeln(space,' Index : ',getlongint);
  1109. end;
  1110. constreal :
  1111. writeln(space,' Value : ',getreal);
  1112. constset :
  1113. begin
  1114. write (space,' Set Type : ');
  1115. readtype;
  1116. for i:=1to 4 do
  1117. begin
  1118. write (space,' Value : ');
  1119. for j:=1to 8 do
  1120. begin
  1121. if j>1 then
  1122. write(',');
  1123. write(hexb(getbyte));
  1124. end;
  1125. writeln;
  1126. end;
  1127. end;
  1128. constwstring:
  1129. begin
  1130. end;
  1131. constguid:
  1132. begin
  1133. getdata(guid,sizeof(guid));
  1134. write (space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-');
  1135. for i:=0 to 7 do
  1136. begin
  1137. write(hexstr(guid.d4[i],2));
  1138. if i=1 then write('-');
  1139. end;
  1140. writeln('}');
  1141. end
  1142. else
  1143. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  1144. end;
  1145. end;
  1146. ibabsolutevarsym :
  1147. begin
  1148. readabstractvarsym('Absolute variable symbol ',varoptions);
  1149. Write (space,' Relocated to ');
  1150. b:=getbyte;
  1151. case absolutetyp(b) of
  1152. tovar :
  1153. readsymlist(space+' Sym : ');
  1154. toasm :
  1155. Writeln('Assembler name : ',getstring);
  1156. toaddr :
  1157. begin
  1158. Write('Address : ',getlongint);
  1159. if tsystemcpu(ppufile.header.cpu)=cpu_i386 then
  1160. WriteLn(' (Far: ',getbyte<>0,')');
  1161. end;
  1162. else
  1163. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  1164. end;
  1165. end;
  1166. ibfieldvarsym :
  1167. begin
  1168. readabstractvarsym('Field Variable symbol ',varoptions);
  1169. writeln(space,' Address : ',getlongint);
  1170. end;
  1171. ibglobalvarsym :
  1172. begin
  1173. readabstractvarsym('Global Variable symbol ',varoptions);
  1174. write (space,' DefaultConst : ');
  1175. readderef;
  1176. if (vo_has_mangledname in varoptions) then
  1177. writeln(space,' Mangledname : ',getstring);
  1178. end;
  1179. iblocalvarsym :
  1180. begin
  1181. readabstractvarsym('Local Variable symbol ',varoptions);
  1182. write (space,' DefaultConst : ');
  1183. readderef;
  1184. end;
  1185. ibparavarsym :
  1186. begin
  1187. readabstractvarsym('Parameter Variable symbol ',varoptions);
  1188. write (space,' DefaultConst : ');
  1189. readderef;
  1190. writeln(space,' ParaNr : ',getword);
  1191. if (vo_has_explicit_paraloc in varoptions) then
  1192. begin
  1193. i:=getbyte;
  1194. getdata(tempbuf,i);
  1195. end;
  1196. end;
  1197. ibenumsym :
  1198. begin
  1199. readcommonsym('Enumeration symbol ');
  1200. write (space,' Definition : ');
  1201. readderef;
  1202. writeln(space,' Value : ',getlongint);
  1203. end;
  1204. ibsyssym :
  1205. begin
  1206. readcommonsym('Internal system symbol ');
  1207. writeln(space,' Internal Nr : ',getlongint);
  1208. end;
  1209. ibrttisym :
  1210. begin
  1211. readcommonsym('RTTI symbol ');
  1212. writeln(space,' RTTI Type : ',getbyte);
  1213. end;
  1214. ibmacrosym :
  1215. begin
  1216. readcommonsym('Macro symbol ');
  1217. writeln(space,' Name: ',getstring);
  1218. writeln(space,' Defined: ',getbyte);
  1219. writeln(space,' Compiler var: ',getbyte);
  1220. len:=getlongint;
  1221. writeln(space,' Value length: ',len);
  1222. if len > 0 then
  1223. begin
  1224. getmem(pc,len+1);
  1225. getdata(pc^,len);
  1226. (pc+len)^:= #0;
  1227. writeln(space,' Value: "',pc,'"');
  1228. freemem(pc,len+1);
  1229. end;
  1230. end;
  1231. ibtypedconstsym :
  1232. begin
  1233. readcommonsym('Typed constant ');
  1234. write (space,' Constant Type : ');
  1235. readtype;
  1236. writeln(space,' ReallyConst : ',(getbyte<>0));
  1237. end;
  1238. ibpropertysym :
  1239. begin
  1240. readcommonsym('Property ');
  1241. i:=getlongint;
  1242. writeln(space,' PropOptions : ',i);
  1243. if (i and 32)>0 then
  1244. begin
  1245. write (space,' OverrideProp : ');
  1246. readderef;
  1247. end
  1248. else
  1249. begin
  1250. write (space,' Prop Type : ');
  1251. readtype;
  1252. writeln(space,' Index : ',getlongint);
  1253. writeln(space,' Default : ',getlongint);
  1254. write (space,' Index Type : ');
  1255. readtype;
  1256. write (space,' Readaccess : ');
  1257. readsymlist(space+' Sym: ');
  1258. write (space,' Writeaccess : ');
  1259. readsymlist(space+' Sym: ');
  1260. write (space,' Storedaccess : ');
  1261. readsymlist(space+' Sym: ');
  1262. end;
  1263. end;
  1264. iberror :
  1265. begin
  1266. Writeln('!! Error in PPU');
  1267. exit;
  1268. end;
  1269. ibendsyms :
  1270. break;
  1271. else
  1272. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  1273. end;
  1274. if not EndOfEntry then
  1275. Writeln('!! Entry has more information stored');
  1276. until false;
  1277. if (totalsyms<>-1) and (symcnt-1<>totalsyms) then
  1278. Writeln('!! Only read ',symcnt-1,' of ',totalsyms,' symbols');
  1279. end;
  1280. end;
  1281. {****************************************************************************
  1282. Read defintions Part
  1283. ****************************************************************************}
  1284. procedure readdefinitions(const s:string;start_read : boolean);
  1285. type
  1286. tsettype = (normset,smallset,varset);
  1287. tbasetype = (
  1288. uvoid,
  1289. u8bit,u16bit,u32bit,u64bit,
  1290. s8bit,s16bit,s32bit,s64bit,
  1291. bool8bit,bool16bit,bool32bit,
  1292. uchar,uwidechar
  1293. );
  1294. tobjectdeftype = (odt_none,
  1295. odt_class,
  1296. odt_object,
  1297. odt_interfacecom,
  1298. odt_interfacecorba,
  1299. odt_cppclass
  1300. );
  1301. tvarianttype = (
  1302. vt_normalvariant,vt_olevariant
  1303. );
  1304. var
  1305. b : byte;
  1306. totaldefs,l,j,
  1307. defcnt : longint;
  1308. calloption : tproccalloption;
  1309. procoptions : tprocoptions;
  1310. procinfooptions : tprocinfoflag;
  1311. begin
  1312. defcnt:=0;
  1313. with ppufile do
  1314. begin
  1315. if space<>'' then
  1316. Writeln(space,'------ ',s,' ------');
  1317. if not start_read then
  1318. if readentry=ibstartdefs then
  1319. begin
  1320. totaldefs:=getlongint;
  1321. Writeln(space,'Number of definitions: ',totaldefs);
  1322. end
  1323. else
  1324. begin
  1325. totaldefs:=-1;
  1326. Writeln('!! ibstartdef not found');
  1327. end;
  1328. repeat
  1329. b:=readentry;
  1330. if not (b in [iberror,ibenddefs]) then
  1331. inc(defcnt);
  1332. case b of
  1333. ibpointerdef :
  1334. begin
  1335. readcommondef('Pointer definition');
  1336. write (space,' Pointed Type : ');
  1337. readtype;
  1338. writeln(space,' Is Far : ',(getbyte<>0));
  1339. end;
  1340. iborddef :
  1341. begin
  1342. readcommondef('Ordinal definition');
  1343. write (space,' Base type : ');
  1344. b:=getbyte;
  1345. case tbasetype(b) of
  1346. uvoid : writeln('uvoid');
  1347. u8bit : writeln('u8bit');
  1348. u16bit : writeln('u16bit');
  1349. u32bit : writeln('s32bit');
  1350. u64bit : writeln('u64bit');
  1351. s8bit : writeln('s8bit');
  1352. s16bit : writeln('s16bit');
  1353. s32bit : writeln('s32bit');
  1354. s64bit : writeln('s64bit');
  1355. bool8bit : writeln('bool8bit');
  1356. bool16bit : writeln('bool16bit');
  1357. bool32bit : writeln('bool32bit');
  1358. uchar : writeln('uchar');
  1359. uwidechar : writeln('uwidechar');
  1360. else writeln('!! Warning: Invalid base type ',b);
  1361. end;
  1362. writeln(space,' Range : ',getint64,' to ',getint64);
  1363. end;
  1364. ibfloatdef :
  1365. begin
  1366. readcommondef('Float definition');
  1367. writeln(space,' Float type : ',getbyte);
  1368. end;
  1369. ibarraydef :
  1370. begin
  1371. readcommondef('Array definition');
  1372. write (space,' Element type : ');
  1373. readtype;
  1374. write (space,' Range Type : ');
  1375. readtype;
  1376. writeln(space,' Range : ',getlongint,' to ',getlongint);
  1377. writeln(space,' Is Constructor : ',(getbyte<>0));
  1378. writeln(space,' Is Dynamic : ',(getbyte<>0));
  1379. end;
  1380. ibprocdef :
  1381. begin
  1382. readcommondef('Procedure definition');
  1383. read_abstract_proc_def(calloption,procoptions);
  1384. if (po_has_mangledname in procoptions) then
  1385. writeln(space,' Mangled name : ',getstring);
  1386. writeln(space,' Number : ',getword);
  1387. writeln(space,' Level : ',getbyte);
  1388. write (space,' Class : ');
  1389. readderef;
  1390. write (space,' Procsym : ');
  1391. readderef;
  1392. write (space,' File Pos : ');
  1393. readposinfo;
  1394. write (space,' SymOptions : ');
  1395. readsymoptions;
  1396. if tsystemcpu(ppufile.header.cpu)=cpu_powerpc then
  1397. begin
  1398. { library symbol for AmigaOS/MorphOS }
  1399. write (space,' Library symbol : ');
  1400. readderef;
  1401. end;
  1402. if (calloption=pocall_inline) then
  1403. begin
  1404. write (space,' FuncretSym : ');
  1405. readderef;
  1406. ppufile.getsmallset(procinfooptions);
  1407. writeln(space,' ProcInfoOptions : ',dword(procinfooptions));
  1408. b := ppufile.getbyte;
  1409. writeln(space,' Inline node tree : ',b);
  1410. end;
  1411. if not EndOfEntry then
  1412. Writeln('!! Entry has more information stored');
  1413. space:=' '+space;
  1414. { parast }
  1415. readdefinitions('parast',false);
  1416. readsymbols('parast');
  1417. { localst }
  1418. if (calloption = pocall_inline) then
  1419. begin
  1420. readdefinitions('localst',false);
  1421. readsymbols('localst');
  1422. end;
  1423. if (calloption=pocall_inline) then
  1424. readnodetree;
  1425. delete(space,1,4);
  1426. end;
  1427. ibprocvardef :
  1428. begin
  1429. readcommondef('Procedural type (ProcVar) definition');
  1430. read_abstract_proc_def(calloption,procoptions);
  1431. if not EndOfEntry then
  1432. Writeln('!! Entry has more information stored');
  1433. space:=' '+space;
  1434. { parast }
  1435. readdefinitions('parast',false);
  1436. readsymbols('parast');
  1437. delete(space,1,4);
  1438. end;
  1439. ibshortstringdef :
  1440. begin
  1441. readcommondef('ShortString definition');
  1442. writeln(space,' Length : ',getbyte);
  1443. end;
  1444. ibwidestringdef :
  1445. begin
  1446. readcommondef('WideString definition');
  1447. writeln(space,' Length : ',getlongint);
  1448. end;
  1449. ibansistringdef :
  1450. begin
  1451. readcommondef('AnsiString definition');
  1452. writeln(space,' Length : ',getlongint);
  1453. end;
  1454. iblongstringdef :
  1455. begin
  1456. readcommondef('Longstring definition');
  1457. writeln(space,' Length : ',getlongint);
  1458. end;
  1459. ibrecorddef :
  1460. begin
  1461. readcommondef('Record definition');
  1462. writeln(space,' DataSize : ',getlongint);
  1463. writeln(space,' FieldAlign : ',getbyte);
  1464. writeln(space,' RecordAlign : ',getbyte);
  1465. writeln(space,' PadAlign : ',getbyte);
  1466. if not EndOfEntry then
  1467. Writeln('!! Entry has more information stored');
  1468. {read the record definitions and symbols}
  1469. space:=' '+space;
  1470. readdefinitions('fields',false);
  1471. readsymbols('fields');
  1472. Delete(space,1,4);
  1473. end;
  1474. ibobjectdef :
  1475. begin
  1476. readcommondef('Object/Class definition');
  1477. b:=getbyte;
  1478. write (space,' Type : ');
  1479. case tobjectdeftype(b) of
  1480. odt_class : writeln('class');
  1481. odt_object : writeln('object');
  1482. odt_interfacecom : writeln('interfacecom');
  1483. odt_interfacecorba : writeln('interfacecorba');
  1484. odt_cppclass : writeln('cppclass');
  1485. else writeln('!! Warning: Invalid object type ',b);
  1486. end;
  1487. writeln(space,' Name of Class : ',getstring);
  1488. writeln(space,' DataSize : ',getlongint);
  1489. writeln(space,' FieldAlign : ',getbyte);
  1490. writeln(space,' RecordAlign : ',getbyte);
  1491. writeln(space,' Vmt offset : ',getlongint);
  1492. write(space, ' Ancestor Class : ');
  1493. readderef;
  1494. writeln(space,' Options : ',getlongint);
  1495. if tobjectdeftype(b) in [odt_interfacecom,odt_interfacecorba] then
  1496. begin
  1497. { IIDGUID }
  1498. for j:=1to 16 do
  1499. getbyte;
  1500. writeln(space,' IID String : ',getstring);
  1501. writeln(space,' Last VTable idx : ',getlongint);
  1502. end;
  1503. if tobjectdeftype(b) in [odt_class,odt_interfacecorba] then
  1504. begin
  1505. l:=getlongint;
  1506. writeln(space,' Impl Intf Count : ',l);
  1507. for j:=1 to l do
  1508. begin
  1509. write (space,' - Definition : ');
  1510. readderef;
  1511. writeln(space,' IOffset : ',getlongint);
  1512. end;
  1513. end;
  1514. if not EndOfEntry then
  1515. Writeln('!! Entry has more information stored');
  1516. {read the record definitions and symbols}
  1517. space:=' '+space;
  1518. readdefinitions('fields',false);
  1519. readsymbols('fields');
  1520. Delete(space,1,4);
  1521. end;
  1522. ibfiledef :
  1523. begin
  1524. ReadCommonDef('File definition');
  1525. write (space,' Type : ');
  1526. case getbyte of
  1527. 0 : writeln('Text');
  1528. 1 : begin
  1529. writeln('Typed');
  1530. write (space,' File of Type : ');
  1531. Readtype;
  1532. end;
  1533. 2 : writeln('Untyped');
  1534. end;
  1535. end;
  1536. ibformaldef :
  1537. readcommondef('Generic Definition (void-typ)');
  1538. ibenumdef :
  1539. begin
  1540. readcommondef('Enumeration type definition');
  1541. write(space,'Base enumeration type : ');
  1542. readderef;
  1543. writeln(space,' Smallest element : ',getlongint);
  1544. writeln(space,' Largest element : ',getlongint);
  1545. writeln(space,' Size : ',getlongint);
  1546. end;
  1547. ibclassrefdef :
  1548. begin
  1549. readcommondef('Class reference definition');
  1550. write (space,' Pointed Type : ');
  1551. readtype;
  1552. end;
  1553. ibsetdef :
  1554. begin
  1555. readcommondef('Set definition');
  1556. write (space,' Element type : ');
  1557. readtype;
  1558. b:=getbyte;
  1559. case tsettype(b) of
  1560. smallset : writeln(space,' Set with 32 Elements');
  1561. normset : writeln(space,' Set with 256 Elements');
  1562. varset : writeln(space,' Set with ',getlongint,' Elements');
  1563. else writeln('!! Warning: Invalid set type ',b);
  1564. end;
  1565. end;
  1566. ibvariantdef :
  1567. begin
  1568. readcommondef('Variant definition');
  1569. write (space,' Varianttype : ');
  1570. b:=getbyte;
  1571. case tvarianttype(b) of
  1572. vt_normalvariant :
  1573. writeln('Normal');
  1574. vt_olevariant :
  1575. writeln('OLE');
  1576. else
  1577. writeln('!! Warning: Invalid varianttype ',b);
  1578. end;
  1579. end;
  1580. iberror :
  1581. begin
  1582. Writeln('!! Error in PPU');
  1583. exit;
  1584. end;
  1585. ibenddefs :
  1586. break;
  1587. else
  1588. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  1589. end;
  1590. if not EndOfEntry then
  1591. Writeln('!! Entry has more information stored');
  1592. until false;
  1593. if (totaldefs<>-1) and (defcnt<>totaldefs) then
  1594. Writeln('!! Only read ',defcnt,' of ',totaldefs,' definitions');
  1595. end;
  1596. end;
  1597. {****************************************************************************
  1598. Read General Part
  1599. ****************************************************************************}
  1600. procedure readinterface;
  1601. var
  1602. b : byte;
  1603. sourcenumber : longint;
  1604. begin
  1605. with ppufile do
  1606. begin
  1607. repeat
  1608. b:=readentry;
  1609. case b of
  1610. ibmodulename :
  1611. Writeln('Module Name: ',getstring);
  1612. ibsourcefiles :
  1613. begin
  1614. sourcenumber:=1;
  1615. while not EndOfEntry do
  1616. begin
  1617. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  1618. inc(sourcenumber);
  1619. end;
  1620. end;
  1621. {$IFDEF MACRO_DIFF_HINT}
  1622. ibusedmacros :
  1623. begin
  1624. while not EndOfEntry do
  1625. begin
  1626. Write('Conditional ',getstring);
  1627. b:=getbyte;
  1628. if boolean(b)=true then
  1629. write(' defined at startup')
  1630. else
  1631. write(' not defined at startup');
  1632. b:=getbyte;
  1633. if boolean(b)=true then
  1634. writeln(' was used')
  1635. else
  1636. writeln;
  1637. end;
  1638. end;
  1639. {$ENDIF}
  1640. ibloadunit :
  1641. ReadLoadUnit;
  1642. iblinkunitofiles :
  1643. ReadLinkContainer('Link unit object file: ');
  1644. iblinkunitstaticlibs :
  1645. ReadLinkContainer('Link unit static lib: ');
  1646. iblinkunitsharedlibs :
  1647. ReadLinkContainer('Link unit shared lib: ');
  1648. iblinkotherofiles :
  1649. ReadLinkContainer('Link other object file: ');
  1650. iblinkotherstaticlibs :
  1651. ReadLinkContainer('Link other static lib: ');
  1652. iblinkothersharedlibs :
  1653. ReadLinkContainer('Link other shared lib: ');
  1654. ibderefdata :
  1655. ReadDerefData;
  1656. ibderefmap :
  1657. ReadDerefMap;
  1658. iberror :
  1659. begin
  1660. Writeln('Error in PPU');
  1661. exit;
  1662. end;
  1663. ibendinterface :
  1664. break;
  1665. else
  1666. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  1667. end;
  1668. until false;
  1669. end;
  1670. end;
  1671. {****************************************************************************
  1672. Read Implementation Part
  1673. ****************************************************************************}
  1674. procedure readimplementation;
  1675. var
  1676. b : byte;
  1677. begin
  1678. with ppufile do
  1679. begin
  1680. repeat
  1681. b:=readentry;
  1682. case b of
  1683. ibasmsymbols :
  1684. ReadAsmSymbols;
  1685. ibloadunit :
  1686. ReadLoadUnit;
  1687. iberror :
  1688. begin
  1689. Writeln('Error in PPU');
  1690. exit;
  1691. end;
  1692. ibendimplementation :
  1693. break;
  1694. else
  1695. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  1696. end;
  1697. until false;
  1698. end;
  1699. end;
  1700. {****************************************************************************
  1701. Read Browser Part
  1702. ****************************************************************************}
  1703. procedure readbrowser;
  1704. var
  1705. b : byte;
  1706. const indent : string = '';
  1707. begin
  1708. Writeln(indent,'Start of symtable browser');
  1709. indent:=indent+'**';
  1710. with ppufile do
  1711. begin
  1712. repeat
  1713. b:=readentry;
  1714. case b of
  1715. ibbeginsymtablebrowser :
  1716. begin
  1717. { here we must read object and record symtables !! }
  1718. indent:=indent+' ';
  1719. Writeln(indent,'Record/Object symtable');
  1720. readbrowser;
  1721. Indent:=Copy(Indent,1,Length(Indent)-2);
  1722. end;
  1723. ibsymref :
  1724. begin
  1725. readderef;
  1726. readref;
  1727. end;
  1728. ibdefref :
  1729. begin
  1730. readderef;
  1731. readref;
  1732. if ((ppufile.header.flags and uf_local_browser)<>0) and
  1733. (UnitIndex=0) then
  1734. begin
  1735. { parast and localst }
  1736. indent:=indent+' ';
  1737. b:=ppufile.readentry;
  1738. if b=ibbeginsymtablebrowser then
  1739. readbrowser;
  1740. b:=ppufile.readentry;
  1741. if b=ibbeginsymtablebrowser then
  1742. readbrowser;
  1743. Indent:=Copy(Indent,1,Length(Indent)-2);
  1744. end;
  1745. end;
  1746. iberror :
  1747. begin
  1748. Writeln('Error in PPU');
  1749. exit;
  1750. end;
  1751. ibendsymtablebrowser :
  1752. break;
  1753. else
  1754. begin
  1755. WriteLn('!! Skipping unsupported PPU Entry in Browser: ',b);
  1756. Halt;
  1757. end;
  1758. end;
  1759. until false;
  1760. end;
  1761. Indent:=Copy(Indent,1,Length(Indent)-2);
  1762. Writeln(Indent,'End of symtable browser');
  1763. end;
  1764. procedure dofile (filename : string);
  1765. var
  1766. b : byte;
  1767. begin
  1768. { reset }
  1769. space:='';
  1770. { fix filename }
  1771. if pos('.',filename)=0 then
  1772. filename:=filename+'.ppu';
  1773. ppufile:=tppufile.create(filename);
  1774. if not ppufile.openfile then
  1775. begin
  1776. writeln ('IO-Error when opening : ',filename,', Skipping');
  1777. exit;
  1778. end;
  1779. { PPU File is open, check for PPU Id }
  1780. if not ppufile.CheckPPUID then
  1781. begin
  1782. writeln(Filename,' : Not a valid PPU file, Skipping');
  1783. exit;
  1784. end;
  1785. { Check PPU Version }
  1786. Writeln('Analyzing ',filename,' (v',ppufile.GetPPUVersion,')');
  1787. if ppufile.GetPPUVersion<16 then
  1788. begin
  1789. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  1790. exit;
  1791. end;
  1792. { Write PPU Header Information }
  1793. if (verbose and v_header)<>0 then
  1794. begin
  1795. Writeln;
  1796. Writeln('Header');
  1797. Writeln('-------');
  1798. with ppufile.header do
  1799. begin
  1800. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  1801. (ppufile.header.compiler shr 7) and $7f,'.',
  1802. ppufile.header.compiler and $7f);
  1803. WriteLn('Target processor : ',Cpu2Str(cpu));
  1804. WriteLn('Target operating system : ',Target2Str(target));
  1805. Writeln('Unit flags : ',PPUFlags2Str(flags));
  1806. Writeln('FileSize (w/o header) : ',size);
  1807. Writeln('Checksum : ',hexstr(checksum,8));
  1808. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  1809. end;
  1810. end;
  1811. {read the general stuff}
  1812. if (verbose and v_interface)<>0 then
  1813. begin
  1814. Writeln;
  1815. Writeln('Interface section');
  1816. Writeln('------------------');
  1817. readinterface;
  1818. end
  1819. else
  1820. ppufile.skipuntilentry(ibendinterface);
  1821. {read the definitions}
  1822. if (verbose and v_defs)<>0 then
  1823. begin
  1824. Writeln;
  1825. Writeln('Interface definitions');
  1826. Writeln('----------------------');
  1827. readdefinitions('interface',false);
  1828. end
  1829. else
  1830. ppufile.skipuntilentry(ibenddefs);
  1831. {read the symbols}
  1832. if (verbose and v_syms)<>0 then
  1833. begin
  1834. Writeln;
  1835. Writeln('Interface Symbols');
  1836. Writeln('------------------');
  1837. readsymbols('interface');
  1838. end
  1839. else
  1840. ppufile.skipuntilentry(ibendsyms);
  1841. {read the macro symbols}
  1842. if (verbose and v_syms)<>0 then
  1843. begin
  1844. Writeln;
  1845. Writeln('Interface Macro Symbols');
  1846. Writeln('-----------------------');
  1847. end;
  1848. if ppufile.readentry<>ibexportedmacros then
  1849. begin
  1850. Writeln('!! Error in PPU');
  1851. exit;
  1852. end;
  1853. if boolean(ppufile.getbyte) then
  1854. begin
  1855. {skip the definition section for macros (since they are never used) }
  1856. ppufile.skipuntilentry(ibenddefs);
  1857. {read the macro symbols}
  1858. if (verbose and v_syms)<>0 then
  1859. readsymbols('interface macro')
  1860. else
  1861. ppufile.skipuntilentry(ibendsyms);
  1862. end
  1863. else
  1864. Writeln('(no exported macros)');
  1865. {read the implementation stuff}
  1866. if (verbose and v_implementation)<>0 then
  1867. begin
  1868. Writeln;
  1869. Writeln('Implementation section');
  1870. Writeln('-----------------------');
  1871. readimplementation;
  1872. end
  1873. else
  1874. ppufile.skipuntilentry(ibendimplementation);
  1875. {read the static browser units stuff}
  1876. if (ppufile.header.flags and uf_local_symtable)<>0 then
  1877. begin
  1878. if (verbose and v_defs)<>0 then
  1879. begin
  1880. Writeln;
  1881. Writeln('Static definitions');
  1882. Writeln('----------------------');
  1883. readdefinitions('implementation',false);
  1884. end
  1885. else
  1886. ppufile.skipuntilentry(ibenddefs);
  1887. {read the symbols}
  1888. if (verbose and v_syms)<>0 then
  1889. begin
  1890. Writeln;
  1891. Writeln('Static Symbols');
  1892. Writeln('------------------');
  1893. readsymbols('implementation');
  1894. end
  1895. else
  1896. ppufile.skipuntilentry(ibendsyms);
  1897. end;
  1898. {read the browser units stuff}
  1899. if (ppufile.header.flags and uf_has_browser)<>0 then
  1900. begin
  1901. if (verbose and v_browser)<>0 then
  1902. begin
  1903. Writeln;
  1904. Writeln('Browser section');
  1905. Writeln('---------------');
  1906. UnitIndex:=0;
  1907. repeat
  1908. b:=ppufile.readentry;
  1909. if b = ibendbrowser then break;
  1910. if b=ibbeginsymtablebrowser then
  1911. begin
  1912. Writeln('Unit ',UnitIndex);
  1913. readbrowser;
  1914. Inc(UnitIndex);
  1915. end
  1916. else
  1917. Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
  1918. until false;
  1919. end;
  1920. end;
  1921. {read the static browser units stuff}
  1922. if (ppufile.header.flags and uf_local_browser)<>0 then
  1923. begin
  1924. if (verbose and v_browser)<>0 then
  1925. begin
  1926. Writeln;
  1927. Writeln('Static browser section');
  1928. Writeln('---------------');
  1929. UnitIndex:=0;
  1930. b:=ppufile.readentry;
  1931. if b=ibbeginsymtablebrowser then
  1932. readbrowser
  1933. else
  1934. Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
  1935. end;
  1936. end;
  1937. {shutdown ppufile}
  1938. ppufile.closefile;
  1939. ppufile.free;
  1940. Writeln;
  1941. end;
  1942. procedure help;
  1943. begin
  1944. writeln('usage: ppudump [options] <filename1> <filename2>...');
  1945. writeln;
  1946. writeln('[options] can be:');
  1947. writeln(' -V<verbose> Set verbosity to <verbose>');
  1948. writeln(' H - Show header info');
  1949. writeln(' I - Show interface');
  1950. writeln(' M - Show implementation');
  1951. writeln(' S - Show interface symbols');
  1952. writeln(' D - Show interface definitions');
  1953. writeln(' B - Show browser info');
  1954. writeln(' A - Show all');
  1955. writeln(' -h, -? This helpscreen');
  1956. halt;
  1957. end;
  1958. var
  1959. startpara,
  1960. nrfile,i : longint;
  1961. para : string;
  1962. begin
  1963. writeln(Title+' '+Version);
  1964. writeln(Copyright);
  1965. writeln;
  1966. if paramcount<1 then
  1967. begin
  1968. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  1969. halt(1);
  1970. end;
  1971. { turn verbose on by default }
  1972. verbose:=v_all;
  1973. { read options }
  1974. startpara:=1;
  1975. while copy(paramstr(startpara),1,1)='-' do
  1976. begin
  1977. para:=paramstr(startpara);
  1978. case upcase(para[2]) of
  1979. 'V' : begin
  1980. verbose:=0;
  1981. for i:=3 to length(para) do
  1982. case upcase(para[i]) of
  1983. 'H' : verbose:=verbose or v_header;
  1984. 'I' : verbose:=verbose or v_interface;
  1985. 'M' : verbose:=verbose or v_implementation;
  1986. 'D' : verbose:=verbose or v_defs;
  1987. 'S' : verbose:=verbose or v_syms;
  1988. 'B' : verbose:=verbose or v_browser;
  1989. 'A' : verbose:=verbose or v_all;
  1990. end;
  1991. end;
  1992. 'H' : help;
  1993. '?' : help;
  1994. end;
  1995. inc(startpara);
  1996. end;
  1997. { process files }
  1998. for nrfile:=startpara to paramcount do
  1999. dofile (paramstr(nrfile));
  2000. if has_errors then
  2001. Halt(1);
  2002. end.