ppudump.pp 90 KB

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