ppudump.pp 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033
  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. );
  995. var
  996. symoptions : tsymoptions;
  997. i : longint;
  998. first : boolean;
  999. begin
  1000. ppufile.getsmallset(symoptions);
  1001. if symoptions<>[] then
  1002. begin
  1003. first:=true;
  1004. for i:=1to symopts do
  1005. if (symopt[i].mask in symoptions) then
  1006. begin
  1007. if first then
  1008. first:=false
  1009. else
  1010. write(', ');
  1011. write(symopt[i].str);
  1012. end;
  1013. end;
  1014. writeln;
  1015. if sp_has_deprecated_msg in symoptions then
  1016. writeln(space,'Deprecated : ', ppufile.getstring);
  1017. end;
  1018. procedure readcommonsym(const s:string);
  1019. begin
  1020. writeln(space,'** Symbol Id ',ppufile.getlongint,' **');
  1021. writeln(space,s,ppufile.getstring);
  1022. write (space,' File Pos : ');
  1023. readposinfo;
  1024. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  1025. write (space,' SymOptions : ');
  1026. readsymoptions(space+' ');
  1027. end;
  1028. var
  1029. { needed during tobjectdef parsing... }
  1030. current_defoptions : tdefoptions;
  1031. current_objectoptions : tobjectoptions;
  1032. procedure readcommondef(const s:string; out defoptions: tdefoptions);
  1033. type
  1034. tdefopt=record
  1035. mask : tdefoption;
  1036. str : string[30];
  1037. end;
  1038. tdefstateinfo=record
  1039. mask : tdefstate;
  1040. str : string[30];
  1041. end;
  1042. ptoken=^ttoken;
  1043. pmsgstate =^tmsgstate;
  1044. const
  1045. defopt : array[1..ord(high(tdefoption))] of tdefopt=(
  1046. (mask:df_unique; str:'Unique Type'),
  1047. (mask:df_generic; str:'Generic'),
  1048. (mask:df_specialization; str:'Specialization'),
  1049. (mask:df_copied_def; str:'Copied Typedef')
  1050. );
  1051. defstate : array[1..ord(high(tdefstate))] of tdefstateinfo=(
  1052. (mask:ds_vmt_written; str:'VMT Written'),
  1053. (mask:ds_rtti_table_used; str:'RTTITable Used'),
  1054. (mask:ds_init_table_used; str:'InitTable Used'),
  1055. (mask:ds_rtti_table_written; str:'RTTITable Written'),
  1056. (mask:ds_init_table_written; str:'InitTable Written'),
  1057. (mask:ds_dwarf_dbg_info_used; str:'Dwarf DbgInfo Used'),
  1058. (mask:ds_dwarf_dbg_info_written;str:'Dwarf DbgInfo Written')
  1059. );
  1060. var
  1061. defstates : tdefstates;
  1062. i, nb, msgvalue, mesgnb : longint;
  1063. first : boolean;
  1064. copy_size, min_size, tokenbufsize : longint;
  1065. tokenbuf : pbyte;
  1066. idtoken,
  1067. token : ttoken;
  1068. state : tmsgstate;
  1069. new_settings : Tsettings;
  1070. len : sizeint;
  1071. wstring : widestring;
  1072. astring : ansistring;
  1073. function readtoken: ttoken;
  1074. var
  1075. b,b2 : byte;
  1076. begin
  1077. b:=tokenbuf[i];
  1078. inc(i);
  1079. if (b and $80)<>0 then
  1080. begin
  1081. b2:=tokenbuf[i];
  1082. inc(i);
  1083. result:=ttoken(((b and $7f) shl 8) or b2);
  1084. end
  1085. else
  1086. result:=ttoken(b);
  1087. end;
  1088. function gettokenbufdword : dword;
  1089. var
  1090. var32 : dword;
  1091. begin
  1092. var32:=pdword(@tokenbuf[i])^;
  1093. inc(i,sizeof(dword));
  1094. if ppufile.change_endian then
  1095. var32:=swapendian(var32);
  1096. result:=var32;
  1097. end;
  1098. function gettokenbufword : word;
  1099. var
  1100. var16 : word;
  1101. begin
  1102. var16:=pword(@tokenbuf[i])^;
  1103. inc(i,sizeof(word));
  1104. if ppufile.change_endian then
  1105. var16:=swapendian(var16);
  1106. result:=var16;
  1107. end;
  1108. function gettokenbufsizeint : int64;
  1109. var
  1110. var64 : int64;
  1111. var32 : longint;
  1112. var16 : smallint;
  1113. begin
  1114. if CpuAddrBitSize[cpu]=64 then
  1115. begin
  1116. var64:=pint64(@tokenbuf[i])^;
  1117. inc(i,sizeof(int64));
  1118. if ppufile.change_endian then
  1119. var64:=swapendian(var64);
  1120. result:=var64;
  1121. end
  1122. else if CpuAddrBitSize[cpu]=32 then
  1123. begin
  1124. var32:=plongint(@tokenbuf[i])^;
  1125. inc(i,sizeof(longint));
  1126. if ppufile.change_endian then
  1127. var32:=swapendian(var32);
  1128. result:=var32;
  1129. end
  1130. else if CpuAddrBitSize[cpu]=16 then
  1131. begin
  1132. var16:=psmallint(@tokenbuf[i])^;
  1133. inc(i,sizeof(smallint));
  1134. if ppufile.change_endian then
  1135. var16:=swapendian(var16);
  1136. result:=var16;
  1137. end
  1138. else
  1139. begin
  1140. WriteError('Wrong CpuAddrBitSize');
  1141. result:=0;
  1142. end;
  1143. end;
  1144. begin
  1145. writeln(space,'** Definition Id ',ppufile.getlongint,' **');
  1146. writeln(space,s);
  1147. write (space,' Type symbol : ');
  1148. readderef('');
  1149. write (space,' DefOptions : ');
  1150. ppufile.getsmallset(defoptions);
  1151. if defoptions<>[] then
  1152. begin
  1153. first:=true;
  1154. for i:=1to high(defopt) do
  1155. if (defopt[i].mask in defoptions) then
  1156. begin
  1157. if first then
  1158. first:=false
  1159. else
  1160. write(', ');
  1161. write(defopt[i].str);
  1162. end;
  1163. end;
  1164. writeln;
  1165. write (space,' DefStates : ');
  1166. ppufile.getsmallset(defstates);
  1167. if defstates<>[] then
  1168. begin
  1169. first:=true;
  1170. for i:=1 to high(defstate) do
  1171. if (defstate[i].mask in defstates) then
  1172. begin
  1173. if first then
  1174. first:=false
  1175. else
  1176. write(', ');
  1177. write(defstate[i].str);
  1178. end;
  1179. end;
  1180. writeln;
  1181. if df_generic in defoptions then
  1182. begin
  1183. tokenbufsize:=ppufile.getlongint;
  1184. writeln(space,' Tokenbuffer size : ',tokenbufsize);
  1185. tokenbuf:=allocmem(tokenbufsize);
  1186. ppufile.getdata(tokenbuf^,tokenbufsize);
  1187. i:=0;
  1188. write(space,' Tokens: ');
  1189. while i<tokenbufsize do
  1190. begin
  1191. token:=readtoken;
  1192. if token<>_GENERICSPECIALTOKEN then
  1193. begin
  1194. if token <= high(ttoken) then
  1195. write(arraytokeninfo[token].str)
  1196. else
  1197. begin
  1198. HasMoreInfos;
  1199. write('Error in Token List');
  1200. break;
  1201. end;
  1202. idtoken:=readtoken;
  1203. end;
  1204. case token of
  1205. _CWCHAR,
  1206. _CWSTRING :
  1207. begin
  1208. len:=gettokenbufsizeint;
  1209. setlength(wstring,len);
  1210. move(tokenbuf[i],wstring[1],len*2);
  1211. write(' ',wstring);
  1212. inc(i,len*2);
  1213. end;
  1214. _CSTRING:
  1215. begin
  1216. len:=gettokenbufsizeint;
  1217. setlength(astring,len);
  1218. move(tokenbuf[i],astring[1],len);
  1219. write(' ',astring);
  1220. inc(i,len);
  1221. end;
  1222. _CCHAR,
  1223. _INTCONST,
  1224. _REALNUMBER :
  1225. begin
  1226. write(' ',pshortstring(@tokenbuf[i])^);
  1227. inc(i,tokenbuf[i]+1);
  1228. end;
  1229. _ID :
  1230. begin
  1231. write(' ',pshortstring(@tokenbuf[i])^);
  1232. inc(i,tokenbuf[i]+1);
  1233. end;
  1234. _GENERICSPECIALTOKEN:
  1235. begin
  1236. { Short version of column change,
  1237. byte or $80 used }
  1238. if (tokenbuf[i] and $80)<>0 then
  1239. begin
  1240. write('Col: ',tokenbuf[i] and $7f);
  1241. inc(i);
  1242. end
  1243. else
  1244. case tspecialgenerictoken(tokenbuf[i]) of
  1245. ST_LOADSETTINGS:
  1246. begin
  1247. inc(i);
  1248. write('Settings');
  1249. { This does not load pmessage pointer }
  1250. new_settings.pmessage:=nil;
  1251. { TSettings size depends in target...
  1252. We first read the size of the copied part }
  1253. { Still not cross endian ready :( }
  1254. copy_size:=gettokenbufsizeint;
  1255. if copy_size < sizeof(tsettings)-sizeof(pointer) then
  1256. min_size:=copy_size
  1257. else
  1258. min_size:= sizeof(tsettings)-sizeof(pointer);
  1259. move(tokenbuf[i],new_settings, min_size);
  1260. inc(i,copy_size);
  1261. end;
  1262. ST_LOADMESSAGES:
  1263. begin
  1264. inc(i);
  1265. write('Messages:');
  1266. mesgnb:=tokenbuf[i];
  1267. inc(i);
  1268. for nb:=1 to mesgnb do
  1269. begin
  1270. msgvalue:=gettokenbufsizeint;
  1271. inc(i,sizeof(sizeint));
  1272. state:=tmsgstate(gettokenbufsizeint);
  1273. end;
  1274. end;
  1275. ST_LINE:
  1276. begin
  1277. inc(i);
  1278. write('Line: ',gettokenbufdword);
  1279. end;
  1280. ST_COLUMN:
  1281. begin
  1282. inc(i);
  1283. write('Col: ',gettokenbufword);
  1284. end;
  1285. ST_FILEINDEX:
  1286. begin
  1287. inc(i);
  1288. write('File: ',gettokenbufword);
  1289. end;
  1290. end;
  1291. end;
  1292. end;
  1293. if i<tokenbufsize then
  1294. write(',');
  1295. end;
  1296. writeln;
  1297. freemem(tokenbuf);
  1298. end;
  1299. if df_specialization in defoptions then
  1300. begin
  1301. write (space,' Orig. GenericDef : ');
  1302. readderef('');
  1303. end;
  1304. current_defoptions:=defoptions;
  1305. end;
  1306. { Read abstract procdef and return if inline procdef }
  1307. { type tproccalloption is in globtype unit }
  1308. { type tproctypeoption is in globtype unit }
  1309. { type tprocoption is in globtype unit }
  1310. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions);
  1311. type
  1312. tproccallopt=record
  1313. mask : tproccalloption;
  1314. str : string[30];
  1315. end;
  1316. tproctypeopt=record
  1317. mask : tproctypeoption;
  1318. str : string[30];
  1319. end;
  1320. tprocopt=record
  1321. mask : tprocoption;
  1322. str : string[30];
  1323. end;
  1324. const
  1325. {proccalloptionStr is also in globtype unit }
  1326. proctypeopt : array[1..ord(high(tproctypeoption))] of tproctypeopt=(
  1327. (mask:potype_proginit; str:'ProgInit'),
  1328. (mask:potype_unitinit; str:'UnitInit'),
  1329. (mask:potype_unitfinalize; str:'UnitFinalize'),
  1330. (mask:potype_constructor; str:'Constructor'),
  1331. (mask:potype_destructor; str:'Destructor'),
  1332. (mask:potype_operator; str:'Operator'),
  1333. (mask:potype_procedure; str:'Procedure'),
  1334. (mask:potype_function; str:'Function'),
  1335. (mask:potype_class_constructor; str:'Class Constructor'),
  1336. (mask:potype_class_destructor; str:'Class Destructor'),
  1337. { Dispinterface property accessors }
  1338. (mask:potype_propgetter; str:'Property Getter'),
  1339. (mask:potype_propsetter; str:'Property Setter')
  1340. );
  1341. procopt : array[1..ord(high(tprocoption))] of tprocopt=(
  1342. (mask:po_classmethod; str:'ClassMethod'),
  1343. (mask:po_virtualmethod; str:'VirtualMethod'),
  1344. (mask:po_abstractmethod; str:'AbstractMethod'),
  1345. (mask:po_finalmethod; str:'FinalMethod'),
  1346. (mask:po_staticmethod; str:'StaticMethod'),
  1347. (mask:po_overridingmethod;str:'OverridingMethod'),
  1348. (mask:po_methodpointer; str:'MethodPointer'),
  1349. (mask:po_interrupt; str:'Interrupt'),
  1350. (mask:po_iocheck; str:'IOCheck'),
  1351. (mask:po_assembler; str:'Assembler'),
  1352. (mask:po_msgstr; str:'MsgStr'),
  1353. (mask:po_msgint; str:'MsgInt'),
  1354. (mask:po_exports; str:'Exports'),
  1355. (mask:po_external; str:'External'),
  1356. (mask:po_overload; str:'Overload'),
  1357. (mask:po_varargs; str:'VarArgs'),
  1358. (mask:po_internconst; str:'InternConst'),
  1359. (mask:po_addressonly; str:'AddressOnly'),
  1360. (mask:po_public; str:'Public'),
  1361. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  1362. (mask:po_reintroduce; str:'ReIntroduce'),
  1363. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  1364. (mask:po_nostackframe; str:'NoStackFrame'),
  1365. (mask:po_has_mangledname; str:'HasMangledName'),
  1366. (mask:po_has_public_name; str:'HasPublicName'),
  1367. (mask:po_forward; str:'Forward'),
  1368. (mask:po_global; str:'Global'),
  1369. (mask:po_has_inlininginfo;str:'HasInliningInfo'),
  1370. (mask:po_syscall_legacy; str:'SyscallLegacy'),
  1371. (mask:po_syscall_sysv; str:'SyscallSysV'),
  1372. (mask:po_syscall_basesysv;str:'SyscallBaseSysV'),
  1373. (mask:po_syscall_sysvbase;str:'SyscallSysVBase'),
  1374. (mask:po_syscall_r12base; str:'SyscallR12Base'),
  1375. (mask:po_inline; str:'Inline'),
  1376. (mask:po_compilerproc; str:'CompilerProc'),
  1377. (mask:po_has_importdll; str:'HasImportDLL'),
  1378. (mask:po_has_importname; str:'HasImportName'),
  1379. (mask:po_kylixlocal; str:'KylixLocal'),
  1380. (mask:po_dispid; str:'DispId'),
  1381. (mask:po_weakexternal; str:'WeakExternal'),
  1382. (mask:po_objc; str:'ObjC'),
  1383. (mask:po_enumerator_movenext; str:'EnumeratorMoveNext'),
  1384. (mask:po_optional; str: 'Optional'),
  1385. (mask:po_delphi_nested_cc;str: 'Delphi-style nested frameptr'),
  1386. (mask:po_rtlproc; str: 'RTL procedure')
  1387. );
  1388. var
  1389. proctypeoption : tproctypeoption;
  1390. i : longint;
  1391. first : boolean;
  1392. tempbuf : array[0..255] of byte;
  1393. begin
  1394. write(space,' Return type : ');
  1395. readderef('');
  1396. writeln(space,' Fpu used : ',ppufile.getbyte);
  1397. proctypeoption:=tproctypeoption(ppufile.getbyte);
  1398. write(space,' TypeOption : ');
  1399. first:=true;
  1400. for i:=1 to high(proctypeopt) do
  1401. if (proctypeopt[i].mask=proctypeoption) then
  1402. begin
  1403. if first then
  1404. first:=false
  1405. else
  1406. write(', ');
  1407. write(proctypeopt[i].str);
  1408. end;
  1409. writeln;
  1410. proccalloption:=tproccalloption(ppufile.getbyte);
  1411. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  1412. ppufile.getnormalset(procoptions);
  1413. if procoptions<>[] then
  1414. begin
  1415. write(space,' Options : ');
  1416. first:=true;
  1417. for i:=1 to high(procopt) do
  1418. if (procopt[i].mask in procoptions) then
  1419. begin
  1420. if first then
  1421. first:=false
  1422. else
  1423. write(', ');
  1424. write(procopt[i].str);
  1425. end;
  1426. writeln;
  1427. end;
  1428. if (po_explicitparaloc in procoptions) then
  1429. begin
  1430. i:=ppufile.getbyte;
  1431. ppufile.getdata(tempbuf,i);
  1432. end;
  1433. end;
  1434. { type tvaroption is in unit symconst }
  1435. { register variable }
  1436. { type tvarregable is in unit symconst }
  1437. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions);
  1438. type
  1439. tvaropt=record
  1440. mask : tvaroption;
  1441. str : string[30];
  1442. end;
  1443. const
  1444. varopt : array[1..ord(high(tvaroption))] of tvaropt=(
  1445. (mask:vo_is_external; str:'External'),
  1446. (mask:vo_is_dll_var; str:'DLLVar'),
  1447. (mask:vo_is_thread_var; str:'ThreadVar'),
  1448. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  1449. (mask:vo_is_const; str:'Constant'),
  1450. (mask:vo_is_public; str:'Public'),
  1451. (mask:vo_is_high_para; str:'HighValue'),
  1452. (mask:vo_is_funcret; str:'Funcret'),
  1453. (mask:vo_is_self; str:'Self'),
  1454. (mask:vo_is_vmt; str:'VMT'),
  1455. (mask:vo_is_result; str:'Result'),
  1456. (mask:vo_is_parentfp; str:'ParentFP'),
  1457. (mask:vo_is_loop_counter; str:'LoopCounter'),
  1458. (mask:vo_is_hidden_para; str:'Hidden'),
  1459. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  1460. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  1461. (mask:vo_has_mangledname; str:'HasMangledName'),
  1462. (mask:vo_is_typed_const; str:'TypedConst'),
  1463. (mask:vo_is_range_check; str:'RangeCheckSwitch'),
  1464. (mask:vo_is_overflow_check; str:'OverflowCheckSwitch'),
  1465. (mask:vo_is_typinfo_para; str:'TypeInfo'),
  1466. (mask:vo_is_msgsel;str:'MsgSel'),
  1467. (mask:vo_is_weak_external;str:'WeakExternal'),
  1468. (mask:vo_is_first_field;str:'IsFirstField'),
  1469. (mask:vo_volatile;str:'Volatile'),
  1470. (mask:vo_has_section;str:'HasSection'),
  1471. (mask:vo_force_finalize;str:'ForceFinalize')
  1472. );
  1473. var
  1474. i : longint;
  1475. first : boolean;
  1476. begin
  1477. readcommonsym(s);
  1478. writeln(space,' Spez : ',Varspez2Str(ppufile.getbyte));
  1479. writeln(space,' Regable : ',Varregable2Str(ppufile.getbyte));
  1480. writeln(space,' Addr Taken : ',(ppufile.getbyte<>0));
  1481. write (space,' Var Type : ');
  1482. readderef('');
  1483. ppufile.getsmallset(varoptions);
  1484. if varoptions<>[] then
  1485. begin
  1486. write(space,' Options : ');
  1487. first:=true;
  1488. for i:=1 to high(varopt) do
  1489. if (varopt[i].mask in varoptions) then
  1490. begin
  1491. if first then
  1492. first:=false
  1493. else
  1494. write(', ');
  1495. write(varopt[i].str);
  1496. if varopt[i].mask = vo_has_section then
  1497. writeln('Section name:',ppufile.getansistring);
  1498. end;
  1499. writeln;
  1500. end;
  1501. end;
  1502. procedure readobjectdefoptions;
  1503. type
  1504. tsymopt=record
  1505. mask : tobjectoption;
  1506. str : string[30];
  1507. end;
  1508. const
  1509. symopt : array[1..ord(high(tobjectoption))] of tsymopt=(
  1510. (mask:oo_is_forward; str:'IsForward'),
  1511. (mask:oo_is_abstract; str:'IsAbstract'),
  1512. (mask:oo_is_sealed; str:'IsSealed'),
  1513. (mask:oo_has_virtual; str:'HasVirtual'),
  1514. (mask:oo_has_private; str:'HasPrivate'),
  1515. (mask:oo_has_protected; str:'HasProtected'),
  1516. (mask:oo_has_strictprivate; str:'HasStrictPrivate'),
  1517. (mask:oo_has_strictprotected;str:'HasStrictProtected'),
  1518. (mask:oo_has_constructor; str:'HasConstructor'),
  1519. (mask:oo_has_destructor; str:'HasDestructor'),
  1520. (mask:oo_has_vmt; str:'HasVMT'),
  1521. (mask:oo_has_msgstr; str:'HasMsgStr'),
  1522. (mask:oo_has_msgint; str:'HasMsgInt'),
  1523. (mask:oo_can_have_published; str:'CanHavePublished'),
  1524. (mask:oo_has_default_property;str:'HasDefaultProperty'),
  1525. (mask:oo_has_valid_guid; str:'HasValidGUID'),
  1526. (mask:oo_has_enumerator_movenext; str:'HasEnumeratorMoveNext'),
  1527. (mask:oo_has_enumerator_current; str:'HasEnumeratorCurrent'),
  1528. (mask:oo_is_external; str:'External'),
  1529. (mask:oo_is_formal; str:'Formal'),
  1530. (mask:oo_is_classhelper; str:'Class Helper/Category'),
  1531. (mask:oo_has_class_constructor; str:'HasClassConstructor'),
  1532. (mask:oo_has_class_destructor; str:'HasClassDestructor')
  1533. );
  1534. var
  1535. i : longint;
  1536. first : boolean;
  1537. begin
  1538. ppufile.getsmallset(current_objectoptions);
  1539. if current_objectoptions<>[] then
  1540. begin
  1541. first:=true;
  1542. for i:=1 to high(symopt) do
  1543. if (symopt[i].mask in current_objectoptions) then
  1544. begin
  1545. if first then
  1546. first:=false
  1547. else
  1548. write(', ');
  1549. write(symopt[i].str);
  1550. end;
  1551. end;
  1552. writeln;
  1553. end;
  1554. procedure readarraydefoptions;
  1555. { type tarraydefoption is in unit symconst }
  1556. type
  1557. tsymopt=record
  1558. mask : tarraydefoption;
  1559. str : string[30];
  1560. end;
  1561. const
  1562. symopt : array[1..ord(high(tarraydefoption))] of tsymopt=(
  1563. (mask:ado_IsConvertedPointer;str:'ConvertedPointer'),
  1564. (mask:ado_IsDynamicArray; str:'IsDynamicArray'),
  1565. (mask:ado_IsVariant; str:'IsVariant'),
  1566. (mask:ado_IsConstructor; str:'IsConstructor'),
  1567. (mask:ado_IsArrayOfConst; str:'ArrayOfConst'),
  1568. (mask:ado_IsConstString; str:'ConstString'),
  1569. (mask:ado_IsBitPacked; str:'BitPacked')
  1570. );
  1571. var
  1572. symoptions : tarraydefoptions;
  1573. i : longint;
  1574. first : boolean;
  1575. begin
  1576. ppufile.getsmallset(symoptions);
  1577. if symoptions<>[] then
  1578. begin
  1579. first:=true;
  1580. for i:=1 to high(symopt) do
  1581. if (symopt[i].mask in symoptions) then
  1582. begin
  1583. if first then
  1584. first:=false
  1585. else
  1586. write(', ');
  1587. write(symopt[i].str);
  1588. end;
  1589. end;
  1590. writeln;
  1591. end;
  1592. (* options for properties
  1593. tpropertyoption=(ppo_none,
  1594. ppo_indexed,
  1595. ppo_defaultproperty,
  1596. ppo_stored,
  1597. ppo_hasparameters,
  1598. ppo_implements,
  1599. ppo_enumerator_current,
  1600. ppo_overrides,
  1601. ppo_dispid_write { no longer used }
  1602. );
  1603. tpropertyoptions=set of tpropertyoption;
  1604. *)
  1605. function readpropertyoptions:tpropertyoptions;
  1606. { type tarraydefoption is in unit symconst }
  1607. type
  1608. tpropopt=record
  1609. mask : tpropertyoption;
  1610. str : string[30];
  1611. end;
  1612. const
  1613. symopt : array[1..ord(high(tpropertyoption))] of tpropopt=(
  1614. (mask:ppo_indexed;str:'indexed'),
  1615. (mask:ppo_defaultproperty;str:'default'),
  1616. (mask:ppo_stored;str:'stored'),
  1617. (mask:ppo_hasparameters;str:'has parameters'),
  1618. (mask:ppo_implements;str:'implements'),
  1619. (mask:ppo_enumerator_current;str:'enumerator current'),
  1620. (mask:ppo_overrides;str:'overrides'),
  1621. (mask:ppo_dispid_write;str:'dispid write') { no longer used }
  1622. );
  1623. var
  1624. i : longint;
  1625. first : boolean;
  1626. begin
  1627. ppufile.getsmallset(result);
  1628. if result<>[] then
  1629. begin
  1630. first:=true;
  1631. for i:=1 to high(symopt) do
  1632. if (symopt[i].mask in result) then
  1633. begin
  1634. if first then
  1635. first:=false
  1636. else
  1637. write(', ');
  1638. write(symopt[i].str);
  1639. end;
  1640. end;
  1641. writeln;
  1642. end;
  1643. procedure readnodetree;
  1644. var
  1645. l : longint;
  1646. p : pointer;
  1647. begin
  1648. with ppufile do
  1649. begin
  1650. if space<>'' then
  1651. Writeln(space,'------ nodetree ------');
  1652. if readentry=ibnodetree then
  1653. begin
  1654. l:=entrysize;
  1655. Writeln(space,'Tree size : ',l);
  1656. { Read data to prevent error that entry is not completly read }
  1657. getmem(p,l);
  1658. getdata(p^,l);
  1659. freemem(p);
  1660. end
  1661. else
  1662. begin
  1663. WriteError('!! ibnodetree not found');
  1664. end;
  1665. end;
  1666. end;
  1667. procedure ReadCreatedObjTypes;
  1668. var
  1669. i,j,
  1670. len,
  1671. bssize: longint;
  1672. bs: pbyte;
  1673. begin
  1674. if ppufile.readentry<>ibcreatedobjtypes then
  1675. begin
  1676. writeln('!! ibcreatedobjtypes entry not found');
  1677. ppufile.skipdata(ppufile.entrysize);
  1678. has_errors:=true;
  1679. exit
  1680. end;
  1681. writeln;
  1682. writeln(space,'WPO info');
  1683. writeln(space,'--------');
  1684. len:=ppufile.getlongint;
  1685. writeln(space,'** Instantiated Object/Class types: ',len,' **');
  1686. space:=space+' ';
  1687. for i:=0 to len-1 do
  1688. readderef(space);
  1689. setlength(space,length(space)-2);
  1690. len:=ppufile.getlongint;
  1691. writeln(space,'** Instantiated ClassRef types: ',len,' **');
  1692. space:=space+' ';
  1693. for i:=0 to len-1 do
  1694. readderef(space);
  1695. setlength(space,length(space)-2);
  1696. len:=ppufile.getlongint;
  1697. writeln(space,'** Possibly instantiated ClassRef types : ',len,' **');
  1698. space:=space+' ';
  1699. for i:=0 to len-1 do
  1700. readderef(space);
  1701. setlength(space,length(space)-2);
  1702. len:=ppufile.getlongint;
  1703. writeln(space,'** Class types with called virtual methods info : ',len,' **');
  1704. space:=space+' ';
  1705. for i:=0 to len-1 do
  1706. begin
  1707. write(space,'Class def : ');
  1708. readderef('');
  1709. write(space+' ','Called vmtentries : ');
  1710. bssize:=ppufile.getlongint;
  1711. getmem(bs,bssize);
  1712. ppufile.readdata(bs^,bssize);
  1713. for j:=0 to bssize*8-1 do
  1714. if (((bs+j shr 3)^ shr (j and 7)) and 1) <> 0 then
  1715. write(j,', ');
  1716. writeln;
  1717. freemem(bs);
  1718. end;
  1719. setlength(space,length(space)-2);
  1720. end;
  1721. {****************************************************************************
  1722. Read Symbols Part
  1723. ****************************************************************************}
  1724. procedure readsymbols(const s:string);
  1725. type
  1726. pguid = ^tguid;
  1727. tguid = packed record
  1728. D1: LongWord;
  1729. D2: Word;
  1730. D3: Word;
  1731. D4: array[0..7] of Byte;
  1732. end;
  1733. var
  1734. b : byte;
  1735. pc : pchar;
  1736. ch : dword;
  1737. startnewline : boolean;
  1738. i,j,len : longint;
  1739. prettyname : ansistring;
  1740. guid : tguid;
  1741. realvalue : ppureal;
  1742. doublevalue : double;
  1743. singlevalue : single;
  1744. extended : TSplit80bitReal;
  1745. tempbuf : array[0..127] of char;
  1746. pw : pcompilerwidestring;
  1747. varoptions : tvaroptions;
  1748. propoptions : tpropertyoptions;
  1749. begin
  1750. with ppufile do
  1751. begin
  1752. if space<>'' then
  1753. Writeln(space,'------ ',s,' ------');
  1754. if readentry=ibstartsyms then
  1755. begin
  1756. Writeln(space,'Symtable datasize : ',getlongint);
  1757. Writeln(space,'Symtable alignment: ',getlongint);
  1758. end
  1759. else
  1760. Writeln('!! ibstartsym not found');
  1761. repeat
  1762. b:=readentry;
  1763. case b of
  1764. ibunitsym :
  1765. readcommonsym('Unit symbol ');
  1766. ibnamespacesym :
  1767. begin
  1768. readcommonsym('NameSpace symbol ');
  1769. write(space,' Hidden Unit : ');
  1770. readderef('');
  1771. end;
  1772. iblabelsym :
  1773. readcommonsym('Label symbol ');
  1774. ibtypesym :
  1775. begin
  1776. readcommonsym('Type symbol ');
  1777. write(space,' Result Type : ');
  1778. readderef('');
  1779. prettyname:=getansistring;
  1780. if prettyname<>'' then
  1781. begin
  1782. write(space,' Pretty Name : ');
  1783. Writeln(prettyname);
  1784. end;
  1785. end;
  1786. ibprocsym :
  1787. begin
  1788. readcommonsym('Procedure symbol ');
  1789. len:=ppufile.getword;
  1790. for i:=1 to len do
  1791. begin
  1792. write(space,' Definition : ');
  1793. readderef('');
  1794. end;
  1795. end;
  1796. ibconstsym :
  1797. begin
  1798. readcommonsym('Constant symbol ');
  1799. b:=getbyte;
  1800. case tconsttyp(b) of
  1801. constord :
  1802. begin
  1803. write (space,' OrdinalType : ');
  1804. readderef('');
  1805. writeln(space,' Value : ',constexp.tostr(getexprint));
  1806. end;
  1807. constpointer :
  1808. begin
  1809. write (space,' PointerType : ');
  1810. readderef('');
  1811. writeln(space,' Value : ',getaint)
  1812. end;
  1813. conststring,
  1814. constresourcestring :
  1815. begin
  1816. len:=getlongint;
  1817. getmem(pc,len+1);
  1818. getdata(pc^,len);
  1819. (pc+len)^:= #0;
  1820. writeln(space,' Length : ',len);
  1821. writeln(space,' Value : "',pc,'"');
  1822. freemem(pc,len+1);
  1823. end;
  1824. constreal :
  1825. begin
  1826. write(space,' Value : ');
  1827. if entryleft=sizeof(ppureal) then
  1828. begin
  1829. realvalue:=getrealsize(sizeof(ppureal));
  1830. writeln(realvalue);
  1831. end
  1832. else if entryleft=sizeof(double) then
  1833. begin
  1834. doublevalue:=getrealsize(sizeof(double));
  1835. writeln(doublevalue);
  1836. end
  1837. else if entryleft=sizeof(single) then
  1838. begin
  1839. singlevalue:=getrealsize(sizeof(single));
  1840. writeln(singlevalue);
  1841. end
  1842. else if entryleft=10 then
  1843. begin
  1844. getdata(extended,entryleft);
  1845. writeln(Real80bitToStr(extended));
  1846. end
  1847. else
  1848. begin
  1849. realvalue:=0.0;
  1850. writeln(realvalue,' Error reading real value');
  1851. has_errors:=true;
  1852. end;
  1853. end;
  1854. constset :
  1855. begin
  1856. write (space,' Set Type : ');
  1857. readderef('');
  1858. for i:=1to 4 do
  1859. begin
  1860. write (space,' Value : ');
  1861. for j:=1to 8 do
  1862. begin
  1863. if j>1 then
  1864. write(',');
  1865. write(hexstr(getbyte,2));
  1866. end;
  1867. writeln;
  1868. end;
  1869. end;
  1870. constnil:
  1871. writeln(space,' NIL pointer.');
  1872. constwstring :
  1873. begin
  1874. initwidestring(pw);
  1875. setlengthwidestring(pw,getlongint);
  1876. if widecharsize=2 then
  1877. { don't use getdata, because the compilerwidechars may have to
  1878. be byteswapped
  1879. }
  1880. begin
  1881. for i:=0 to pw^.len-1 do
  1882. pw^.data[i]:=ppufile.getword;
  1883. end
  1884. else if widecharsize=4 then
  1885. begin
  1886. for i:=0 to pw^.len-1 do
  1887. pw^.data[i]:=cardinal(ppufile.getlongint);
  1888. end
  1889. else
  1890. begin
  1891. WriteError('Unsupported tcompilerwidechar size');
  1892. end;
  1893. Writeln(space,'Wide string type');
  1894. startnewline:=true;
  1895. for i:=0 to pw^.len-1 do
  1896. begin
  1897. if startnewline then
  1898. begin
  1899. write(space);
  1900. startnewline:=false;
  1901. end;
  1902. ch:=pw^.data[i];
  1903. if widecharsize=2 then
  1904. write(hexstr(ch,4))
  1905. else
  1906. write(hexstr(ch,8));
  1907. if (i mod 8)= 0 then
  1908. startnewline:=true
  1909. else
  1910. write(', ');
  1911. end;
  1912. donewidestring(pw);
  1913. end;
  1914. constguid:
  1915. begin
  1916. getdata(guid,sizeof(guid));
  1917. write (space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-');
  1918. for i:=0 to 7 do
  1919. begin
  1920. write(hexstr(guid.d4[i],2));
  1921. if i=1 then write('-');
  1922. end;
  1923. writeln('}');
  1924. end
  1925. else
  1926. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  1927. end;
  1928. end;
  1929. ibabsolutevarsym :
  1930. begin
  1931. readabstractvarsym('Absolute variable symbol ',varoptions);
  1932. Write (space,' Relocated to ');
  1933. b:=getbyte;
  1934. case absolutetyp(b) of
  1935. tovar :
  1936. readpropaccesslist(space+' Sym : ');
  1937. toasm :
  1938. Writeln('Assembler name : ',getstring);
  1939. toaddr :
  1940. begin
  1941. Write('Address : ',getlongint);
  1942. if tsystemcpu(ppufile.header.cpu)=cpu_i386 then
  1943. WriteLn(' (Far: ',getbyte<>0,')');
  1944. end;
  1945. else
  1946. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  1947. end;
  1948. end;
  1949. ibfieldvarsym :
  1950. begin
  1951. readabstractvarsym('Field Variable symbol ',varoptions);
  1952. writeln(space,' Address : ',getaint);
  1953. end;
  1954. ibstaticvarsym :
  1955. begin
  1956. readabstractvarsym('Global Variable symbol ',varoptions);
  1957. write (space,' DefaultConst : ');
  1958. readderef('');
  1959. if (vo_has_mangledname in varoptions) then
  1960. writeln(space,' Mangledname : ',getstring);
  1961. end;
  1962. iblocalvarsym :
  1963. begin
  1964. readabstractvarsym('Local Variable symbol ',varoptions);
  1965. write (space,' DefaultConst : ');
  1966. readderef('');
  1967. end;
  1968. ibparavarsym :
  1969. begin
  1970. readabstractvarsym('Parameter Variable symbol ',varoptions);
  1971. write (space,' DefaultConst : ');
  1972. readderef('');
  1973. writeln(space,' ParaNr : ',getword);
  1974. writeln(space,' Univ : ',boolean(getbyte));
  1975. writeln(space,' VarState : ',getbyte);
  1976. if (vo_has_explicit_paraloc in varoptions) then
  1977. begin
  1978. i:=getbyte;
  1979. getdata(tempbuf,i);
  1980. end;
  1981. end;
  1982. ibenumsym :
  1983. begin
  1984. readcommonsym('Enumeration symbol ');
  1985. write (space,' Definition : ');
  1986. readderef('');
  1987. writeln(space,' Value : ',getlongint);
  1988. end;
  1989. ibsyssym :
  1990. begin
  1991. readcommonsym('Internal system symbol ');
  1992. writeln(space,' Internal Nr : ',getlongint);
  1993. end;
  1994. ibmacrosym :
  1995. begin
  1996. readcommonsym('Macro symbol ');
  1997. writeln(space,' Name: ',getstring);
  1998. writeln(space,' Defined: ',getbyte);
  1999. writeln(space,' Compiler var: ',getbyte);
  2000. len:=getlongint;
  2001. writeln(space,' Value length: ',len);
  2002. if len > 0 then
  2003. begin
  2004. getmem(pc,len+1);
  2005. getdata(pc^,len);
  2006. (pc+len)^:= #0;
  2007. writeln(space,' Value: "',pc,'"');
  2008. freemem(pc,len+1);
  2009. end;
  2010. end;
  2011. ibpropertysym :
  2012. begin
  2013. readcommonsym('Property ');
  2014. propoptions:=readpropertyoptions;
  2015. if ppo_overrides in propoptions then
  2016. begin
  2017. write (space,' OverrideProp : ');
  2018. readderef('');
  2019. end;
  2020. write (space,' Prop Type : ');
  2021. readderef('');
  2022. writeln(space,' Index : ',getlongint);
  2023. writeln(space,' Default : ',getlongint);
  2024. write (space,' Index Type : ');
  2025. readderef('');
  2026. { palt_none }
  2027. readpropaccesslist('');
  2028. write (space,' Readaccess : ');
  2029. readpropaccesslist(space+' Sym: ');
  2030. write (space,' Writeaccess : ');
  2031. readpropaccesslist(space+' Sym: ');
  2032. write (space,' Storedaccess : ');
  2033. readpropaccesslist(space+' Sym: ');
  2034. if [ppo_hasparameters,ppo_overrides]*propoptions=[ppo_hasparameters] then
  2035. begin
  2036. space:=' '+space;
  2037. readsymtable('parast');
  2038. delete(space,1,4);
  2039. end;
  2040. end;
  2041. iberror :
  2042. begin
  2043. WriteError('!! Error in PPU');
  2044. exit;
  2045. end;
  2046. ibendsyms :
  2047. break;
  2048. else
  2049. begin
  2050. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  2051. has_errors:=true;
  2052. end;
  2053. end;
  2054. if not EndOfEntry then
  2055. HasMoreInfos;
  2056. until false;
  2057. end;
  2058. end;
  2059. {****************************************************************************
  2060. Read defintions Part
  2061. ****************************************************************************}
  2062. procedure readdefinitions(const s:string);
  2063. { type tordtype is in symconst unit }
  2064. {
  2065. uvoid,
  2066. u8bit,u16bit,u32bit,u64bit,
  2067. s8bit,s16bit,s32bit,s64bit,
  2068. bool8bit,bool16bit,bool32bit,bool64bit,
  2069. uchar,uwidechar,scurrency
  2070. ); }
  2071. { type tobjecttyp is in symconst unit }
  2072. { type tvarianttype is in symconst unit }
  2073. var
  2074. b : byte;
  2075. l,j : longint;
  2076. calloption : tproccalloption;
  2077. procoptions : tprocoptions;
  2078. defoptions: tdefoptions;
  2079. begin
  2080. with ppufile do
  2081. begin
  2082. if space<>'' then
  2083. Writeln(space,'------ ',s,' ------');
  2084. if readentry<>ibstartdefs then
  2085. Writeln('!! ibstartdefs not found');
  2086. repeat
  2087. b:=readentry;
  2088. case b of
  2089. ibpointerdef :
  2090. begin
  2091. readcommondef('Pointer definition',defoptions);
  2092. write (space,' Pointed Type : ');
  2093. readderef('');
  2094. writeln(space,' Is Far : ',(getbyte<>0));
  2095. writeln(space,' Has Pointer Math : ',(getbyte<>0));
  2096. end;
  2097. iborddef :
  2098. begin
  2099. readcommondef('Ordinal definition',defoptions);
  2100. write (space,' Base type : ');
  2101. b:=getbyte;
  2102. case tordtype(b) of
  2103. uvoid : writeln('uvoid');
  2104. u8bit : writeln('u8bit');
  2105. u16bit : writeln('u16bit');
  2106. u32bit : writeln('s32bit');
  2107. u64bit : writeln('u64bit');
  2108. s8bit : writeln('s8bit');
  2109. s16bit : writeln('s16bit');
  2110. s32bit : writeln('s32bit');
  2111. s64bit : writeln('s64bit');
  2112. bool8bit : writeln('bool8bit');
  2113. bool16bit : writeln('bool16bit');
  2114. bool32bit : writeln('bool32bit');
  2115. bool64bit : writeln('bool64bit');
  2116. uchar : writeln('uchar');
  2117. uwidechar : writeln('uwidechar');
  2118. scurrency : writeln('ucurrency');
  2119. else writeln('!! Warning: Invalid base type ',b);
  2120. end;
  2121. writeln(space,' Range : ',constexp.tostr(getexprint),' to ',constexp.tostr(getexprint));
  2122. end;
  2123. ibfloatdef :
  2124. begin
  2125. readcommondef('Float definition',defoptions);
  2126. writeln(space,' Float type : ',getbyte);
  2127. end;
  2128. ibarraydef :
  2129. begin
  2130. readcommondef('Array definition',defoptions);
  2131. write (space,' Element type : ');
  2132. readderef('');
  2133. write (space,' Range Type : ');
  2134. readderef('');
  2135. writeln(space,' Range : ',getaint,' to ',getaint);
  2136. write (space,' Options : ');
  2137. readarraydefoptions;
  2138. readsymtable('symbols');
  2139. end;
  2140. ibprocdef :
  2141. begin
  2142. readcommondef('Procedure definition',defoptions);
  2143. read_abstract_proc_def(calloption,procoptions);
  2144. if (po_has_mangledname in procoptions) then
  2145. writeln(space,' Mangled name : ',getstring);
  2146. writeln(space,' Number : ',getword);
  2147. writeln(space,' Level : ',getbyte);
  2148. write (space,' Class : ');
  2149. readderef('');
  2150. write (space,' Procsym : ');
  2151. readderef('');
  2152. write (space,' File Pos : ');
  2153. readposinfo;
  2154. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  2155. write (space,' SymOptions : ');
  2156. readsymoptions(space+' ');
  2157. if tsystemcpu(ppufile.header.cpu)=cpu_powerpc then
  2158. begin
  2159. { library symbol for AmigaOS/MorphOS }
  2160. write (space,' Library symbol : ');
  2161. readderef('');
  2162. end;
  2163. if (po_has_importdll in procoptions) then
  2164. writeln(space,' Import DLL : ',getstring);
  2165. if (po_has_importname in procoptions) then
  2166. writeln(space,' Import Name : ',getstring);
  2167. writeln(space,' Import Nr : ',getword);
  2168. if (po_msgint in procoptions) then
  2169. writeln(space,' MsgInt : ',getlongint);
  2170. if (po_msgstr in procoptions) then
  2171. writeln(space,' MsgStr : ',getstring);
  2172. if (po_dispid in procoptions) then
  2173. writeln(space,' DispID: ',ppufile.getlongint);
  2174. if (po_has_inlininginfo in procoptions) then
  2175. begin
  2176. write (space,' FuncretSym : ');
  2177. readderef('');
  2178. readprocinfooptions(space);
  2179. end;
  2180. b:=ppufile.getbyte;
  2181. if b<>0 then
  2182. begin
  2183. write (space,' Alias names : ');
  2184. for j:=1 to b do
  2185. begin
  2186. write(ppufile.getstring);
  2187. if j<b then
  2188. write(', ');
  2189. end;
  2190. writeln;
  2191. end;
  2192. if not EndOfEntry then
  2193. HasMoreInfos;
  2194. space:=' '+space;
  2195. { parast }
  2196. readsymtable('parast');
  2197. { localst }
  2198. if (po_has_inlininginfo in procoptions) then
  2199. readsymtable('localst');
  2200. if (po_has_inlininginfo in procoptions) then
  2201. readnodetree;
  2202. delete(space,1,4);
  2203. end;
  2204. ibprocvardef :
  2205. begin
  2206. readcommondef('Procedural type (ProcVar) definition',defoptions);
  2207. read_abstract_proc_def(calloption,procoptions);
  2208. writeln(space,' Symtable level :',ppufile.getbyte);
  2209. if not EndOfEntry then
  2210. HasMoreInfos;
  2211. space:=' '+space;
  2212. { parast }
  2213. readsymtable('parast');
  2214. delete(space,1,4);
  2215. end;
  2216. ibshortstringdef :
  2217. begin
  2218. readcommondef('ShortString definition',defoptions);
  2219. writeln(space,' Length : ',getbyte);
  2220. end;
  2221. ibwidestringdef :
  2222. begin
  2223. readcommondef('WideString definition',defoptions);
  2224. writeln(space,' Length : ',getaint);
  2225. end;
  2226. ibunicodestringdef :
  2227. begin
  2228. readcommondef('UnicodeString definition',defoptions);
  2229. writeln(space,' Length : ',getaint);
  2230. end;
  2231. ibansistringdef :
  2232. begin
  2233. readcommondef('AnsiString definition',defoptions);
  2234. writeln(space,' Length : ',getaint);
  2235. end;
  2236. iblongstringdef :
  2237. begin
  2238. readcommondef('Longstring definition',defoptions);
  2239. writeln(space,' Length : ',getaint);
  2240. end;
  2241. ibrecorddef :
  2242. begin
  2243. readcommondef('Record definition',defoptions);
  2244. writeln(space,' Name of Record : ',getstring);
  2245. write (space,' Options : ');
  2246. readobjectdefoptions;
  2247. writeln(space,' FieldAlign : ',shortint(getbyte));
  2248. writeln(space,' RecordAlign : ',shortint(getbyte));
  2249. writeln(space,' PadAlign : ',shortint(getbyte));
  2250. writeln(space,'UseFieldAlignment : ',shortint(getbyte));
  2251. writeln(space,' DataSize : ',getasizeint);
  2252. writeln(space,' PaddingSize : ',getword);
  2253. if df_copied_def in current_defoptions then
  2254. begin
  2255. writeln(' Copy of def: ');
  2256. readderef('');
  2257. end;
  2258. if not EndOfEntry then
  2259. HasMoreInfos;
  2260. {read the record definitions and symbols}
  2261. if not(df_copied_def in current_defoptions) then
  2262. begin
  2263. space:=' '+space;
  2264. readrecsymtableoptions;
  2265. readsymtable('fields');
  2266. Delete(space,1,4);
  2267. end;
  2268. end;
  2269. ibobjectdef :
  2270. begin
  2271. readcommondef('Object/Class definition',defoptions);
  2272. writeln(space,' Name of Class : ',getstring);
  2273. write (space,' Options : ');
  2274. readobjectdefoptions;
  2275. b:=getbyte;
  2276. write (space,' Type : ');
  2277. case tobjecttyp(b) of
  2278. odt_class : writeln('class');
  2279. odt_object : writeln('object');
  2280. odt_interfacecom : writeln('interfacecom');
  2281. odt_interfacecorba : writeln('interfacecorba');
  2282. odt_cppclass : writeln('cppclass');
  2283. odt_dispinterface : writeln('dispinterface');
  2284. odt_objcclass : writeln('objcclass');
  2285. odt_objcprotocol : writeln('objcprotocol');
  2286. odt_helper : writeln('helper');
  2287. else writeln('!! Warning: Invalid object type ',b);
  2288. end;
  2289. writeln(space,' External name : ',getstring);
  2290. writeln(space,' Import lib : ',getstring);
  2291. writeln(space,' DataSize : ',getasizeint);
  2292. writeln(space,' PaddingSize : ',getword);
  2293. writeln(space,' FieldAlign : ',shortint(getbyte));
  2294. writeln(space,' RecordAlign : ',shortint(getbyte));
  2295. writeln(space,' Vmt offset : ',getlongint);
  2296. write (space, ' Ancestor Class : ');
  2297. readderef('');
  2298. if tobjecttyp(b) in [odt_interfacecom,odt_interfacecorba,odt_dispinterface] then
  2299. begin
  2300. { IIDGUID }
  2301. for j:=1to 16 do
  2302. getbyte;
  2303. writeln(space,' IID String : ',getstring);
  2304. end;
  2305. if (tobjecttyp(b)=odt_helper) or
  2306. (oo_is_classhelper in current_objectoptions) then
  2307. begin
  2308. write(space,' Helper parent : ');
  2309. readderef('');
  2310. end;
  2311. l:=getlongint;
  2312. writeln(space,' VMT entries: ',l);
  2313. for j:=1 to l do
  2314. begin
  2315. write(space,' ');
  2316. readderef('');
  2317. writeln(space,' Visibility: ',Visibility2Str(getbyte));
  2318. end;
  2319. if tobjecttyp(b) in [odt_class,odt_interfacecorba,odt_objcclass,odt_objcprotocol] then
  2320. begin
  2321. l:=getlongint;
  2322. writeln(space,' Impl Intf Count : ',l);
  2323. for j:=1 to l do
  2324. begin
  2325. write (space,' - Definition : ');
  2326. readderef('');
  2327. writeln(space,' IOffset : ',getlongint);
  2328. end;
  2329. end;
  2330. if df_copied_def in current_defoptions then
  2331. begin
  2332. writeln(' Copy of def: ');
  2333. readderef('');
  2334. end;
  2335. if not EndOfEntry then
  2336. HasMoreInfos;
  2337. if not(df_copied_def in current_defoptions) then
  2338. begin
  2339. {read the record definitions and symbols}
  2340. space:=' '+space;
  2341. readrecsymtableoptions;
  2342. readsymtable('fields');
  2343. Delete(space,1,4);
  2344. end;
  2345. end;
  2346. ibfiledef :
  2347. begin
  2348. ReadCommonDef('File definition',defoptions);
  2349. write (space,' Type : ');
  2350. case getbyte of
  2351. 0 : writeln('Text');
  2352. 1 : begin
  2353. writeln('Typed');
  2354. write (space,' File of Type : ');
  2355. readderef('');
  2356. end;
  2357. 2 : writeln('Untyped');
  2358. end;
  2359. end;
  2360. ibformaldef :
  2361. begin
  2362. readcommondef('Generic definition (void-typ)',defoptions);
  2363. writeln(space,' Is Typed : ',(getbyte<>0));
  2364. end;
  2365. ibundefineddef :
  2366. readcommondef('Undefined definition (generic parameter)',defoptions);
  2367. ibenumdef :
  2368. begin
  2369. readcommondef('Enumeration type definition',defoptions);
  2370. writeln(space,' Smallest element : ',getaint);
  2371. writeln(space,' Largest element : ',getaint);
  2372. writeln(space,' Size : ',getaint);
  2373. if df_copied_def in defoptions then
  2374. begin
  2375. write(space,'Base enumeration type : ');
  2376. readderef('');
  2377. end
  2378. else
  2379. begin
  2380. space:=' '+space;
  2381. readsymtable('elements');
  2382. delete(space,1,4);
  2383. end;
  2384. end;
  2385. ibclassrefdef :
  2386. begin
  2387. readcommondef('Class reference definition',defoptions);
  2388. write (space,' Pointed Type : ');
  2389. readderef('');
  2390. end;
  2391. ibsetdef :
  2392. begin
  2393. readcommondef('Set definition',defoptions);
  2394. write (space,' Element type : ');
  2395. readderef('');
  2396. writeln(space,' Size : ',getaint);
  2397. writeln(space,' Set Base : ',getaint);
  2398. writeln(space,' Set Max : ',getaint);
  2399. end;
  2400. ibvariantdef :
  2401. begin
  2402. readcommondef('Variant definition',defoptions);
  2403. write (space,' Varianttype : ');
  2404. b:=getbyte;
  2405. case tvarianttype(b) of
  2406. vt_normalvariant :
  2407. writeln('Normal');
  2408. vt_olevariant :
  2409. writeln('OLE');
  2410. else
  2411. writeln('!! Warning: Invalid varianttype ',b);
  2412. end;
  2413. end;
  2414. iberror :
  2415. begin
  2416. WriteError('!! Error in PPU');
  2417. exit;
  2418. end;
  2419. ibenddefs :
  2420. break;
  2421. else
  2422. begin
  2423. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  2424. has_errors:=true;
  2425. end;
  2426. end;
  2427. if not EndOfEntry then
  2428. HasMoreInfos;
  2429. until false;
  2430. end;
  2431. end;
  2432. procedure readmoduleoptions(space : string);
  2433. type
  2434. { tmoduleoption type is in unit fmodule }
  2435. tmoduleoption = (mo_none,
  2436. mo_hint_deprecated,
  2437. mo_hint_platform,
  2438. mo_hint_library,
  2439. mo_hint_unimplemented,
  2440. mo_hint_experimental,
  2441. mo_has_deprecated_msg
  2442. );
  2443. tmoduleoptions = set of tmoduleoption;
  2444. tmoduleopt=record
  2445. mask : tmoduleoption;
  2446. str : string[30];
  2447. end;
  2448. const
  2449. moduleopts=ord(high(tmoduleoption));
  2450. moduleopt : array[1..moduleopts] of tmoduleopt=(
  2451. (mask:mo_hint_deprecated; str:'Hint Deprecated'),
  2452. (mask:mo_hint_platform; str:'Hint Platform'),
  2453. (mask:mo_hint_library; str:'Hint Library'),
  2454. (mask:mo_hint_unimplemented; str:'Hint Unimplemented'),
  2455. (mask:mo_hint_experimental; str:'Hint Experimental'),
  2456. (mask:mo_has_deprecated_msg; str:'Has Deprecated Message')
  2457. );
  2458. var
  2459. moduleoptions : tmoduleoptions;
  2460. i : longint;
  2461. first : boolean;
  2462. begin
  2463. ppufile.getsmallset(moduleoptions);
  2464. if moduleoptions<>[] then
  2465. begin
  2466. first:=true;
  2467. for i:=1to moduleopts do
  2468. if (moduleopt[i].mask in moduleoptions) then
  2469. begin
  2470. if first then
  2471. first:=false
  2472. else
  2473. write(', ');
  2474. write(moduleopt[i].str);
  2475. end;
  2476. end;
  2477. writeln;
  2478. if mo_has_deprecated_msg in moduleoptions then
  2479. writeln(space,'Deprecated : ', ppufile.getstring);
  2480. end;
  2481. {****************************************************************************
  2482. Read General Part
  2483. ****************************************************************************}
  2484. procedure readinterface;
  2485. var
  2486. b : byte;
  2487. sourcenumber : longint;
  2488. begin
  2489. with ppufile do
  2490. begin
  2491. repeat
  2492. b:=readentry;
  2493. case b of
  2494. ibmodulename :
  2495. Writeln('Module Name: ',getstring);
  2496. ibmoduleoptions:
  2497. readmoduleoptions(' ');
  2498. ibsourcefiles :
  2499. begin
  2500. sourcenumber:=1;
  2501. while not EndOfEntry do
  2502. begin
  2503. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  2504. inc(sourcenumber);
  2505. end;
  2506. end;
  2507. {$IFDEF MACRO_DIFF_HINT}
  2508. ibusedmacros :
  2509. begin
  2510. while not EndOfEntry do
  2511. begin
  2512. Write('Conditional ',getstring);
  2513. b:=getbyte;
  2514. if boolean(b)=true then
  2515. write(' defined at startup')
  2516. else
  2517. write(' not defined at startup');
  2518. b:=getbyte;
  2519. if boolean(b)=true then
  2520. writeln(' was used')
  2521. else
  2522. writeln;
  2523. end;
  2524. end;
  2525. {$ENDIF}
  2526. ibloadunit :
  2527. ReadLoadUnit;
  2528. iblinkunitofiles :
  2529. ReadLinkContainer('Link unit object file: ');
  2530. iblinkunitstaticlibs :
  2531. ReadLinkContainer('Link unit static lib: ');
  2532. iblinkunitsharedlibs :
  2533. ReadLinkContainer('Link unit shared lib: ');
  2534. iblinkotherofiles :
  2535. ReadLinkContainer('Link other object file: ');
  2536. iblinkotherstaticlibs :
  2537. ReadLinkContainer('Link other static lib: ');
  2538. iblinkothersharedlibs :
  2539. ReadLinkContainer('Link other shared lib: ');
  2540. iblinkotherframeworks:
  2541. ReadLinkContainer('Link framework: ');
  2542. ibmainname:
  2543. Writeln('Specified main program symbol name: ',getstring);
  2544. ibImportSymbols :
  2545. ReadImportSymbols;
  2546. ibderefdata :
  2547. ReadDerefData;
  2548. ibderefmap :
  2549. ReadDerefMap;
  2550. ibwpofile :
  2551. ReadWpoFileInfo;
  2552. ibresources :
  2553. ReadLinkContainer('Resource file: ');
  2554. iberror :
  2555. begin
  2556. WriteError('Error in PPU');
  2557. exit;
  2558. end;
  2559. ibendinterface :
  2560. break;
  2561. else
  2562. begin
  2563. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  2564. has_errors:=true;
  2565. end;
  2566. end;
  2567. until false;
  2568. end;
  2569. end;
  2570. {****************************************************************************
  2571. Read Implementation Part
  2572. ****************************************************************************}
  2573. procedure readimplementation;
  2574. var
  2575. b : byte;
  2576. begin
  2577. with ppufile do
  2578. begin
  2579. repeat
  2580. b:=readentry;
  2581. case b of
  2582. ibasmsymbols :
  2583. ReadAsmSymbols;
  2584. ibloadunit :
  2585. ReadLoadUnit;
  2586. iberror :
  2587. begin
  2588. WriteError('Error in PPU');
  2589. exit;
  2590. end;
  2591. ibendimplementation :
  2592. break;
  2593. else
  2594. begin
  2595. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  2596. has_errors:=true;
  2597. end;
  2598. end;
  2599. until false;
  2600. end;
  2601. end;
  2602. procedure dofile (filename : string);
  2603. begin
  2604. { reset }
  2605. space:='';
  2606. { fix filename }
  2607. if pos('.',filename)=0 then
  2608. filename:=filename+'.ppu';
  2609. ppufile:=tppufile.create(filename);
  2610. if not ppufile.openfile then
  2611. begin
  2612. WriteError('IO-Error when opening : '+filename+', Skipping');
  2613. exit;
  2614. end;
  2615. { PPU File is open, check for PPU Id }
  2616. if not ppufile.CheckPPUID then
  2617. begin
  2618. writeln(Filename,' : Not a valid PPU file, Skipping');
  2619. has_errors:=true;
  2620. exit;
  2621. end;
  2622. { Check PPU Version }
  2623. ppuversion:=ppufile.GetPPUVersion;
  2624. Writeln('Analyzing ',filename,' (v',PPUVersion,')');
  2625. if PPUVersion<16 then
  2626. begin
  2627. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  2628. has_errors:=true;
  2629. exit;
  2630. end;
  2631. { Write PPU Header Information }
  2632. if (verbose and v_header)<>0 then
  2633. begin
  2634. Writeln;
  2635. Writeln('Header');
  2636. Writeln('-------');
  2637. with ppufile.header do
  2638. begin
  2639. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  2640. (ppufile.header.compiler shr 7) and $7f,'.',
  2641. ppufile.header.compiler and $7f);
  2642. WriteLn('Target processor : ',Cpu2Str(cpu));
  2643. WriteLn('Target operating system : ',Target2Str(target));
  2644. Writeln('Unit flags : ',PPUFlags2Str(flags));
  2645. Writeln('FileSize (w/o header) : ',size);
  2646. Writeln('Checksum : ',hexstr(checksum,8));
  2647. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  2648. Writeln('Indirect Checksum : ',hexstr(indirect_checksum,8));
  2649. Writeln('Definitions stored : ',tostr(deflistsize));
  2650. Writeln('Symbols stored : ',tostr(symlistsize));
  2651. end;
  2652. end;
  2653. {read the general stuff}
  2654. if (verbose and v_interface)<>0 then
  2655. begin
  2656. Writeln;
  2657. Writeln('Interface section');
  2658. Writeln('------------------');
  2659. readinterface;
  2660. end
  2661. else
  2662. ppufile.skipuntilentry(ibendinterface);
  2663. Writeln;
  2664. Writeln('Interface symtable');
  2665. Writeln('----------------------');
  2666. readsymtableoptions('interface');
  2667. {read the definitions}
  2668. if (verbose and v_defs)<>0 then
  2669. begin
  2670. Writeln;
  2671. Writeln('Interface definitions');
  2672. Writeln('----------------------');
  2673. readdefinitions('interface');
  2674. end
  2675. else
  2676. ppufile.skipuntilentry(ibenddefs);
  2677. {read the symbols}
  2678. if (verbose and v_syms)<>0 then
  2679. begin
  2680. Writeln;
  2681. Writeln('Interface Symbols');
  2682. Writeln('------------------');
  2683. readsymbols('interface');
  2684. end
  2685. else
  2686. ppufile.skipuntilentry(ibendsyms);
  2687. {read the macro symbols}
  2688. if (verbose and v_syms)<>0 then
  2689. begin
  2690. Writeln;
  2691. Writeln('Interface Macro Symbols');
  2692. Writeln('-----------------------');
  2693. end;
  2694. if ppufile.readentry<>ibexportedmacros then
  2695. begin
  2696. WriteError('!! Error in PPU');
  2697. exit;
  2698. end;
  2699. if boolean(ppufile.getbyte) then
  2700. begin
  2701. readsymtableoptions('interface macro');
  2702. {skip the definition section for macros (since they are never used) }
  2703. ppufile.skipuntilentry(ibenddefs);
  2704. {read the macro symbols}
  2705. if (verbose and v_syms)<>0 then
  2706. readsymbols('interface macro')
  2707. else
  2708. ppufile.skipuntilentry(ibendsyms);
  2709. end
  2710. else
  2711. Writeln('(no exported macros)');
  2712. {read the implementation stuff}
  2713. if (verbose and v_implementation)<>0 then
  2714. begin
  2715. Writeln;
  2716. Writeln('Implementation section');
  2717. Writeln('-----------------------');
  2718. readimplementation;
  2719. end
  2720. else
  2721. ppufile.skipuntilentry(ibendimplementation);
  2722. {read the static symtable}
  2723. Writeln;
  2724. Writeln('Implementation symtable');
  2725. Writeln('----------------------');
  2726. readsymtableoptions('implementation');
  2727. if (ppufile.header.flags and uf_local_symtable)<>0 then
  2728. begin
  2729. if (verbose and v_defs)<>0 then
  2730. begin
  2731. Writeln;
  2732. Writeln('Static definitions');
  2733. Writeln('----------------------');
  2734. readdefinitions('implementation');
  2735. end
  2736. else
  2737. ppufile.skipuntilentry(ibenddefs);
  2738. {read the symbols}
  2739. if (verbose and v_syms)<>0 then
  2740. begin
  2741. Writeln;
  2742. Writeln('Static Symbols');
  2743. Writeln('------------------');
  2744. readsymbols('implementation');
  2745. end
  2746. else
  2747. ppufile.skipuntilentry(ibendsyms);
  2748. end;
  2749. ReadCreatedObjTypes;
  2750. FreeDerefdata;
  2751. {shutdown ppufile}
  2752. ppufile.closefile;
  2753. ppufile.free;
  2754. Writeln;
  2755. end;
  2756. procedure help;
  2757. begin
  2758. writeln('usage: ppudump [options] <filename1> <filename2>...');
  2759. writeln;
  2760. writeln('[options] can be:');
  2761. writeln(' -M Exit with ExitCode=2 if more information is available');
  2762. writeln(' -V<verbose> Set verbosity to <verbose>');
  2763. writeln(' H - Show header info');
  2764. writeln(' I - Show interface');
  2765. writeln(' M - Show implementation');
  2766. writeln(' S - Show interface symbols');
  2767. writeln(' D - Show interface definitions');
  2768. // writeln(' B - Show browser info');
  2769. writeln(' A - Show all');
  2770. writeln(' -h, -? This helpscreen');
  2771. halt;
  2772. end;
  2773. var
  2774. startpara,
  2775. nrfile,i : longint;
  2776. para : string;
  2777. const
  2778. error_on_more : boolean = false;
  2779. begin
  2780. writeln(Title+' '+Version);
  2781. writeln(Copyright);
  2782. writeln;
  2783. if paramcount<1 then
  2784. begin
  2785. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  2786. halt(1);
  2787. end;
  2788. { turn verbose on by default }
  2789. verbose:=v_all;
  2790. { read options }
  2791. startpara:=1;
  2792. while copy(paramstr(startpara),1,1)='-' do
  2793. begin
  2794. para:=paramstr(startpara);
  2795. case upcase(para[2]) of
  2796. 'M' : error_on_more:=true;
  2797. 'V' : begin
  2798. verbose:=0;
  2799. for i:=3 to length(para) do
  2800. case upcase(para[i]) of
  2801. 'H' : verbose:=verbose or v_header;
  2802. 'I' : verbose:=verbose or v_interface;
  2803. 'M' : verbose:=verbose or v_implementation;
  2804. 'D' : verbose:=verbose or v_defs;
  2805. 'S' : verbose:=verbose or v_syms;
  2806. 'A' : verbose:=verbose or v_all;
  2807. end;
  2808. end;
  2809. 'H' : help;
  2810. '?' : help;
  2811. end;
  2812. inc(startpara);
  2813. end;
  2814. { process files }
  2815. for nrfile:=startpara to paramcount do
  2816. dofile (paramstr(nrfile));
  2817. if has_errors then
  2818. Halt(1);
  2819. if error_on_more and has_more_infos then
  2820. Halt(2);
  2821. end.