ppudump.pp 81 KB

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