ppudump.pp 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688
  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. const
  809. defopt : array[1..ord(high(tdefoption))] of tdefopt=(
  810. (mask:df_unique; str:'Unique Type'),
  811. (mask:df_generic; str:'Generic'),
  812. (mask:df_specialization; str:'Specialization'),
  813. (mask:df_copied_def; str:'Copied Typedef')
  814. );
  815. defstate : array[1..ord(high(tdefstate))] of tdefstateinfo=(
  816. (mask:ds_vmt_written; str:'VMT Written'),
  817. (mask:ds_rtti_table_used; str:'RTTITable Used'),
  818. (mask:ds_init_table_used; str:'InitTable Used'),
  819. (mask:ds_rtti_table_written; str:'RTTITable Written'),
  820. (mask:ds_init_table_written; str:'InitTable Written'),
  821. (mask:ds_dwarf_dbg_info_used; str:'Dwarf DbgInfo Used'),
  822. (mask:ds_dwarf_dbg_info_written;str:'Dwarf DbgInfo Written')
  823. );
  824. var
  825. defstates : tdefstates;
  826. i : longint;
  827. first : boolean;
  828. tokenbufsize : longint;
  829. tokenbuf : pbyte;
  830. len : sizeint;
  831. wstring : widestring;
  832. astring : ansistring;
  833. begin
  834. writeln(space,'** Definition Id ',ppufile.getlongint,' **');
  835. writeln(space,s);
  836. write (space,' Type symbol : ');
  837. readderef('');
  838. write (space,' DefOptions : ');
  839. ppufile.getsmallset(defoptions);
  840. if defoptions<>[] then
  841. begin
  842. first:=true;
  843. for i:=1to high(defopt) do
  844. if (defopt[i].mask in defoptions) then
  845. begin
  846. if first then
  847. first:=false
  848. else
  849. write(', ');
  850. write(defopt[i].str);
  851. end;
  852. end;
  853. writeln;
  854. write (space,' DefStates : ');
  855. ppufile.getsmallset(defstates);
  856. if defstates<>[] then
  857. begin
  858. first:=true;
  859. for i:=1to high(defstate) do
  860. if (defstate[i].mask in defstates) then
  861. begin
  862. if first then
  863. first:=false
  864. else
  865. write(', ');
  866. write(defstate[i].str);
  867. end;
  868. end;
  869. writeln;
  870. if df_generic in defoptions then
  871. begin
  872. tokenbufsize:=ppufile.getlongint;
  873. writeln(space,' Tokenbuffer size : ',tokenbufsize);
  874. tokenbuf:=allocmem(tokenbufsize);
  875. ppufile.getdata(tokenbuf^,tokenbufsize);
  876. i:=0;
  877. write(space,' Tokens: ');
  878. while i<tokenbufsize do
  879. begin
  880. if ttoken(tokenbuf[i])<>_GENERICSPECIALTOKEN then
  881. write(arraytokeninfo[ttoken(tokenbuf[i])].str);
  882. case ttoken(tokenbuf[i]) of
  883. _CWCHAR,
  884. _CWSTRING :
  885. begin
  886. inc(i);
  887. len:=psizeint(@tokenbuf[i])^;
  888. inc(i,sizeof(sizeint));
  889. setlength(wstring,len);
  890. move(tokenbuf[i],wstring[1],len*2);
  891. write(' ',wstring);
  892. inc(i,len*2);
  893. end;
  894. _CSTRING:
  895. begin
  896. inc(i);
  897. len:=psizeint(@tokenbuf[i])^;
  898. inc(i,sizeof(sizeint));
  899. setlength(astring,len);
  900. move(tokenbuf[i],astring[1],len);
  901. write(' ',astring);
  902. inc(i,len);
  903. end;
  904. _CCHAR,
  905. _INTCONST,
  906. _REALNUMBER :
  907. begin
  908. inc(i);
  909. write(' ',pshortstring(@tokenbuf[i])^);
  910. inc(i,tokenbuf[i]+1);
  911. end;
  912. _ID :
  913. begin
  914. inc(i);
  915. inc(i);
  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. inc(i);
  927. case tspecialgenerictoken(tokenbuf[i]) of
  928. ST_LOADSETTINGS:
  929. begin
  930. inc(i);
  931. write('Settings');
  932. inc(i,sizeof(tsettings));
  933. end;
  934. ST_LINE:
  935. begin
  936. inc(i);
  937. write('Line: ',pdword(@tokenbuf[i])^);
  938. inc(i,4);
  939. end;
  940. ST_COLUMN:
  941. begin
  942. inc(i);
  943. write('Col: ',pword(@tokenbuf[i])^);
  944. inc(i,2);
  945. end;
  946. ST_FILEINDEX:
  947. begin
  948. inc(i);
  949. write('File: ',pword(@tokenbuf[i])^);
  950. inc(i,2);
  951. end;
  952. end;
  953. {
  954. replaytokenbuf.read(specialtoken,1);
  955. case specialtoken of
  956. ST_LOADSETTINGS:
  957. begin
  958. replaytokenbuf.read(current_settings,sizeof(current_settings));
  959. end
  960. else
  961. internalerror(2006103010);
  962. end;
  963. continue;
  964. }
  965. end;
  966. else
  967. inc(i);
  968. end;
  969. if i<tokenbufsize then
  970. write(',');
  971. end;
  972. writeln;
  973. freemem(tokenbuf);
  974. end;
  975. if df_specialization in defoptions then
  976. begin
  977. write (space,' Orig. GenericDef : ');
  978. readderef('');
  979. end;
  980. current_defoptions:=defoptions;
  981. end;
  982. { Read abstract procdef and return if inline procdef }
  983. type
  984. tproccalloption=(pocall_none,
  985. { procedure uses C styled calling }
  986. pocall_cdecl,
  987. { C++ calling conventions }
  988. pocall_cppdecl,
  989. { Far16 for OS/2 }
  990. pocall_far16,
  991. { Old style FPC default calling }
  992. pocall_oldfpccall,
  993. { Procedure has compiler magic}
  994. pocall_internproc,
  995. { procedure is a system call, applies e.g. to MorphOS and PalmOS }
  996. pocall_syscall,
  997. { pascal standard left to right }
  998. pocall_pascal,
  999. { procedure uses register (fastcall) calling }
  1000. pocall_register,
  1001. { safe call calling conventions }
  1002. pocall_safecall,
  1003. { procedure uses stdcall call }
  1004. pocall_stdcall,
  1005. { Special calling convention for cpus without a floating point
  1006. unit. Floating point numbers are passed in integer registers
  1007. instead of floating point registers. Depending on the other
  1008. available calling conventions available for the cpu
  1009. this replaces either pocall_fastcall or pocall_stdcall.
  1010. }
  1011. pocall_softfloat,
  1012. { Metrowerks Pascal. Special case on Mac OS (X): passes all }
  1013. { constant records by reference. }
  1014. pocall_mwpascal
  1015. );
  1016. tproccalloptions = set of tproccalloption;
  1017. tproctypeoption=(potype_none,
  1018. potype_proginit, { Program initialization }
  1019. potype_unitinit, { unit initialization }
  1020. potype_unitfinalize, { unit finalization }
  1021. potype_constructor, { Procedure is a constructor }
  1022. potype_destructor, { Procedure is a destructor }
  1023. potype_operator, { Procedure defines an operator }
  1024. potype_procedure,
  1025. potype_function,
  1026. potype_class_constructor, { class constructor }
  1027. potype_class_destructor { class destructor }
  1028. );
  1029. tproctypeoptions=set of tproctypeoption;
  1030. tprocoption=(po_none,
  1031. po_classmethod, { class method }
  1032. po_virtualmethod, { Procedure is a virtual method }
  1033. po_abstractmethod, { Procedure is an abstract method }
  1034. po_finalmethod, { Procedure is a final method }
  1035. po_staticmethod, { static method }
  1036. po_overridingmethod, { method with override directive }
  1037. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  1038. po_interrupt, { Procedure is an interrupt handler }
  1039. po_iocheck, { IO checking should be done after a call to the procedure }
  1040. po_assembler, { Procedure is written in assembler }
  1041. po_msgstr, { method for string message handling }
  1042. po_msgint, { method for int message handling }
  1043. po_exports, { Procedure has export directive (needed for OS/2) }
  1044. po_external, { Procedure is external (in other object or lib)}
  1045. po_overload, { procedure is declared with overload directive }
  1046. po_varargs, { printf like arguments }
  1047. po_internconst, { procedure has constant evaluator intern }
  1048. { flag that only the address of a method is returned and not a full methodpointer }
  1049. po_addressonly,
  1050. { procedure is exported }
  1051. po_public,
  1052. { calling convention is specified explicitly }
  1053. po_hascallingconvention,
  1054. { reintroduce flag }
  1055. po_reintroduce,
  1056. { location of parameters is given explicitly as it is necessary for some syscall
  1057. conventions like that one of MorphOS }
  1058. po_explicitparaloc,
  1059. { no stackframe will be generated, used by lowlevel assembler like get_frame }
  1060. po_nostackframe,
  1061. po_has_mangledname,
  1062. po_has_public_name,
  1063. po_forward,
  1064. po_global,
  1065. po_has_inlininginfo,
  1066. { The different kind of syscalls on MorphOS }
  1067. po_syscall_legacy,
  1068. po_syscall_sysv,
  1069. po_syscall_basesysv,
  1070. po_syscall_sysvbase,
  1071. po_syscall_r12base,
  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. { nested procedure that uses Delphi-style calling convention for passing
  1090. the frame pointer (pushed on the stack, always the last parameter,
  1091. removed by the caller). Required for nested procvar compatibility,
  1092. because such procvars can hold both regular and nested procedures
  1093. (when calling a regular procedure using the above convention, it will
  1094. simply not see the frame pointer parameter, and since the caller cleans
  1095. up the stack will also remain balanced) }
  1096. po_delphi_nested_cc
  1097. );
  1098. tprocoptions=set of tprocoption;
  1099. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions);
  1100. type
  1101. tproccallopt=record
  1102. mask : tproccalloption;
  1103. str : string[30];
  1104. end;
  1105. tproctypeopt=record
  1106. mask : tproctypeoption;
  1107. str : string[30];
  1108. end;
  1109. tprocopt=record
  1110. mask : tprocoption;
  1111. str : string[30];
  1112. end;
  1113. const
  1114. proccalloptionStr : array[tproccalloption] of string[14]=('',
  1115. 'CDecl',
  1116. 'CPPDecl',
  1117. 'Far16',
  1118. 'OldFPCCall',
  1119. 'InternProc',
  1120. 'SysCall',
  1121. 'Pascal',
  1122. 'Register',
  1123. 'SafeCall',
  1124. 'StdCall',
  1125. 'SoftFloat',
  1126. 'MWPascal'
  1127. );
  1128. proctypeopt : array[1..ord(high(tproctypeoption))] of tproctypeopt=(
  1129. (mask:potype_proginit; str:'ProgInit'),
  1130. (mask:potype_unitinit; str:'UnitInit'),
  1131. (mask:potype_unitfinalize; str:'UnitFinalize'),
  1132. (mask:potype_constructor; str:'Constructor'),
  1133. (mask:potype_destructor; str:'Destructor'),
  1134. (mask:potype_operator; str:'Operator'),
  1135. (mask:potype_procedure; str:'Procedure'),
  1136. (mask:potype_function; str:'Function'),
  1137. (mask:potype_class_constructor; str:'Class Constructor'),
  1138. (mask:potype_class_destructor; str:'Class Destructor')
  1139. );
  1140. procopt : array[1..ord(high(tprocoption))] of tprocopt=(
  1141. (mask:po_classmethod; str:'ClassMethod'),
  1142. (mask:po_virtualmethod; str:'VirtualMethod'),
  1143. (mask:po_abstractmethod; str:'AbstractMethod'),
  1144. (mask:po_finalmethod; str:'FinalMethod'),
  1145. (mask:po_staticmethod; str:'StaticMethod'),
  1146. (mask:po_overridingmethod;str:'OverridingMethod'),
  1147. (mask:po_methodpointer; str:'MethodPointer'),
  1148. (mask:po_interrupt; str:'Interrupt'),
  1149. (mask:po_iocheck; str:'IOCheck'),
  1150. (mask:po_assembler; str:'Assembler'),
  1151. (mask:po_msgstr; str:'MsgStr'),
  1152. (mask:po_msgint; str:'MsgInt'),
  1153. (mask:po_exports; str:'Exports'),
  1154. (mask:po_external; str:'External'),
  1155. (mask:po_overload; str:'Overload'),
  1156. (mask:po_varargs; str:'VarArgs'),
  1157. (mask:po_internconst; str:'InternConst'),
  1158. (mask:po_addressonly; str:'AddressOnly'),
  1159. (mask:po_public; str:'Public'),
  1160. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  1161. (mask:po_reintroduce; str:'ReIntroduce'),
  1162. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  1163. (mask:po_nostackframe; str:'NoStackFrame'),
  1164. (mask:po_has_mangledname; str:'HasMangledName'),
  1165. (mask:po_has_public_name; str:'HasPublicName'),
  1166. (mask:po_forward; str:'Forward'),
  1167. (mask:po_global; str:'Global'),
  1168. (mask:po_has_inlininginfo;str:'HasInliningInfo'),
  1169. (mask:po_syscall_legacy; str:'SyscallLegacy'),
  1170. (mask:po_syscall_sysv; str:'SyscallSysV'),
  1171. (mask:po_syscall_basesysv;str:'SyscallBaseSysV'),
  1172. (mask:po_syscall_sysvbase;str:'SyscallSysVBase'),
  1173. (mask:po_syscall_r12base; str:'SyscallR12Base'),
  1174. (mask:po_inline; str:'Inline'),
  1175. (mask:po_compilerproc; str:'CompilerProc'),
  1176. (mask:po_has_importdll; str:'HasImportDLL'),
  1177. (mask:po_has_importname; str:'HasImportName'),
  1178. (mask:po_kylixlocal; str:'KylixLocal'),
  1179. (mask:po_dispid; str:'DispId'),
  1180. (mask:po_weakexternal; str:'WeakExternal'),
  1181. (mask:po_objc; str:'ObjC'),
  1182. (mask:po_enumerator_movenext; str:'EnumeratorMoveNext'),
  1183. (mask:po_optional; str: 'Optional'),
  1184. (mask:po_delphi_nested_cc;str: 'Delphi-style nested frameptr')
  1185. );
  1186. var
  1187. proctypeoption : tproctypeoption;
  1188. i : longint;
  1189. first : boolean;
  1190. tempbuf : array[0..255] of byte;
  1191. begin
  1192. write(space,' Return type : ');
  1193. readderef('');
  1194. writeln(space,' Fpu used : ',ppufile.getbyte);
  1195. proctypeoption:=tproctypeoption(ppufile.getbyte);
  1196. write(space,' TypeOption : ');
  1197. first:=true;
  1198. for i:=1 to high(proctypeopt) do
  1199. if (proctypeopt[i].mask=proctypeoption) then
  1200. begin
  1201. if first then
  1202. first:=false
  1203. else
  1204. write(', ');
  1205. write(proctypeopt[i].str);
  1206. end;
  1207. writeln;
  1208. proccalloption:=tproccalloption(ppufile.getbyte);
  1209. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  1210. ppufile.getnormalset(procoptions);
  1211. if procoptions<>[] then
  1212. begin
  1213. write(space,' Options : ');
  1214. first:=true;
  1215. for i:=1 to high(procopt) do
  1216. if (procopt[i].mask in procoptions) then
  1217. begin
  1218. if first then
  1219. first:=false
  1220. else
  1221. write(', ');
  1222. write(procopt[i].str);
  1223. end;
  1224. writeln;
  1225. end;
  1226. if (po_explicitparaloc in procoptions) then
  1227. begin
  1228. i:=ppufile.getbyte;
  1229. ppufile.getdata(tempbuf,i);
  1230. end;
  1231. end;
  1232. type
  1233. tvaroption=(vo_none,
  1234. vo_is_external,
  1235. vo_is_dll_var,
  1236. vo_is_thread_var,
  1237. vo_has_local_copy,
  1238. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  1239. vo_is_public,
  1240. vo_is_high_para,
  1241. vo_is_funcret,
  1242. vo_is_self,
  1243. vo_is_vmt,
  1244. vo_is_result, { special result variable }
  1245. vo_is_parentfp,
  1246. vo_is_loop_counter, { used to detect assignments to loop counter }
  1247. vo_is_hidden_para,
  1248. vo_has_explicit_paraloc,
  1249. vo_is_syscall_lib,
  1250. vo_has_mangledname,
  1251. vo_is_typed_const,
  1252. vo_is_range_check,
  1253. vo_is_overflow_check,
  1254. vo_is_typinfo_para,
  1255. vo_is_weak_external,
  1256. vo_is_msgsel,
  1257. vo_is_first_field
  1258. );
  1259. tvaroptions=set of tvaroption;
  1260. { register variable }
  1261. tvarregable=(vr_none,
  1262. vr_intreg,
  1263. vr_fpureg,
  1264. vr_mmreg,
  1265. { does not mean "needs address register", but "if it's a parameter which is }
  1266. { passed by reference, then its address can be put in a register }
  1267. vr_addr
  1268. );
  1269. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions);
  1270. type
  1271. tvaropt=record
  1272. mask : tvaroption;
  1273. str : string[30];
  1274. end;
  1275. const
  1276. varopt : array[1..ord(high(tvaroption))] of tvaropt=(
  1277. (mask:vo_is_external; str:'External'),
  1278. (mask:vo_is_dll_var; str:'DLLVar'),
  1279. (mask:vo_is_thread_var; str:'ThreadVar'),
  1280. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  1281. (mask:vo_is_const; str:'Constant'),
  1282. (mask:vo_is_public; str:'Public'),
  1283. (mask:vo_is_high_para; str:'HighValue'),
  1284. (mask:vo_is_funcret; str:'Funcret'),
  1285. (mask:vo_is_self; str:'Self'),
  1286. (mask:vo_is_vmt; str:'VMT'),
  1287. (mask:vo_is_result; str:'Result'),
  1288. (mask:vo_is_parentfp; str:'ParentFP'),
  1289. (mask:vo_is_loop_counter; str:'LoopCounter'),
  1290. (mask:vo_is_hidden_para; str:'Hidden'),
  1291. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  1292. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  1293. (mask:vo_has_mangledname; str:'HasMangledName'),
  1294. (mask:vo_is_typed_const; str:'TypedConst'),
  1295. (mask:vo_is_range_check; str:'RangeCheckSwitch'),
  1296. (mask:vo_is_overflow_check; str:'OverflowCheckSwitch'),
  1297. (mask:vo_is_typinfo_para; str:'TypeInfo'),
  1298. (mask:vo_is_msgsel;str:'MsgSel'),
  1299. (mask:vo_is_weak_external;str:'WeakExternal'),
  1300. (mask:vo_is_first_field;str:'IsFirstField')
  1301. );
  1302. var
  1303. i : longint;
  1304. first : boolean;
  1305. begin
  1306. readcommonsym(s);
  1307. writeln(space,' Spez : ',Varspez2Str(ppufile.getbyte));
  1308. writeln(space,' Regable : ',Varregable2Str(ppufile.getbyte));
  1309. writeln(space,' Addr Taken : ',(ppufile.getbyte<>0));
  1310. write (space,' Var Type : ');
  1311. readderef('');
  1312. ppufile.getsmallset(varoptions);
  1313. if varoptions<>[] then
  1314. begin
  1315. write(space,' Options : ');
  1316. first:=true;
  1317. for i:=1 to high(varopt) do
  1318. if (varopt[i].mask in varoptions) then
  1319. begin
  1320. if first then
  1321. first:=false
  1322. else
  1323. write(', ');
  1324. write(varopt[i].str);
  1325. end;
  1326. writeln;
  1327. end;
  1328. end;
  1329. procedure readobjectdefoptions;
  1330. type
  1331. tobjectoption=(oo_none,
  1332. oo_is_forward, { the class is only a forward declared yet }
  1333. oo_is_abstract, { the class is abstract - only descendants can be used }
  1334. oo_is_sealed, { the class is sealed - can't have descendants }
  1335. oo_has_virtual, { the object/class has virtual methods }
  1336. oo_has_private,
  1337. oo_has_protected,
  1338. oo_has_strictprivate,
  1339. oo_has_strictprotected,
  1340. oo_has_constructor, { the object/class has a constructor }
  1341. oo_has_destructor, { the object/class has a destructor }
  1342. oo_has_vmt, { the object/class has a vmt }
  1343. oo_has_msgstr,
  1344. oo_has_msgint,
  1345. oo_can_have_published,{ the class has rtti, i.e. you can publish properties }
  1346. oo_has_default_property,
  1347. oo_has_valid_guid,
  1348. oo_has_enumerator_movenext,
  1349. oo_has_enumerator_current,
  1350. oo_is_external, { the class is externally implemented (objcclass, cppclass) }
  1351. oo_is_anonymous, { the class is only formally defined in this module (objcclass x = class; external;) }
  1352. oo_is_classhelper, { objcclasses that represent categories, and Delpi-style class helpers, are marked like this }
  1353. oo_has_class_constructor, { the object/class has a class constructor }
  1354. oo_has_class_destructor { the object/class has a class destructor }
  1355. );
  1356. tobjectoptions=set of tobjectoption;
  1357. tsymopt=record
  1358. mask : tobjectoption;
  1359. str : string[30];
  1360. end;
  1361. const
  1362. symopt : array[1..ord(high(tobjectoption))] of tsymopt=(
  1363. (mask:oo_is_forward; str:'IsForward'),
  1364. (mask:oo_is_abstract; str:'IsAbstract'),
  1365. (mask:oo_is_sealed; str:'IsSealed'),
  1366. (mask:oo_has_virtual; str:'HasVirtual'),
  1367. (mask:oo_has_private; str:'HasPrivate'),
  1368. (mask:oo_has_protected; str:'HasProtected'),
  1369. (mask:oo_has_strictprivate; str:'HasStrictPrivate'),
  1370. (mask:oo_has_strictprotected;str:'HasStrictProtected'),
  1371. (mask:oo_has_constructor; str:'HasConstructor'),
  1372. (mask:oo_has_destructor; str:'HasDestructor'),
  1373. (mask:oo_has_vmt; str:'HasVMT'),
  1374. (mask:oo_has_msgstr; str:'HasMsgStr'),
  1375. (mask:oo_has_msgint; str:'HasMsgInt'),
  1376. (mask:oo_can_have_published; str:'CanHavePublished'),
  1377. (mask:oo_has_default_property;str:'HasDefaultProperty'),
  1378. (mask:oo_has_valid_guid; str:'HasValidGUID'),
  1379. (mask:oo_has_enumerator_movenext; str:'HasEnumeratorMoveNext'),
  1380. (mask:oo_has_enumerator_current; str:'HasEnumeratorCurrent'),
  1381. (mask:oo_is_external; str:'External'),
  1382. (mask:oo_is_anonymous; str:'Anonymous'),
  1383. (mask:oo_is_classhelper; str:'Class Helper/Category'),
  1384. (mask:oo_has_class_constructor; str:'HasClassConstructor'),
  1385. (mask:oo_has_class_destructor; str:'HasClassDestructor')
  1386. );
  1387. var
  1388. symoptions : tobjectoptions;
  1389. i : longint;
  1390. first : boolean;
  1391. begin
  1392. ppufile.getsmallset(symoptions);
  1393. if symoptions<>[] then
  1394. begin
  1395. first:=true;
  1396. for i:=1 to high(symopt) do
  1397. if (symopt[i].mask in symoptions) then
  1398. begin
  1399. if first then
  1400. first:=false
  1401. else
  1402. write(', ');
  1403. write(symopt[i].str);
  1404. end;
  1405. end;
  1406. writeln;
  1407. end;
  1408. procedure readarraydefoptions;
  1409. type
  1410. tarraydefoption=(ado_none,
  1411. ado_IsConvertedPointer,
  1412. ado_IsDynamicArray,
  1413. ado_IsVariant,
  1414. ado_IsConstructor,
  1415. ado_IsArrayOfConst,
  1416. ado_IsConstString,
  1417. ado_IsBitPacked
  1418. );
  1419. tarraydefoptions=set of tarraydefoption;
  1420. tsymopt=record
  1421. mask : tarraydefoption;
  1422. str : string[30];
  1423. end;
  1424. const
  1425. symopt : array[1..ord(high(tarraydefoption))] of tsymopt=(
  1426. (mask:ado_IsConvertedPointer;str:'ConvertedPointer'),
  1427. (mask:ado_IsDynamicArray; str:'IsDynamicArray'),
  1428. (mask:ado_IsVariant; str:'IsVariant'),
  1429. (mask:ado_IsConstructor; str:'IsConstructor'),
  1430. (mask:ado_IsArrayOfConst; str:'ArrayOfConst'),
  1431. (mask:ado_IsConstString; str:'ConstString'),
  1432. (mask:ado_IsBitPacked; str:'BitPacked')
  1433. );
  1434. var
  1435. symoptions : tarraydefoptions;
  1436. i : longint;
  1437. first : boolean;
  1438. begin
  1439. ppufile.getsmallset(symoptions);
  1440. if symoptions<>[] then
  1441. begin
  1442. first:=true;
  1443. for i:=1 to high(symopt) do
  1444. if (symopt[i].mask in symoptions) then
  1445. begin
  1446. if first then
  1447. first:=false
  1448. else
  1449. write(', ');
  1450. write(symopt[i].str);
  1451. end;
  1452. end;
  1453. writeln;
  1454. end;
  1455. procedure readnodetree;
  1456. var
  1457. l : longint;
  1458. p : pointer;
  1459. begin
  1460. with ppufile do
  1461. begin
  1462. if space<>'' then
  1463. Writeln(space,'------ nodetree ------');
  1464. if readentry=ibnodetree then
  1465. begin
  1466. l:=entrysize;
  1467. Writeln(space,'Tree size : ',l);
  1468. { Read data to prevent error that entry is not completly read }
  1469. getmem(p,l);
  1470. getdata(p^,l);
  1471. freemem(p);
  1472. end
  1473. else
  1474. begin
  1475. Writeln('!! ibnodetree not found');
  1476. end;
  1477. end;
  1478. end;
  1479. procedure ReadCreatedObjTypes;
  1480. var
  1481. i,j,
  1482. len,
  1483. bssize: longint;
  1484. bs: pbyte;
  1485. begin
  1486. if ppufile.readentry<>ibcreatedobjtypes then
  1487. begin
  1488. writeln('!! ibcreatedobjtypes entry not found');
  1489. ppufile.skipdata(ppufile.entrysize);
  1490. exit
  1491. end;
  1492. writeln;
  1493. writeln(space,'WPO info');
  1494. writeln(space,'--------');
  1495. len:=ppufile.getlongint;
  1496. writeln(space,'** Instantiated Object/Class types: ',len,' **');
  1497. space:=space+' ';
  1498. for i:=0 to len-1 do
  1499. readderef(space);
  1500. setlength(space,length(space)-2);
  1501. len:=ppufile.getlongint;
  1502. writeln(space,'** Instantiated ClassRef types: ',len,' **');
  1503. space:=space+' ';
  1504. for i:=0 to len-1 do
  1505. readderef(space);
  1506. setlength(space,length(space)-2);
  1507. len:=ppufile.getlongint;
  1508. writeln(space,'** Possibly instantiated ClassRef types : ',len,' **');
  1509. space:=space+' ';
  1510. for i:=0 to len-1 do
  1511. readderef(space);
  1512. setlength(space,length(space)-2);
  1513. len:=ppufile.getlongint;
  1514. writeln(space,'** Class types with called virtual methods info : ',len,' **');
  1515. space:=space+' ';
  1516. for i:=0 to len-1 do
  1517. begin
  1518. write(space,'Class def : ');
  1519. readderef('');
  1520. write(space+' ','Called vmtentries : ');
  1521. bssize:=ppufile.getlongint;
  1522. getmem(bs,bssize);
  1523. ppufile.readdata(bs^,bssize);
  1524. for j:=0 to bssize*8-1 do
  1525. if (((bs+j shr 3)^ shr (j and 7)) and 1) <> 0 then
  1526. write(j,', ');
  1527. writeln;
  1528. freemem(bs);
  1529. end;
  1530. setlength(space,length(space)-2);
  1531. end;
  1532. {****************************************************************************
  1533. Read Symbols Part
  1534. ****************************************************************************}
  1535. procedure readsymbols(const s:string);
  1536. type
  1537. pguid = ^tguid;
  1538. tguid = packed record
  1539. D1: LongWord;
  1540. D2: Word;
  1541. D3: Word;
  1542. D4: array[0..7] of Byte;
  1543. end;
  1544. absolutetyp = (tovar,toasm,toaddr);
  1545. tconsttyp = (constnone,
  1546. constord,conststring,constreal,
  1547. constset,constpointer,constnil,
  1548. constresourcestring,constwstring,constguid
  1549. );
  1550. var
  1551. b : byte;
  1552. pc : pchar;
  1553. i,j,len : longint;
  1554. guid : tguid;
  1555. tempbuf : array[0..127] of char;
  1556. varoptions : tvaroptions;
  1557. begin
  1558. with ppufile do
  1559. begin
  1560. if space<>'' then
  1561. Writeln(space,'------ ',s,' ------');
  1562. if readentry=ibstartsyms then
  1563. begin
  1564. Writeln(space,'Symtable datasize : ',getlongint);
  1565. Writeln(space,'Symtable alignment: ',getlongint);
  1566. end
  1567. else
  1568. Writeln('!! ibstartsym not found');
  1569. repeat
  1570. b:=readentry;
  1571. case b of
  1572. ibunitsym :
  1573. readcommonsym('Unit symbol ');
  1574. iblabelsym :
  1575. readcommonsym('Label symbol ');
  1576. ibtypesym :
  1577. begin
  1578. readcommonsym('Type symbol ');
  1579. write(space,' Result Type : ');
  1580. readderef('');
  1581. end;
  1582. ibprocsym :
  1583. begin
  1584. readcommonsym('Procedure symbol ');
  1585. len:=ppufile.getword;
  1586. for i:=1 to len do
  1587. begin
  1588. write(space,' Definition : ');
  1589. readderef('');
  1590. end;
  1591. end;
  1592. ibconstsym :
  1593. begin
  1594. readcommonsym('Constant symbol ');
  1595. b:=getbyte;
  1596. case tconsttyp(b) of
  1597. constord :
  1598. begin
  1599. write (space,' OrdinalType : ');
  1600. readderef('');
  1601. writeln(space,' Value : ',constexp.tostr(getexprint));
  1602. end;
  1603. constpointer :
  1604. begin
  1605. write (space,' PointerType : ');
  1606. readderef('');
  1607. writeln(space,' Value : ',getlongint)
  1608. end;
  1609. conststring,
  1610. constresourcestring :
  1611. begin
  1612. len:=getlongint;
  1613. getmem(pc,len+1);
  1614. getdata(pc^,len);
  1615. (pc+len)^:= #0;
  1616. writeln(space,' Length : ',len);
  1617. writeln(space,' Value : "',pc,'"');
  1618. freemem(pc,len+1);
  1619. end;
  1620. constreal :
  1621. writeln(space,' Value : ',getreal);
  1622. constset :
  1623. begin
  1624. write (space,' Set Type : ');
  1625. readderef('');
  1626. for i:=1to 4 do
  1627. begin
  1628. write (space,' Value : ');
  1629. for j:=1to 8 do
  1630. begin
  1631. if j>1 then
  1632. write(',');
  1633. write(hexstr(getbyte,2));
  1634. end;
  1635. writeln;
  1636. end;
  1637. end;
  1638. constwstring:
  1639. begin
  1640. end;
  1641. constguid:
  1642. begin
  1643. getdata(guid,sizeof(guid));
  1644. write (space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-');
  1645. for i:=0 to 7 do
  1646. begin
  1647. write(hexstr(guid.d4[i],2));
  1648. if i=1 then write('-');
  1649. end;
  1650. writeln('}');
  1651. end
  1652. else
  1653. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  1654. end;
  1655. end;
  1656. ibabsolutevarsym :
  1657. begin
  1658. readabstractvarsym('Absolute variable symbol ',varoptions);
  1659. Write (space,' Relocated to ');
  1660. b:=getbyte;
  1661. case absolutetyp(b) of
  1662. tovar :
  1663. readpropaccesslist(space+' Sym : ');
  1664. toasm :
  1665. Writeln('Assembler name : ',getstring);
  1666. toaddr :
  1667. begin
  1668. Write('Address : ',getlongint);
  1669. if tsystemcpu(ppufile.header.cpu)=cpu_i386 then
  1670. WriteLn(' (Far: ',getbyte<>0,')');
  1671. end;
  1672. else
  1673. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  1674. end;
  1675. end;
  1676. ibfieldvarsym :
  1677. begin
  1678. readabstractvarsym('Field Variable symbol ',varoptions);
  1679. writeln(space,' Address : ',getaint);
  1680. end;
  1681. ibstaticvarsym :
  1682. begin
  1683. readabstractvarsym('Global Variable symbol ',varoptions);
  1684. write (space,' DefaultConst : ');
  1685. readderef('');
  1686. if (vo_has_mangledname in varoptions) then
  1687. writeln(space,' Mangledname : ',getstring);
  1688. end;
  1689. iblocalvarsym :
  1690. begin
  1691. readabstractvarsym('Local Variable symbol ',varoptions);
  1692. write (space,' DefaultConst : ');
  1693. readderef('');
  1694. end;
  1695. ibparavarsym :
  1696. begin
  1697. readabstractvarsym('Parameter Variable symbol ',varoptions);
  1698. write (space,' DefaultConst : ');
  1699. readderef('');
  1700. writeln(space,' ParaNr : ',getword);
  1701. writeln(space,' Univ : ',boolean(getbyte));
  1702. writeln(space,' VarState : ',getbyte);
  1703. if (vo_has_explicit_paraloc in varoptions) then
  1704. begin
  1705. i:=getbyte;
  1706. getdata(tempbuf,i);
  1707. end;
  1708. end;
  1709. ibenumsym :
  1710. begin
  1711. readcommonsym('Enumeration symbol ');
  1712. write (space,' Definition : ');
  1713. readderef('');
  1714. writeln(space,' Value : ',getlongint);
  1715. end;
  1716. ibsyssym :
  1717. begin
  1718. readcommonsym('Internal system symbol ');
  1719. writeln(space,' Internal Nr : ',getlongint);
  1720. end;
  1721. ibmacrosym :
  1722. begin
  1723. readcommonsym('Macro symbol ');
  1724. writeln(space,' Name: ',getstring);
  1725. writeln(space,' Defined: ',getbyte);
  1726. writeln(space,' Compiler var: ',getbyte);
  1727. len:=getlongint;
  1728. writeln(space,' Value length: ',len);
  1729. if len > 0 then
  1730. begin
  1731. getmem(pc,len+1);
  1732. getdata(pc^,len);
  1733. (pc+len)^:= #0;
  1734. writeln(space,' Value: "',pc,'"');
  1735. freemem(pc,len+1);
  1736. end;
  1737. end;
  1738. ibpropertysym :
  1739. begin
  1740. readcommonsym('Property ');
  1741. i:=getlongint;
  1742. writeln(space,' PropOptions : ',i);
  1743. write (space,' OverrideProp : ');
  1744. readderef('');
  1745. write (space,' Prop Type : ');
  1746. readderef('');
  1747. writeln(space,' Index : ',getlongint);
  1748. writeln(space,' Default : ',getlongint);
  1749. write (space,' Index Type : ');
  1750. readderef('');
  1751. { palt_none }
  1752. readpropaccesslist('');
  1753. write (space,' Readaccess : ');
  1754. readpropaccesslist(space+' Sym: ');
  1755. write (space,' Writeaccess : ');
  1756. readpropaccesslist(space+' Sym: ');
  1757. write (space,' Storedaccess : ');
  1758. readpropaccesslist(space+' Sym: ');
  1759. end;
  1760. iberror :
  1761. begin
  1762. Writeln('!! Error in PPU');
  1763. exit;
  1764. end;
  1765. ibendsyms :
  1766. break;
  1767. else
  1768. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  1769. end;
  1770. if not EndOfEntry then
  1771. Writeln('!! Entry has more information stored');
  1772. until false;
  1773. end;
  1774. end;
  1775. {****************************************************************************
  1776. Read defintions Part
  1777. ****************************************************************************}
  1778. procedure readdefinitions(const s:string);
  1779. type
  1780. tordtype = (
  1781. uvoid,
  1782. u8bit,u16bit,u32bit,u64bit,
  1783. s8bit,s16bit,s32bit,s64bit,
  1784. bool8bit,bool16bit,bool32bit,bool64bit,
  1785. uchar,uwidechar,scurrency
  1786. );
  1787. tobjecttyp = (odt_none,
  1788. odt_class,
  1789. odt_object,
  1790. odt_interfacecom,
  1791. odt_interfacecom_property,
  1792. odt_interfacecom_function,
  1793. odt_interfacecorba,
  1794. odt_cppclass,
  1795. odt_dispinterface,
  1796. odt_objcclass,
  1797. odt_objcprotocol
  1798. );
  1799. tvarianttype = (
  1800. vt_normalvariant,vt_olevariant
  1801. );
  1802. var
  1803. b : byte;
  1804. l,j : longint;
  1805. calloption : tproccalloption;
  1806. procoptions : tprocoptions;
  1807. procinfooptions : tprocinfoflag;
  1808. defoptions: tdefoptions;
  1809. begin
  1810. with ppufile do
  1811. begin
  1812. if space<>'' then
  1813. Writeln(space,'------ ',s,' ------');
  1814. if readentry<>ibstartdefs then
  1815. Writeln('!! ibstartdefs not found');
  1816. repeat
  1817. b:=readentry;
  1818. case b of
  1819. ibpointerdef :
  1820. begin
  1821. readcommondef('Pointer definition',defoptions);
  1822. write (space,' Pointed Type : ');
  1823. readderef('');
  1824. writeln(space,' Is Far : ',(getbyte<>0));
  1825. writeln(space,' Has Pointer Math : ',(getbyte<>0));
  1826. end;
  1827. iborddef :
  1828. begin
  1829. readcommondef('Ordinal definition',defoptions);
  1830. write (space,' Base type : ');
  1831. b:=getbyte;
  1832. case tordtype(b) of
  1833. uvoid : writeln('uvoid');
  1834. u8bit : writeln('u8bit');
  1835. u16bit : writeln('u16bit');
  1836. u32bit : writeln('s32bit');
  1837. u64bit : writeln('u64bit');
  1838. s8bit : writeln('s8bit');
  1839. s16bit : writeln('s16bit');
  1840. s32bit : writeln('s32bit');
  1841. s64bit : writeln('s64bit');
  1842. bool8bit : writeln('bool8bit');
  1843. bool16bit : writeln('bool16bit');
  1844. bool32bit : writeln('bool32bit');
  1845. bool64bit : writeln('bool64bit');
  1846. uchar : writeln('uchar');
  1847. uwidechar : writeln('uwidechar');
  1848. scurrency : writeln('ucurrency');
  1849. else writeln('!! Warning: Invalid base type ',b);
  1850. end;
  1851. writeln(space,' Range : ',constexp.tostr(getexprint),' to ',constexp.tostr(getexprint));
  1852. end;
  1853. ibfloatdef :
  1854. begin
  1855. readcommondef('Float definition',defoptions);
  1856. writeln(space,' Float type : ',getbyte);
  1857. end;
  1858. ibarraydef :
  1859. begin
  1860. readcommondef('Array definition',defoptions);
  1861. write (space,' Element type : ');
  1862. readderef('');
  1863. write (space,' Range Type : ');
  1864. readderef('');
  1865. writeln(space,' Range : ',getaint,' to ',getaint);
  1866. write (space,' Options : ');
  1867. readarraydefoptions;
  1868. readdefinitions('symbols');
  1869. readsymbols('symbols');
  1870. end;
  1871. ibprocdef :
  1872. begin
  1873. readcommondef('Procedure definition',defoptions);
  1874. read_abstract_proc_def(calloption,procoptions);
  1875. if (po_has_mangledname in procoptions) then
  1876. writeln(space,' Mangled name : ',getstring);
  1877. writeln(space,' Number : ',getword);
  1878. writeln(space,' Level : ',getbyte);
  1879. write (space,' Class : ');
  1880. readderef('');
  1881. write (space,' Procsym : ');
  1882. readderef('');
  1883. write (space,' File Pos : ');
  1884. readposinfo;
  1885. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  1886. write (space,' SymOptions : ');
  1887. readsymoptions(space+' ');
  1888. if tsystemcpu(ppufile.header.cpu)=cpu_powerpc then
  1889. begin
  1890. { library symbol for AmigaOS/MorphOS }
  1891. write (space,' Library symbol : ');
  1892. readderef('');
  1893. end;
  1894. if (po_has_importdll in procoptions) then
  1895. writeln(space,' Import DLL : ',getstring);
  1896. if (po_has_importname in procoptions) then
  1897. writeln(space,' Import Name : ',getstring);
  1898. writeln(space,' Import Nr : ',getword);
  1899. if (po_msgint in procoptions) then
  1900. writeln(space,' MsgInt : ',getlongint);
  1901. if (po_msgstr in procoptions) then
  1902. writeln(space,' MsgStr : ',getstring);
  1903. if (po_dispid in procoptions) then
  1904. writeln(space,' DispID: ',ppufile.getlongint);
  1905. if (po_has_inlininginfo in procoptions) then
  1906. begin
  1907. write (space,' FuncretSym : ');
  1908. readderef('');
  1909. ppufile.getsmallset(procinfooptions);
  1910. writeln(space,' ProcInfoOptions : ',dword(procinfooptions));
  1911. end;
  1912. b:=ppufile.getbyte;
  1913. if b<>0 then
  1914. begin
  1915. write (space,' Alias names : ');
  1916. for j:=1 to b do
  1917. begin
  1918. write(ppufile.getstring);
  1919. if j<b then
  1920. write(', ');
  1921. end;
  1922. writeln;
  1923. end;
  1924. if not EndOfEntry then
  1925. Writeln('!! Entry has more information stored');
  1926. space:=' '+space;
  1927. { parast }
  1928. readdefinitions('parast');
  1929. readsymbols('parast');
  1930. { localst }
  1931. if (po_has_inlininginfo in procoptions) then
  1932. begin
  1933. readdefinitions('localst');
  1934. readsymbols('localst');
  1935. end;
  1936. if (po_has_inlininginfo in procoptions) then
  1937. readnodetree;
  1938. delete(space,1,4);
  1939. end;
  1940. ibprocvardef :
  1941. begin
  1942. readcommondef('Procedural type (ProcVar) definition',defoptions);
  1943. read_abstract_proc_def(calloption,procoptions);
  1944. writeln(space,' Symtable level :',ppufile.getbyte);
  1945. if not EndOfEntry then
  1946. Writeln('!! Entry has more information stored');
  1947. space:=' '+space;
  1948. { parast }
  1949. readdefinitions('parast');
  1950. readsymbols('parast');
  1951. delete(space,1,4);
  1952. end;
  1953. ibshortstringdef :
  1954. begin
  1955. readcommondef('ShortString definition',defoptions);
  1956. writeln(space,' Length : ',getbyte);
  1957. end;
  1958. ibwidestringdef :
  1959. begin
  1960. readcommondef('WideString definition',defoptions);
  1961. writeln(space,' Length : ',getlongint);
  1962. end;
  1963. ibunicodestringdef :
  1964. begin
  1965. readcommondef('UnicodeString definition',defoptions);
  1966. writeln(space,' Length : ',getlongint);
  1967. end;
  1968. ibansistringdef :
  1969. begin
  1970. readcommondef('AnsiString definition',defoptions);
  1971. writeln(space,' Length : ',getlongint);
  1972. end;
  1973. iblongstringdef :
  1974. begin
  1975. readcommondef('Longstring definition',defoptions);
  1976. writeln(space,' Length : ',getlongint);
  1977. end;
  1978. ibrecorddef :
  1979. begin
  1980. readcommondef('Record definition',defoptions);
  1981. writeln(space,' Name of Record : ',getstring);
  1982. write (space,' Options : ');
  1983. readobjectdefoptions;
  1984. writeln(space,' FieldAlign : ',getbyte);
  1985. writeln(space,' RecordAlign : ',getbyte);
  1986. writeln(space,' PadAlign : ',getbyte);
  1987. writeln(space,'UseFieldAlignment : ',getbyte);
  1988. writeln(space,' DataSize : ',getaint);
  1989. if not EndOfEntry then
  1990. Writeln('!! Entry has more information stored');
  1991. {read the record definitions and symbols}
  1992. space:=' '+space;
  1993. readdefinitions('fields');
  1994. readsymbols('fields');
  1995. Delete(space,1,4);
  1996. end;
  1997. ibobjectdef :
  1998. begin
  1999. readcommondef('Object/Class definition',defoptions);
  2000. writeln(space,' Name of Class : ',getstring);
  2001. write (space,' Options : ');
  2002. readobjectdefoptions;
  2003. b:=getbyte;
  2004. write (space,' Type : ');
  2005. case tobjecttyp(b) of
  2006. odt_class : writeln('class');
  2007. odt_object : writeln('object');
  2008. odt_interfacecom : writeln('interfacecom');
  2009. odt_interfacecorba : writeln('interfacecorba');
  2010. odt_cppclass : writeln('cppclass');
  2011. odt_dispinterface : writeln('dispinterface');
  2012. odt_objcclass : writeln('objcclass');
  2013. odt_objcprotocol : writeln('objcprotocol');
  2014. else writeln('!! Warning: Invalid object type ',b);
  2015. end;
  2016. writeln(space,' External name : ',getstring);
  2017. writeln(space,' Import lib : ',getstring);
  2018. writeln(space,' DataSize : ',getaint);
  2019. writeln(space,' FieldAlign : ',getbyte);
  2020. writeln(space,' RecordAlign : ',getbyte);
  2021. writeln(space,' Vmt offset : ',getlongint);
  2022. write (space, ' Ancestor Class : ');
  2023. readderef('');
  2024. if tobjecttyp(b) in [odt_interfacecom,odt_interfacecorba,odt_dispinterface] then
  2025. begin
  2026. { IIDGUID }
  2027. for j:=1to 16 do
  2028. getbyte;
  2029. writeln(space,' IID String : ',getstring);
  2030. end;
  2031. l:=getlongint;
  2032. writeln(space,' VMT entries: ',l);
  2033. for j:=1 to l do
  2034. begin
  2035. write(space,' ');
  2036. readderef('');
  2037. writeln(space,' Visibility: ',Visibility2Str(getbyte));
  2038. end;
  2039. if tobjecttyp(b) in [odt_class,odt_interfacecorba,odt_objcclass,odt_objcprotocol] then
  2040. begin
  2041. l:=getlongint;
  2042. writeln(space,' Impl Intf Count : ',l);
  2043. for j:=1 to l do
  2044. begin
  2045. write (space,' - Definition : ');
  2046. readderef('');
  2047. writeln(space,' IOffset : ',getlongint);
  2048. end;
  2049. end;
  2050. if df_copied_def in current_defoptions then
  2051. begin
  2052. writeln(' Copy of def: ');
  2053. readderef('');
  2054. end;
  2055. if not EndOfEntry then
  2056. Writeln('!! Entry has more information stored');
  2057. if not(df_copied_def in current_defoptions) then
  2058. begin
  2059. {read the record definitions and symbols}
  2060. space:=' '+space;
  2061. readdefinitions('fields');
  2062. readsymbols('fields');
  2063. Delete(space,1,4);
  2064. end;
  2065. end;
  2066. ibfiledef :
  2067. begin
  2068. ReadCommonDef('File definition',defoptions);
  2069. write (space,' Type : ');
  2070. case getbyte of
  2071. 0 : writeln('Text');
  2072. 1 : begin
  2073. writeln('Typed');
  2074. write (space,' File of Type : ');
  2075. readderef('');
  2076. end;
  2077. 2 : writeln('Untyped');
  2078. end;
  2079. end;
  2080. ibformaldef :
  2081. begin
  2082. readcommondef('Generic definition (void-typ)',defoptions);
  2083. writeln(space,' Is Typed : ',(getbyte<>0));
  2084. end;
  2085. ibundefineddef :
  2086. readcommondef('Undefined definition (generic parameter)',defoptions);
  2087. ibenumdef :
  2088. begin
  2089. readcommondef('Enumeration type definition',defoptions);
  2090. writeln(space,' Smallest element : ',getaint);
  2091. writeln(space,' Largest element : ',getaint);
  2092. writeln(space,' Size : ',getaint);
  2093. if df_copied_def in defoptions then
  2094. begin
  2095. write(space,'Base enumeration type : ');
  2096. readderef('');
  2097. end
  2098. else
  2099. begin
  2100. space:=' '+space;
  2101. readdefinitions('elements');
  2102. readsymbols('elements');
  2103. delete(space,1,4);
  2104. end;
  2105. end;
  2106. ibclassrefdef :
  2107. begin
  2108. readcommondef('Class reference definition',defoptions);
  2109. write (space,' Pointed Type : ');
  2110. readderef('');
  2111. end;
  2112. ibsetdef :
  2113. begin
  2114. readcommondef('Set definition',defoptions);
  2115. write (space,' Element type : ');
  2116. readderef('');
  2117. writeln(space,' Size : ',getaint);
  2118. writeln(space,' Set Base : ',getaint);
  2119. writeln(space,' Set Max : ',getaint);
  2120. end;
  2121. ibvariantdef :
  2122. begin
  2123. readcommondef('Variant definition',defoptions);
  2124. write (space,' Varianttype : ');
  2125. b:=getbyte;
  2126. case tvarianttype(b) of
  2127. vt_normalvariant :
  2128. writeln('Normal');
  2129. vt_olevariant :
  2130. writeln('OLE');
  2131. else
  2132. writeln('!! Warning: Invalid varianttype ',b);
  2133. end;
  2134. end;
  2135. iberror :
  2136. begin
  2137. Writeln('!! Error in PPU');
  2138. exit;
  2139. end;
  2140. ibenddefs :
  2141. break;
  2142. else
  2143. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  2144. end;
  2145. if not EndOfEntry then
  2146. Writeln('!! Entry has more information stored');
  2147. until false;
  2148. end;
  2149. end;
  2150. procedure readmoduleoptions(space : string);
  2151. type
  2152. tmoduleoption = (mo_none,
  2153. mo_hint_deprecated,
  2154. mo_hint_platform,
  2155. mo_hint_library,
  2156. mo_hint_unimplemented,
  2157. mo_hint_experimental,
  2158. mo_has_deprecated_msg
  2159. );
  2160. tmoduleoptions = set of tmoduleoption;
  2161. tmoduleopt=record
  2162. mask : tmoduleoption;
  2163. str : string[30];
  2164. end;
  2165. const
  2166. moduleopts=6;
  2167. moduleopt : array[1..moduleopts] of tmoduleopt=(
  2168. (mask:mo_hint_deprecated; str:'Hint Deprecated'),
  2169. (mask:mo_hint_platform; str:'Hint Platform'),
  2170. (mask:mo_hint_library; str:'Hint Library'),
  2171. (mask:mo_hint_unimplemented; str:'Hint Unimplemented'),
  2172. (mask:mo_hint_experimental; str:'Hint Experimental'),
  2173. (mask:mo_has_deprecated_msg; str:'Has Deprecated Message')
  2174. );
  2175. var
  2176. moduleoptions : tmoduleoptions;
  2177. i : longint;
  2178. first : boolean;
  2179. begin
  2180. ppufile.getsmallset(moduleoptions);
  2181. if moduleoptions<>[] then
  2182. begin
  2183. first:=true;
  2184. for i:=1to moduleopts do
  2185. if (moduleopt[i].mask in moduleoptions) then
  2186. begin
  2187. if first then
  2188. first:=false
  2189. else
  2190. write(', ');
  2191. write(moduleopt[i].str);
  2192. end;
  2193. end;
  2194. writeln;
  2195. if mo_has_deprecated_msg in moduleoptions then
  2196. writeln(space,'Deprecated : ', ppufile.getstring);
  2197. end;
  2198. {****************************************************************************
  2199. Read General Part
  2200. ****************************************************************************}
  2201. procedure readinterface;
  2202. var
  2203. b : byte;
  2204. sourcenumber : longint;
  2205. begin
  2206. with ppufile do
  2207. begin
  2208. repeat
  2209. b:=readentry;
  2210. case b of
  2211. ibmodulename :
  2212. Writeln('Module Name: ',getstring);
  2213. ibmoduleoptions:
  2214. readmoduleoptions(' ');
  2215. ibsourcefiles :
  2216. begin
  2217. sourcenumber:=1;
  2218. while not EndOfEntry do
  2219. begin
  2220. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  2221. inc(sourcenumber);
  2222. end;
  2223. end;
  2224. {$IFDEF MACRO_DIFF_HINT}
  2225. ibusedmacros :
  2226. begin
  2227. while not EndOfEntry do
  2228. begin
  2229. Write('Conditional ',getstring);
  2230. b:=getbyte;
  2231. if boolean(b)=true then
  2232. write(' defined at startup')
  2233. else
  2234. write(' not defined at startup');
  2235. b:=getbyte;
  2236. if boolean(b)=true then
  2237. writeln(' was used')
  2238. else
  2239. writeln;
  2240. end;
  2241. end;
  2242. {$ENDIF}
  2243. ibloadunit :
  2244. ReadLoadUnit;
  2245. iblinkunitofiles :
  2246. ReadLinkContainer('Link unit object file: ');
  2247. iblinkunitstaticlibs :
  2248. ReadLinkContainer('Link unit static lib: ');
  2249. iblinkunitsharedlibs :
  2250. ReadLinkContainer('Link unit shared lib: ');
  2251. iblinkotherofiles :
  2252. ReadLinkContainer('Link other object file: ');
  2253. iblinkotherstaticlibs :
  2254. ReadLinkContainer('Link other static lib: ');
  2255. iblinkothersharedlibs :
  2256. ReadLinkContainer('Link other shared lib: ');
  2257. iblinkotherframeworks:
  2258. ReadLinkContainer('Link framework: ');
  2259. ibmainname:
  2260. Writeln('Specified main program symbol name: ',getstring);
  2261. ibImportSymbols :
  2262. ReadImportSymbols;
  2263. ibderefdata :
  2264. ReadDerefData;
  2265. ibderefmap :
  2266. ReadDerefMap;
  2267. ibwpofile :
  2268. ReadWpoFileInfo;
  2269. ibresources :
  2270. ReadLinkContainer('Resource file: ');
  2271. iberror :
  2272. begin
  2273. Writeln('Error in PPU');
  2274. exit;
  2275. end;
  2276. ibendinterface :
  2277. break;
  2278. else
  2279. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  2280. end;
  2281. until false;
  2282. end;
  2283. end;
  2284. {****************************************************************************
  2285. Read Implementation Part
  2286. ****************************************************************************}
  2287. procedure readimplementation;
  2288. var
  2289. b : byte;
  2290. begin
  2291. with ppufile do
  2292. begin
  2293. repeat
  2294. b:=readentry;
  2295. case b of
  2296. ibasmsymbols :
  2297. ReadAsmSymbols;
  2298. ibloadunit :
  2299. ReadLoadUnit;
  2300. iberror :
  2301. begin
  2302. Writeln('Error in PPU');
  2303. exit;
  2304. end;
  2305. ibendimplementation :
  2306. break;
  2307. else
  2308. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  2309. end;
  2310. until false;
  2311. end;
  2312. end;
  2313. procedure dofile (filename : string);
  2314. begin
  2315. { reset }
  2316. space:='';
  2317. { fix filename }
  2318. if pos('.',filename)=0 then
  2319. filename:=filename+'.ppu';
  2320. ppufile:=tppufile.create(filename);
  2321. if not ppufile.openfile then
  2322. begin
  2323. writeln ('IO-Error when opening : ',filename,', Skipping');
  2324. exit;
  2325. end;
  2326. { PPU File is open, check for PPU Id }
  2327. if not ppufile.CheckPPUID then
  2328. begin
  2329. writeln(Filename,' : Not a valid PPU file, Skipping');
  2330. exit;
  2331. end;
  2332. { Check PPU Version }
  2333. Writeln('Analyzing ',filename,' (v',ppufile.GetPPUVersion,')');
  2334. if ppufile.GetPPUVersion<16 then
  2335. begin
  2336. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  2337. exit;
  2338. end;
  2339. { Write PPU Header Information }
  2340. if (verbose and v_header)<>0 then
  2341. begin
  2342. Writeln;
  2343. Writeln('Header');
  2344. Writeln('-------');
  2345. with ppufile.header do
  2346. begin
  2347. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  2348. (ppufile.header.compiler shr 7) and $7f,'.',
  2349. ppufile.header.compiler and $7f);
  2350. WriteLn('Target processor : ',Cpu2Str(cpu));
  2351. WriteLn('Target operating system : ',Target2Str(target));
  2352. Writeln('Unit flags : ',PPUFlags2Str(flags));
  2353. Writeln('FileSize (w/o header) : ',size);
  2354. Writeln('Checksum : ',hexstr(checksum,8));
  2355. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  2356. Writeln('Indirect Checksum : ',hexstr(indirect_checksum,8));
  2357. Writeln('Definitions stored : ',tostr(deflistsize));
  2358. Writeln('Symbols stored : ',tostr(symlistsize));
  2359. end;
  2360. end;
  2361. {read the general stuff}
  2362. if (verbose and v_interface)<>0 then
  2363. begin
  2364. Writeln;
  2365. Writeln('Interface section');
  2366. Writeln('------------------');
  2367. readinterface;
  2368. end
  2369. else
  2370. ppufile.skipuntilentry(ibendinterface);
  2371. {read the definitions}
  2372. if (verbose and v_defs)<>0 then
  2373. begin
  2374. Writeln;
  2375. Writeln('Interface definitions');
  2376. Writeln('----------------------');
  2377. readdefinitions('interface');
  2378. end
  2379. else
  2380. ppufile.skipuntilentry(ibenddefs);
  2381. {read the symbols}
  2382. if (verbose and v_syms)<>0 then
  2383. begin
  2384. Writeln;
  2385. Writeln('Interface Symbols');
  2386. Writeln('------------------');
  2387. readsymbols('interface');
  2388. end
  2389. else
  2390. ppufile.skipuntilentry(ibendsyms);
  2391. {read the macro symbols}
  2392. if (verbose and v_syms)<>0 then
  2393. begin
  2394. Writeln;
  2395. Writeln('Interface Macro Symbols');
  2396. Writeln('-----------------------');
  2397. end;
  2398. if ppufile.readentry<>ibexportedmacros then
  2399. begin
  2400. Writeln('!! Error in PPU');
  2401. exit;
  2402. end;
  2403. if boolean(ppufile.getbyte) then
  2404. begin
  2405. {skip the definition section for macros (since they are never used) }
  2406. ppufile.skipuntilentry(ibenddefs);
  2407. {read the macro symbols}
  2408. if (verbose and v_syms)<>0 then
  2409. readsymbols('interface macro')
  2410. else
  2411. ppufile.skipuntilentry(ibendsyms);
  2412. end
  2413. else
  2414. Writeln('(no exported macros)');
  2415. {read the implementation stuff}
  2416. if (verbose and v_implementation)<>0 then
  2417. begin
  2418. Writeln;
  2419. Writeln('Implementation section');
  2420. Writeln('-----------------------');
  2421. readimplementation;
  2422. end
  2423. else
  2424. ppufile.skipuntilentry(ibendimplementation);
  2425. {read the static symtable}
  2426. if (ppufile.header.flags and uf_local_symtable)<>0 then
  2427. begin
  2428. if (verbose and v_defs)<>0 then
  2429. begin
  2430. Writeln;
  2431. Writeln('Static definitions');
  2432. Writeln('----------------------');
  2433. readdefinitions('implementation');
  2434. end
  2435. else
  2436. ppufile.skipuntilentry(ibenddefs);
  2437. {read the symbols}
  2438. if (verbose and v_syms)<>0 then
  2439. begin
  2440. Writeln;
  2441. Writeln('Static Symbols');
  2442. Writeln('------------------');
  2443. readsymbols('implementation');
  2444. end
  2445. else
  2446. ppufile.skipuntilentry(ibendsyms);
  2447. end;
  2448. ReadCreatedObjTypes;
  2449. {shutdown ppufile}
  2450. ppufile.closefile;
  2451. ppufile.free;
  2452. Writeln;
  2453. end;
  2454. procedure help;
  2455. begin
  2456. writeln('usage: ppudump [options] <filename1> <filename2>...');
  2457. writeln;
  2458. writeln('[options] can be:');
  2459. writeln(' -V<verbose> Set verbosity to <verbose>');
  2460. writeln(' H - Show header info');
  2461. writeln(' I - Show interface');
  2462. writeln(' M - Show implementation');
  2463. writeln(' S - Show interface symbols');
  2464. writeln(' D - Show interface definitions');
  2465. // writeln(' B - Show browser info');
  2466. writeln(' A - Show all');
  2467. writeln(' -h, -? This helpscreen');
  2468. halt;
  2469. end;
  2470. var
  2471. startpara,
  2472. nrfile,i : longint;
  2473. para : string;
  2474. begin
  2475. writeln(Title+' '+Version);
  2476. writeln(Copyright);
  2477. writeln;
  2478. if paramcount<1 then
  2479. begin
  2480. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  2481. halt(1);
  2482. end;
  2483. { turn verbose on by default }
  2484. verbose:=v_all;
  2485. { read options }
  2486. startpara:=1;
  2487. while copy(paramstr(startpara),1,1)='-' do
  2488. begin
  2489. para:=paramstr(startpara);
  2490. case upcase(para[2]) of
  2491. 'V' : begin
  2492. verbose:=0;
  2493. for i:=3 to length(para) do
  2494. case upcase(para[i]) of
  2495. 'H' : verbose:=verbose or v_header;
  2496. 'I' : verbose:=verbose or v_interface;
  2497. 'M' : verbose:=verbose or v_implementation;
  2498. 'D' : verbose:=verbose or v_defs;
  2499. 'S' : verbose:=verbose or v_syms;
  2500. 'A' : verbose:=verbose or v_all;
  2501. end;
  2502. end;
  2503. 'H' : help;
  2504. '?' : help;
  2505. end;
  2506. inc(startpara);
  2507. end;
  2508. { process files }
  2509. for nrfile:=startpara to paramcount do
  2510. dofile (paramstr(nrfile));
  2511. if has_errors then
  2512. Halt(1);
  2513. end.