ppudump.pp 90 KB

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