ppudump.pp 89 KB

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