ppudump.pp 87 KB

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