ppudump.pp 87 KB

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