ppudump.pp 79 KB

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