ppudump.pp 87 KB

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