ppudump.pp 89 KB

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