ppudump.pp 87 KB

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