ppudump.pp 90 KB

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