ppudump.pp 60 KB

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