ppudump.pp 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075
  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. {$i fpcdefs.inc}
  18. {$H+}
  19. {$define IN_PPUDUMP}
  20. uses
  21. { do NOT add symconst or globtype to make merging easier }
  22. { do include symconst and globtype now before splitting 2.5 PM 2011-06-15 }
  23. SysUtils,
  24. constexp,
  25. symconst,
  26. ppu,
  27. systems,
  28. globals,
  29. globtype,
  30. widestr,
  31. tokens;
  32. const
  33. Version = 'Version 2.5.1';
  34. Title = 'PPU-Analyser';
  35. Copyright = 'Copyright (c) 1998-2010 by the Free Pascal Development Team';
  36. { verbosity }
  37. v_none = $0;
  38. v_header = $1;
  39. v_defs = $2;
  40. v_syms = $4;
  41. v_interface = $8;
  42. v_implementation = $10;
  43. // v_browser = $20;
  44. v_all = $ff;
  45. { not needed anymore $i systems.inc }
  46. { List of all supported cpus }
  47. const
  48. CpuTxt : array[tsystemcpu] of string[9]=
  49. (
  50. { 0 } 'none',
  51. { 1 } 'i386',
  52. { 2 } 'm68k',
  53. { 3 } 'alpha',
  54. { 4 } 'powerpc',
  55. { 5 } 'sparc',
  56. { 6 } 'vis',
  57. { 7 } 'ia64',
  58. { 8 } 'x86_64',
  59. { 9 } 'mipseb',
  60. { 10 } 'arm',
  61. { 11 } 'powerpc64',
  62. { 12 } 'avr',
  63. { 13 } 'mipsel',
  64. { 14 } 'jvm'
  65. );
  66. { List of all supported system-cpu couples }
  67. const
  68. Targets : array[tsystem] of string[18]=(
  69. { 0 } 'none',
  70. { 1 } 'GO32V1 (obsolete)',
  71. { 2 } 'GO32V2',
  72. { 3 } 'Linux-i386',
  73. { 4 } 'OS/2',
  74. { 5 } 'Win32',
  75. { 6 } 'FreeBSD-i386',
  76. { 7 } 'Amiga',
  77. { 8 } 'Atari',
  78. { 9 } 'MacOS-m68k',
  79. { 10 } 'Linux-m68k',
  80. { 11 } 'PalmOS-m68k',
  81. { 12 } 'Linux-alpha',
  82. { 13 } 'Linux-ppc',
  83. { 14 } 'MacOS-ppc',
  84. { 15 } 'Solaris-i386',
  85. { 16 } 'BeOS-i386',
  86. { 17 } 'NetBSD-i386',
  87. { 18 } 'NetBSD-m68k',
  88. { 19 } 'Netware-i386-clib',
  89. { 20 } 'Qnx-i386',
  90. { 21 } 'WDOSX-i386',
  91. { 22 } 'Solaris-sparc',
  92. { 23 } 'Linux-sparc',
  93. { 24 } 'OpenBSD-i386',
  94. { 25 } 'OpenBSD-m68k',
  95. { 26 } 'Linux-x86-64',
  96. { 27 } 'MacOSX-ppc',
  97. { 28 } 'OS/2 via EMX',
  98. { 29 } 'NetBSD-powerpc',
  99. { 30 } 'OpenBSD-powerpc',
  100. { 31 } 'Linux-arm',
  101. { 32 } 'Watcom-i386',
  102. { 33 } 'MorphOS-powerpc',
  103. { 34 } 'FreeBSD-x86-64',
  104. { 35 } 'Netware-i386-libc',
  105. { 36 } 'Amiga-PowerPC',
  106. { 37 } 'Win64-x64',
  107. { 38 } 'WinCE-ARM',
  108. { 39 } 'Win64-iA64',
  109. { 40 } 'WinCE-i386',
  110. { 41 } 'Linux-x64',
  111. { 42 } 'GBA-arm',
  112. { 43 } 'Linux-powerpc64',
  113. { 44 } 'Darwin-i386',
  114. { 45 } 'PalmOS-arm',
  115. { 46 } 'MacOSX-powerpc64',
  116. { 47 } 'NDS-arm',
  117. { 48 } 'Embedded-i386',
  118. { 49 } 'Embedded-m68k',
  119. { 50 } 'Embedded-alpha',
  120. { 51 } 'Embedded-powerpc',
  121. { 52 } 'Embedded-sparc',
  122. { 53 } 'Embedded-vm',
  123. { 54 } 'Embedded-iA64',
  124. { 55 } 'Embedded-x64',
  125. { 56 } 'Embedded-mips',
  126. { 57 } 'Embedded-arm',
  127. { 58 } 'Embedded-powerpc64',
  128. { 59 } 'Symbian-i386',
  129. { 60 } 'Symbian-arm',
  130. { 61 } 'MacOSX-x64',
  131. { 62 } 'Embedded-avr',
  132. { 63 } 'Haiku-i386',
  133. { 64 } 'Darwin-ARM',
  134. { 65 } 'Solaris-x86-64',
  135. { 66 } 'Linux-MIPS',
  136. { 67 } 'Linux-MIPSel',
  137. { 68 } 'NativeNT-i386',
  138. { 69 } 'iPhoneSim-i386',
  139. { 70 } 'Wii-powerpc',
  140. { 71 } 'OpenBSD-x86-64',
  141. { 72 } 'NetBSD-x86-64',
  142. { 73 } 'AIX-powerpc',
  143. { 74 } 'AIX-powerpc64',
  144. { 75 } 'Java-JVM',
  145. { 76 } 'Android-JVM'
  146. );
  147. const
  148. { in widestr, we have the following definition
  149. type
  150. tcompilerwidechar = word;
  151. thus widecharsize seems to always be 2 bytes }
  152. widecharsize : longint = 2;
  153. cpu : tsystemcpu = cpu_no;
  154. { This type is defined in scanner.pas unit }
  155. type
  156. tspecialgenerictoken = (
  157. ST_LOADSETTINGS,
  158. ST_LINE,
  159. ST_COLUMN,
  160. ST_FILEINDEX,
  161. ST_LOADMESSAGES);
  162. var
  163. ppufile : tppufile;
  164. ppuversion : dword;
  165. space : string;
  166. verbose : longint;
  167. derefdata : pbyte;
  168. derefdatalen : longint;
  169. {****************************************************************************
  170. Helper Routines
  171. ****************************************************************************}
  172. {****************************************************************************
  173. Routine to read 80-bit reals
  174. ****************************************************************************
  175. }
  176. type
  177. TSplit80bitReal = packed record
  178. case byte of
  179. 0: (bytes: Array[0..9] of byte);
  180. 1: (words: Array[0..4] of word);
  181. 2: (cards: Array[0..1] of cardinal; w: word);
  182. end;
  183. const
  184. maxDigits = 17;
  185. function Real80bitToStr(var e : TSplit80bitReal) : string;
  186. var
  187. Temp : string;
  188. new : TSplit80bitReal;
  189. fraczero, expmaximal, sign, outside_double : boolean;
  190. exp : smallint;
  191. ext : extended;
  192. d : double;
  193. i : longint;
  194. mantval : qword;
  195. begin
  196. if ppufile.change_endian then
  197. begin
  198. for i:=0 to 9 do
  199. new.bytes[i]:=e.bytes[9-i];
  200. e:=new;
  201. end;
  202. if sizeof(ext)=10 then
  203. begin
  204. ext:=pextended(@e)^;
  205. str(ext,result);
  206. exit;
  207. end;
  208. { extended, format (MSB): 1 Sign bit, 15 bit exponent, 64 bit mantissa }
  209. sign := (e.w and $8000) <> 0;
  210. expMaximal := (e.w and $7fff) = 32767;
  211. exp:=(e.w and $7fff) - 16383 - 63;
  212. fraczero := (e.cards[0] = 0) and
  213. ((e.cards[1] and $7fffffff) = 0);
  214. mantval := qword(e.cards[0]) or (qword(e.cards[1]) shl 32);
  215. if expMaximal then
  216. if fraczero then
  217. if sign then
  218. temp := '-Inf'
  219. else temp := '+Inf'
  220. else temp := 'Nan'
  221. else
  222. begin
  223. d:=double(mantval);
  224. if sign then
  225. d:=-d;
  226. outside_double:=false;
  227. Try
  228. if exp > 0 then
  229. begin
  230. for i:=1 to exp do
  231. d:=d *2.0;
  232. end
  233. else if exp < 0 then
  234. begin
  235. for i:=1 to -exp do
  236. d:=d /2.0;
  237. end;
  238. Except
  239. outside_double:=true;
  240. end;
  241. if (mantval<>0) and (d=0.0) then
  242. outside_double:=true;
  243. if outside_double then
  244. Temp:='Extended value outside double bound'
  245. else
  246. system.str(d,temp);
  247. end;
  248. result:=temp;
  249. end;
  250. const has_errors : boolean = false;
  251. has_more_infos : boolean = false;
  252. Procedure HasMoreInfos;
  253. begin
  254. Writeln('!! Entry has more information stored');
  255. has_more_infos:=true;
  256. end;
  257. Procedure WriteError(const S : string);
  258. Begin
  259. Writeln(S);
  260. has_errors:=true;
  261. End;
  262. function Unknown(const st : string; val :longint) : string;
  263. Begin
  264. Unknown:='<!! Unknown'+st+' value '+tostr(val)+'>';
  265. has_errors:=true;
  266. end;
  267. function ToStr(w:longint):String;
  268. begin
  269. Str(w,ToStr);
  270. end;
  271. Function Target2Str(w:longint):string;
  272. begin
  273. if w<=ord(high(tsystem)) then
  274. Target2Str:=Targets[tsystem(w)]
  275. else
  276. Target2Str:=Unknown('target',w);
  277. end;
  278. Function Cpu2Str(w:longint):string;
  279. begin
  280. if w<=ord(high(tsystemcpu)) then
  281. begin
  282. cpu:=tsystemcpu(w);
  283. Cpu2Str:=CpuTxt[cpu];
  284. end
  285. else
  286. Cpu2Str:=Unknown('cpu',w);
  287. end;
  288. Function Varspez2Str(w:longint):string;
  289. const
  290. { in symconst unit
  291. tvarspez = (vs_value,vs_const,vs_var,vs_out,vs_constref); }
  292. varspezstr : array[tvarspez] of string[8]=('Value','Const','Var','Out','ConstRef','Final');
  293. begin
  294. if w<=ord(high(varspezstr)) then
  295. Varspez2Str:=varspezstr[tvarspez(w)]
  296. else
  297. Varspez2Str:=Unknown('varspez',w);
  298. end;
  299. Function VarRegable2Str(w:longint):string;
  300. { tvarregable type is defined in symconst unit }
  301. const
  302. varregableStr : array[tvarregable] of string[6]=('None','IntReg','FPUReg','MMReg','Addr');
  303. begin
  304. if w<=ord(high(varregablestr)) then
  305. Varregable2Str:=varregablestr[tvarregable(w)]
  306. else
  307. Varregable2Str:=Unknown('regable',w);
  308. end;
  309. Function Visibility2Str(w:longint):string;
  310. const
  311. { tvisibility type is defined in symconst unit }
  312. visibilityName : array[tvisibility] of string[16] = (
  313. 'hidden','strict private','private','strict protected','protected',
  314. 'public','published','<none>'
  315. );
  316. begin
  317. if w<=ord(high(visibilityName)) then
  318. result:=visibilityName[tvisibility(w)]
  319. else
  320. result:=Unknown('visibility',w);
  321. end;
  322. function PPUFlags2Str(flags:longint):string;
  323. type
  324. tflagopt=record
  325. mask : longint;
  326. str : string[30];
  327. end;
  328. const
  329. flagopts=24;
  330. flagopt : array[1..flagopts] of tflagopt=(
  331. (mask: $1 ;str:'init'),
  332. (mask: $2 ;str:'final'),
  333. (mask: $4 ;str:'big_endian'),
  334. (mask: $8 ;str:'dbx'),
  335. // (mask: $10 ;str:'browser'),
  336. (mask: $20 ;str:'in_library'),
  337. (mask: $40 ;str:'smart_linked'),
  338. (mask: $80 ;str:'static_linked'),
  339. (mask: $100 ;str:'shared_linked'),
  340. // (mask: $200 ;str:'local_browser'),
  341. (mask: $400 ;str:'no_link'),
  342. (mask: $800 ;str:'has_resources'),
  343. (mask: $1000 ;str:'little_endian'),
  344. (mask: $2000 ;str:'release'),
  345. (mask: $4000 ;str:'local_threadvars'),
  346. (mask: $8000 ;str:'fpu_emulation_on'),
  347. (mask: $210000 ;str:'has_debug_info'),
  348. (mask: $10000 ;str:'stabs_debug_info'),
  349. (mask: $200000 ;str:'dwarf_debug_info'),
  350. (mask: $20000 ;str:'local_symtable'),
  351. (mask: $40000 ;str:'uses_variants'),
  352. (mask: $80000 ;str:'has_resourcefiles'),
  353. (mask: $100000 ;str:'has_exports'),
  354. (mask: $400000 ;str:'has_wideinits'),
  355. (mask: $800000 ;str:'has_classinits'),
  356. (mask: $1000000 ;str:'has_resstrinits')
  357. );
  358. var
  359. i,ntflags : longint;
  360. first : boolean;
  361. s : string;
  362. begin
  363. s:='';
  364. if flags<>0 then
  365. begin
  366. ntflags:=flags;
  367. first:=true;
  368. for i:=1to flagopts do
  369. if (flags and flagopt[i].mask)<>0 then
  370. begin
  371. if first then
  372. first:=false
  373. else
  374. s:=s+', ';
  375. s:=s+flagopt[i].str;
  376. ntflags:=ntflags and (not flagopt[i].mask);
  377. end;
  378. end
  379. else
  380. s:='none';
  381. if ntflags<>0 then
  382. begin
  383. s:=s+' unknown '+hexstr(ntflags,8);
  384. has_errors:=true;
  385. end;
  386. PPUFlags2Str:=s;
  387. end;
  388. Function L0(l:longint):string;
  389. {
  390. return the string of value l, if l<10 then insert a zero, so
  391. the string is always at least 2 chars '01','02',etc
  392. }
  393. var
  394. s : string;
  395. begin
  396. Str(l,s);
  397. if l<10 then
  398. s:='0'+s;
  399. L0:=s;
  400. end;
  401. function filetimestring( t : longint) : string;
  402. {
  403. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  404. }
  405. var
  406. DT : TDateTime;
  407. hsec : word;
  408. Year,Month,Day: Word;
  409. hour,min,sec : word;
  410. begin
  411. if t=-1 then
  412. begin
  413. Result := 'Not Found';
  414. has_errors:=true;
  415. exit;
  416. end;
  417. DT := FileDateToDateTime(t);
  418. DecodeTime(DT,hour,min,sec,hsec);
  419. DecodeDate(DT,year,month,day);
  420. Result := L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  421. end;
  422. {****************************************************************************
  423. Read Routines
  424. ****************************************************************************}
  425. procedure readrecsymtableoptions;
  426. var
  427. usefieldalignment : shortint;
  428. begin
  429. if ppufile.readentry<>ibrecsymtableoptions then
  430. begin
  431. has_errors:=true;
  432. exit;
  433. end;
  434. writeln(space,' recordalignment: ',shortint(ppufile.getbyte));
  435. usefieldalignment:=shortint(ppufile.getbyte);
  436. writeln(space,' usefieldalignment: ',usefieldalignment);
  437. if (usefieldalignment=C_alignment) then
  438. writeln(space,' fieldalignment: ',shortint(ppufile.getbyte));
  439. end;
  440. procedure readsymtableoptions(const s: string);
  441. type
  442. tsymtblopt=record
  443. mask : tsymtableoption;
  444. str : string[30];
  445. end;
  446. const
  447. symtblopts=ord(high(tsymtableoption)) + 1;
  448. symtblopt : array[1..symtblopts] of tsymtblopt=(
  449. (mask:sto_has_helper; str:'Has helper'),
  450. (mask:sto_has_generic; str:'Has generic')
  451. );
  452. var
  453. options : tsymtableoptions;
  454. first : boolean;
  455. i : integer;
  456. begin
  457. if ppufile.readentry<>ibsymtableoptions then
  458. begin
  459. has_errors:=true;
  460. exit;
  461. end;
  462. ppufile.getsmallset(options);
  463. if space<>'' then
  464. writeln(space,'------ ',s,' ------');
  465. write(space,'Symtable options: ');
  466. if options<>[] then
  467. begin
  468. first:=true;
  469. for i:=1 to symtblopts do
  470. if (symtblopt[i].mask in options) then
  471. begin
  472. if first then
  473. first:=false
  474. else
  475. write(', ');
  476. write(symtblopt[i].str);
  477. end;
  478. end
  479. else
  480. write('none');
  481. writeln;
  482. end;
  483. procedure readdefinitions(const s:string); forward;
  484. procedure readsymbols(const s:string); forward;
  485. procedure readsymtable(const s: string);
  486. begin
  487. readsymtableoptions(s);
  488. readdefinitions(s);
  489. readsymbols(s);
  490. end;
  491. Procedure ReadLinkContainer(const prefix:string);
  492. {
  493. Read a serie of strings and write to the screen starting every line
  494. with prefix
  495. }
  496. function maskstr(m:longint):string;
  497. { link options are in globtype unit
  498. const
  499. link_none = $0;
  500. link_always = $1;
  501. link_static = $2;
  502. link_smart = $4;
  503. link_shared = $8; }
  504. var
  505. s : string;
  506. begin
  507. s:='';
  508. if (m and link_always)<>0 then
  509. s:=s+'always ';
  510. if (m and link_static)<>0 then
  511. s:=s+'static ';
  512. if (m and link_smart)<>0 then
  513. s:=s+'smart ';
  514. if (m and link_shared)<>0 then
  515. s:=s+'shared ';
  516. maskstr:=s;
  517. end;
  518. var
  519. s : string;
  520. m : longint;
  521. begin
  522. while not ppufile.endofentry do
  523. begin
  524. s:=ppufile.getstring;
  525. m:=ppufile.getlongint;
  526. WriteLn(prefix,s,' (',maskstr(m),')');
  527. end;
  528. end;
  529. Procedure ReadContainer(const prefix:string);
  530. {
  531. Read a serie of strings and write to the screen starting every line
  532. with prefix
  533. }
  534. begin
  535. while not ppufile.endofentry do
  536. WriteLn(prefix,ppufile.getstring);
  537. end;
  538. procedure ReadLoadUnit;
  539. var
  540. ucrc,uintfcrc, indcrc : cardinal;
  541. begin
  542. while not ppufile.EndOfEntry do
  543. begin
  544. write('Uses unit: ',ppufile.getstring);
  545. ucrc:=cardinal(ppufile.getlongint);
  546. uintfcrc:=cardinal(ppufile.getlongint);
  547. indcrc:=cardinal(ppufile.getlongint);
  548. writeln(' (Crc: ',hexstr(ucrc,8),', IntfcCrc: ',hexstr(uintfcrc,8),', IndCrc: ',hexstr(indcrc,8),')');
  549. end;
  550. end;
  551. Procedure ReadDerefmap;
  552. var
  553. i,mapsize : longint;
  554. begin
  555. mapsize:=ppufile.getlongint;
  556. writeln('DerefMapsize: ',mapsize);
  557. for i:=0 to mapsize-1 do
  558. writeln('DerefMap[',i,'] = ',ppufile.getstring);
  559. end;
  560. Procedure ReadImportSymbols;
  561. var
  562. extlibname : string;
  563. j,
  564. extsymcnt : longint;
  565. extsymname : string;
  566. extsymmangledname : string;
  567. extsymordnr : longint;
  568. extsymisvar : boolean;
  569. begin
  570. while not ppufile.endofentry do
  571. begin
  572. extlibname:=ppufile.getstring;
  573. extsymcnt:=ppufile.getlongint;
  574. writeln('External Library: ',extlibname,' (',extsymcnt,' imports)');
  575. for j:=0 to extsymcnt-1 do
  576. begin
  577. extsymname:=ppufile.getstring;
  578. if ppuversion>130 then
  579. extsymmangledname:=ppufile.getstring
  580. else
  581. extsymmangledname:=extsymname;
  582. extsymordnr:=ppufile.getlongint;
  583. extsymisvar:=ppufile.getbyte<>0;
  584. writeln(' ',extsymname,' as ',extsymmangledname,
  585. '(OrdNr: ',extsymordnr,' IsVar: ',extsymisvar,')');
  586. end;
  587. end;
  588. end;
  589. Procedure ReadDerefdata;
  590. begin
  591. derefdatalen:=ppufile.entrysize;
  592. if derefdatalen=0 then
  593. begin
  594. WriteError('!! Error: derefdatalen=0');
  595. exit;
  596. end;
  597. Writeln('Derefdata length: ',derefdatalen);
  598. derefdata:=allocmem(derefdatalen);
  599. ppufile.getdata(derefdata^,derefdatalen);
  600. end;
  601. Procedure FreeDerefdata;
  602. begin
  603. if assigned(derefdata) then
  604. begin
  605. FreeMem(derefdata);
  606. derefdata:=nil;
  607. derefdatalen:=0;
  608. end;
  609. end;
  610. Procedure ReadWpoFileInfo;
  611. begin
  612. Writeln('Compiled with input whole-program optimisation from ',ppufile.getstring,' ',filetimestring(ppufile.getlongint));
  613. end;
  614. Procedure ReadAsmSymbols;
  615. type
  616. { Copied from aasmbase.pas }
  617. TAsmsymbind=(
  618. AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL,AB_WEAK_EXTERNAL,
  619. { global in the current program/library, but not visible outside it }
  620. AB_PRIVATE_EXTERN,AB_LAZY,AB_IMPORT);
  621. TAsmsymtype=(
  622. AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL,
  623. {
  624. the address of this code label is taken somewhere in the code
  625. so it must be taken care of it when creating pic
  626. }
  627. AT_ADDR
  628. );
  629. var
  630. s,
  631. bindstr,
  632. typestr : string;
  633. i : longint;
  634. begin
  635. writeln(space,'Number of AsmSymbols: ',ppufile.getlongint);
  636. i:=0;
  637. while (not ppufile.endofentry) and (not ppufile.error) do
  638. begin
  639. s:=ppufile.getstring;
  640. case tasmsymbind(ppufile.getbyte) of
  641. AB_EXTERNAL :
  642. bindstr:='External';
  643. AB_COMMON :
  644. bindstr:='Common';
  645. AB_LOCAL :
  646. bindstr:='Local';
  647. AB_GLOBAL :
  648. bindstr:='Global';
  649. AB_WEAK_EXTERNAL :
  650. bindstr:='Weak external';
  651. AB_PRIVATE_EXTERN :
  652. bindstr:='Private extern';
  653. AB_LAZY :
  654. bindstr:='Lazy';
  655. AB_IMPORT :
  656. bindstr:='Import';
  657. else
  658. begin
  659. bindstr:='<Error !!>';
  660. has_errors:=true;
  661. end;
  662. end;
  663. case tasmsymtype(ppufile.getbyte) of
  664. AT_FUNCTION :
  665. typestr:='Function';
  666. AT_DATA :
  667. typestr:='Data';
  668. AT_SECTION :
  669. typestr:='Section';
  670. AT_LABEL :
  671. typestr:='Label';
  672. AT_ADDR :
  673. typestr:='Label (with address taken)';
  674. else
  675. begin
  676. typestr:='<Error !!>';
  677. has_errors:=true;
  678. end;
  679. end;
  680. Writeln(space,' ',i,' : ',s,' [',bindstr,',',typestr,']');
  681. inc(i);
  682. end;
  683. end;
  684. function getexprint:Tconstexprint;
  685. begin
  686. getexprint.overflow:=false;
  687. getexprint.signed:=boolean(ppufile.getbyte);
  688. getexprint.svalue:=ppufile.getint64;
  689. end;
  690. Procedure ReadPosInfo;
  691. var
  692. info : byte;
  693. fileindex,line,column : longint;
  694. begin
  695. with ppufile do
  696. begin
  697. {
  698. info byte layout in bits:
  699. 0-1 - amount of bytes for fileindex
  700. 2-3 - amount of bytes for line
  701. 4-5 - amount of bytes for column
  702. }
  703. info:=getbyte;
  704. case (info and $03) of
  705. 0 : fileindex:=getbyte;
  706. 1 : fileindex:=getword;
  707. 2 : fileindex:=(getbyte shl 16) or getword;
  708. 3 : fileindex:=getlongint;
  709. end;
  710. case ((info shr 2) and $03) of
  711. 0 : line:=getbyte;
  712. 1 : line:=getword;
  713. 2 : line:=(getbyte shl 16) or getword;
  714. 3 : line:=getlongint;
  715. end;
  716. case ((info shr 4) and $03) of
  717. 0 : column:=getbyte;
  718. 1 : column:=getword;
  719. 2 : column:=(getbyte shl 16) or getword;
  720. 3 : column:=getlongint;
  721. end;
  722. Writeln(fileindex,' (',line,',',column,')');
  723. end;
  724. end;
  725. procedure readderef(const derefspace: string);
  726. var
  727. b : tdereftype;
  728. first : boolean;
  729. idx : longint;
  730. i,n : byte;
  731. pdata : pbyte;
  732. begin
  733. if not assigned(derefdata) then
  734. exit;
  735. first:=true;
  736. idx:=ppufile.getlongint;
  737. if (idx>derefdatalen) then
  738. begin
  739. writeln('!! Error: Deref idx ',idx,' > ',derefdatalen);
  740. has_errors:=true;
  741. exit;
  742. end;
  743. write(derefspace,'(',idx,') ');
  744. pdata:=@derefdata[idx];
  745. i:=0;
  746. n:=pdata[i];
  747. inc(i);
  748. if n<1 then
  749. begin
  750. WriteError('!! Error: Deref len < 1');
  751. exit;
  752. end;
  753. while (i<=n) do
  754. begin
  755. if not first then
  756. write(', ')
  757. else
  758. first:=false;
  759. b:=tdereftype(pdata[i]);
  760. inc(i);
  761. case b of
  762. deref_nil :
  763. write('Nil');
  764. deref_symid :
  765. begin
  766. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  767. inc(i,4);
  768. write('SymId ',idx);
  769. end;
  770. deref_defid :
  771. begin
  772. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  773. inc(i,4);
  774. write('DefId ',idx);
  775. end;
  776. deref_unit :
  777. begin
  778. idx:=pdata[i] shl 8 or pdata[i+1];
  779. inc(i,2);
  780. write('Unit ',idx);
  781. end;
  782. else
  783. begin
  784. writeln('!! unsupported dereftyp: ',ord(b));
  785. has_errors:=true;
  786. break;
  787. end;
  788. end;
  789. end;
  790. writeln;
  791. end;
  792. procedure readpropaccesslist(const s:string);
  793. { type tsltype is in symconst unit }
  794. const
  795. slstr : array[tsltype] of string[12] = (
  796. '',
  797. 'load',
  798. 'call',
  799. 'subscript',
  800. 'vec',
  801. 'typeconv',
  802. 'absolutetype'
  803. );
  804. var
  805. sl : tsltype;
  806. begin
  807. readderef('');
  808. repeat
  809. sl:=tsltype(ppufile.getbyte);
  810. if sl=sl_none then
  811. break;
  812. write(s,'(',slstr[sl],') ');
  813. case sl of
  814. sl_call,
  815. sl_load,
  816. sl_subscript :
  817. readderef('');
  818. sl_absolutetype,
  819. sl_typeconv :
  820. readderef('');
  821. sl_vec :
  822. begin
  823. writeln(ppufile.getlongint);
  824. readderef('');
  825. end;
  826. end;
  827. until false;
  828. end;
  829. (*
  830. talignmentinfo = packed record
  831. procalign,
  832. loopalign,
  833. jumpalign,
  834. constalignmin,
  835. constalignmax,
  836. varalignmin,
  837. varalignmax,
  838. localalignmin,
  839. localalignmax,
  840. recordalignmin,
  841. recordalignmax,
  842. maxCrecordalign : longint;
  843. end;
  844. tsettings = packed record
  845. alignment : talignmentinfo;
  846. globalswitches : tglobalswitches;
  847. moduleswitches : tmoduleswitches;
  848. localswitches : tlocalswitches;
  849. modeswitches : tmodeswitches;
  850. optimizerswitches : toptimizerswitches;
  851. { generate information necessary to perform these wpo's during a subsequent compilation }
  852. genwpoptimizerswitches: twpoptimizerswitches;
  853. { perform these wpo's using information generated during a previous compilation }
  854. dowpoptimizerswitches: twpoptimizerswitches;
  855. debugswitches : tdebugswitches;
  856. { 0: old behaviour for sets <=256 elements
  857. >0: round to this size }
  858. setalloc,
  859. packenum : shortint;
  860. packrecords : shortint;
  861. maxfpuregisters : shortint;
  862. cputype,
  863. optimizecputype : tcputype;
  864. fputype : tfputype;
  865. asmmode : tasmmode;
  866. interfacetype : tinterfacetypes;
  867. defproccall : tproccalloption;
  868. sourcecodepage : tcodepagestring;
  869. minfpconstprec : tfloattype;
  870. disabledircache : boolean;
  871. { CPU targets with microcontroller support can add a controller specific unit }
  872. {$if defined(ARM) or defined(AVR)}
  873. controllertype : tcontrollertype;
  874. {$endif defined(ARM) or defined(AVR)}
  875. { WARNING: this pointer cannot be written as such in record token }
  876. pmessage : pmessagestaterecord;
  877. end;
  878. *)
  879. procedure readprocinfooptions(space : string);
  880. (*
  881. tprocinfoflag=(
  882. { procedure has at least one assembler block }
  883. pi_has_assembler_block,
  884. { procedure does a call }
  885. pi_do_call,
  886. { procedure has a try statement = no register optimization }
  887. pi_uses_exceptions,
  888. { procedure is declared as @var(assembler), don't optimize}
  889. pi_is_assembler,
  890. { procedure contains data which needs to be finalized }
  891. pi_needs_implicit_finally,
  892. { procedure has the implicit try..finally generated }
  893. pi_has_implicit_finally,
  894. { procedure uses fpu}
  895. pi_uses_fpu,
  896. { procedure uses GOT for PIC code }
  897. pi_needs_got,
  898. { references var/proc/type/const in static symtable,
  899. i.e. not allowed for inlining from other units }
  900. pi_uses_static_symtable,
  901. { set if the procedure has to push parameters onto the stack }
  902. pi_has_stackparameter,
  903. { set if the procedure has at least one label }
  904. pi_has_label,
  905. { calls itself recursive }
  906. pi_is_recursive,
  907. { stack frame optimization not possible (only on x86 probably) }
  908. pi_needs_stackframe,
  909. { set if the procedure has at least one register saved on the stack }
  910. pi_has_saved_regs,
  911. { dfa was generated for this proc }
  912. pi_dfaavailable,
  913. { subroutine contains interprocedural used labels }
  914. pi_has_interproclabel,
  915. { subroutine contains interprocedural gotos }
  916. pi_has_global_goto
  917. ); *)
  918. type
  919. tprocinfoopt=record
  920. mask : tprocinfoflag;
  921. str : string[80];
  922. end;
  923. const
  924. procinfoopts=ord(high(tprocinfoflag)) - ord(low(tprocinfoflag));
  925. procinfoopt : array[0..procinfoopts] of tprocinfoopt=(
  926. (mask:pi_has_assembler_block;
  927. str:' has at least one assembler block'),
  928. (mask:pi_do_call;
  929. str:' does a call'),
  930. (mask:pi_uses_exceptions;
  931. str:' has a try statement = no register optimization '),
  932. (mask:pi_is_assembler;
  933. str:' is declared as @var(assembler), don''t optimize'),
  934. (mask:pi_needs_implicit_finally;
  935. str:' contains data which needs to be finalized '),
  936. (mask:pi_has_implicit_finally;
  937. str:' has the implicit try..finally generated '),
  938. (mask:pi_uses_fpu;
  939. str:' uses fpu'),
  940. (mask:pi_needs_got;
  941. str:' uses GOT for PIC code '),
  942. (mask:pi_uses_static_symtable;
  943. str:' references var/proc/type/const in static symtable'),
  944. (mask:pi_has_stackparameter;
  945. str:' set if the procedure has to push parameters onto the stack '),
  946. (mask:pi_has_label;
  947. str:' set if the procedure has at least one label '),
  948. (mask:pi_is_recursive;
  949. str:' calls itself recursive '),
  950. (mask:pi_needs_stackframe;
  951. str:' stack frame optimization not possible (only on x86 probably) '),
  952. (mask:pi_has_saved_regs;
  953. str:' set if the procedure has at least one register saved on the stack '),
  954. (mask:pi_dfaavailable;
  955. str:' dfa was generated for this proc '),
  956. (mask:pi_has_interproclabel;
  957. str:' subroutine contains interprocedural used labels '),
  958. (mask:pi_has_unwind_info;
  959. str:' unwinding info was generated for this proc '),
  960. (mask:pi_has_global_goto;
  961. str:' subroutine contains interprocedural goto '),
  962. (mask:pi_has_inherited;
  963. str:' subroutine contains inherited call ')
  964. );
  965. var
  966. procinfooptions : tprocinfoflags;
  967. i : longint;
  968. first : boolean;
  969. begin
  970. ppufile.getsmallset(procinfooptions);
  971. if procinfooptions<>[] then
  972. begin
  973. first:=true;
  974. for i:=0 to procinfoopts do
  975. if (procinfoopt[i].mask in procinfooptions) then
  976. begin
  977. if first then
  978. first:=false
  979. else
  980. write(', ');
  981. write(procinfoopt[i].str);
  982. end;
  983. end;
  984. writeln;
  985. end;
  986. procedure readsymoptions(space : string);
  987. type
  988. tsymopt=record
  989. mask : tsymoption;
  990. str : string[30];
  991. end;
  992. const
  993. symopts=ord(high(tsymoption)) - ord(low(tsymoption));
  994. { sp_none = 0 corresponds to nothing }
  995. symopt : array[1..symopts] of tsymopt=(
  996. (mask:sp_static; str:'Static'),
  997. (mask:sp_hint_deprecated; str:'Hint Deprecated'),
  998. (mask:sp_hint_platform; str:'Hint Platform'),
  999. (mask:sp_hint_library; str:'Hint Library'),
  1000. (mask:sp_hint_unimplemented; str:'Hint Unimplemented'),
  1001. (mask:sp_hint_experimental; str:'Hint Experimental'),
  1002. (mask:sp_has_overloaded; str:'Has overloaded'),
  1003. (mask:sp_internal; str:'Internal'),
  1004. (mask:sp_implicitrename; str:'Implicit Rename'),
  1005. (mask:sp_generic_para; str:'Generic Parameter'),
  1006. (mask:sp_has_deprecated_msg; str:'Has Deprecated Message'),
  1007. (mask:sp_generic_dummy; str:'Generic Dummy'),
  1008. (mask:sp_explicitrename; str:'Explicit Rename')
  1009. );
  1010. var
  1011. symoptions : tsymoptions;
  1012. i : longint;
  1013. first : boolean;
  1014. begin
  1015. ppufile.getsmallset(symoptions);
  1016. if symoptions<>[] then
  1017. begin
  1018. first:=true;
  1019. for i:=1to symopts do
  1020. if (symopt[i].mask in symoptions) then
  1021. begin
  1022. if first then
  1023. first:=false
  1024. else
  1025. write(', ');
  1026. write(symopt[i].str);
  1027. end;
  1028. end;
  1029. writeln;
  1030. if sp_has_deprecated_msg in symoptions then
  1031. writeln(space,'Deprecated : ', ppufile.getstring);
  1032. end;
  1033. procedure readcommonsym(const s:string);
  1034. begin
  1035. writeln(space,'** Symbol Id ',ppufile.getlongint,' **');
  1036. writeln(space,s,ppufile.getstring);
  1037. write (space,' File Pos : ');
  1038. readposinfo;
  1039. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  1040. write (space,' SymOptions : ');
  1041. readsymoptions(space+' ');
  1042. end;
  1043. var
  1044. { needed during tobjectdef parsing... }
  1045. current_defoptions : tdefoptions;
  1046. current_objectoptions : tobjectoptions;
  1047. procedure readcommondef(const s:string; out defoptions: tdefoptions);
  1048. type
  1049. tdefopt=record
  1050. mask : tdefoption;
  1051. str : string[30];
  1052. end;
  1053. tdefstateinfo=record
  1054. mask : tdefstate;
  1055. str : string[30];
  1056. end;
  1057. ptoken=^ttoken;
  1058. pmsgstate =^tmsgstate;
  1059. const
  1060. defopt : array[1..ord(high(tdefoption))] of tdefopt=(
  1061. (mask:df_unique; str:'Unique Type'),
  1062. (mask:df_generic; str:'Generic'),
  1063. (mask:df_specialization; str:'Specialization'),
  1064. (mask:df_copied_def; str:'Copied Typedef')
  1065. );
  1066. defstate : array[1..ord(high(tdefstate))] of tdefstateinfo=(
  1067. (mask:ds_vmt_written; str:'VMT Written'),
  1068. (mask:ds_rtti_table_used; str:'RTTITable Used'),
  1069. (mask:ds_init_table_used; str:'InitTable Used'),
  1070. (mask:ds_rtti_table_written; str:'RTTITable Written'),
  1071. (mask:ds_init_table_written; str:'InitTable Written'),
  1072. (mask:ds_dwarf_dbg_info_used; str:'Dwarf DbgInfo Used'),
  1073. (mask:ds_dwarf_dbg_info_written;str:'Dwarf DbgInfo Written')
  1074. );
  1075. var
  1076. defstates : tdefstates;
  1077. i, nb, msgvalue, mesgnb : longint;
  1078. first : boolean;
  1079. copy_size, min_size, tokenbufsize : longint;
  1080. tokenbuf : pbyte;
  1081. idtoken,
  1082. token : ttoken;
  1083. state : tmsgstate;
  1084. new_settings : Tsettings;
  1085. len : sizeint;
  1086. wstring : widestring;
  1087. astring : ansistring;
  1088. function readtoken: ttoken;
  1089. var
  1090. b,b2 : byte;
  1091. begin
  1092. b:=tokenbuf[i];
  1093. inc(i);
  1094. if (b and $80)<>0 then
  1095. begin
  1096. b2:=tokenbuf[i];
  1097. inc(i);
  1098. result:=ttoken(((b and $7f) shl 8) or b2);
  1099. end
  1100. else
  1101. result:=ttoken(b);
  1102. end;
  1103. function gettokenbufdword : dword;
  1104. var
  1105. var32 : dword;
  1106. begin
  1107. var32:=pdword(@tokenbuf[i])^;
  1108. inc(i,sizeof(dword));
  1109. if ppufile.change_endian then
  1110. var32:=swapendian(var32);
  1111. result:=var32;
  1112. end;
  1113. function gettokenbufword : word;
  1114. var
  1115. var16 : word;
  1116. begin
  1117. var16:=pword(@tokenbuf[i])^;
  1118. inc(i,sizeof(word));
  1119. if ppufile.change_endian then
  1120. var16:=swapendian(var16);
  1121. result:=var16;
  1122. end;
  1123. function gettokenbufsizeint : int64;
  1124. var
  1125. var64 : int64;
  1126. var32 : longint;
  1127. var16 : smallint;
  1128. begin
  1129. if CpuAddrBitSize[cpu]=64 then
  1130. begin
  1131. var64:=pint64(@tokenbuf[i])^;
  1132. inc(i,sizeof(int64));
  1133. if ppufile.change_endian then
  1134. var64:=swapendian(var64);
  1135. result:=var64;
  1136. end
  1137. else if CpuAddrBitSize[cpu]=32 then
  1138. begin
  1139. var32:=plongint(@tokenbuf[i])^;
  1140. inc(i,sizeof(longint));
  1141. if ppufile.change_endian then
  1142. var32:=swapendian(var32);
  1143. result:=var32;
  1144. end
  1145. else if CpuAddrBitSize[cpu]=16 then
  1146. begin
  1147. var16:=psmallint(@tokenbuf[i])^;
  1148. inc(i,sizeof(smallint));
  1149. if ppufile.change_endian then
  1150. var16:=swapendian(var16);
  1151. result:=var16;
  1152. end
  1153. else
  1154. begin
  1155. WriteError('Wrong CpuAddrBitSize');
  1156. result:=0;
  1157. end;
  1158. end;
  1159. begin
  1160. writeln(space,'** Definition Id ',ppufile.getlongint,' **');
  1161. writeln(space,s);
  1162. write (space,' Type symbol : ');
  1163. readderef('');
  1164. write (space,' DefOptions : ');
  1165. ppufile.getsmallset(defoptions);
  1166. if defoptions<>[] then
  1167. begin
  1168. first:=true;
  1169. for i:=1to high(defopt) do
  1170. if (defopt[i].mask in defoptions) then
  1171. begin
  1172. if first then
  1173. first:=false
  1174. else
  1175. write(', ');
  1176. write(defopt[i].str);
  1177. end;
  1178. end;
  1179. writeln;
  1180. write (space,' DefStates : ');
  1181. ppufile.getsmallset(defstates);
  1182. if defstates<>[] then
  1183. begin
  1184. first:=true;
  1185. for i:=1 to high(defstate) do
  1186. if (defstate[i].mask in defstates) then
  1187. begin
  1188. if first then
  1189. first:=false
  1190. else
  1191. write(', ');
  1192. write(defstate[i].str);
  1193. end;
  1194. end;
  1195. writeln;
  1196. if df_generic in defoptions then
  1197. begin
  1198. tokenbufsize:=ppufile.getlongint;
  1199. writeln(space,' Tokenbuffer size : ',tokenbufsize);
  1200. tokenbuf:=allocmem(tokenbufsize);
  1201. ppufile.getdata(tokenbuf^,tokenbufsize);
  1202. i:=0;
  1203. write(space,' Tokens: ');
  1204. while i<tokenbufsize do
  1205. begin
  1206. token:=readtoken;
  1207. if token<>_GENERICSPECIALTOKEN then
  1208. begin
  1209. if token <= high(ttoken) then
  1210. write(arraytokeninfo[token].str)
  1211. else
  1212. begin
  1213. HasMoreInfos;
  1214. write('Error in Token List');
  1215. break;
  1216. end;
  1217. idtoken:=readtoken;
  1218. end;
  1219. case token of
  1220. _CWCHAR,
  1221. _CWSTRING :
  1222. begin
  1223. len:=gettokenbufsizeint;
  1224. setlength(wstring,len);
  1225. move(tokenbuf[i],wstring[1],len*2);
  1226. write(' ',wstring);
  1227. inc(i,len*2);
  1228. end;
  1229. _CSTRING:
  1230. begin
  1231. len:=gettokenbufsizeint;
  1232. setlength(astring,len);
  1233. move(tokenbuf[i],astring[1],len);
  1234. write(' ',astring);
  1235. inc(i,len);
  1236. end;
  1237. _CCHAR,
  1238. _INTCONST,
  1239. _REALNUMBER :
  1240. begin
  1241. write(' ',pshortstring(@tokenbuf[i])^);
  1242. inc(i,tokenbuf[i]+1);
  1243. end;
  1244. _ID :
  1245. begin
  1246. write(' ',pshortstring(@tokenbuf[i])^);
  1247. inc(i,tokenbuf[i]+1);
  1248. end;
  1249. _GENERICSPECIALTOKEN:
  1250. begin
  1251. { Short version of column change,
  1252. byte or $80 used }
  1253. if (tokenbuf[i] and $80)<>0 then
  1254. begin
  1255. write('Col: ',tokenbuf[i] and $7f);
  1256. inc(i);
  1257. end
  1258. else
  1259. case tspecialgenerictoken(tokenbuf[i]) of
  1260. ST_LOADSETTINGS:
  1261. begin
  1262. inc(i);
  1263. write('Settings');
  1264. { This does not load pmessage pointer }
  1265. new_settings.pmessage:=nil;
  1266. { TSettings size depends in target...
  1267. We first read the size of the copied part }
  1268. { Still not cross endian ready :( }
  1269. copy_size:=gettokenbufsizeint;
  1270. if copy_size < sizeof(tsettings)-sizeof(pointer) then
  1271. min_size:=copy_size
  1272. else
  1273. min_size:= sizeof(tsettings)-sizeof(pointer);
  1274. move(tokenbuf[i],new_settings, min_size);
  1275. inc(i,copy_size);
  1276. end;
  1277. ST_LOADMESSAGES:
  1278. begin
  1279. inc(i);
  1280. write('Messages:');
  1281. mesgnb:=tokenbuf[i];
  1282. inc(i);
  1283. for nb:=1 to mesgnb do
  1284. begin
  1285. msgvalue:=gettokenbufsizeint;
  1286. inc(i,sizeof(sizeint));
  1287. state:=tmsgstate(gettokenbufsizeint);
  1288. end;
  1289. end;
  1290. ST_LINE:
  1291. begin
  1292. inc(i);
  1293. write('Line: ',gettokenbufdword);
  1294. end;
  1295. ST_COLUMN:
  1296. begin
  1297. inc(i);
  1298. write('Col: ',gettokenbufword);
  1299. end;
  1300. ST_FILEINDEX:
  1301. begin
  1302. inc(i);
  1303. write('File: ',gettokenbufword);
  1304. end;
  1305. end;
  1306. end;
  1307. end;
  1308. if i<tokenbufsize then
  1309. write(',');
  1310. end;
  1311. writeln;
  1312. freemem(tokenbuf);
  1313. end;
  1314. if df_specialization in defoptions then
  1315. begin
  1316. write (space,' Orig. GenericDef : ');
  1317. readderef('');
  1318. end;
  1319. current_defoptions:=defoptions;
  1320. end;
  1321. { Read abstract procdef and return if inline procdef }
  1322. { type tproccalloption is in globtype unit }
  1323. { type tproctypeoption is in globtype unit }
  1324. { type tprocoption is in globtype unit }
  1325. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions);
  1326. type
  1327. tproccallopt=record
  1328. mask : tproccalloption;
  1329. str : string[30];
  1330. end;
  1331. tproctypeopt=record
  1332. mask : tproctypeoption;
  1333. str : string[30];
  1334. end;
  1335. tprocopt=record
  1336. mask : tprocoption;
  1337. str : string[31];
  1338. end;
  1339. const
  1340. {proccalloptionStr is also in globtype unit }
  1341. proctypeopt : array[1..ord(high(tproctypeoption))] of tproctypeopt=(
  1342. (mask:potype_proginit; str:'ProgInit'),
  1343. (mask:potype_unitinit; str:'UnitInit'),
  1344. (mask:potype_unitfinalize; str:'UnitFinalize'),
  1345. (mask:potype_constructor; str:'Constructor'),
  1346. (mask:potype_destructor; str:'Destructor'),
  1347. (mask:potype_operator; str:'Operator'),
  1348. (mask:potype_procedure; str:'Procedure'),
  1349. (mask:potype_function; str:'Function'),
  1350. (mask:potype_class_constructor; str:'Class Constructor'),
  1351. (mask:potype_class_destructor; str:'Class Destructor'),
  1352. { Dispinterface property accessors }
  1353. (mask:potype_propgetter; str:'Property Getter'),
  1354. (mask:potype_propsetter; str:'Property Setter'),
  1355. (mask:potype_exceptfilter; str:'SEH filter')
  1356. );
  1357. procopt : array[1..ord(high(tprocoption))] of tprocopt=(
  1358. (mask:po_classmethod; str:'ClassMethod'),
  1359. (mask:po_virtualmethod; str:'VirtualMethod'),
  1360. (mask:po_abstractmethod; str:'AbstractMethod'),
  1361. (mask:po_finalmethod; str:'FinalMethod'),
  1362. (mask:po_staticmethod; str:'StaticMethod'),
  1363. (mask:po_overridingmethod;str:'OverridingMethod'),
  1364. (mask:po_methodpointer; str:'MethodPointer'),
  1365. (mask:po_interrupt; str:'Interrupt'),
  1366. (mask:po_iocheck; str:'IOCheck'),
  1367. (mask:po_assembler; str:'Assembler'),
  1368. (mask:po_msgstr; str:'MsgStr'),
  1369. (mask:po_msgint; str:'MsgInt'),
  1370. (mask:po_exports; str:'Exports'),
  1371. (mask:po_external; str:'External'),
  1372. (mask:po_overload; str:'Overload'),
  1373. (mask:po_varargs; str:'VarArgs'),
  1374. (mask:po_internconst; str:'InternConst'),
  1375. (mask:po_addressonly; str:'AddressOnly'),
  1376. (mask:po_public; str:'Public'),
  1377. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  1378. (mask:po_reintroduce; str:'ReIntroduce'),
  1379. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  1380. (mask:po_nostackframe; str:'NoStackFrame'),
  1381. (mask:po_has_mangledname; str:'HasMangledName'),
  1382. (mask:po_has_public_name; str:'HasPublicName'),
  1383. (mask:po_forward; str:'Forward'),
  1384. (mask:po_global; str:'Global'),
  1385. (mask:po_has_inlininginfo;str:'HasInliningInfo'),
  1386. (mask:po_syscall_legacy; str:'SyscallLegacy'),
  1387. (mask:po_syscall_sysv; str:'SyscallSysV'),
  1388. (mask:po_syscall_basesysv;str:'SyscallBaseSysV'),
  1389. (mask:po_syscall_sysvbase;str:'SyscallSysVBase'),
  1390. (mask:po_syscall_r12base; str:'SyscallR12Base'),
  1391. (mask:po_inline; str:'Inline'),
  1392. (mask:po_compilerproc; str:'CompilerProc'),
  1393. (mask:po_has_importdll; str:'HasImportDLL'),
  1394. (mask:po_has_importname; str:'HasImportName'),
  1395. (mask:po_kylixlocal; str:'KylixLocal'),
  1396. (mask:po_dispid; str:'DispId'),
  1397. (mask:po_weakexternal; str:'WeakExternal'),
  1398. (mask:po_objc; str:'ObjC'),
  1399. (mask:po_enumerator_movenext; str:'EnumeratorMoveNext'),
  1400. (mask:po_optional; str: 'Optional'),
  1401. (mask:po_delphi_nested_cc;str: 'Delphi-style nested frameptr'),
  1402. (mask:po_java_nonvirtual; str: 'Java non-virtual method'),
  1403. (mask:po_ignore_for_overload_resolution;str: 'Ignored for overload resolution'),
  1404. (mask:po_rtlproc; str: 'RTL procedure')
  1405. );
  1406. var
  1407. proctypeoption : tproctypeoption;
  1408. i : longint;
  1409. first : boolean;
  1410. tempbuf : array[0..255] of byte;
  1411. begin
  1412. write(space,' Return type : ');
  1413. readderef('');
  1414. writeln(space,' Fpu used : ',ppufile.getbyte);
  1415. proctypeoption:=tproctypeoption(ppufile.getbyte);
  1416. write(space,' TypeOption : ');
  1417. first:=true;
  1418. for i:=1 to high(proctypeopt) do
  1419. if (proctypeopt[i].mask=proctypeoption) then
  1420. begin
  1421. if first then
  1422. first:=false
  1423. else
  1424. write(', ');
  1425. write(proctypeopt[i].str);
  1426. end;
  1427. writeln;
  1428. proccalloption:=tproccalloption(ppufile.getbyte);
  1429. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  1430. ppufile.getnormalset(procoptions);
  1431. if procoptions<>[] then
  1432. begin
  1433. write(space,' Options : ');
  1434. first:=true;
  1435. for i:=1 to high(procopt) do
  1436. if (procopt[i].mask in procoptions) then
  1437. begin
  1438. if first then
  1439. first:=false
  1440. else
  1441. write(', ');
  1442. write(procopt[i].str);
  1443. end;
  1444. writeln;
  1445. end;
  1446. if (po_explicitparaloc in procoptions) then
  1447. begin
  1448. i:=ppufile.getbyte;
  1449. ppufile.getdata(tempbuf,i);
  1450. end;
  1451. end;
  1452. { type tvaroption is in unit symconst }
  1453. { register variable }
  1454. { type tvarregable is in unit symconst }
  1455. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions);
  1456. type
  1457. tvaropt=record
  1458. mask : tvaroption;
  1459. str : string[30];
  1460. end;
  1461. const
  1462. varopt : array[1..ord(high(tvaroption))] of tvaropt=(
  1463. (mask:vo_is_external; str:'External'),
  1464. (mask:vo_is_dll_var; str:'DLLVar'),
  1465. (mask:vo_is_thread_var; str:'ThreadVar'),
  1466. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  1467. (mask:vo_is_const; str:'Constant'),
  1468. (mask:vo_is_public; str:'Public'),
  1469. (mask:vo_is_high_para; str:'HighValue'),
  1470. (mask:vo_is_funcret; str:'Funcret'),
  1471. (mask:vo_is_self; str:'Self'),
  1472. (mask:vo_is_vmt; str:'VMT'),
  1473. (mask:vo_is_result; str:'Result'),
  1474. (mask:vo_is_parentfp; str:'ParentFP'),
  1475. (mask:vo_is_loop_counter; str:'LoopCounter'),
  1476. (mask:vo_is_hidden_para; str:'Hidden'),
  1477. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  1478. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  1479. (mask:vo_has_mangledname; str:'HasMangledName'),
  1480. (mask:vo_is_typed_const; str:'TypedConst'),
  1481. (mask:vo_is_range_check; str:'RangeCheckSwitch'),
  1482. (mask:vo_is_overflow_check; str:'OverflowCheckSwitch'),
  1483. (mask:vo_is_typinfo_para; str:'TypeInfo'),
  1484. (mask:vo_is_msgsel;str:'MsgSel'),
  1485. (mask:vo_is_weak_external;str:'WeakExternal'),
  1486. (mask:vo_is_first_field;str:'IsFirstField'),
  1487. (mask:vo_volatile;str:'Volatile'),
  1488. (mask:vo_has_section;str:'HasSection'),
  1489. (mask:vo_force_finalize;str:'ForceFinalize'),
  1490. (mask:vo_is_default_var;str:'DefaultIntrinsicVar')
  1491. );
  1492. var
  1493. i : longint;
  1494. first : boolean;
  1495. begin
  1496. readcommonsym(s);
  1497. writeln(space,' Spez : ',Varspez2Str(ppufile.getbyte));
  1498. writeln(space,' Regable : ',Varregable2Str(ppufile.getbyte));
  1499. writeln(space,' Addr Taken : ',(ppufile.getbyte<>0));
  1500. write (space,' Var Type : ');
  1501. readderef('');
  1502. ppufile.getsmallset(varoptions);
  1503. if varoptions<>[] then
  1504. begin
  1505. write(space,' Options : ');
  1506. first:=true;
  1507. for i:=1 to high(varopt) do
  1508. if (varopt[i].mask in varoptions) then
  1509. begin
  1510. if first then
  1511. first:=false
  1512. else
  1513. write(', ');
  1514. write(varopt[i].str);
  1515. if varopt[i].mask = vo_has_section then
  1516. writeln('Section name:',ppufile.getansistring);
  1517. end;
  1518. writeln;
  1519. end;
  1520. end;
  1521. procedure readobjectdefoptions;
  1522. type
  1523. tsymopt=record
  1524. mask : tobjectoption;
  1525. str : string[30];
  1526. end;
  1527. const
  1528. symopt : array[1..ord(high(tobjectoption))] of tsymopt=(
  1529. (mask:oo_is_forward; str:'IsForward'),
  1530. (mask:oo_is_abstract; str:'IsAbstract'),
  1531. (mask:oo_is_sealed; str:'IsSealed'),
  1532. (mask:oo_has_virtual; str:'HasVirtual'),
  1533. (mask:oo_has_private; str:'HasPrivate'),
  1534. (mask:oo_has_protected; str:'HasProtected'),
  1535. (mask:oo_has_strictprivate; str:'HasStrictPrivate'),
  1536. (mask:oo_has_strictprotected;str:'HasStrictProtected'),
  1537. (mask:oo_has_constructor; str:'HasConstructor'),
  1538. (mask:oo_has_destructor; str:'HasDestructor'),
  1539. (mask:oo_has_vmt; str:'HasVMT'),
  1540. (mask:oo_has_msgstr; str:'HasMsgStr'),
  1541. (mask:oo_has_msgint; str:'HasMsgInt'),
  1542. (mask:oo_can_have_published; str:'CanHavePublished'),
  1543. (mask:oo_has_default_property;str:'HasDefaultProperty'),
  1544. (mask:oo_has_valid_guid; str:'HasValidGUID'),
  1545. (mask:oo_has_enumerator_movenext; str:'HasEnumeratorMoveNext'),
  1546. (mask:oo_has_enumerator_current; str:'HasEnumeratorCurrent'),
  1547. (mask:oo_is_external; str:'External'),
  1548. (mask:oo_is_formal; str:'Formal'),
  1549. (mask:oo_is_classhelper; str:'Class Helper/Category'),
  1550. (mask:oo_has_class_constructor; str:'HasClassConstructor'),
  1551. (mask:oo_has_class_destructor; str:'HasClassDestructor'),
  1552. (mask:oo_is_enum_class; str:'JvmEnumClass'),
  1553. (mask:oo_has_new_destructor; str:'HasNewDestructor')
  1554. );
  1555. var
  1556. i : longint;
  1557. first : boolean;
  1558. begin
  1559. ppufile.getsmallset(current_objectoptions);
  1560. if current_objectoptions<>[] then
  1561. begin
  1562. first:=true;
  1563. for i:=1 to high(symopt) do
  1564. if (symopt[i].mask in current_objectoptions) then
  1565. begin
  1566. if first then
  1567. first:=false
  1568. else
  1569. write(', ');
  1570. write(symopt[i].str);
  1571. end;
  1572. end;
  1573. writeln;
  1574. end;
  1575. procedure readarraydefoptions;
  1576. { type tarraydefoption is in unit symconst }
  1577. type
  1578. tsymopt=record
  1579. mask : tarraydefoption;
  1580. str : string[30];
  1581. end;
  1582. const
  1583. symopt : array[1..ord(high(tarraydefoption))] of tsymopt=(
  1584. (mask:ado_IsConvertedPointer;str:'ConvertedPointer'),
  1585. (mask:ado_IsDynamicArray; str:'IsDynamicArray'),
  1586. (mask:ado_IsVariant; str:'IsVariant'),
  1587. (mask:ado_IsConstructor; str:'IsConstructor'),
  1588. (mask:ado_IsArrayOfConst; str:'ArrayOfConst'),
  1589. (mask:ado_IsConstString; str:'ConstString'),
  1590. (mask:ado_IsBitPacked; str:'BitPacked')
  1591. );
  1592. var
  1593. symoptions : tarraydefoptions;
  1594. i : longint;
  1595. first : boolean;
  1596. begin
  1597. ppufile.getsmallset(symoptions);
  1598. if symoptions<>[] then
  1599. begin
  1600. first:=true;
  1601. for i:=1 to high(symopt) do
  1602. if (symopt[i].mask in symoptions) then
  1603. begin
  1604. if first then
  1605. first:=false
  1606. else
  1607. write(', ');
  1608. write(symopt[i].str);
  1609. end;
  1610. end;
  1611. writeln;
  1612. end;
  1613. (* options for properties
  1614. tpropertyoption=(ppo_none,
  1615. ppo_indexed,
  1616. ppo_defaultproperty,
  1617. ppo_stored,
  1618. ppo_hasparameters,
  1619. ppo_implements,
  1620. ppo_enumerator_current,
  1621. ppo_overrides,
  1622. ppo_dispid_write { no longer used }
  1623. );
  1624. tpropertyoptions=set of tpropertyoption;
  1625. *)
  1626. function readpropertyoptions:tpropertyoptions;
  1627. { type tarraydefoption is in unit symconst }
  1628. type
  1629. tpropopt=record
  1630. mask : tpropertyoption;
  1631. str : string[30];
  1632. end;
  1633. const
  1634. symopt : array[1..ord(high(tpropertyoption))] of tpropopt=(
  1635. (mask:ppo_indexed;str:'indexed'),
  1636. (mask:ppo_defaultproperty;str:'default'),
  1637. (mask:ppo_stored;str:'stored'),
  1638. (mask:ppo_hasparameters;str:'has parameters'),
  1639. (mask:ppo_implements;str:'implements'),
  1640. (mask:ppo_enumerator_current;str:'enumerator current'),
  1641. (mask:ppo_overrides;str:'overrides'),
  1642. (mask:ppo_dispid_write;str:'dispid write') { no longer used }
  1643. );
  1644. var
  1645. i : longint;
  1646. first : boolean;
  1647. begin
  1648. ppufile.getsmallset(result);
  1649. if result<>[] then
  1650. begin
  1651. first:=true;
  1652. for i:=1 to high(symopt) do
  1653. if (symopt[i].mask in result) then
  1654. begin
  1655. if first then
  1656. first:=false
  1657. else
  1658. write(', ');
  1659. write(symopt[i].str);
  1660. end;
  1661. end;
  1662. writeln;
  1663. end;
  1664. procedure readnodetree;
  1665. var
  1666. l : longint;
  1667. p : pointer;
  1668. begin
  1669. with ppufile do
  1670. begin
  1671. if space<>'' then
  1672. Writeln(space,'------ nodetree ------');
  1673. if readentry=ibnodetree then
  1674. begin
  1675. l:=entrysize;
  1676. Writeln(space,'Tree size : ',l);
  1677. { Read data to prevent error that entry is not completly read }
  1678. getmem(p,l);
  1679. getdata(p^,l);
  1680. freemem(p);
  1681. end
  1682. else
  1683. begin
  1684. WriteError('!! ibnodetree not found');
  1685. end;
  1686. end;
  1687. end;
  1688. procedure ReadCreatedObjTypes;
  1689. var
  1690. i,j,
  1691. len,
  1692. bssize: longint;
  1693. bs: pbyte;
  1694. begin
  1695. if ppufile.readentry<>ibcreatedobjtypes then
  1696. begin
  1697. writeln('!! ibcreatedobjtypes entry not found');
  1698. ppufile.skipdata(ppufile.entrysize);
  1699. has_errors:=true;
  1700. exit
  1701. end;
  1702. writeln;
  1703. writeln(space,'WPO info');
  1704. writeln(space,'--------');
  1705. len:=ppufile.getlongint;
  1706. writeln(space,'** Instantiated Object/Class types: ',len,' **');
  1707. space:=space+' ';
  1708. for i:=0 to len-1 do
  1709. readderef(space);
  1710. setlength(space,length(space)-2);
  1711. len:=ppufile.getlongint;
  1712. writeln(space,'** Instantiated ClassRef types: ',len,' **');
  1713. space:=space+' ';
  1714. for i:=0 to len-1 do
  1715. readderef(space);
  1716. setlength(space,length(space)-2);
  1717. len:=ppufile.getlongint;
  1718. writeln(space,'** Possibly instantiated ClassRef types : ',len,' **');
  1719. space:=space+' ';
  1720. for i:=0 to len-1 do
  1721. readderef(space);
  1722. setlength(space,length(space)-2);
  1723. len:=ppufile.getlongint;
  1724. writeln(space,'** Class types with called virtual methods info : ',len,' **');
  1725. space:=space+' ';
  1726. for i:=0 to len-1 do
  1727. begin
  1728. write(space,'Class def : ');
  1729. readderef('');
  1730. write(space+' ','Called vmtentries : ');
  1731. bssize:=ppufile.getlongint;
  1732. getmem(bs,bssize);
  1733. ppufile.readdata(bs^,bssize);
  1734. for j:=0 to bssize*8-1 do
  1735. if (((bs+j shr 3)^ shr (j and 7)) and 1) <> 0 then
  1736. write(j,', ');
  1737. writeln;
  1738. freemem(bs);
  1739. end;
  1740. setlength(space,length(space)-2);
  1741. end;
  1742. {****************************************************************************
  1743. Read Symbols Part
  1744. ****************************************************************************}
  1745. procedure readsymbols(const s:string);
  1746. type
  1747. pguid = ^tguid;
  1748. tguid = packed record
  1749. D1: LongWord;
  1750. D2: Word;
  1751. D3: Word;
  1752. D4: array[0..7] of Byte;
  1753. end;
  1754. var
  1755. b : byte;
  1756. pc : pchar;
  1757. ch : dword;
  1758. startnewline : boolean;
  1759. i,j,len : longint;
  1760. prettyname : ansistring;
  1761. guid : tguid;
  1762. realvalue : ppureal;
  1763. doublevalue : double;
  1764. singlevalue : single;
  1765. extended : TSplit80bitReal;
  1766. tempbuf : array[0..127] of char;
  1767. pw : pcompilerwidestring;
  1768. varoptions : tvaroptions;
  1769. propoptions : tpropertyoptions;
  1770. begin
  1771. with ppufile do
  1772. begin
  1773. if space<>'' then
  1774. Writeln(space,'------ ',s,' ------');
  1775. if readentry=ibstartsyms then
  1776. begin
  1777. Writeln(space,'Symtable datasize : ',getlongint);
  1778. Writeln(space,'Symtable alignment: ',getlongint);
  1779. end
  1780. else
  1781. Writeln('!! ibstartsym not found');
  1782. repeat
  1783. b:=readentry;
  1784. case b of
  1785. ibunitsym :
  1786. readcommonsym('Unit symbol ');
  1787. ibnamespacesym :
  1788. begin
  1789. readcommonsym('NameSpace symbol ');
  1790. write(space,' Hidden Unit : ');
  1791. readderef('');
  1792. end;
  1793. iblabelsym :
  1794. readcommonsym('Label symbol ');
  1795. ibtypesym :
  1796. begin
  1797. readcommonsym('Type symbol ');
  1798. write(space,' Result Type : ');
  1799. readderef('');
  1800. prettyname:=getansistring;
  1801. if prettyname<>'' then
  1802. begin
  1803. write(space,' Pretty Name : ');
  1804. Writeln(prettyname);
  1805. end;
  1806. end;
  1807. ibprocsym :
  1808. begin
  1809. readcommonsym('Procedure symbol ');
  1810. len:=ppufile.getword;
  1811. for i:=1 to len do
  1812. begin
  1813. write(space,' Definition : ');
  1814. readderef('');
  1815. end;
  1816. end;
  1817. ibconstsym :
  1818. begin
  1819. readcommonsym('Constant symbol ');
  1820. b:=getbyte;
  1821. case tconsttyp(b) of
  1822. constord :
  1823. begin
  1824. write (space,' OrdinalType : ');
  1825. readderef('');
  1826. writeln(space,' Value : ',constexp.tostr(getexprint));
  1827. end;
  1828. constpointer :
  1829. begin
  1830. write (space,' PointerType : ');
  1831. readderef('');
  1832. writeln(space,' Value : ',getaint)
  1833. end;
  1834. conststring,
  1835. constresourcestring :
  1836. begin
  1837. len:=getlongint;
  1838. getmem(pc,len+1);
  1839. getdata(pc^,len);
  1840. (pc+len)^:= #0;
  1841. writeln(space,' Length : ',len);
  1842. writeln(space,' Value : "',pc,'"');
  1843. freemem(pc,len+1);
  1844. end;
  1845. constreal :
  1846. begin
  1847. write(space,' Value : ');
  1848. if entryleft=sizeof(ppureal) then
  1849. begin
  1850. realvalue:=getrealsize(sizeof(ppureal));
  1851. writeln(realvalue);
  1852. end
  1853. else if entryleft=sizeof(double) then
  1854. begin
  1855. doublevalue:=getrealsize(sizeof(double));
  1856. writeln(doublevalue);
  1857. end
  1858. else if entryleft=sizeof(single) then
  1859. begin
  1860. singlevalue:=getrealsize(sizeof(single));
  1861. writeln(singlevalue);
  1862. end
  1863. else if entryleft=10 then
  1864. begin
  1865. getdata(extended,entryleft);
  1866. writeln(Real80bitToStr(extended));
  1867. end
  1868. else
  1869. begin
  1870. realvalue:=0.0;
  1871. writeln(realvalue,' Error reading real value');
  1872. has_errors:=true;
  1873. end;
  1874. end;
  1875. constset :
  1876. begin
  1877. write (space,' Set Type : ');
  1878. readderef('');
  1879. for i:=1to 4 do
  1880. begin
  1881. write (space,' Value : ');
  1882. for j:=1to 8 do
  1883. begin
  1884. if j>1 then
  1885. write(',');
  1886. write(hexstr(getbyte,2));
  1887. end;
  1888. writeln;
  1889. end;
  1890. end;
  1891. constnil:
  1892. writeln(space,' NIL pointer.');
  1893. constwstring :
  1894. begin
  1895. initwidestring(pw);
  1896. setlengthwidestring(pw,getlongint);
  1897. if widecharsize=2 then
  1898. { don't use getdata, because the compilerwidechars may have to
  1899. be byteswapped
  1900. }
  1901. begin
  1902. for i:=0 to pw^.len-1 do
  1903. pw^.data[i]:=ppufile.getword;
  1904. end
  1905. else if widecharsize=4 then
  1906. begin
  1907. for i:=0 to pw^.len-1 do
  1908. pw^.data[i]:=cardinal(ppufile.getlongint);
  1909. end
  1910. else
  1911. begin
  1912. WriteError('Unsupported tcompilerwidechar size');
  1913. end;
  1914. Writeln(space,'Wide string type');
  1915. startnewline:=true;
  1916. for i:=0 to pw^.len-1 do
  1917. begin
  1918. if startnewline then
  1919. begin
  1920. write(space);
  1921. startnewline:=false;
  1922. end;
  1923. ch:=pw^.data[i];
  1924. if widecharsize=2 then
  1925. write(hexstr(ch,4))
  1926. else
  1927. write(hexstr(ch,8));
  1928. if (i mod 8)= 0 then
  1929. startnewline:=true
  1930. else
  1931. write(', ');
  1932. end;
  1933. donewidestring(pw);
  1934. end;
  1935. constguid:
  1936. begin
  1937. getdata(guid,sizeof(guid));
  1938. write (space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-');
  1939. for i:=0 to 7 do
  1940. begin
  1941. write(hexstr(guid.d4[i],2));
  1942. if i=1 then write('-');
  1943. end;
  1944. writeln('}');
  1945. end
  1946. else
  1947. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  1948. end;
  1949. end;
  1950. ibabsolutevarsym :
  1951. begin
  1952. readabstractvarsym('Absolute variable symbol ',varoptions);
  1953. Write (space,' Relocated to ');
  1954. b:=getbyte;
  1955. case absolutetyp(b) of
  1956. tovar :
  1957. readpropaccesslist(space+' Sym : ');
  1958. toasm :
  1959. Writeln('Assembler name : ',getstring);
  1960. toaddr :
  1961. begin
  1962. Write('Address : ',getlongint);
  1963. if tsystemcpu(ppufile.header.cpu)=cpu_i386 then
  1964. WriteLn(' (Far: ',getbyte<>0,')');
  1965. end;
  1966. else
  1967. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  1968. end;
  1969. end;
  1970. ibfieldvarsym :
  1971. begin
  1972. readabstractvarsym('Field Variable symbol ',varoptions);
  1973. writeln(space,' Address : ',getaint);
  1974. end;
  1975. ibstaticvarsym :
  1976. begin
  1977. readabstractvarsym('Global Variable symbol ',varoptions);
  1978. write (space,' DefaultConst : ');
  1979. readderef('');
  1980. if (vo_has_mangledname in varoptions) then
  1981. {$ifdef symansistr}
  1982. writeln(space,' Mangledname : ',getansistring);
  1983. {$else symansistr}
  1984. writeln(space,' Mangledname : ',getstring);
  1985. {$endif symansistr}
  1986. end;
  1987. iblocalvarsym :
  1988. begin
  1989. readabstractvarsym('Local Variable symbol ',varoptions);
  1990. write (space,' DefaultConst : ');
  1991. readderef('');
  1992. end;
  1993. ibparavarsym :
  1994. begin
  1995. readabstractvarsym('Parameter Variable symbol ',varoptions);
  1996. write (space,' DefaultConst : ');
  1997. readderef('');
  1998. writeln(space,' ParaNr : ',getword);
  1999. writeln(space,' Univ : ',boolean(getbyte));
  2000. writeln(space,' VarState : ',getbyte);
  2001. writeln(space,' Refs : ',getbyte);
  2002. if (vo_has_explicit_paraloc in varoptions) then
  2003. begin
  2004. i:=getbyte;
  2005. getdata(tempbuf,i);
  2006. end;
  2007. end;
  2008. ibenumsym :
  2009. begin
  2010. readcommonsym('Enumeration symbol ');
  2011. write (space,' Definition : ');
  2012. readderef('');
  2013. writeln(space,' Value : ',getlongint);
  2014. end;
  2015. ibsyssym :
  2016. begin
  2017. readcommonsym('Internal system symbol ');
  2018. writeln(space,' Internal Nr : ',getlongint);
  2019. end;
  2020. ibmacrosym :
  2021. begin
  2022. readcommonsym('Macro symbol ');
  2023. writeln(space,' Name: ',getstring);
  2024. writeln(space,' Defined: ',getbyte);
  2025. writeln(space,' Compiler var: ',getbyte);
  2026. len:=getlongint;
  2027. writeln(space,' Value length: ',len);
  2028. if len > 0 then
  2029. begin
  2030. getmem(pc,len+1);
  2031. getdata(pc^,len);
  2032. (pc+len)^:= #0;
  2033. writeln(space,' Value: "',pc,'"');
  2034. freemem(pc,len+1);
  2035. end;
  2036. end;
  2037. ibpropertysym :
  2038. begin
  2039. readcommonsym('Property ');
  2040. propoptions:=readpropertyoptions;
  2041. if ppo_overrides in propoptions then
  2042. begin
  2043. write (space,' OverrideProp : ');
  2044. readderef('');
  2045. end;
  2046. write (space,' Prop Type : ');
  2047. readderef('');
  2048. writeln(space,' Index : ',getlongint);
  2049. writeln(space,' Default : ',getlongint);
  2050. write (space,' Index Type : ');
  2051. readderef('');
  2052. { palt_none }
  2053. readpropaccesslist('');
  2054. write (space,' Readaccess : ');
  2055. readpropaccesslist(space+' Sym: ');
  2056. write (space,' Writeaccess : ');
  2057. readpropaccesslist(space+' Sym: ');
  2058. write (space,' Storedaccess : ');
  2059. readpropaccesslist(space+' Sym: ');
  2060. if [ppo_hasparameters,ppo_overrides]*propoptions=[ppo_hasparameters] then
  2061. begin
  2062. space:=' '+space;
  2063. readsymtable('parast');
  2064. delete(space,1,4);
  2065. end;
  2066. end;
  2067. iberror :
  2068. begin
  2069. WriteError('!! Error in PPU');
  2070. exit;
  2071. end;
  2072. ibendsyms :
  2073. break;
  2074. else
  2075. begin
  2076. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  2077. has_errors:=true;
  2078. end;
  2079. end;
  2080. if not EndOfEntry then
  2081. HasMoreInfos;
  2082. until false;
  2083. end;
  2084. end;
  2085. {****************************************************************************
  2086. Read defintions Part
  2087. ****************************************************************************}
  2088. procedure readdefinitions(const s:string);
  2089. { type tordtype is in symconst unit }
  2090. {
  2091. uvoid,
  2092. u8bit,u16bit,u32bit,u64bit,
  2093. s8bit,s16bit,s32bit,s64bit,
  2094. bool8bit,bool16bit,bool32bit,bool64bit,
  2095. uchar,uwidechar,scurrency
  2096. ); }
  2097. { type tobjecttyp is in symconst unit }
  2098. { type tvarianttype is in symconst unit }
  2099. var
  2100. b : byte;
  2101. l,j : longint;
  2102. calloption : tproccalloption;
  2103. procoptions : tprocoptions;
  2104. defoptions: tdefoptions;
  2105. begin
  2106. with ppufile do
  2107. begin
  2108. if space<>'' then
  2109. Writeln(space,'------ ',s,' ------');
  2110. if readentry<>ibstartdefs then
  2111. Writeln('!! ibstartdefs not found');
  2112. repeat
  2113. b:=readentry;
  2114. case b of
  2115. ibpointerdef :
  2116. begin
  2117. readcommondef('Pointer definition',defoptions);
  2118. write (space,' Pointed Type : ');
  2119. readderef('');
  2120. writeln(space,' Is Far : ',(getbyte<>0));
  2121. writeln(space,' Has Pointer Math : ',(getbyte<>0));
  2122. end;
  2123. iborddef :
  2124. begin
  2125. readcommondef('Ordinal definition',defoptions);
  2126. write (space,' Base type : ');
  2127. b:=getbyte;
  2128. case tordtype(b) of
  2129. uvoid : writeln('uvoid');
  2130. u8bit : writeln('u8bit');
  2131. u16bit : writeln('u16bit');
  2132. u32bit : writeln('s32bit');
  2133. u64bit : writeln('u64bit');
  2134. s8bit : writeln('s8bit');
  2135. s16bit : writeln('s16bit');
  2136. s32bit : writeln('s32bit');
  2137. s64bit : writeln('s64bit');
  2138. bool8bit : writeln('bool8bit');
  2139. bool16bit : writeln('bool16bit');
  2140. bool32bit : writeln('bool32bit');
  2141. bool64bit : writeln('bool64bit');
  2142. uchar : writeln('uchar');
  2143. uwidechar : writeln('uwidechar');
  2144. scurrency : writeln('ucurrency');
  2145. else writeln('!! Warning: Invalid base type ',b);
  2146. end;
  2147. writeln(space,' Range : ',constexp.tostr(getexprint),' to ',constexp.tostr(getexprint));
  2148. end;
  2149. ibfloatdef :
  2150. begin
  2151. readcommondef('Float definition',defoptions);
  2152. writeln(space,' Float type : ',getbyte);
  2153. end;
  2154. ibarraydef :
  2155. begin
  2156. readcommondef('Array definition',defoptions);
  2157. write (space,' Element type : ');
  2158. readderef('');
  2159. write (space,' Range Type : ');
  2160. readderef('');
  2161. writeln(space,' Range : ',getaint,' to ',getaint);
  2162. write (space,' Options : ');
  2163. readarraydefoptions;
  2164. readsymtable('symbols');
  2165. end;
  2166. ibprocdef :
  2167. begin
  2168. readcommondef('Procedure definition',defoptions);
  2169. read_abstract_proc_def(calloption,procoptions);
  2170. if (po_has_mangledname in procoptions) then
  2171. {$ifdef symansistr}
  2172. writeln(space,' Mangled name : ',getansistring);
  2173. {$else symansistr}
  2174. writeln(space,' Mangled name : ',getstring);
  2175. {$endif symansistr}
  2176. writeln(space,' Number : ',getword);
  2177. writeln(space,' Level : ',getbyte);
  2178. write (space,' Class : ');
  2179. readderef('');
  2180. write (space,' Procsym : ');
  2181. readderef('');
  2182. write (space,' File Pos : ');
  2183. readposinfo;
  2184. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  2185. write (space,' SymOptions : ');
  2186. readsymoptions(space+' ');
  2187. if tsystemcpu(ppufile.header.cpu)=cpu_powerpc then
  2188. begin
  2189. { library symbol for AmigaOS/MorphOS }
  2190. write (space,' Library symbol : ');
  2191. readderef('');
  2192. end;
  2193. if (po_has_importdll in procoptions) then
  2194. writeln(space,' Import DLL : ',getstring);
  2195. if (po_has_importname in procoptions) then
  2196. writeln(space,' Import Name : ',getstring);
  2197. writeln(space,' Import Nr : ',getword);
  2198. if (po_msgint in procoptions) then
  2199. writeln(space,' MsgInt : ',getlongint);
  2200. if (po_msgstr in procoptions) then
  2201. writeln(space,' MsgStr : ',getstring);
  2202. if (po_dispid in procoptions) then
  2203. writeln(space,' DispID: ',ppufile.getlongint);
  2204. if (po_has_inlininginfo in procoptions) then
  2205. begin
  2206. write (space,' FuncretSym : ');
  2207. readderef('');
  2208. readprocinfooptions(space);
  2209. end;
  2210. b:=ppufile.getbyte;
  2211. if b<>0 then
  2212. begin
  2213. write (space,' Alias names : ');
  2214. for j:=1 to b do
  2215. begin
  2216. write(ppufile.getstring);
  2217. if j<b then
  2218. write(', ');
  2219. end;
  2220. writeln;
  2221. end;
  2222. if not EndOfEntry then
  2223. HasMoreInfos;
  2224. space:=' '+space;
  2225. { parast }
  2226. readsymtable('parast');
  2227. { localst }
  2228. if (po_has_inlininginfo in procoptions) then
  2229. readsymtable('localst');
  2230. if (po_has_inlininginfo in procoptions) then
  2231. readnodetree;
  2232. delete(space,1,4);
  2233. end;
  2234. ibprocvardef :
  2235. begin
  2236. readcommondef('Procedural type (ProcVar) definition',defoptions);
  2237. read_abstract_proc_def(calloption,procoptions);
  2238. writeln(space,' Symtable level :',ppufile.getbyte);
  2239. if not EndOfEntry then
  2240. HasMoreInfos;
  2241. space:=' '+space;
  2242. { parast }
  2243. readsymtable('parast');
  2244. delete(space,1,4);
  2245. end;
  2246. ibshortstringdef :
  2247. begin
  2248. readcommondef('ShortString definition',defoptions);
  2249. writeln(space,' Length : ',getbyte);
  2250. end;
  2251. ibwidestringdef :
  2252. begin
  2253. readcommondef('WideString definition',defoptions);
  2254. writeln(space,' Length : ',getaint);
  2255. end;
  2256. ibunicodestringdef :
  2257. begin
  2258. readcommondef('UnicodeString definition',defoptions);
  2259. writeln(space,' Length : ',getaint);
  2260. end;
  2261. ibansistringdef :
  2262. begin
  2263. readcommondef('AnsiString definition',defoptions);
  2264. writeln(space,' Length : ',getaint);
  2265. end;
  2266. iblongstringdef :
  2267. begin
  2268. readcommondef('Longstring definition',defoptions);
  2269. writeln(space,' Length : ',getaint);
  2270. end;
  2271. ibrecorddef :
  2272. begin
  2273. readcommondef('Record definition',defoptions);
  2274. writeln(space,' Name of Record : ',getstring);
  2275. writeln(space,' Import lib/pkg : ',getstring);
  2276. write (space,' Options : ');
  2277. readobjectdefoptions;
  2278. if (df_copied_def in defoptions) then
  2279. begin
  2280. write(space,' Copied from : ');
  2281. readderef('');
  2282. end
  2283. else
  2284. begin
  2285. writeln(space,' FieldAlign : ',shortint(getbyte));
  2286. writeln(space,' RecordAlign : ',shortint(getbyte));
  2287. writeln(space,' PadAlign : ',shortint(getbyte));
  2288. writeln(space,'UseFieldAlignment : ',shortint(getbyte));
  2289. writeln(space,' DataSize : ',getasizeint);
  2290. writeln(space,' PaddingSize : ',getword);
  2291. end;
  2292. if not EndOfEntry then
  2293. HasMoreInfos;
  2294. {read the record definitions and symbols}
  2295. if not(df_copied_def in current_defoptions) then
  2296. begin
  2297. space:=' '+space;
  2298. readrecsymtableoptions;
  2299. readsymtable('fields');
  2300. Delete(space,1,4);
  2301. end;
  2302. end;
  2303. ibobjectdef :
  2304. begin
  2305. readcommondef('Object/Class definition',defoptions);
  2306. writeln(space,' Name of Class : ',getstring);
  2307. writeln(space,' Import lib/pkg : ',getstring);
  2308. write (space,' Options : ');
  2309. readobjectdefoptions;
  2310. b:=getbyte;
  2311. write (space,' Type : ');
  2312. case tobjecttyp(b) of
  2313. odt_class : writeln('class');
  2314. odt_object : writeln('object');
  2315. odt_interfacecom : writeln('interfacecom');
  2316. odt_interfacecorba : writeln('interfacecorba');
  2317. odt_cppclass : writeln('cppclass');
  2318. odt_dispinterface : writeln('dispinterface');
  2319. odt_objcclass : writeln('objcclass');
  2320. odt_objcprotocol : writeln('objcprotocol');
  2321. odt_helper : writeln('helper');
  2322. odt_objccategory : writeln('objccategory');
  2323. odt_javaclass : writeln('Java class');
  2324. odt_interfacejava : writeln('Java interface');
  2325. else writeln('!! Warning: Invalid object type ',b);
  2326. end;
  2327. writeln(space,' External name : ',getstring);
  2328. writeln(space,' DataSize : ',getasizeint);
  2329. writeln(space,' PaddingSize : ',getword);
  2330. writeln(space,' FieldAlign : ',shortint(getbyte));
  2331. writeln(space,' RecordAlign : ',shortint(getbyte));
  2332. writeln(space,' Vmt offset : ',getlongint);
  2333. write (space, ' Ancestor Class : ');
  2334. readderef('');
  2335. if tobjecttyp(b) in [odt_interfacecom,odt_interfacecorba,odt_dispinterface] then
  2336. begin
  2337. { IIDGUID }
  2338. for j:=1to 16 do
  2339. getbyte;
  2340. writeln(space,' IID String : ',getstring);
  2341. end;
  2342. writeln(space,' Abstract methods : ',getlongint);
  2343. if (tobjecttyp(b)=odt_helper) or
  2344. (oo_is_classhelper in current_objectoptions) then
  2345. begin
  2346. write(space,' Helper parent : ');
  2347. readderef('');
  2348. end;
  2349. l:=getlongint;
  2350. writeln(space,' VMT entries: ',l);
  2351. for j:=1 to l do
  2352. begin
  2353. write(space,' ');
  2354. readderef('');
  2355. writeln(space,' Visibility: ',Visibility2Str(getbyte));
  2356. end;
  2357. if tobjecttyp(b) in [odt_class,odt_interfacecorba,odt_objcclass,odt_objcprotocol,odt_javaclass,odt_interfacejava] then
  2358. begin
  2359. l:=getlongint;
  2360. writeln(space,' Impl Intf Count : ',l);
  2361. for j:=1 to l do
  2362. begin
  2363. write (space,' - Definition : ');
  2364. readderef('');
  2365. writeln(space,' IOffset : ',getlongint);
  2366. end;
  2367. end;
  2368. if df_copied_def in current_defoptions then
  2369. begin
  2370. writeln(' Copy of def: ');
  2371. readderef('');
  2372. end;
  2373. if not EndOfEntry then
  2374. HasMoreInfos;
  2375. if not(df_copied_def in current_defoptions) then
  2376. begin
  2377. {read the record definitions and symbols}
  2378. space:=' '+space;
  2379. readrecsymtableoptions;
  2380. readsymtable('fields');
  2381. Delete(space,1,4);
  2382. end;
  2383. end;
  2384. ibfiledef :
  2385. begin
  2386. ReadCommonDef('File definition',defoptions);
  2387. write (space,' Type : ');
  2388. case getbyte of
  2389. 0 : writeln('Text');
  2390. 1 : begin
  2391. writeln('Typed');
  2392. write (space,' File of Type : ');
  2393. readderef('');
  2394. end;
  2395. 2 : writeln('Untyped');
  2396. end;
  2397. end;
  2398. ibformaldef :
  2399. begin
  2400. readcommondef('Generic definition (void-typ)',defoptions);
  2401. writeln(space,' Is Typed : ',(getbyte<>0));
  2402. end;
  2403. ibundefineddef :
  2404. readcommondef('Undefined definition (generic parameter)',defoptions);
  2405. ibenumdef :
  2406. begin
  2407. readcommondef('Enumeration type definition',defoptions);
  2408. writeln(space,' Smallest element : ',getaint);
  2409. writeln(space,' Largest element : ',getaint);
  2410. writeln(space,' Size : ',getaint);
  2411. {$ifdef jvm}
  2412. write(space,' Class def : ');
  2413. readderef('');
  2414. {$endif}
  2415. if df_copied_def in defoptions then
  2416. begin
  2417. write(space,'Base enumeration type : ');
  2418. readderef('');
  2419. end
  2420. else
  2421. begin
  2422. space:=' '+space;
  2423. readsymtable('elements');
  2424. delete(space,1,4);
  2425. end;
  2426. end;
  2427. ibclassrefdef :
  2428. begin
  2429. readcommondef('Class reference definition',defoptions);
  2430. write (space,' Pointed Type : ');
  2431. readderef('');
  2432. end;
  2433. ibsetdef :
  2434. begin
  2435. readcommondef('Set definition',defoptions);
  2436. write (space,' Element type : ');
  2437. readderef('');
  2438. writeln(space,' Size : ',getaint);
  2439. writeln(space,' Set Base : ',getaint);
  2440. writeln(space,' Set Max : ',getaint);
  2441. end;
  2442. ibvariantdef :
  2443. begin
  2444. readcommondef('Variant definition',defoptions);
  2445. write (space,' Varianttype : ');
  2446. b:=getbyte;
  2447. case tvarianttype(b) of
  2448. vt_normalvariant :
  2449. writeln('Normal');
  2450. vt_olevariant :
  2451. writeln('OLE');
  2452. else
  2453. writeln('!! Warning: Invalid varianttype ',b);
  2454. end;
  2455. end;
  2456. iberror :
  2457. begin
  2458. WriteError('!! Error in PPU');
  2459. exit;
  2460. end;
  2461. ibenddefs :
  2462. break;
  2463. else
  2464. begin
  2465. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  2466. has_errors:=true;
  2467. end;
  2468. end;
  2469. if not EndOfEntry then
  2470. HasMoreInfos;
  2471. until false;
  2472. end;
  2473. end;
  2474. procedure readmoduleoptions(space : string);
  2475. type
  2476. { tmoduleoption type is in unit fmodule }
  2477. tmoduleoption = (mo_none,
  2478. mo_hint_deprecated,
  2479. mo_hint_platform,
  2480. mo_hint_library,
  2481. mo_hint_unimplemented,
  2482. mo_hint_experimental,
  2483. mo_has_deprecated_msg
  2484. );
  2485. tmoduleoptions = set of tmoduleoption;
  2486. tmoduleopt=record
  2487. mask : tmoduleoption;
  2488. str : string[30];
  2489. end;
  2490. const
  2491. moduleopts=ord(high(tmoduleoption));
  2492. moduleopt : array[1..moduleopts] of tmoduleopt=(
  2493. (mask:mo_hint_deprecated; str:'Hint Deprecated'),
  2494. (mask:mo_hint_platform; str:'Hint Platform'),
  2495. (mask:mo_hint_library; str:'Hint Library'),
  2496. (mask:mo_hint_unimplemented; str:'Hint Unimplemented'),
  2497. (mask:mo_hint_experimental; str:'Hint Experimental'),
  2498. (mask:mo_has_deprecated_msg; str:'Has Deprecated Message')
  2499. );
  2500. var
  2501. moduleoptions : tmoduleoptions;
  2502. i : longint;
  2503. first : boolean;
  2504. begin
  2505. ppufile.getsmallset(moduleoptions);
  2506. if moduleoptions<>[] then
  2507. begin
  2508. first:=true;
  2509. for i:=1to moduleopts do
  2510. if (moduleopt[i].mask in moduleoptions) then
  2511. begin
  2512. if first then
  2513. first:=false
  2514. else
  2515. write(', ');
  2516. write(moduleopt[i].str);
  2517. end;
  2518. end;
  2519. writeln;
  2520. if mo_has_deprecated_msg in moduleoptions then
  2521. writeln(space,'Deprecated : ', ppufile.getstring);
  2522. end;
  2523. {****************************************************************************
  2524. Read General Part
  2525. ****************************************************************************}
  2526. procedure readinterface;
  2527. var
  2528. b : byte;
  2529. sourcenumber : longint;
  2530. begin
  2531. with ppufile do
  2532. begin
  2533. repeat
  2534. b:=readentry;
  2535. case b of
  2536. ibmodulename :
  2537. Writeln('Module Name: ',getstring);
  2538. ibmoduleoptions:
  2539. readmoduleoptions(' ');
  2540. ibsourcefiles :
  2541. begin
  2542. sourcenumber:=1;
  2543. while not EndOfEntry do
  2544. begin
  2545. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  2546. inc(sourcenumber);
  2547. end;
  2548. end;
  2549. {$IFDEF MACRO_DIFF_HINT}
  2550. ibusedmacros :
  2551. begin
  2552. while not EndOfEntry do
  2553. begin
  2554. Write('Conditional ',getstring);
  2555. b:=getbyte;
  2556. if boolean(b)=true then
  2557. write(' defined at startup')
  2558. else
  2559. write(' not defined at startup');
  2560. b:=getbyte;
  2561. if boolean(b)=true then
  2562. writeln(' was used')
  2563. else
  2564. writeln;
  2565. end;
  2566. end;
  2567. {$ENDIF}
  2568. ibloadunit :
  2569. ReadLoadUnit;
  2570. iblinkunitofiles :
  2571. ReadLinkContainer('Link unit object file: ');
  2572. iblinkunitstaticlibs :
  2573. ReadLinkContainer('Link unit static lib: ');
  2574. iblinkunitsharedlibs :
  2575. ReadLinkContainer('Link unit shared lib: ');
  2576. iblinkotherofiles :
  2577. ReadLinkContainer('Link other object file: ');
  2578. iblinkotherstaticlibs :
  2579. ReadLinkContainer('Link other static lib: ');
  2580. iblinkothersharedlibs :
  2581. ReadLinkContainer('Link other shared lib: ');
  2582. iblinkotherframeworks:
  2583. ReadLinkContainer('Link framework: ');
  2584. ibmainname:
  2585. Writeln('Specified main program symbol name: ',getstring);
  2586. ibImportSymbols :
  2587. ReadImportSymbols;
  2588. ibderefdata :
  2589. ReadDerefData;
  2590. ibderefmap :
  2591. ReadDerefMap;
  2592. ibwpofile :
  2593. ReadWpoFileInfo;
  2594. ibresources :
  2595. ReadLinkContainer('Resource file: ');
  2596. iberror :
  2597. begin
  2598. WriteError('Error in PPU');
  2599. exit;
  2600. end;
  2601. ibendinterface :
  2602. break;
  2603. else
  2604. begin
  2605. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  2606. has_errors:=true;
  2607. end;
  2608. end;
  2609. until false;
  2610. end;
  2611. end;
  2612. {****************************************************************************
  2613. Read Implementation Part
  2614. ****************************************************************************}
  2615. procedure readimplementation;
  2616. var
  2617. b : byte;
  2618. begin
  2619. with ppufile do
  2620. begin
  2621. repeat
  2622. b:=readentry;
  2623. case b of
  2624. ibasmsymbols :
  2625. ReadAsmSymbols;
  2626. ibloadunit :
  2627. ReadLoadUnit;
  2628. iberror :
  2629. begin
  2630. WriteError('Error in PPU');
  2631. exit;
  2632. end;
  2633. ibendimplementation :
  2634. break;
  2635. else
  2636. begin
  2637. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  2638. has_errors:=true;
  2639. end;
  2640. end;
  2641. until false;
  2642. end;
  2643. end;
  2644. procedure dofile (filename : string);
  2645. begin
  2646. { reset }
  2647. space:='';
  2648. { fix filename }
  2649. if pos('.',filename)=0 then
  2650. filename:=filename+'.ppu';
  2651. ppufile:=tppufile.create(filename);
  2652. if not ppufile.openfile then
  2653. begin
  2654. WriteError('IO-Error when opening : '+filename+', Skipping');
  2655. exit;
  2656. end;
  2657. { PPU File is open, check for PPU Id }
  2658. if not ppufile.CheckPPUID then
  2659. begin
  2660. writeln(Filename,' : Not a valid PPU file, Skipping');
  2661. has_errors:=true;
  2662. exit;
  2663. end;
  2664. { Check PPU Version }
  2665. ppuversion:=ppufile.GetPPUVersion;
  2666. Writeln('Analyzing ',filename,' (v',PPUVersion,')');
  2667. if PPUVersion<16 then
  2668. begin
  2669. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  2670. has_errors:=true;
  2671. exit;
  2672. end;
  2673. { Write PPU Header Information }
  2674. if (verbose and v_header)<>0 then
  2675. begin
  2676. Writeln;
  2677. Writeln('Header');
  2678. Writeln('-------');
  2679. with ppufile.header do
  2680. begin
  2681. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  2682. (ppufile.header.compiler shr 7) and $7f,'.',
  2683. ppufile.header.compiler and $7f);
  2684. WriteLn('Target processor : ',Cpu2Str(cpu));
  2685. WriteLn('Target operating system : ',Target2Str(target));
  2686. Writeln('Unit flags : ',PPUFlags2Str(flags));
  2687. Writeln('FileSize (w/o header) : ',size);
  2688. Writeln('Checksum : ',hexstr(checksum,8));
  2689. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  2690. Writeln('Indirect Checksum : ',hexstr(indirect_checksum,8));
  2691. Writeln('Definitions stored : ',tostr(deflistsize));
  2692. Writeln('Symbols stored : ',tostr(symlistsize));
  2693. end;
  2694. end;
  2695. {read the general stuff}
  2696. if (verbose and v_interface)<>0 then
  2697. begin
  2698. Writeln;
  2699. Writeln('Interface section');
  2700. Writeln('------------------');
  2701. readinterface;
  2702. end
  2703. else
  2704. ppufile.skipuntilentry(ibendinterface);
  2705. Writeln;
  2706. Writeln('Interface symtable');
  2707. Writeln('----------------------');
  2708. readsymtableoptions('interface');
  2709. {read the definitions}
  2710. if (verbose and v_defs)<>0 then
  2711. begin
  2712. Writeln;
  2713. Writeln('Interface definitions');
  2714. Writeln('----------------------');
  2715. readdefinitions('interface');
  2716. end
  2717. else
  2718. ppufile.skipuntilentry(ibenddefs);
  2719. {read the symbols}
  2720. if (verbose and v_syms)<>0 then
  2721. begin
  2722. Writeln;
  2723. Writeln('Interface Symbols');
  2724. Writeln('------------------');
  2725. readsymbols('interface');
  2726. end
  2727. else
  2728. ppufile.skipuntilentry(ibendsyms);
  2729. {read the macro symbols}
  2730. if (verbose and v_syms)<>0 then
  2731. begin
  2732. Writeln;
  2733. Writeln('Interface Macro Symbols');
  2734. Writeln('-----------------------');
  2735. end;
  2736. if ppufile.readentry<>ibexportedmacros then
  2737. begin
  2738. WriteError('!! Error in PPU');
  2739. exit;
  2740. end;
  2741. if boolean(ppufile.getbyte) then
  2742. begin
  2743. readsymtableoptions('interface macro');
  2744. {skip the definition section for macros (since they are never used) }
  2745. ppufile.skipuntilentry(ibenddefs);
  2746. {read the macro symbols}
  2747. if (verbose and v_syms)<>0 then
  2748. readsymbols('interface macro')
  2749. else
  2750. ppufile.skipuntilentry(ibendsyms);
  2751. end
  2752. else
  2753. Writeln('(no exported macros)');
  2754. {read the implementation stuff}
  2755. if (verbose and v_implementation)<>0 then
  2756. begin
  2757. Writeln;
  2758. Writeln('Implementation section');
  2759. Writeln('-----------------------');
  2760. readimplementation;
  2761. end
  2762. else
  2763. ppufile.skipuntilentry(ibendimplementation);
  2764. {read the static symtable}
  2765. Writeln;
  2766. Writeln('Implementation symtable');
  2767. Writeln('----------------------');
  2768. readsymtableoptions('implementation');
  2769. if (ppufile.header.flags and uf_local_symtable)<>0 then
  2770. begin
  2771. if (verbose and v_defs)<>0 then
  2772. begin
  2773. Writeln;
  2774. Writeln('Static definitions');
  2775. Writeln('----------------------');
  2776. readdefinitions('implementation');
  2777. end
  2778. else
  2779. ppufile.skipuntilentry(ibenddefs);
  2780. {read the symbols}
  2781. if (verbose and v_syms)<>0 then
  2782. begin
  2783. Writeln;
  2784. Writeln('Static Symbols');
  2785. Writeln('------------------');
  2786. readsymbols('implementation');
  2787. end
  2788. else
  2789. ppufile.skipuntilentry(ibendsyms);
  2790. end;
  2791. ReadCreatedObjTypes;
  2792. FreeDerefdata;
  2793. {shutdown ppufile}
  2794. ppufile.closefile;
  2795. ppufile.free;
  2796. Writeln;
  2797. end;
  2798. procedure help;
  2799. begin
  2800. writeln('usage: ppudump [options] <filename1> <filename2>...');
  2801. writeln;
  2802. writeln('[options] can be:');
  2803. writeln(' -M Exit with ExitCode=2 if more information is available');
  2804. writeln(' -V<verbose> Set verbosity to <verbose>');
  2805. writeln(' H - Show header info');
  2806. writeln(' I - Show interface');
  2807. writeln(' M - Show implementation');
  2808. writeln(' S - Show interface symbols');
  2809. writeln(' D - Show interface definitions');
  2810. // writeln(' B - Show browser info');
  2811. writeln(' A - Show all');
  2812. writeln(' -h, -? This helpscreen');
  2813. halt;
  2814. end;
  2815. var
  2816. startpara,
  2817. nrfile,i : longint;
  2818. para : string;
  2819. const
  2820. error_on_more : boolean = false;
  2821. begin
  2822. writeln(Title+' '+Version);
  2823. writeln(Copyright);
  2824. writeln;
  2825. if paramcount<1 then
  2826. begin
  2827. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  2828. halt(1);
  2829. end;
  2830. { turn verbose on by default }
  2831. verbose:=v_all;
  2832. { read options }
  2833. startpara:=1;
  2834. while copy(paramstr(startpara),1,1)='-' do
  2835. begin
  2836. para:=paramstr(startpara);
  2837. case upcase(para[2]) of
  2838. 'M' : error_on_more:=true;
  2839. 'V' : begin
  2840. verbose:=0;
  2841. for i:=3 to length(para) do
  2842. case upcase(para[i]) of
  2843. 'H' : verbose:=verbose or v_header;
  2844. 'I' : verbose:=verbose or v_interface;
  2845. 'M' : verbose:=verbose or v_implementation;
  2846. 'D' : verbose:=verbose or v_defs;
  2847. 'S' : verbose:=verbose or v_syms;
  2848. 'A' : verbose:=verbose or v_all;
  2849. end;
  2850. end;
  2851. 'H' : help;
  2852. '?' : help;
  2853. end;
  2854. inc(startpara);
  2855. end;
  2856. { process files }
  2857. for nrfile:=startpara to paramcount do
  2858. dofile (paramstr(nrfile));
  2859. if has_errors then
  2860. Halt(1);
  2861. if error_on_more and has_more_infos then
  2862. Halt(2);
  2863. end.