ppudump.pp 90 KB

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