ppudump.pp 88 KB

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