ppudump.pp 77 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655
  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. program ppudump;
  17. {$mode objfpc}
  18. {$H+}
  19. uses
  20. { do NOT add symconst or globtype to make merging easier }
  21. SysUtils,
  22. constexp,
  23. ppu,
  24. globals,
  25. tokens;
  26. const
  27. Version = 'Version 2.5.1';
  28. Title = 'PPU-Analyser';
  29. Copyright = 'Copyright (c) 1998-2010 by the Free Pascal Development Team';
  30. { verbosity }
  31. v_none = $0;
  32. v_header = $1;
  33. v_defs = $2;
  34. v_syms = $4;
  35. v_interface = $8;
  36. v_implementation = $10;
  37. // v_browser = $20;
  38. v_all = $ff;
  39. type
  40. tprocinfoflag=(
  41. { procedure has at least one assembler block }
  42. pi_has_assembler_block,
  43. { procedure does a call }
  44. pi_do_call,
  45. { procedure has a try statement = no register optimization }
  46. pi_uses_exceptions,
  47. { procedure is declared as @var(assembler), don't optimize}
  48. pi_is_assembler,
  49. { procedure contains data which needs to be finalized }
  50. pi_needs_implicit_finally,
  51. { procedure has the implicit try..finally generated }
  52. pi_has_implicit_finally,
  53. { procedure uses fpu}
  54. pi_uses_fpu,
  55. { procedure uses GOT for PIC code }
  56. pi_needs_got,
  57. { references var/proc/type/const in static symtable,
  58. i.e. not allowed for inlining from other units }
  59. pi_uses_static_symtable,
  60. { set if the procedure has to push parameters onto the stack }
  61. pi_has_stackparameter,
  62. { set if the procedure has at least one got }
  63. pi_has_goto,
  64. { calls itself recursive }
  65. pi_is_recursive,
  66. { stack frame optimization not possible (only on x86 probably) }
  67. pi_needs_stackframe,
  68. { set if the procedure has at least one register saved on the stack }
  69. pi_has_saved_regs,
  70. { dfa was generated for this proc }
  71. pi_dfaavailable
  72. );
  73. tprocinfoflags=set of tprocinfoflag;
  74. tspecialgenerictoken = (ST_LOADSETTINGS,ST_LINE,ST_COLUMN,ST_FILEINDEX);
  75. { Copied from systems.pas }
  76. tsystemcpu=
  77. (
  78. cpu_no, { 0 }
  79. cpu_i386, { 1 }
  80. cpu_m68k, { 2 }
  81. cpu_alpha, { 3 }
  82. cpu_powerpc, { 4 }
  83. cpu_sparc, { 5 }
  84. cpu_vm, { 6 }
  85. cpu_iA64, { 7 }
  86. cpu_x86_64, { 8 }
  87. cpu_mips, { 9 }
  88. cpu_arm, { 10 }
  89. cpu_powerpc64, { 11 }
  90. cpu_avr { 12 }
  91. );
  92. var
  93. ppufile : tppufile;
  94. space : string;
  95. verbose : longint;
  96. derefdata : pbyte;
  97. derefdatalen : longint;
  98. {****************************************************************************
  99. Helper Routines
  100. ****************************************************************************}
  101. const has_errors : boolean = false;
  102. Procedure Error(const S : string);
  103. Begin
  104. Writeln(S);
  105. has_errors:=true;
  106. End;
  107. function ToStr(w:longint):String;
  108. begin
  109. Str(w,ToStr);
  110. end;
  111. Function Target2Str(w:longint):string;
  112. type
  113. { taken from systems.pas }
  114. ttarget =
  115. (
  116. target_none, { 0 }
  117. obsolete_target_i386_GO32V1,{ 1 }
  118. target_i386_GO32V2, { 2 }
  119. target_i386_linux, { 3 }
  120. target_i386_OS2, { 4 }
  121. target_i386_Win32, { 5 }
  122. target_i386_freebsd, { 6 }
  123. target_m68k_Amiga, { 7 }
  124. target_m68k_Atari, { 8 }
  125. target_m68k_Mac, { 9 }
  126. target_m68k_linux, { 10 }
  127. target_m68k_PalmOS, { 11 }
  128. target_alpha_linux, { 12 }
  129. target_powerpc_linux, { 13 }
  130. target_powerpc_macos, { 14 }
  131. target_i386_solaris, { 15 }
  132. target_i386_beos, { 16 }
  133. target_i386_netbsd, { 17 }
  134. target_m68k_netbsd, { 18 }
  135. target_i386_Netware, { 19 }
  136. target_i386_qnx, { 20 }
  137. target_i386_wdosx, { 21 }
  138. target_sparc_solaris, { 22 }
  139. target_sparc_linux, { 23 }
  140. target_i386_openbsd, { 24 }
  141. target_m68k_openbsd, { 25 }
  142. target_x86_64_linux, { 26 }
  143. target_powerpc_darwin, { 27 }
  144. target_i386_emx, { 28 }
  145. target_powerpc_netbsd, { 29 }
  146. target_powerpc_openbsd, { 30 }
  147. target_arm_linux, { 31 }
  148. target_i386_watcom, { 32 }
  149. target_powerpc_MorphOS, { 33 }
  150. target_x86_64_freebsd, { 34 }
  151. target_i386_netwlibc, { 35 }
  152. target_powerpc_Amiga, { 36 }
  153. target_x86_64_win64, { 37 }
  154. target_arm_wince, { 38 }
  155. target_ia64_win64, { 39 }
  156. target_i386_wince, { 40 }
  157. target_x86_6432_linux, { 41 }
  158. target_arm_gba, { 42 }
  159. target_powerpc64_linux, { 43 }
  160. target_i386_darwin, { 44 }
  161. target_arm_palmos, { 45 }
  162. target_powerpc64_darwin, { 46 }
  163. target_arm_nds, { 47 }
  164. target_i386_embedded, { 48 }
  165. target_m68k_embedded, { 49 }
  166. target_alpha_embedded, { 50 }
  167. target_powerpc_embedded, { 51 }
  168. target_sparc_embedded, { 52 }
  169. target_vm_embedded, { 53 }
  170. target_iA64_embedded, { 54 }
  171. target_x86_64_embedded, { 55 }
  172. target_mips_embedded, { 56 }
  173. target_arm_embedded, { 57 }
  174. target_powerpc64_embedded, { 58 }
  175. target_i386_symbian, { 59 }
  176. target_arm_symbian, { 60 }
  177. target_x86_64_darwin, { 61 }
  178. target_avr_embedded, { 62 }
  179. target_i386_haiku, { 63 }
  180. target_arm_darwin, { 64 }
  181. target_x86_64_solaris, { 65 }
  182. target_mips_linux, { 66 }
  183. target_mipsel_linux, { 67 }
  184. target_i386_nativent { 68 }
  185. );
  186. const
  187. Targets : array[ttarget] of string[18]=(
  188. { 0 } 'none',
  189. { 1 } 'GO32V1 (obsolete)',
  190. { 2 } 'GO32V2',
  191. { 3 } 'Linux-i386',
  192. { 4 } 'OS/2',
  193. { 5 } 'Win32',
  194. { 6 } 'FreeBSD-i386',
  195. { 7 } 'Amiga',
  196. { 8 } 'Atari',
  197. { 9 } 'MacOS-m68k',
  198. { 10 } 'Linux-m68k',
  199. { 11 } 'PalmOS-m68k',
  200. { 12 } 'Linux-alpha',
  201. { 13 } 'Linux-ppc',
  202. { 14 } 'MacOS-ppc',
  203. { 15 } 'Solaris-i386',
  204. { 16 } 'BeOS-i386',
  205. { 17 } 'NetBSD-i386',
  206. { 18 } 'NetBSD-m68k',
  207. { 19 } 'Netware-i386-clib',
  208. { 20 } 'Qnx-i386',
  209. { 21 } 'WDOSX-i386',
  210. { 22 } 'Solaris-sparc',
  211. { 23 } 'Linux-sparc',
  212. { 24 } 'OpenBSD-i386',
  213. { 25 } 'OpenBSD-m68k',
  214. { 26 } 'Linux-x86-64',
  215. { 27 } 'MacOSX-ppc',
  216. { 28 } 'OS/2 via EMX',
  217. { 29 } 'NetBSD-powerpc',
  218. { 30 } 'OpenBSD-powerpc',
  219. { 31 } 'Linux-arm',
  220. { 32 } 'Watcom-i386',
  221. { 33 } 'MorphOS-powerpc',
  222. { 34 } 'FreeBSD-x86-64',
  223. { 35 } 'Netware-i386-libc',
  224. { 36 } 'Amiga-PowerPC',
  225. { 37 } 'Win64-x64',
  226. { 38 } 'WinCE-ARM',
  227. { 39 } 'Win64-iA64',
  228. { 40 } 'WinCE-i386',
  229. { 41 } 'Linux-x64',
  230. { 42 } 'GBA-arm',
  231. { 43 } 'Linux-powerpc64',
  232. { 44 } 'Darwin-i386',
  233. { 45 } 'PalmOS-arm',
  234. { 46 } 'MacOSX-powerpc64',
  235. { 47 } 'NDS-arm',
  236. { 48 } 'Embedded-i386',
  237. { 49 } 'Embedded-m68k',
  238. { 50 } 'Embedded-alpha',
  239. { 51 } 'Embedded-powerpc',
  240. { 52 } 'Embedded-sparc',
  241. { 53 } 'Embedded-vm',
  242. { 54 } 'Embedded-iA64',
  243. { 55 } 'Embedded-x64',
  244. { 56 } 'Embedded-mips',
  245. { 57 } 'Embedded-arm',
  246. { 58 } 'Embedded-powerpc64',
  247. { 59 } 'Symbian-i386',
  248. { 60 } 'Symbian-arm',
  249. { 61 } 'MacOSX-x64',
  250. { 62 } 'Embedded-avr',
  251. { 63 } 'Haiku-i386',
  252. { 64 } 'Darwin-ARM',
  253. { 65 } 'Solaris-x86-64',
  254. { 66 } 'Linux-MIPS',
  255. { 67 } 'Linux-MIPSel',
  256. { 68 } 'NativeNT-i386'
  257. );
  258. begin
  259. if w<=ord(high(ttarget)) then
  260. Target2Str:=Targets[ttarget(w)]
  261. else
  262. Target2Str:='<!! Unknown target value '+tostr(w)+'>';
  263. end;
  264. Function Cpu2Str(w:longint):string;
  265. const
  266. CpuTxt : array[tsystemcpu] of string[9]=
  267. ('none','i386','m68k','alpha','powerpc','sparc','vis','ia64',
  268. 'x86_64','mips','arm','powerpc64','avr');
  269. begin
  270. if w<=ord(high(tsystemcpu)) then
  271. Cpu2Str:=CpuTxt[tsystemcpu(w)]
  272. else
  273. Cpu2Str:='<!! Unknown cpu value '+tostr(w)+'>';
  274. end;
  275. Function Varspez2Str(w:longint):string;
  276. const
  277. varspezstr : array[0..4] of string[6]=('Value','Const','Var','Out','Hidden');
  278. begin
  279. if w<=ord(high(varspezstr)) then
  280. Varspez2Str:=varspezstr[w]
  281. else
  282. Varspez2Str:='<!! Unknown varspez value '+tostr(w)+'>';
  283. end;
  284. Function VarRegable2Str(w:longint):string;
  285. const
  286. varregableStr : array[0..4] of string[6]=('None','IntReg','FPUReg','MMReg','Addr');
  287. begin
  288. if w<=ord(high(varregablestr)) then
  289. Varregable2Str:=varregablestr[w]
  290. else
  291. Varregable2Str:='<!! Unknown regable value '+tostr(w)+'>';
  292. end;
  293. Function Visibility2Str(w:longint):string;
  294. const
  295. visibilityName : array[0..6] of string[16] = (
  296. 'hidden','strict private','private','strict protected','protected',
  297. 'public','published'
  298. );
  299. begin
  300. if w<=ord(high(visibilityName)) then
  301. result:=visibilityName[w]
  302. else
  303. result:='<!! Unknown visibility value '+tostr(w)+'>';
  304. end;
  305. function PPUFlags2Str(flags:longint):string;
  306. type
  307. tflagopt=record
  308. mask : longint;
  309. str : string[30];
  310. end;
  311. const
  312. flagopts=17;
  313. flagopt : array[1..flagopts] of tflagopt=(
  314. (mask: $1 ;str:'init'),
  315. (mask: $2 ;str:'final'),
  316. (mask: $4 ;str:'big_endian'),
  317. (mask: $8 ;str:'dbx'),
  318. // (mask: $10 ;str:'browser'),
  319. (mask: $20 ;str:'in_library'),
  320. (mask: $40 ;str:'smart_linked'),
  321. (mask: $80 ;str:'static_linked'),
  322. (mask: $100 ;str:'shared_linked'),
  323. // (mask: $200 ;str:'local_browser'),
  324. (mask: $400 ;str:'no_link'),
  325. (mask: $800 ;str:'has_resources'),
  326. (mask: $1000 ;str:'little_endian'),
  327. (mask: $2000 ;str:'release'),
  328. (mask: $4000 ;str:'local_threadvars'),
  329. (mask: $8000 ;str:'fpu_emulation_on'),
  330. (mask: $10000 ;str:'has_debug_info'),
  331. (mask: $20000 ;str:'local_symtable'),
  332. (mask: $40000 ;str:'uses_variants')
  333. );
  334. var
  335. i : longint;
  336. first : boolean;
  337. s : string;
  338. begin
  339. s:='';
  340. if flags<>0 then
  341. begin
  342. first:=true;
  343. for i:=1to flagopts do
  344. if (flags and flagopt[i].mask)<>0 then
  345. begin
  346. if first then
  347. first:=false
  348. else
  349. s:=s+', ';
  350. s:=s+flagopt[i].str;
  351. end;
  352. end
  353. else
  354. s:='none';
  355. PPUFlags2Str:=s;
  356. end;
  357. Function L0(l:longint):string;
  358. {
  359. return the string of value l, if l<10 then insert a zero, so
  360. the string is always at least 2 chars '01','02',etc
  361. }
  362. var
  363. s : string;
  364. begin
  365. Str(l,s);
  366. if l<10 then
  367. s:='0'+s;
  368. L0:=s;
  369. end;
  370. function filetimestring( t : longint) : string;
  371. {
  372. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  373. }
  374. var
  375. DT : TDateTime;
  376. hsec : word;
  377. Year,Month,Day: Word;
  378. hour,min,sec : word;
  379. begin
  380. if t=-1 then
  381. begin
  382. Result := 'Not Found';
  383. exit;
  384. end;
  385. DT := FileDateToDateTime(t);
  386. DecodeTime(DT,hour,min,sec,hsec);
  387. DecodeDate(DT,year,month,day);
  388. Result := L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  389. end;
  390. {****************************************************************************
  391. Read Routines
  392. ****************************************************************************}
  393. Procedure ReadLinkContainer(const prefix:string);
  394. {
  395. Read a serie of strings and write to the screen starting every line
  396. with prefix
  397. }
  398. function maskstr(m:longint):string;
  399. const
  400. { link options }
  401. link_none = $0;
  402. link_always = $1;
  403. link_static = $2;
  404. link_smart = $4;
  405. link_shared = $8;
  406. var
  407. s : string;
  408. begin
  409. s:='';
  410. if (m and link_always)<>0 then
  411. s:=s+'always ';
  412. if (m and link_static)<>0 then
  413. s:=s+'static ';
  414. if (m and link_smart)<>0 then
  415. s:=s+'smart ';
  416. if (m and link_shared)<>0 then
  417. s:=s+'shared ';
  418. maskstr:=s;
  419. end;
  420. var
  421. s : string;
  422. m : longint;
  423. begin
  424. while not ppufile.endofentry do
  425. begin
  426. s:=ppufile.getstring;
  427. m:=ppufile.getlongint;
  428. WriteLn(prefix,s,' (',maskstr(m),')');
  429. end;
  430. end;
  431. Procedure ReadContainer(const prefix:string);
  432. {
  433. Read a serie of strings and write to the screen starting every line
  434. with prefix
  435. }
  436. begin
  437. while not ppufile.endofentry do
  438. WriteLn(prefix,ppufile.getstring);
  439. end;
  440. procedure ReadLoadUnit;
  441. var
  442. ucrc,uintfcrc, indcrc : cardinal;
  443. begin
  444. while not ppufile.EndOfEntry do
  445. begin
  446. write('Uses unit: ',ppufile.getstring);
  447. ucrc:=cardinal(ppufile.getlongint);
  448. uintfcrc:=cardinal(ppufile.getlongint);
  449. indcrc:=cardinal(ppufile.getlongint);
  450. writeln(' (Crc: ',hexstr(ucrc,8),', IntfcCrc: ',hexstr(uintfcrc,8),', IndCrc: ',hexstr(indcrc,8),')');
  451. end;
  452. end;
  453. Procedure ReadDerefmap;
  454. var
  455. i,mapsize : longint;
  456. begin
  457. mapsize:=ppufile.getlongint;
  458. writeln('DerefMapsize: ',mapsize);
  459. for i:=0 to mapsize-1 do
  460. writeln('DerefMap[',i,'] = ',ppufile.getstring);
  461. end;
  462. Procedure ReadImportSymbols;
  463. var
  464. extlibname : string;
  465. j,
  466. extsymcnt : longint;
  467. extsymname : string;
  468. extsymordnr : longint;
  469. extsymisvar : boolean;
  470. begin
  471. while not ppufile.endofentry do
  472. begin
  473. extlibname:=ppufile.getstring;
  474. extsymcnt:=ppufile.getlongint;
  475. writeln('External Library: ',extlibname,' (',extsymcnt,' imports)');
  476. for j:=0 to extsymcnt-1 do
  477. begin
  478. extsymname:=ppufile.getstring;
  479. extsymordnr:=ppufile.getlongint;
  480. extsymisvar:=ppufile.getbyte<>0;
  481. writeln(' ',extsymname,' (OrdNr: ',extsymordnr,' IsVar: ',extsymisvar,')');
  482. end;
  483. end;
  484. end;
  485. Procedure ReadDerefdata;
  486. begin
  487. derefdatalen:=ppufile.entrysize;
  488. if derefdatalen=0 then
  489. begin
  490. writeln('!! Error: derefdatalen=0');
  491. exit;
  492. end;
  493. Writeln('Derefdata length: ',derefdatalen);
  494. derefdata:=allocmem(derefdatalen);
  495. ppufile.getdata(derefdata^,derefdatalen);
  496. end;
  497. Procedure ReadWpoFileInfo;
  498. begin
  499. Writeln('Compiled with input whole-program optimisation from ',ppufile.getstring,' ',filetimestring(ppufile.getlongint));
  500. end;
  501. Procedure ReadAsmSymbols;
  502. type
  503. { Copied from aasmbase.pas }
  504. TAsmsymbind=(AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL);
  505. TAsmsymtype=(AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL);
  506. var
  507. s,
  508. bindstr,
  509. typestr : string;
  510. i : longint;
  511. begin
  512. writeln(space,'Number of AsmSymbols: ',ppufile.getlongint);
  513. i:=0;
  514. while (not ppufile.endofentry) and (not ppufile.error) do
  515. begin
  516. s:=ppufile.getstring;
  517. case tasmsymbind(ppufile.getbyte) of
  518. AB_EXTERNAL :
  519. bindstr:='External';
  520. AB_COMMON :
  521. bindstr:='Common';
  522. AB_LOCAL :
  523. bindstr:='Local';
  524. AB_GLOBAL :
  525. bindstr:='Global';
  526. else
  527. bindstr:='<Error !!>'
  528. end;
  529. case tasmsymtype(ppufile.getbyte) of
  530. AT_FUNCTION :
  531. typestr:='Function';
  532. AT_DATA :
  533. typestr:='Data';
  534. AT_SECTION :
  535. typestr:='Section';
  536. AT_LABEL :
  537. typestr:='Label';
  538. else
  539. typestr:='<Error !!>'
  540. end;
  541. Writeln(space,' ',i,' : ',s,' [',bindstr,',',typestr,']');
  542. inc(i);
  543. end;
  544. end;
  545. function getexprint:Tconstexprint;
  546. begin
  547. getexprint.overflow:=false;
  548. getexprint.signed:=boolean(ppufile.getbyte);
  549. getexprint.svalue:=ppufile.getint64;
  550. end;
  551. Procedure ReadPosInfo;
  552. var
  553. info : byte;
  554. fileindex,line,column : longint;
  555. begin
  556. with ppufile do
  557. begin
  558. {
  559. info byte layout in bits:
  560. 0-1 - amount of bytes for fileindex
  561. 2-3 - amount of bytes for line
  562. 4-5 - amount of bytes for column
  563. }
  564. info:=getbyte;
  565. case (info and $03) of
  566. 0 : fileindex:=getbyte;
  567. 1 : fileindex:=getword;
  568. 2 : fileindex:=(getbyte shl 16) or getword;
  569. 3 : fileindex:=getlongint;
  570. end;
  571. case ((info shr 2) and $03) of
  572. 0 : line:=getbyte;
  573. 1 : line:=getword;
  574. 2 : line:=(getbyte shl 16) or getword;
  575. 3 : line:=getlongint;
  576. end;
  577. case ((info shr 4) and $03) of
  578. 0 : column:=getbyte;
  579. 1 : column:=getword;
  580. 2 : column:=(getbyte shl 16) or getword;
  581. 3 : column:=getlongint;
  582. end;
  583. Writeln(fileindex,' (',line,',',column,')');
  584. end;
  585. end;
  586. procedure readderef(const derefspace: string);
  587. type
  588. tdereftype = (deref_nil,
  589. deref_unit,
  590. deref_symid,
  591. deref_defid
  592. );
  593. var
  594. b : tdereftype;
  595. first : boolean;
  596. idx : longint;
  597. i,n : byte;
  598. pdata : pbyte;
  599. begin
  600. if not assigned(derefdata) then
  601. exit;
  602. first:=true;
  603. idx:=ppufile.getlongint;
  604. if (idx>derefdatalen) then
  605. begin
  606. writeln('!! Error: Deref idx ',idx,' > ',derefdatalen);
  607. exit;
  608. end;
  609. write(derefspace,'(',idx,') ');
  610. pdata:=@derefdata[idx];
  611. i:=0;
  612. n:=pdata[i];
  613. inc(i);
  614. if n<1 then
  615. begin
  616. writeln('!! Error: Deref len < 1');
  617. exit;
  618. end;
  619. while (i<=n) do
  620. begin
  621. if not first then
  622. write(', ')
  623. else
  624. first:=false;
  625. b:=tdereftype(pdata[i]);
  626. inc(i);
  627. case b of
  628. deref_nil :
  629. write('Nil');
  630. deref_symid :
  631. begin
  632. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  633. inc(i,4);
  634. write('SymId ',idx);
  635. end;
  636. deref_defid :
  637. begin
  638. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  639. inc(i,4);
  640. write('DefId ',idx);
  641. end;
  642. deref_unit :
  643. begin
  644. idx:=pdata[i] shl 8 or pdata[i+1];
  645. inc(i,2);
  646. write('Unit ',idx);
  647. end;
  648. else
  649. begin
  650. writeln('!! unsupported dereftyp: ',ord(b));
  651. break;
  652. end;
  653. end;
  654. end;
  655. writeln;
  656. end;
  657. procedure readpropaccesslist(const s:string);
  658. type
  659. tsltype = (sl_none,
  660. sl_load,
  661. sl_call,
  662. sl_subscript,
  663. sl_vec,
  664. sl_typeconv,
  665. sl_absolutetype
  666. );
  667. const
  668. slstr : array[tsltype] of string[12] = ('',
  669. 'load',
  670. 'call',
  671. 'subscript',
  672. 'vec',
  673. 'typeconv',
  674. 'absolutetype'
  675. );
  676. var
  677. sl : tsltype;
  678. begin
  679. readderef('');
  680. repeat
  681. sl:=tsltype(ppufile.getbyte);
  682. if sl=sl_none then
  683. break;
  684. write(s,'(',slstr[sl],') ');
  685. case sl of
  686. sl_call,
  687. sl_load,
  688. sl_subscript :
  689. readderef('');
  690. sl_absolutetype,
  691. sl_typeconv :
  692. readderef('');
  693. sl_vec :
  694. begin
  695. writeln(ppufile.getlongint);
  696. readderef('');
  697. end;
  698. end;
  699. until false;
  700. end;
  701. procedure readsymoptions(space : string);
  702. type
  703. { symbol options }
  704. tsymoption=(sp_none,
  705. sp_static,
  706. sp_hint_deprecated,
  707. sp_hint_platform,
  708. sp_hint_library,
  709. sp_hint_unimplemented,
  710. sp_hint_experimental,
  711. sp_has_overloaded,
  712. sp_internal, { internal symbol, not reported as unused }
  713. sp_implicitrename,
  714. sp_generic_para,
  715. sp_has_deprecated_msg
  716. );
  717. tsymoptions=set of tsymoption;
  718. tsymopt=record
  719. mask : tsymoption;
  720. str : string[30];
  721. end;
  722. const
  723. symopts=11;
  724. symopt : array[1..symopts] of tsymopt=(
  725. (mask:sp_static; str:'Static'),
  726. (mask:sp_hint_deprecated; str:'Hint Deprecated'),
  727. (mask:sp_hint_platform; str:'Hint Platform'),
  728. (mask:sp_hint_library; str:'Hint Library'),
  729. (mask:sp_hint_unimplemented; str:'Hint Unimplemented'),
  730. (mask:sp_hint_experimental; str:'Hint Experimental'),
  731. (mask:sp_has_overloaded; str:'Has overloaded'),
  732. (mask:sp_internal; str:'Internal'),
  733. (mask:sp_implicitrename; str:'Implicit Rename'),
  734. (mask:sp_generic_para; str:'Generic Parameter'),
  735. (mask:sp_has_deprecated_msg; str:'Has Deprecated Message')
  736. );
  737. var
  738. symoptions : tsymoptions;
  739. i : longint;
  740. first : boolean;
  741. begin
  742. ppufile.getsmallset(symoptions);
  743. if symoptions<>[] then
  744. begin
  745. first:=true;
  746. for i:=1to symopts do
  747. if (symopt[i].mask in symoptions) then
  748. begin
  749. if first then
  750. first:=false
  751. else
  752. write(', ');
  753. write(symopt[i].str);
  754. end;
  755. end;
  756. writeln;
  757. if sp_has_deprecated_msg in symoptions then
  758. writeln(space,'Deprecated : ', ppufile.getstring);
  759. end;
  760. procedure readcommonsym(const s:string);
  761. begin
  762. writeln(space,'** Symbol Id ',ppufile.getlongint,' **');
  763. writeln(space,s,ppufile.getstring);
  764. write (space,' File Pos : ');
  765. readposinfo;
  766. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  767. write (space,' SymOptions : ');
  768. readsymoptions(space+' ');
  769. end;
  770. type
  771. { flags for a definition }
  772. tdefoption=(df_none,
  773. { type is unique, i.e. declared with type = type <tdef>; }
  774. df_unique,
  775. { type is a generic }
  776. df_generic,
  777. { type is a specialization of a generic type }
  778. df_specialization,
  779. { def has been copied from another def so symtable is not owned }
  780. df_copied_def
  781. );
  782. tdefoptions=set of tdefoption;
  783. var
  784. { needed during tobjectdef parsing... }
  785. current_defoptions : tdefoptions;
  786. procedure readcommondef(const s:string);
  787. type
  788. tdefstate=(ds_none,
  789. ds_vmt_written,
  790. ds_rtti_table_used,
  791. ds_init_table_used,
  792. ds_rtti_table_written,
  793. ds_init_table_written,
  794. ds_dwarf_dbg_info_used,
  795. ds_dwarf_dbg_info_written
  796. );
  797. tdefstates=set of tdefstate;
  798. tdefopt=record
  799. mask : tdefoption;
  800. str : string[30];
  801. end;
  802. tdefstateinfo=record
  803. mask : tdefstate;
  804. str : string[30];
  805. end;
  806. const
  807. defopt : array[1..ord(high(tdefoption))] of tdefopt=(
  808. (mask:df_unique; str:'Unique Type'),
  809. (mask:df_generic; str:'Generic'),
  810. (mask:df_specialization; str:'Specialization'),
  811. (mask:df_copied_def; str:'Copied Typedef')
  812. );
  813. defstate : array[1..ord(high(tdefstate))] of tdefstateinfo=(
  814. (mask:ds_vmt_written; str:'VMT Written'),
  815. (mask:ds_rtti_table_used; str:'RTTITable Used'),
  816. (mask:ds_init_table_used; str:'InitTable Used'),
  817. (mask:ds_rtti_table_written; str:'RTTITable Written'),
  818. (mask:ds_init_table_written; str:'InitTable Written'),
  819. (mask:ds_dwarf_dbg_info_used; str:'Dwarf DbgInfo Used'),
  820. (mask:ds_dwarf_dbg_info_written;str:'Dwarf DbgInfo Written')
  821. );
  822. var
  823. defoptions : tdefoptions;
  824. defstates : tdefstates;
  825. i : longint;
  826. first : boolean;
  827. tokenbufsize : longint;
  828. tokenbuf : pbyte;
  829. len : sizeint;
  830. wstring : widestring;
  831. astring : ansistring;
  832. begin
  833. writeln(space,'** Definition Id ',ppufile.getlongint,' **');
  834. writeln(space,s);
  835. write (space,' Type symbol : ');
  836. readderef('');
  837. write (space,' DefOptions : ');
  838. ppufile.getsmallset(defoptions);
  839. if defoptions<>[] then
  840. begin
  841. first:=true;
  842. for i:=1to high(defopt) do
  843. if (defopt[i].mask in defoptions) then
  844. begin
  845. if first then
  846. first:=false
  847. else
  848. write(', ');
  849. write(defopt[i].str);
  850. end;
  851. end;
  852. writeln;
  853. write (space,' DefStates : ');
  854. ppufile.getsmallset(defstates);
  855. if defstates<>[] then
  856. begin
  857. first:=true;
  858. for i:=1to high(defstate) do
  859. if (defstate[i].mask in defstates) then
  860. begin
  861. if first then
  862. first:=false
  863. else
  864. write(', ');
  865. write(defstate[i].str);
  866. end;
  867. end;
  868. writeln;
  869. if df_generic in defoptions then
  870. begin
  871. tokenbufsize:=ppufile.getlongint;
  872. writeln(space,' Tokenbuffer size : ',tokenbufsize);
  873. tokenbuf:=allocmem(tokenbufsize);
  874. ppufile.getdata(tokenbuf^,tokenbufsize);
  875. i:=0;
  876. write(space,' Tokens: ');
  877. while i<tokenbufsize do
  878. begin
  879. if ttoken(tokenbuf[i])<>_GENERICSPECIALTOKEN then
  880. write(arraytokeninfo[ttoken(tokenbuf[i])].str);
  881. case ttoken(tokenbuf[i]) of
  882. _CWCHAR,
  883. _CWSTRING :
  884. begin
  885. inc(i);
  886. len:=psizeint(@tokenbuf[i])^;
  887. inc(i,sizeof(sizeint));
  888. setlength(wstring,len);
  889. move(tokenbuf[i],wstring[1],len*2);
  890. write(' ',wstring);
  891. inc(i,len*2);
  892. end;
  893. _CSTRING:
  894. begin
  895. inc(i);
  896. len:=psizeint(@tokenbuf[i])^;
  897. inc(i,sizeof(sizeint));
  898. setlength(astring,len);
  899. move(tokenbuf[i],astring[1],len);
  900. write(' ',astring);
  901. inc(i,len);
  902. end;
  903. _CCHAR,
  904. _INTCONST,
  905. _REALNUMBER :
  906. begin
  907. inc(i);
  908. write(' ',pshortstring(@tokenbuf[i])^);
  909. inc(i,tokenbuf[i]+1);
  910. end;
  911. _ID :
  912. begin
  913. inc(i);
  914. inc(i);
  915. write(' ',pshortstring(@tokenbuf[i])^);
  916. inc(i,tokenbuf[i]+1);
  917. {
  918. replaytokenbuf.read(orgpattern[0],1);
  919. replaytokenbuf.read(orgpattern[1],length(orgpattern));
  920. pattern:=upper(orgpattern);
  921. }
  922. end;
  923. _GENERICSPECIALTOKEN:
  924. begin
  925. inc(i);
  926. case tspecialgenerictoken(tokenbuf[i]) of
  927. ST_LOADSETTINGS:
  928. begin
  929. inc(i);
  930. write('Settings');
  931. inc(i,sizeof(tsettings));
  932. end;
  933. ST_LINE:
  934. begin
  935. inc(i);
  936. write('Line: ',pdword(@tokenbuf[i])^);
  937. inc(i,4);
  938. end;
  939. ST_COLUMN:
  940. begin
  941. inc(i);
  942. write('Col: ',pword(@tokenbuf[i])^);
  943. inc(i,2);
  944. end;
  945. ST_FILEINDEX:
  946. begin
  947. inc(i);
  948. write('File: ',pword(@tokenbuf[i])^);
  949. inc(i,2);
  950. end;
  951. end;
  952. {
  953. replaytokenbuf.read(specialtoken,1);
  954. case specialtoken of
  955. ST_LOADSETTINGS:
  956. begin
  957. replaytokenbuf.read(current_settings,sizeof(current_settings));
  958. end
  959. else
  960. internalerror(2006103010);
  961. end;
  962. continue;
  963. }
  964. end;
  965. else
  966. inc(i);
  967. end;
  968. if i<tokenbufsize then
  969. write(',');
  970. end;
  971. writeln;
  972. freemem(tokenbuf);
  973. end;
  974. if df_specialization in defoptions then
  975. begin
  976. write (space,' Orig. GenericDef : ');
  977. readderef('');
  978. end;
  979. current_defoptions:=defoptions;
  980. end;
  981. { Read abstract procdef and return if inline procdef }
  982. type
  983. tproccalloption=(pocall_none,
  984. { procedure uses C styled calling }
  985. pocall_cdecl,
  986. { C++ calling conventions }
  987. pocall_cppdecl,
  988. { Far16 for OS/2 }
  989. pocall_far16,
  990. { Old style FPC default calling }
  991. pocall_oldfpccall,
  992. { Procedure has compiler magic}
  993. pocall_internproc,
  994. { procedure is a system call, applies e.g. to MorphOS and PalmOS }
  995. pocall_syscall,
  996. { pascal standard left to right }
  997. pocall_pascal,
  998. { procedure uses register (fastcall) calling }
  999. pocall_register,
  1000. { safe call calling conventions }
  1001. pocall_safecall,
  1002. { procedure uses stdcall call }
  1003. pocall_stdcall,
  1004. { Special calling convention for cpus without a floating point
  1005. unit. Floating point numbers are passed in integer registers
  1006. instead of floating point registers. Depending on the other
  1007. available calling conventions available for the cpu
  1008. this replaces either pocall_fastcall or pocall_stdcall.
  1009. }
  1010. pocall_softfloat,
  1011. { Metrowerks Pascal. Special case on Mac OS (X): passes all }
  1012. { constant records by reference. }
  1013. pocall_mwpascal
  1014. );
  1015. tproccalloptions = set of tproccalloption;
  1016. tproctypeoption=(potype_none,
  1017. potype_proginit, { Program initialization }
  1018. potype_unitinit, { unit initialization }
  1019. potype_unitfinalize, { unit finalization }
  1020. potype_constructor, { Procedure is a constructor }
  1021. potype_destructor, { Procedure is a destructor }
  1022. potype_operator, { Procedure defines an operator }
  1023. potype_procedure,
  1024. potype_function,
  1025. potype_class_constructor, { class constructor }
  1026. potype_class_destructor { class destructor }
  1027. );
  1028. tproctypeoptions=set of tproctypeoption;
  1029. tprocoption=(po_none,
  1030. po_classmethod, { class method }
  1031. po_virtualmethod, { Procedure is a virtual method }
  1032. po_abstractmethod, { Procedure is an abstract method }
  1033. po_finalmethod, { Procedure is a final method }
  1034. po_staticmethod, { static method }
  1035. po_overridingmethod, { method with override directive }
  1036. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  1037. po_interrupt, { Procedure is an interrupt handler }
  1038. po_iocheck, { IO checking should be done after a call to the procedure }
  1039. po_assembler, { Procedure is written in assembler }
  1040. po_msgstr, { method for string message handling }
  1041. po_msgint, { method for int message handling }
  1042. po_exports, { Procedure has export directive (needed for OS/2) }
  1043. po_external, { Procedure is external (in other object or lib)}
  1044. po_overload, { procedure is declared with overload directive }
  1045. po_varargs, { printf like arguments }
  1046. po_internconst, { procedure has constant evaluator intern }
  1047. { flag that only the address of a method is returned and not a full methodpointer }
  1048. po_addressonly,
  1049. { procedure is exported }
  1050. po_public,
  1051. { calling convention is specified explicitly }
  1052. po_hascallingconvention,
  1053. { reintroduce flag }
  1054. po_reintroduce,
  1055. { location of parameters is given explicitly as it is necessary for some syscall
  1056. conventions like that one of MorphOS }
  1057. po_explicitparaloc,
  1058. { no stackframe will be generated, used by lowlevel assembler like get_frame }
  1059. po_nostackframe,
  1060. po_has_mangledname,
  1061. po_has_public_name,
  1062. po_forward,
  1063. po_global,
  1064. po_has_inlininginfo,
  1065. { The different kind of syscalls on MorphOS }
  1066. po_syscall_legacy,
  1067. po_syscall_sysv,
  1068. po_syscall_basesysv,
  1069. po_syscall_sysvbase,
  1070. po_syscall_r12base,
  1071. po_local,
  1072. { Procedure can be inlined }
  1073. po_inline,
  1074. { Procedure is used for internal compiler calls }
  1075. po_compilerproc,
  1076. { importing }
  1077. po_has_importdll,
  1078. po_has_importname,
  1079. po_kylixlocal,
  1080. po_dispid,
  1081. { weakly linked (i.e., may or may not exist at run time) }
  1082. po_weakexternal,
  1083. { Objective-C method }
  1084. po_objc,
  1085. { enumerator support }
  1086. po_enumerator_movenext,
  1087. { optional Objective-C protocol method }
  1088. po_optional
  1089. );
  1090. tprocoptions=set of tprocoption;
  1091. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions);
  1092. type
  1093. tproccallopt=record
  1094. mask : tproccalloption;
  1095. str : string[30];
  1096. end;
  1097. tproctypeopt=record
  1098. mask : tproctypeoption;
  1099. str : string[30];
  1100. end;
  1101. tprocopt=record
  1102. mask : tprocoption;
  1103. str : string[30];
  1104. end;
  1105. const
  1106. proccalloptionStr : array[tproccalloption] of string[14]=('',
  1107. 'CDecl',
  1108. 'CPPDecl',
  1109. 'Far16',
  1110. 'OldFPCCall',
  1111. 'InternProc',
  1112. 'SysCall',
  1113. 'Pascal',
  1114. 'Register',
  1115. 'SafeCall',
  1116. 'StdCall',
  1117. 'SoftFloat',
  1118. 'MWPascal'
  1119. );
  1120. proctypeopt : array[1..ord(high(tproctypeoption))] of tproctypeopt=(
  1121. (mask:potype_proginit; str:'ProgInit'),
  1122. (mask:potype_unitinit; str:'UnitInit'),
  1123. (mask:potype_unitfinalize; str:'UnitFinalize'),
  1124. (mask:potype_constructor; str:'Constructor'),
  1125. (mask:potype_destructor; str:'Destructor'),
  1126. (mask:potype_operator; str:'Operator'),
  1127. (mask:potype_procedure; str:'Procedure'),
  1128. (mask:potype_function; str:'Function'),
  1129. (mask:potype_class_constructor; str:'Class Constructor'),
  1130. (mask:potype_class_destructor; str:'Class Destructor')
  1131. );
  1132. procopt : array[1..ord(high(tprocoption))] of tprocopt=(
  1133. (mask:po_classmethod; str:'ClassMethod'),
  1134. (mask:po_virtualmethod; str:'VirtualMethod'),
  1135. (mask:po_abstractmethod; str:'AbstractMethod'),
  1136. (mask:po_finalmethod; str:'FinalMethod'),
  1137. (mask:po_staticmethod; str:'StaticMethod'),
  1138. (mask:po_overridingmethod;str:'OverridingMethod'),
  1139. (mask:po_methodpointer; str:'MethodPointer'),
  1140. (mask:po_interrupt; str:'Interrupt'),
  1141. (mask:po_iocheck; str:'IOCheck'),
  1142. (mask:po_assembler; str:'Assembler'),
  1143. (mask:po_msgstr; str:'MsgStr'),
  1144. (mask:po_msgint; str:'MsgInt'),
  1145. (mask:po_exports; str:'Exports'),
  1146. (mask:po_external; str:'External'),
  1147. (mask:po_overload; str:'Overload'),
  1148. (mask:po_varargs; str:'VarArgs'),
  1149. (mask:po_internconst; str:'InternConst'),
  1150. (mask:po_addressonly; str:'AddressOnly'),
  1151. (mask:po_public; str:'Public'),
  1152. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  1153. (mask:po_reintroduce; str:'ReIntroduce'),
  1154. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  1155. (mask:po_nostackframe; str:'NoStackFrame'),
  1156. (mask:po_has_mangledname; str:'HasMangledName'),
  1157. (mask:po_has_public_name; str:'HasPublicName'),
  1158. (mask:po_forward; str:'Forward'),
  1159. (mask:po_global; str:'Global'),
  1160. (mask:po_has_inlininginfo;str:'HasInliningInfo'),
  1161. (mask:po_syscall_legacy; str:'SyscallLegacy'),
  1162. (mask:po_syscall_sysv; str:'SyscallSysV'),
  1163. (mask:po_syscall_basesysv;str:'SyscallBaseSysV'),
  1164. (mask:po_syscall_sysvbase;str:'SyscallSysVBase'),
  1165. (mask:po_syscall_r12base; str:'SyscallR12Base'),
  1166. (mask:po_local; str:'Local'),
  1167. (mask:po_inline; str:'Inline'),
  1168. (mask:po_compilerproc; str:'CompilerProc'),
  1169. (mask:po_has_importdll; str:'HasImportDLL'),
  1170. (mask:po_has_importname; str:'HasImportName'),
  1171. (mask:po_kylixlocal; str:'KylixLocal'),
  1172. (mask:po_dispid; str:'DispId'),
  1173. (mask:po_weakexternal; str:'WeakExternal'),
  1174. (mask:po_objc; str:'ObjC'),
  1175. (mask:po_enumerator_movenext; str:'EnumeratorMoveNext'),
  1176. (mask:po_optional; str: 'Optional')
  1177. );
  1178. var
  1179. proctypeoption : tproctypeoption;
  1180. i : longint;
  1181. first : boolean;
  1182. tempbuf : array[0..255] of byte;
  1183. begin
  1184. write(space,' Return type : ');
  1185. readderef('');
  1186. writeln(space,' Fpu used : ',ppufile.getbyte);
  1187. proctypeoption:=tproctypeoption(ppufile.getbyte);
  1188. write(space,' TypeOption : ');
  1189. first:=true;
  1190. for i:=1 to high(proctypeopt) do
  1191. if (proctypeopt[i].mask=proctypeoption) then
  1192. begin
  1193. if first then
  1194. first:=false
  1195. else
  1196. write(', ');
  1197. write(proctypeopt[i].str);
  1198. end;
  1199. writeln;
  1200. proccalloption:=tproccalloption(ppufile.getbyte);
  1201. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  1202. ppufile.getnormalset(procoptions);
  1203. if procoptions<>[] then
  1204. begin
  1205. write(space,' Options : ');
  1206. first:=true;
  1207. for i:=1 to high(procopt) do
  1208. if (procopt[i].mask in procoptions) then
  1209. begin
  1210. if first then
  1211. first:=false
  1212. else
  1213. write(', ');
  1214. write(procopt[i].str);
  1215. end;
  1216. writeln;
  1217. end;
  1218. if (po_explicitparaloc in procoptions) then
  1219. begin
  1220. i:=ppufile.getbyte;
  1221. ppufile.getdata(tempbuf,i);
  1222. end;
  1223. end;
  1224. type
  1225. tvaroption=(vo_none,
  1226. vo_is_external,
  1227. vo_is_dll_var,
  1228. vo_is_thread_var,
  1229. vo_has_local_copy,
  1230. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  1231. vo_is_public,
  1232. vo_is_high_para,
  1233. vo_is_funcret,
  1234. vo_is_self,
  1235. vo_is_vmt,
  1236. vo_is_result, { special result variable }
  1237. vo_is_parentfp,
  1238. vo_is_loop_counter, { used to detect assignments to loop counter }
  1239. vo_is_hidden_para,
  1240. vo_has_explicit_paraloc,
  1241. vo_is_syscall_lib,
  1242. vo_has_mangledname,
  1243. vo_is_typed_const,
  1244. vo_is_range_check,
  1245. vo_is_overflow_check,
  1246. vo_is_typinfo_para,
  1247. vo_is_weak_external,
  1248. vo_is_msgsel,
  1249. vo_is_first_field
  1250. );
  1251. tvaroptions=set of tvaroption;
  1252. { register variable }
  1253. tvarregable=(vr_none,
  1254. vr_intreg,
  1255. vr_fpureg,
  1256. vr_mmreg,
  1257. { does not mean "needs address register", but "if it's a parameter which is }
  1258. { passed by reference, then its address can be put in a register }
  1259. vr_addr
  1260. );
  1261. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions);
  1262. type
  1263. tvaropt=record
  1264. mask : tvaroption;
  1265. str : string[30];
  1266. end;
  1267. const
  1268. varopt : array[1..ord(high(tvaroption))] of tvaropt=(
  1269. (mask:vo_is_external; str:'External'),
  1270. (mask:vo_is_dll_var; str:'DLLVar'),
  1271. (mask:vo_is_thread_var; str:'ThreadVar'),
  1272. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  1273. (mask:vo_is_const; str:'Constant'),
  1274. (mask:vo_is_public; str:'Public'),
  1275. (mask:vo_is_high_para; str:'HighValue'),
  1276. (mask:vo_is_funcret; str:'Funcret'),
  1277. (mask:vo_is_self; str:'Self'),
  1278. (mask:vo_is_vmt; str:'VMT'),
  1279. (mask:vo_is_result; str:'Result'),
  1280. (mask:vo_is_parentfp; str:'ParentFP'),
  1281. (mask:vo_is_loop_counter; str:'LoopCounter'),
  1282. (mask:vo_is_hidden_para; str:'Hidden'),
  1283. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  1284. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  1285. (mask:vo_has_mangledname; str:'HasMangledName'),
  1286. (mask:vo_is_typed_const; str:'TypedConst'),
  1287. (mask:vo_is_range_check; str:'RangeCheckSwitch'),
  1288. (mask:vo_is_overflow_check; str:'OverflowCheckSwitch'),
  1289. (mask:vo_is_typinfo_para; str:'TypeInfo'),
  1290. (mask:vo_is_msgsel;str:'MsgSel'),
  1291. (mask:vo_is_weak_external;str:'WeakExternal'),
  1292. (mask:vo_is_first_field;str:'IsFirstField')
  1293. );
  1294. var
  1295. i : longint;
  1296. first : boolean;
  1297. begin
  1298. readcommonsym(s);
  1299. writeln(space,' Spez : ',Varspez2Str(ppufile.getbyte));
  1300. writeln(space,' Regable : ',Varregable2Str(ppufile.getbyte));
  1301. writeln(space,' Addr Taken : ',(ppufile.getbyte<>0));
  1302. write (space,' Var Type : ');
  1303. readderef('');
  1304. ppufile.getsmallset(varoptions);
  1305. if varoptions<>[] then
  1306. begin
  1307. write(space,' Options : ');
  1308. first:=true;
  1309. for i:=1 to high(varopt) do
  1310. if (varopt[i].mask in varoptions) then
  1311. begin
  1312. if first then
  1313. first:=false
  1314. else
  1315. write(', ');
  1316. write(varopt[i].str);
  1317. end;
  1318. writeln;
  1319. end;
  1320. end;
  1321. procedure readobjectdefoptions;
  1322. type
  1323. tobjectoption=(oo_none,
  1324. oo_is_forward, { the class is only a forward declared yet }
  1325. oo_is_abstract, { the class is abstract - only descendants can be used }
  1326. oo_is_sealed, { the class is sealed - can't have descendants }
  1327. oo_has_virtual, { the object/class has virtual methods }
  1328. oo_has_private,
  1329. oo_has_protected,
  1330. oo_has_strictprivate,
  1331. oo_has_strictprotected,
  1332. oo_has_constructor, { the object/class has a constructor }
  1333. oo_has_destructor, { the object/class has a destructor }
  1334. oo_has_vmt, { the object/class has a vmt }
  1335. oo_has_msgstr,
  1336. oo_has_msgint,
  1337. oo_can_have_published,{ the class has rtti, i.e. you can publish properties }
  1338. oo_has_default_property,
  1339. oo_has_valid_guid,
  1340. oo_has_enumerator_movenext,
  1341. oo_has_enumerator_current,
  1342. oo_is_external, { the class is externally implemented (objcclass, cppclass) }
  1343. oo_is_anonymous, { the class is only formally defined in this module (objcclass x = class; external;) }
  1344. oo_is_classhelper, { objcclasses that represent categories, and Delpi-style class helpers, are marked like this }
  1345. oo_has_class_constructor, { the object/class has a class constructor }
  1346. oo_has_class_destructor { the object/class has a class destructor }
  1347. );
  1348. tobjectoptions=set of tobjectoption;
  1349. tsymopt=record
  1350. mask : tobjectoption;
  1351. str : string[30];
  1352. end;
  1353. const
  1354. symopt : array[1..ord(high(tobjectoption))] of tsymopt=(
  1355. (mask:oo_is_forward; str:'IsForward'),
  1356. (mask:oo_is_abstract; str:'IsAbstract'),
  1357. (mask:oo_is_sealed; str:'IsSealed'),
  1358. (mask:oo_has_virtual; str:'HasVirtual'),
  1359. (mask:oo_has_private; str:'HasPrivate'),
  1360. (mask:oo_has_protected; str:'HasProtected'),
  1361. (mask:oo_has_strictprivate; str:'HasStrictPrivate'),
  1362. (mask:oo_has_strictprotected;str:'HasStrictProtected'),
  1363. (mask:oo_has_constructor; str:'HasConstructor'),
  1364. (mask:oo_has_destructor; str:'HasDestructor'),
  1365. (mask:oo_has_vmt; str:'HasVMT'),
  1366. (mask:oo_has_msgstr; str:'HasMsgStr'),
  1367. (mask:oo_has_msgint; str:'HasMsgInt'),
  1368. (mask:oo_can_have_published; str:'CanHavePublished'),
  1369. (mask:oo_has_default_property;str:'HasDefaultProperty'),
  1370. (mask:oo_has_valid_guid; str:'HasValidGUID'),
  1371. (mask:oo_has_enumerator_movenext; str:'HasEnumeratorMoveNext'),
  1372. (mask:oo_has_enumerator_current; str:'HasEnumeratorCurrent'),
  1373. (mask:oo_is_external; str:'External'),
  1374. (mask:oo_is_anonymous; str:'Anonymous'),
  1375. (mask:oo_is_classhelper; str:'Class Helper/Category'),
  1376. (mask:oo_has_class_constructor; str:'HasClassConstructor'),
  1377. (mask:oo_has_class_destructor; str:'HasClassDestructor')
  1378. );
  1379. var
  1380. symoptions : tobjectoptions;
  1381. i : longint;
  1382. first : boolean;
  1383. begin
  1384. ppufile.getsmallset(symoptions);
  1385. if symoptions<>[] then
  1386. begin
  1387. first:=true;
  1388. for i:=1 to high(symopt) do
  1389. if (symopt[i].mask in symoptions) then
  1390. begin
  1391. if first then
  1392. first:=false
  1393. else
  1394. write(', ');
  1395. write(symopt[i].str);
  1396. end;
  1397. end;
  1398. writeln;
  1399. end;
  1400. procedure readarraydefoptions;
  1401. type
  1402. tarraydefoption=(ado_none,
  1403. ado_IsConvertedPointer,
  1404. ado_IsDynamicArray,
  1405. ado_IsVariant,
  1406. ado_IsConstructor,
  1407. ado_IsArrayOfConst,
  1408. ado_IsConstString,
  1409. ado_IsBitPacked
  1410. );
  1411. tarraydefoptions=set of tarraydefoption;
  1412. tsymopt=record
  1413. mask : tarraydefoption;
  1414. str : string[30];
  1415. end;
  1416. const
  1417. symopt : array[1..ord(high(tarraydefoption))] of tsymopt=(
  1418. (mask:ado_IsConvertedPointer;str:'ConvertedPointer'),
  1419. (mask:ado_IsDynamicArray; str:'IsDynamicArray'),
  1420. (mask:ado_IsVariant; str:'IsVariant'),
  1421. (mask:ado_IsConstructor; str:'IsConstructor'),
  1422. (mask:ado_IsArrayOfConst; str:'ArrayOfConst'),
  1423. (mask:ado_IsConstString; str:'ConstString'),
  1424. (mask:ado_IsBitPacked; str:'BitPacked')
  1425. );
  1426. var
  1427. symoptions : tarraydefoptions;
  1428. i : longint;
  1429. first : boolean;
  1430. begin
  1431. ppufile.getsmallset(symoptions);
  1432. if symoptions<>[] then
  1433. begin
  1434. first:=true;
  1435. for i:=1 to high(symopt) do
  1436. if (symopt[i].mask in symoptions) then
  1437. begin
  1438. if first then
  1439. first:=false
  1440. else
  1441. write(', ');
  1442. write(symopt[i].str);
  1443. end;
  1444. end;
  1445. writeln;
  1446. end;
  1447. procedure readnodetree;
  1448. var
  1449. l : longint;
  1450. p : pointer;
  1451. begin
  1452. with ppufile do
  1453. begin
  1454. if space<>'' then
  1455. Writeln(space,'------ nodetree ------');
  1456. if readentry=ibnodetree then
  1457. begin
  1458. l:=entrysize;
  1459. Writeln(space,'Tree size : ',l);
  1460. { Read data to prevent error that entry is not completly read }
  1461. getmem(p,l);
  1462. getdata(p^,l);
  1463. freemem(p);
  1464. end
  1465. else
  1466. begin
  1467. Writeln('!! ibnodetree not found');
  1468. end;
  1469. end;
  1470. end;
  1471. procedure ReadCreatedObjTypes;
  1472. var
  1473. i,j,
  1474. len,
  1475. bssize: longint;
  1476. bs: pbyte;
  1477. begin
  1478. if ppufile.readentry<>ibcreatedobjtypes then
  1479. begin
  1480. writeln('!! ibcreatedobjtypes entry not found');
  1481. ppufile.skipdata(ppufile.entrysize);
  1482. exit
  1483. end;
  1484. writeln;
  1485. writeln(space,'WPO info');
  1486. writeln(space,'--------');
  1487. len:=ppufile.getlongint;
  1488. writeln(space,'** Instantiated Object/Class types: ',len,' **');
  1489. space:=space+' ';
  1490. for i:=0 to len-1 do
  1491. readderef(space);
  1492. setlength(space,length(space)-2);
  1493. len:=ppufile.getlongint;
  1494. writeln(space,'** Instantiated ClassRef types: ',len,' **');
  1495. space:=space+' ';
  1496. for i:=0 to len-1 do
  1497. readderef(space);
  1498. setlength(space,length(space)-2);
  1499. len:=ppufile.getlongint;
  1500. writeln(space,'** Possibly instantiated ClassRef types : ',len,' **');
  1501. space:=space+' ';
  1502. for i:=0 to len-1 do
  1503. readderef(space);
  1504. setlength(space,length(space)-2);
  1505. len:=ppufile.getlongint;
  1506. writeln(space,'** Class types with called virtual methods info : ',len,' **');
  1507. space:=space+' ';
  1508. for i:=0 to len-1 do
  1509. begin
  1510. write(space,'Class def : ');
  1511. readderef('');
  1512. write(space+' ','Called vmtentries : ');
  1513. bssize:=ppufile.getlongint;
  1514. getmem(bs,bssize);
  1515. ppufile.readdata(bs^,bssize);
  1516. for j:=0 to bssize*8-1 do
  1517. if (((bs+j shr 3)^ shr (j and 7)) and 1) <> 0 then
  1518. write(j,', ');
  1519. writeln;
  1520. freemem(bs);
  1521. end;
  1522. setlength(space,length(space)-2);
  1523. end;
  1524. {****************************************************************************
  1525. Read Symbols Part
  1526. ****************************************************************************}
  1527. procedure readsymbols(const s:string);
  1528. type
  1529. pguid = ^tguid;
  1530. tguid = packed record
  1531. D1: LongWord;
  1532. D2: Word;
  1533. D3: Word;
  1534. D4: array[0..7] of Byte;
  1535. end;
  1536. absolutetyp = (tovar,toasm,toaddr);
  1537. tconsttyp = (constnone,
  1538. constord,conststring,constreal,
  1539. constset,constpointer,constnil,
  1540. constresourcestring,constwstring,constguid
  1541. );
  1542. var
  1543. b : byte;
  1544. pc : pchar;
  1545. i,j,len : longint;
  1546. guid : tguid;
  1547. tempbuf : array[0..127] of char;
  1548. varoptions : tvaroptions;
  1549. begin
  1550. with ppufile do
  1551. begin
  1552. if space<>'' then
  1553. Writeln(space,'------ ',s,' ------');
  1554. if readentry=ibstartsyms then
  1555. begin
  1556. Writeln(space,'Symtable datasize : ',getlongint);
  1557. Writeln(space,'Symtable alignment: ',getlongint);
  1558. end
  1559. else
  1560. Writeln('!! ibstartsym not found');
  1561. repeat
  1562. b:=readentry;
  1563. case b of
  1564. ibunitsym :
  1565. readcommonsym('Unit symbol ');
  1566. iblabelsym :
  1567. readcommonsym('Label symbol ');
  1568. ibtypesym :
  1569. begin
  1570. readcommonsym('Type symbol ');
  1571. write(space,' Result Type : ');
  1572. readderef('');
  1573. end;
  1574. ibprocsym :
  1575. begin
  1576. readcommonsym('Procedure symbol ');
  1577. len:=ppufile.getword;
  1578. for i:=1 to len do
  1579. begin
  1580. write(space,' Definition : ');
  1581. readderef('');
  1582. end;
  1583. end;
  1584. ibconstsym :
  1585. begin
  1586. readcommonsym('Constant symbol ');
  1587. b:=getbyte;
  1588. case tconsttyp(b) of
  1589. constord :
  1590. begin
  1591. write (space,' OrdinalType : ');
  1592. readderef('');
  1593. writeln(space,' Value : ',constexp.tostr(getexprint));
  1594. end;
  1595. constpointer :
  1596. begin
  1597. write (space,' PointerType : ');
  1598. readderef('');
  1599. writeln(space,' Value : ',getlongint)
  1600. end;
  1601. conststring,
  1602. constresourcestring :
  1603. begin
  1604. len:=getlongint;
  1605. getmem(pc,len+1);
  1606. getdata(pc^,len);
  1607. (pc+len)^:= #0;
  1608. writeln(space,' Length : ',len);
  1609. writeln(space,' Value : "',pc,'"');
  1610. freemem(pc,len+1);
  1611. end;
  1612. constreal :
  1613. writeln(space,' Value : ',getreal);
  1614. constset :
  1615. begin
  1616. write (space,' Set Type : ');
  1617. readderef('');
  1618. for i:=1to 4 do
  1619. begin
  1620. write (space,' Value : ');
  1621. for j:=1to 8 do
  1622. begin
  1623. if j>1 then
  1624. write(',');
  1625. write(hexstr(getbyte,2));
  1626. end;
  1627. writeln;
  1628. end;
  1629. end;
  1630. constwstring:
  1631. begin
  1632. end;
  1633. constguid:
  1634. begin
  1635. getdata(guid,sizeof(guid));
  1636. write (space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-');
  1637. for i:=0 to 7 do
  1638. begin
  1639. write(hexstr(guid.d4[i],2));
  1640. if i=1 then write('-');
  1641. end;
  1642. writeln('}');
  1643. end
  1644. else
  1645. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  1646. end;
  1647. end;
  1648. ibabsolutevarsym :
  1649. begin
  1650. readabstractvarsym('Absolute variable symbol ',varoptions);
  1651. Write (space,' Relocated to ');
  1652. b:=getbyte;
  1653. case absolutetyp(b) of
  1654. tovar :
  1655. readpropaccesslist(space+' Sym : ');
  1656. toasm :
  1657. Writeln('Assembler name : ',getstring);
  1658. toaddr :
  1659. begin
  1660. Write('Address : ',getlongint);
  1661. if tsystemcpu(ppufile.header.cpu)=cpu_i386 then
  1662. WriteLn(' (Far: ',getbyte<>0,')');
  1663. end;
  1664. else
  1665. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  1666. end;
  1667. end;
  1668. ibfieldvarsym :
  1669. begin
  1670. readabstractvarsym('Field Variable symbol ',varoptions);
  1671. writeln(space,' Address : ',getaint);
  1672. end;
  1673. ibstaticvarsym :
  1674. begin
  1675. readabstractvarsym('Global Variable symbol ',varoptions);
  1676. write (space,' DefaultConst : ');
  1677. readderef('');
  1678. if (vo_has_mangledname in varoptions) then
  1679. writeln(space,' Mangledname : ',getstring);
  1680. end;
  1681. iblocalvarsym :
  1682. begin
  1683. readabstractvarsym('Local Variable symbol ',varoptions);
  1684. write (space,' DefaultConst : ');
  1685. readderef('');
  1686. end;
  1687. ibparavarsym :
  1688. begin
  1689. readabstractvarsym('Parameter Variable symbol ',varoptions);
  1690. write (space,' DefaultConst : ');
  1691. readderef('');
  1692. writeln(space,' ParaNr : ',getword);
  1693. writeln(space,' Univ : ',boolean(getbyte));
  1694. writeln(space,' VarState : ',getbyte);
  1695. if (vo_has_explicit_paraloc in varoptions) then
  1696. begin
  1697. i:=getbyte;
  1698. getdata(tempbuf,i);
  1699. end;
  1700. end;
  1701. ibenumsym :
  1702. begin
  1703. readcommonsym('Enumeration symbol ');
  1704. write (space,' Definition : ');
  1705. readderef('');
  1706. writeln(space,' Value : ',getlongint);
  1707. end;
  1708. ibsyssym :
  1709. begin
  1710. readcommonsym('Internal system symbol ');
  1711. writeln(space,' Internal Nr : ',getlongint);
  1712. end;
  1713. ibmacrosym :
  1714. begin
  1715. readcommonsym('Macro symbol ');
  1716. writeln(space,' Name: ',getstring);
  1717. writeln(space,' Defined: ',getbyte);
  1718. writeln(space,' Compiler var: ',getbyte);
  1719. len:=getlongint;
  1720. writeln(space,' Value length: ',len);
  1721. if len > 0 then
  1722. begin
  1723. getmem(pc,len+1);
  1724. getdata(pc^,len);
  1725. (pc+len)^:= #0;
  1726. writeln(space,' Value: "',pc,'"');
  1727. freemem(pc,len+1);
  1728. end;
  1729. end;
  1730. ibpropertysym :
  1731. begin
  1732. readcommonsym('Property ');
  1733. i:=getlongint;
  1734. writeln(space,' PropOptions : ',i);
  1735. write (space,' OverrideProp : ');
  1736. readderef('');
  1737. write (space,' Prop Type : ');
  1738. readderef('');
  1739. writeln(space,' Index : ',getlongint);
  1740. writeln(space,' Default : ',getlongint);
  1741. write (space,' Index Type : ');
  1742. readderef('');
  1743. write (space,' Readaccess : ');
  1744. readpropaccesslist(space+' Sym: ');
  1745. write (space,' Writeaccess : ');
  1746. readpropaccesslist(space+' Sym: ');
  1747. write (space,' Storedaccess : ');
  1748. readpropaccesslist(space+' Sym: ');
  1749. end;
  1750. iberror :
  1751. begin
  1752. Writeln('!! Error in PPU');
  1753. exit;
  1754. end;
  1755. ibendsyms :
  1756. break;
  1757. else
  1758. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  1759. end;
  1760. if not EndOfEntry then
  1761. Writeln('!! Entry has more information stored');
  1762. until false;
  1763. end;
  1764. end;
  1765. {****************************************************************************
  1766. Read defintions Part
  1767. ****************************************************************************}
  1768. procedure readdefinitions(const s:string);
  1769. type
  1770. tordtype = (
  1771. uvoid,
  1772. u8bit,u16bit,u32bit,u64bit,
  1773. s8bit,s16bit,s32bit,s64bit,
  1774. bool8bit,bool16bit,bool32bit,bool64bit,
  1775. uchar,uwidechar,scurrency
  1776. );
  1777. tobjecttyp = (odt_none,
  1778. odt_class,
  1779. odt_object,
  1780. odt_interfacecom,
  1781. odt_interfacecom_property,
  1782. odt_interfacecom_function,
  1783. odt_interfacecorba,
  1784. odt_cppclass,
  1785. odt_dispinterface,
  1786. odt_objcclass,
  1787. odt_objcprotocol
  1788. );
  1789. tvarianttype = (
  1790. vt_normalvariant,vt_olevariant
  1791. );
  1792. var
  1793. b : byte;
  1794. l,j : longint;
  1795. calloption : tproccalloption;
  1796. procoptions : tprocoptions;
  1797. procinfooptions : tprocinfoflag;
  1798. begin
  1799. with ppufile do
  1800. begin
  1801. if space<>'' then
  1802. Writeln(space,'------ ',s,' ------');
  1803. if readentry<>ibstartdefs then
  1804. Writeln('!! ibstartdefs not found');
  1805. repeat
  1806. b:=readentry;
  1807. case b of
  1808. ibpointerdef :
  1809. begin
  1810. readcommondef('Pointer definition');
  1811. write (space,' Pointed Type : ');
  1812. readderef('');
  1813. writeln(space,' Is Far : ',(getbyte<>0));
  1814. end;
  1815. iborddef :
  1816. begin
  1817. readcommondef('Ordinal definition');
  1818. write (space,' Base type : ');
  1819. b:=getbyte;
  1820. case tordtype(b) of
  1821. uvoid : writeln('uvoid');
  1822. u8bit : writeln('u8bit');
  1823. u16bit : writeln('u16bit');
  1824. u32bit : writeln('s32bit');
  1825. u64bit : writeln('u64bit');
  1826. s8bit : writeln('s8bit');
  1827. s16bit : writeln('s16bit');
  1828. s32bit : writeln('s32bit');
  1829. s64bit : writeln('s64bit');
  1830. bool8bit : writeln('bool8bit');
  1831. bool16bit : writeln('bool16bit');
  1832. bool32bit : writeln('bool32bit');
  1833. bool64bit : writeln('bool64bit');
  1834. uchar : writeln('uchar');
  1835. uwidechar : writeln('uwidechar');
  1836. scurrency : writeln('ucurrency');
  1837. else writeln('!! Warning: Invalid base type ',b);
  1838. end;
  1839. writeln(space,' Range : ',constexp.tostr(getexprint),' to ',constexp.tostr(getexprint));
  1840. end;
  1841. ibfloatdef :
  1842. begin
  1843. readcommondef('Float definition');
  1844. writeln(space,' Float type : ',getbyte);
  1845. end;
  1846. ibarraydef :
  1847. begin
  1848. readcommondef('Array definition');
  1849. write (space,' Element type : ');
  1850. readderef('');
  1851. write (space,' Range Type : ');
  1852. readderef('');
  1853. writeln(space,' Range : ',getaint,' to ',getaint);
  1854. write (space,' Options : ');
  1855. readarraydefoptions;
  1856. end;
  1857. ibprocdef :
  1858. begin
  1859. readcommondef('Procedure definition');
  1860. read_abstract_proc_def(calloption,procoptions);
  1861. if (po_has_mangledname in procoptions) then
  1862. writeln(space,' Mangled name : ',getstring);
  1863. writeln(space,' Number : ',getword);
  1864. writeln(space,' Level : ',getbyte);
  1865. write (space,' Class : ');
  1866. readderef('');
  1867. write (space,' Procsym : ');
  1868. readderef('');
  1869. write (space,' File Pos : ');
  1870. readposinfo;
  1871. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  1872. write (space,' SymOptions : ');
  1873. readsymoptions(space+' ');
  1874. if tsystemcpu(ppufile.header.cpu)=cpu_powerpc then
  1875. begin
  1876. { library symbol for AmigaOS/MorphOS }
  1877. write (space,' Library symbol : ');
  1878. readderef('');
  1879. end;
  1880. if (po_has_importdll in procoptions) then
  1881. writeln(space,' Import DLL : ',getstring);
  1882. if (po_has_importname in procoptions) then
  1883. writeln(space,' Import Name : ',getstring);
  1884. writeln(space,' Import Nr : ',getword);
  1885. if (po_msgint in procoptions) then
  1886. writeln(space,' MsgInt : ',getlongint);
  1887. if (po_msgstr in procoptions) then
  1888. writeln(space,' MsgStr : ',getstring);
  1889. if (po_dispid in procoptions) then
  1890. writeln(space,' DispID: ',ppufile.getlongint);
  1891. if (po_has_inlininginfo in procoptions) then
  1892. begin
  1893. write (space,' FuncretSym : ');
  1894. readderef('');
  1895. ppufile.getsmallset(procinfooptions);
  1896. writeln(space,' ProcInfoOptions : ',dword(procinfooptions));
  1897. end;
  1898. b:=ppufile.getbyte;
  1899. if b<>0 then
  1900. begin
  1901. write (space,' Alias names : ');
  1902. for j:=1 to b do
  1903. begin
  1904. write(ppufile.getstring);
  1905. if j<b then
  1906. write(', ');
  1907. end;
  1908. writeln;
  1909. end;
  1910. if not EndOfEntry then
  1911. Writeln('!! Entry has more information stored');
  1912. space:=' '+space;
  1913. { parast }
  1914. readdefinitions('parast');
  1915. readsymbols('parast');
  1916. { localst }
  1917. if (po_has_inlininginfo in procoptions) then
  1918. begin
  1919. readdefinitions('localst');
  1920. readsymbols('localst');
  1921. end;
  1922. if (po_has_inlininginfo in procoptions) then
  1923. readnodetree;
  1924. delete(space,1,4);
  1925. end;
  1926. ibprocvardef :
  1927. begin
  1928. readcommondef('Procedural type (ProcVar) definition');
  1929. read_abstract_proc_def(calloption,procoptions);
  1930. if not EndOfEntry then
  1931. Writeln('!! Entry has more information stored');
  1932. space:=' '+space;
  1933. { parast }
  1934. readdefinitions('parast');
  1935. readsymbols('parast');
  1936. delete(space,1,4);
  1937. end;
  1938. ibshortstringdef :
  1939. begin
  1940. readcommondef('ShortString definition');
  1941. writeln(space,' Length : ',getbyte);
  1942. end;
  1943. ibwidestringdef :
  1944. begin
  1945. readcommondef('WideString definition');
  1946. writeln(space,' Length : ',getlongint);
  1947. end;
  1948. ibansistringdef :
  1949. begin
  1950. readcommondef('AnsiString definition');
  1951. writeln(space,' Length : ',getlongint);
  1952. end;
  1953. iblongstringdef :
  1954. begin
  1955. readcommondef('Longstring definition');
  1956. writeln(space,' Length : ',getlongint);
  1957. end;
  1958. ibrecorddef :
  1959. begin
  1960. readcommondef('Record definition');
  1961. writeln(space,' FieldAlign : ',getbyte);
  1962. writeln(space,' RecordAlign : ',getbyte);
  1963. writeln(space,' PadAlign : ',getbyte);
  1964. writeln(space,'UseFieldAlignment : ',getbyte);
  1965. writeln(space,' DataSize : ',getaint);
  1966. if not EndOfEntry then
  1967. Writeln('!! Entry has more information stored');
  1968. {read the record definitions and symbols}
  1969. space:=' '+space;
  1970. readdefinitions('fields');
  1971. readsymbols('fields');
  1972. Delete(space,1,4);
  1973. end;
  1974. ibobjectdef :
  1975. begin
  1976. readcommondef('Object/Class definition');
  1977. b:=getbyte;
  1978. write (space,' Type : ');
  1979. case tobjecttyp(b) of
  1980. odt_class : writeln('class');
  1981. odt_object : writeln('object');
  1982. odt_interfacecom : writeln('interfacecom');
  1983. odt_interfacecorba : writeln('interfacecorba');
  1984. odt_cppclass : writeln('cppclass');
  1985. odt_dispinterface : writeln('dispinterface');
  1986. odt_objcclass : writeln('objcclass');
  1987. odt_objcprotocol : writeln('objcprotocol');
  1988. else writeln('!! Warning: Invalid object type ',b);
  1989. end;
  1990. writeln(space,' Name of Class : ',getstring);
  1991. writeln(space,' External name : ',getstring);
  1992. writeln(space,' Import lib : ',getstring);
  1993. writeln(space,' DataSize : ',getaint);
  1994. writeln(space,' FieldAlign : ',getbyte);
  1995. writeln(space,' RecordAlign : ',getbyte);
  1996. writeln(space,' Vmt offset : ',getlongint);
  1997. write (space, ' Ancestor Class : ');
  1998. readderef('');
  1999. write (space,' Options : ');
  2000. readobjectdefoptions;
  2001. if tobjecttyp(b) in [odt_interfacecom,odt_interfacecorba,odt_dispinterface] then
  2002. begin
  2003. { IIDGUID }
  2004. for j:=1to 16 do
  2005. getbyte;
  2006. writeln(space,' IID String : ',getstring);
  2007. writeln(space,' Last VTable idx : ',getlongint);
  2008. end;
  2009. l:=getlongint;
  2010. writeln(space,' VMT entries: ',l);
  2011. for j:=1 to l do
  2012. begin
  2013. write(space,' ');
  2014. readderef('');
  2015. writeln(space,' Visibility: ',Visibility2Str(getbyte));
  2016. end;
  2017. if tobjecttyp(b) in [odt_class,odt_interfacecorba,odt_objcclass,odt_objcprotocol] then
  2018. begin
  2019. l:=getlongint;
  2020. writeln(space,' Impl Intf Count : ',l);
  2021. for j:=1 to l do
  2022. begin
  2023. write (space,' - Definition : ');
  2024. readderef('');
  2025. writeln(space,' IOffset : ',getlongint);
  2026. end;
  2027. end;
  2028. if df_copied_def in current_defoptions then
  2029. begin
  2030. writeln(' Copy of def: ');
  2031. readderef('');
  2032. end;
  2033. if not EndOfEntry then
  2034. Writeln('!! Entry has more information stored');
  2035. if not(df_copied_def in current_defoptions) then
  2036. begin
  2037. {read the record definitions and symbols}
  2038. space:=' '+space;
  2039. readdefinitions('fields');
  2040. readsymbols('fields');
  2041. Delete(space,1,4);
  2042. end;
  2043. end;
  2044. ibfiledef :
  2045. begin
  2046. ReadCommonDef('File definition');
  2047. write (space,' Type : ');
  2048. case getbyte of
  2049. 0 : writeln('Text');
  2050. 1 : begin
  2051. writeln('Typed');
  2052. write (space,' File of Type : ');
  2053. readderef('');
  2054. end;
  2055. 2 : writeln('Untyped');
  2056. end;
  2057. end;
  2058. ibformaldef :
  2059. begin
  2060. readcommondef('Generic definition (void-typ)');
  2061. writeln(space,' Is Typed : ',(getbyte<>0));
  2062. end;
  2063. ibundefineddef :
  2064. readcommondef('Undefined definition (generic parameter)');
  2065. ibenumdef :
  2066. begin
  2067. readcommondef('Enumeration type definition');
  2068. write(space,'Base enumeration type : ');
  2069. readderef('');
  2070. writeln(space,' Smallest element : ',getaint);
  2071. writeln(space,' Largest element : ',getaint);
  2072. writeln(space,' Size : ',getaint);
  2073. end;
  2074. ibclassrefdef :
  2075. begin
  2076. readcommondef('Class reference definition');
  2077. write (space,' Pointed Type : ');
  2078. readderef('');
  2079. end;
  2080. ibsetdef :
  2081. begin
  2082. readcommondef('Set definition');
  2083. write (space,' Element type : ');
  2084. readderef('');
  2085. writeln(space,' Size : ',getaint);
  2086. writeln(space,' Set Base : ',getaint);
  2087. writeln(space,' Set Max : ',getaint);
  2088. end;
  2089. ibvariantdef :
  2090. begin
  2091. readcommondef('Variant definition');
  2092. write (space,' Varianttype : ');
  2093. b:=getbyte;
  2094. case tvarianttype(b) of
  2095. vt_normalvariant :
  2096. writeln('Normal');
  2097. vt_olevariant :
  2098. writeln('OLE');
  2099. else
  2100. writeln('!! Warning: Invalid varianttype ',b);
  2101. end;
  2102. end;
  2103. iberror :
  2104. begin
  2105. Writeln('!! Error in PPU');
  2106. exit;
  2107. end;
  2108. ibenddefs :
  2109. break;
  2110. else
  2111. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  2112. end;
  2113. if not EndOfEntry then
  2114. Writeln('!! Entry has more information stored');
  2115. until false;
  2116. end;
  2117. end;
  2118. procedure readmoduleoptions(space : string);
  2119. type
  2120. tmoduleoption = (mo_none,
  2121. mo_hint_deprecated,
  2122. mo_hint_platform,
  2123. mo_hint_library,
  2124. mo_hint_unimplemented,
  2125. mo_hint_experimental,
  2126. mo_has_deprecated_msg
  2127. );
  2128. tmoduleoptions = set of tmoduleoption;
  2129. tmoduleopt=record
  2130. mask : tmoduleoption;
  2131. str : string[30];
  2132. end;
  2133. const
  2134. moduleopts=6;
  2135. moduleopt : array[1..moduleopts] of tmoduleopt=(
  2136. (mask:mo_hint_deprecated; str:'Hint Deprecated'),
  2137. (mask:mo_hint_platform; str:'Hint Platform'),
  2138. (mask:mo_hint_library; str:'Hint Library'),
  2139. (mask:mo_hint_unimplemented; str:'Hint Unimplemented'),
  2140. (mask:mo_hint_experimental; str:'Hint Experimental'),
  2141. (mask:mo_has_deprecated_msg; str:'Has Deprecated Message')
  2142. );
  2143. var
  2144. moduleoptions : tmoduleoptions;
  2145. i : longint;
  2146. first : boolean;
  2147. begin
  2148. ppufile.getsmallset(moduleoptions);
  2149. if moduleoptions<>[] then
  2150. begin
  2151. first:=true;
  2152. for i:=1to moduleopts do
  2153. if (moduleopt[i].mask in moduleoptions) then
  2154. begin
  2155. if first then
  2156. first:=false
  2157. else
  2158. write(', ');
  2159. write(moduleopt[i].str);
  2160. end;
  2161. end;
  2162. writeln;
  2163. if mo_has_deprecated_msg in moduleoptions then
  2164. writeln(space,'Deprecated : ', ppufile.getstring);
  2165. end;
  2166. {****************************************************************************
  2167. Read General Part
  2168. ****************************************************************************}
  2169. procedure readinterface;
  2170. var
  2171. b : byte;
  2172. sourcenumber : longint;
  2173. begin
  2174. with ppufile do
  2175. begin
  2176. repeat
  2177. b:=readentry;
  2178. case b of
  2179. ibmodulename :
  2180. Writeln('Module Name: ',getstring);
  2181. ibmoduleoptions:
  2182. readmoduleoptions(' ');
  2183. ibsourcefiles :
  2184. begin
  2185. sourcenumber:=1;
  2186. while not EndOfEntry do
  2187. begin
  2188. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  2189. inc(sourcenumber);
  2190. end;
  2191. end;
  2192. {$IFDEF MACRO_DIFF_HINT}
  2193. ibusedmacros :
  2194. begin
  2195. while not EndOfEntry do
  2196. begin
  2197. Write('Conditional ',getstring);
  2198. b:=getbyte;
  2199. if boolean(b)=true then
  2200. write(' defined at startup')
  2201. else
  2202. write(' not defined at startup');
  2203. b:=getbyte;
  2204. if boolean(b)=true then
  2205. writeln(' was used')
  2206. else
  2207. writeln;
  2208. end;
  2209. end;
  2210. {$ENDIF}
  2211. ibloadunit :
  2212. ReadLoadUnit;
  2213. iblinkunitofiles :
  2214. ReadLinkContainer('Link unit object file: ');
  2215. iblinkunitstaticlibs :
  2216. ReadLinkContainer('Link unit static lib: ');
  2217. iblinkunitsharedlibs :
  2218. ReadLinkContainer('Link unit shared lib: ');
  2219. iblinkotherofiles :
  2220. ReadLinkContainer('Link other object file: ');
  2221. iblinkotherstaticlibs :
  2222. ReadLinkContainer('Link other static lib: ');
  2223. iblinkothersharedlibs :
  2224. ReadLinkContainer('Link other shared lib: ');
  2225. iblinkotherframeworks:
  2226. ReadLinkContainer('Link framework: ');
  2227. ibmainname:
  2228. Writeln('Specified main program symbol name: ',getstring);
  2229. ibImportSymbols :
  2230. ReadImportSymbols;
  2231. ibderefdata :
  2232. ReadDerefData;
  2233. ibderefmap :
  2234. ReadDerefMap;
  2235. ibwpofile :
  2236. ReadWpoFileInfo;
  2237. ibresources :
  2238. ReadLinkContainer('Resource file: ');
  2239. iberror :
  2240. begin
  2241. Writeln('Error in PPU');
  2242. exit;
  2243. end;
  2244. ibendinterface :
  2245. break;
  2246. else
  2247. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  2248. end;
  2249. until false;
  2250. end;
  2251. end;
  2252. {****************************************************************************
  2253. Read Implementation Part
  2254. ****************************************************************************}
  2255. procedure readimplementation;
  2256. var
  2257. b : byte;
  2258. begin
  2259. with ppufile do
  2260. begin
  2261. repeat
  2262. b:=readentry;
  2263. case b of
  2264. ibasmsymbols :
  2265. ReadAsmSymbols;
  2266. ibloadunit :
  2267. ReadLoadUnit;
  2268. iberror :
  2269. begin
  2270. Writeln('Error in PPU');
  2271. exit;
  2272. end;
  2273. ibendimplementation :
  2274. break;
  2275. else
  2276. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  2277. end;
  2278. until false;
  2279. end;
  2280. end;
  2281. procedure dofile (filename : string);
  2282. begin
  2283. { reset }
  2284. space:='';
  2285. { fix filename }
  2286. if pos('.',filename)=0 then
  2287. filename:=filename+'.ppu';
  2288. ppufile:=tppufile.create(filename);
  2289. if not ppufile.openfile then
  2290. begin
  2291. writeln ('IO-Error when opening : ',filename,', Skipping');
  2292. exit;
  2293. end;
  2294. { PPU File is open, check for PPU Id }
  2295. if not ppufile.CheckPPUID then
  2296. begin
  2297. writeln(Filename,' : Not a valid PPU file, Skipping');
  2298. exit;
  2299. end;
  2300. { Check PPU Version }
  2301. Writeln('Analyzing ',filename,' (v',ppufile.GetPPUVersion,')');
  2302. if ppufile.GetPPUVersion<16 then
  2303. begin
  2304. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  2305. exit;
  2306. end;
  2307. { Write PPU Header Information }
  2308. if (verbose and v_header)<>0 then
  2309. begin
  2310. Writeln;
  2311. Writeln('Header');
  2312. Writeln('-------');
  2313. with ppufile.header do
  2314. begin
  2315. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  2316. (ppufile.header.compiler shr 7) and $7f,'.',
  2317. ppufile.header.compiler and $7f);
  2318. WriteLn('Target processor : ',Cpu2Str(cpu));
  2319. WriteLn('Target operating system : ',Target2Str(target));
  2320. Writeln('Unit flags : ',PPUFlags2Str(flags));
  2321. Writeln('FileSize (w/o header) : ',size);
  2322. Writeln('Checksum : ',hexstr(checksum,8));
  2323. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  2324. Writeln('Indirect Checksum : ',hexstr(indirect_checksum,8));
  2325. Writeln('Definitions stored : ',tostr(deflistsize));
  2326. Writeln('Symbols stored : ',tostr(symlistsize));
  2327. end;
  2328. end;
  2329. {read the general stuff}
  2330. if (verbose and v_interface)<>0 then
  2331. begin
  2332. Writeln;
  2333. Writeln('Interface section');
  2334. Writeln('------------------');
  2335. readinterface;
  2336. end
  2337. else
  2338. ppufile.skipuntilentry(ibendinterface);
  2339. {read the definitions}
  2340. if (verbose and v_defs)<>0 then
  2341. begin
  2342. Writeln;
  2343. Writeln('Interface definitions');
  2344. Writeln('----------------------');
  2345. readdefinitions('interface');
  2346. end
  2347. else
  2348. ppufile.skipuntilentry(ibenddefs);
  2349. {read the symbols}
  2350. if (verbose and v_syms)<>0 then
  2351. begin
  2352. Writeln;
  2353. Writeln('Interface Symbols');
  2354. Writeln('------------------');
  2355. readsymbols('interface');
  2356. end
  2357. else
  2358. ppufile.skipuntilentry(ibendsyms);
  2359. {read the macro symbols}
  2360. if (verbose and v_syms)<>0 then
  2361. begin
  2362. Writeln;
  2363. Writeln('Interface Macro Symbols');
  2364. Writeln('-----------------------');
  2365. end;
  2366. if ppufile.readentry<>ibexportedmacros then
  2367. begin
  2368. Writeln('!! Error in PPU');
  2369. exit;
  2370. end;
  2371. if boolean(ppufile.getbyte) then
  2372. begin
  2373. {skip the definition section for macros (since they are never used) }
  2374. ppufile.skipuntilentry(ibenddefs);
  2375. {read the macro symbols}
  2376. if (verbose and v_syms)<>0 then
  2377. readsymbols('interface macro')
  2378. else
  2379. ppufile.skipuntilentry(ibendsyms);
  2380. end
  2381. else
  2382. Writeln('(no exported macros)');
  2383. {read the implementation stuff}
  2384. if (verbose and v_implementation)<>0 then
  2385. begin
  2386. Writeln;
  2387. Writeln('Implementation section');
  2388. Writeln('-----------------------');
  2389. readimplementation;
  2390. end
  2391. else
  2392. ppufile.skipuntilentry(ibendimplementation);
  2393. {read the static symtable}
  2394. if (ppufile.header.flags and uf_local_symtable)<>0 then
  2395. begin
  2396. if (verbose and v_defs)<>0 then
  2397. begin
  2398. Writeln;
  2399. Writeln('Static definitions');
  2400. Writeln('----------------------');
  2401. readdefinitions('implementation');
  2402. end
  2403. else
  2404. ppufile.skipuntilentry(ibenddefs);
  2405. {read the symbols}
  2406. if (verbose and v_syms)<>0 then
  2407. begin
  2408. Writeln;
  2409. Writeln('Static Symbols');
  2410. Writeln('------------------');
  2411. readsymbols('implementation');
  2412. end
  2413. else
  2414. ppufile.skipuntilentry(ibendsyms);
  2415. end;
  2416. ReadCreatedObjTypes;
  2417. {shutdown ppufile}
  2418. ppufile.closefile;
  2419. ppufile.free;
  2420. Writeln;
  2421. end;
  2422. procedure help;
  2423. begin
  2424. writeln('usage: ppudump [options] <filename1> <filename2>...');
  2425. writeln;
  2426. writeln('[options] can be:');
  2427. writeln(' -V<verbose> Set verbosity to <verbose>');
  2428. writeln(' H - Show header info');
  2429. writeln(' I - Show interface');
  2430. writeln(' M - Show implementation');
  2431. writeln(' S - Show interface symbols');
  2432. writeln(' D - Show interface definitions');
  2433. // writeln(' B - Show browser info');
  2434. writeln(' A - Show all');
  2435. writeln(' -h, -? This helpscreen');
  2436. halt;
  2437. end;
  2438. var
  2439. startpara,
  2440. nrfile,i : longint;
  2441. para : string;
  2442. begin
  2443. writeln(Title+' '+Version);
  2444. writeln(Copyright);
  2445. writeln;
  2446. if paramcount<1 then
  2447. begin
  2448. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  2449. halt(1);
  2450. end;
  2451. { turn verbose on by default }
  2452. verbose:=v_all;
  2453. { read options }
  2454. startpara:=1;
  2455. while copy(paramstr(startpara),1,1)='-' do
  2456. begin
  2457. para:=paramstr(startpara);
  2458. case upcase(para[2]) of
  2459. 'V' : begin
  2460. verbose:=0;
  2461. for i:=3 to length(para) do
  2462. case upcase(para[i]) of
  2463. 'H' : verbose:=verbose or v_header;
  2464. 'I' : verbose:=verbose or v_interface;
  2465. 'M' : verbose:=verbose or v_implementation;
  2466. 'D' : verbose:=verbose or v_defs;
  2467. 'S' : verbose:=verbose or v_syms;
  2468. 'A' : verbose:=verbose or v_all;
  2469. end;
  2470. end;
  2471. 'H' : help;
  2472. '?' : help;
  2473. end;
  2474. inc(startpara);
  2475. end;
  2476. { process files }
  2477. for nrfile:=startpara to paramcount do
  2478. dofile (paramstr(nrfile));
  2479. if has_errors then
  2480. Halt(1);
  2481. end.