ppudump.pp 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026
  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. );
  941. var
  942. procinfooptions : tprocinfoflags;
  943. i : longint;
  944. first : boolean;
  945. begin
  946. ppufile.getsmallset(procinfooptions);
  947. if procinfooptions<>[] then
  948. begin
  949. first:=true;
  950. for i:=0 to procinfoopts do
  951. if (procinfoopt[i].mask in procinfooptions) then
  952. begin
  953. if first then
  954. first:=false
  955. else
  956. write(', ');
  957. write(procinfoopt[i].str);
  958. end;
  959. end;
  960. writeln;
  961. end;
  962. procedure readsymoptions(space : string);
  963. type
  964. tsymopt=record
  965. mask : tsymoption;
  966. str : string[30];
  967. end;
  968. const
  969. symopts=ord(high(tsymoption)) - ord(low(tsymoption));
  970. { sp_none = 0 corresponds to nothing }
  971. symopt : array[1..symopts] of tsymopt=(
  972. (mask:sp_static; str:'Static'),
  973. (mask:sp_hint_deprecated; str:'Hint Deprecated'),
  974. (mask:sp_hint_platform; str:'Hint Platform'),
  975. (mask:sp_hint_library; str:'Hint Library'),
  976. (mask:sp_hint_unimplemented; str:'Hint Unimplemented'),
  977. (mask:sp_hint_experimental; str:'Hint Experimental'),
  978. (mask:sp_has_overloaded; str:'Has overloaded'),
  979. (mask:sp_internal; str:'Internal'),
  980. (mask:sp_implicitrename; str:'Implicit Rename'),
  981. (mask:sp_generic_para; str:'Generic Parameter'),
  982. (mask:sp_has_deprecated_msg; str:'Has Deprecated Message')
  983. );
  984. var
  985. symoptions : tsymoptions;
  986. i : longint;
  987. first : boolean;
  988. begin
  989. ppufile.getsmallset(symoptions);
  990. if symoptions<>[] then
  991. begin
  992. first:=true;
  993. for i:=1to symopts do
  994. if (symopt[i].mask in symoptions) then
  995. begin
  996. if first then
  997. first:=false
  998. else
  999. write(', ');
  1000. write(symopt[i].str);
  1001. end;
  1002. end;
  1003. writeln;
  1004. if sp_has_deprecated_msg in symoptions then
  1005. writeln(space,'Deprecated : ', ppufile.getstring);
  1006. end;
  1007. procedure readcommonsym(const s:string);
  1008. begin
  1009. writeln(space,'** Symbol Id ',ppufile.getlongint,' **');
  1010. writeln(space,s,ppufile.getstring);
  1011. write (space,' File Pos : ');
  1012. readposinfo;
  1013. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  1014. write (space,' SymOptions : ');
  1015. readsymoptions(space+' ');
  1016. end;
  1017. var
  1018. { needed during tobjectdef parsing... }
  1019. current_defoptions : tdefoptions;
  1020. current_objectoptions : tobjectoptions;
  1021. procedure readcommondef(const s:string; out defoptions: tdefoptions);
  1022. type
  1023. tdefopt=record
  1024. mask : tdefoption;
  1025. str : string[30];
  1026. end;
  1027. tdefstateinfo=record
  1028. mask : tdefstate;
  1029. str : string[30];
  1030. end;
  1031. ptoken=^ttoken;
  1032. pmsgstate =^tmsgstate;
  1033. const
  1034. defopt : array[1..ord(high(tdefoption))] of tdefopt=(
  1035. (mask:df_unique; str:'Unique Type'),
  1036. (mask:df_generic; str:'Generic'),
  1037. (mask:df_specialization; str:'Specialization'),
  1038. (mask:df_copied_def; str:'Copied Typedef')
  1039. );
  1040. defstate : array[1..ord(high(tdefstate))] of tdefstateinfo=(
  1041. (mask:ds_vmt_written; str:'VMT Written'),
  1042. (mask:ds_rtti_table_used; str:'RTTITable Used'),
  1043. (mask:ds_init_table_used; str:'InitTable Used'),
  1044. (mask:ds_rtti_table_written; str:'RTTITable Written'),
  1045. (mask:ds_init_table_written; str:'InitTable Written'),
  1046. (mask:ds_dwarf_dbg_info_used; str:'Dwarf DbgInfo Used'),
  1047. (mask:ds_dwarf_dbg_info_written;str:'Dwarf DbgInfo Written')
  1048. );
  1049. var
  1050. defstates : tdefstates;
  1051. i, nb, msgvalue, mesgnb : longint;
  1052. first : boolean;
  1053. copy_size, min_size, tokenbufsize : longint;
  1054. tokenbuf : pbyte;
  1055. idtoken,
  1056. token : ttoken;
  1057. state : tmsgstate;
  1058. new_settings : Tsettings;
  1059. len : sizeint;
  1060. wstring : widestring;
  1061. astring : ansistring;
  1062. function readtoken: ttoken;
  1063. var
  1064. b,b2 : byte;
  1065. begin
  1066. b:=tokenbuf[i];
  1067. inc(i);
  1068. if (b and $80)<>0 then
  1069. begin
  1070. b2:=tokenbuf[i];
  1071. inc(i);
  1072. result:=ttoken(((b and $7f) shl 8) or b2);
  1073. end
  1074. else
  1075. result:=ttoken(b);
  1076. end;
  1077. function gettokenbufdword : dword;
  1078. var
  1079. var32 : dword;
  1080. begin
  1081. var32:=pdword(@tokenbuf[i])^;
  1082. inc(i,sizeof(dword));
  1083. if ppufile.change_endian then
  1084. var32:=swapendian(var32);
  1085. result:=var32;
  1086. end;
  1087. function gettokenbufword : word;
  1088. var
  1089. var16 : word;
  1090. begin
  1091. var16:=pword(@tokenbuf[i])^;
  1092. inc(i,sizeof(word));
  1093. if ppufile.change_endian then
  1094. var16:=swapendian(var16);
  1095. result:=var16;
  1096. end;
  1097. function gettokenbufsizeint : int64;
  1098. var
  1099. var64 : int64;
  1100. var32 : longint;
  1101. var16 : smallint;
  1102. begin
  1103. if CpuAddrBitSize[cpu]=64 then
  1104. begin
  1105. var64:=pint64(@tokenbuf[i])^;
  1106. inc(i,sizeof(int64));
  1107. if ppufile.change_endian then
  1108. var64:=swapendian(var64);
  1109. result:=var64;
  1110. end
  1111. else if CpuAddrBitSize[cpu]=32 then
  1112. begin
  1113. var32:=plongint(@tokenbuf[i])^;
  1114. inc(i,sizeof(longint));
  1115. if ppufile.change_endian then
  1116. var32:=swapendian(var32);
  1117. result:=var32;
  1118. end
  1119. else if CpuAddrBitSize[cpu]=16 then
  1120. begin
  1121. var16:=psmallint(@tokenbuf[i])^;
  1122. inc(i,sizeof(smallint));
  1123. if ppufile.change_endian then
  1124. var16:=swapendian(var16);
  1125. result:=var16;
  1126. end
  1127. else
  1128. begin
  1129. WriteError('Wrong CpuAddrBitSize');
  1130. result:=0;
  1131. end;
  1132. end;
  1133. begin
  1134. writeln(space,'** Definition Id ',ppufile.getlongint,' **');
  1135. writeln(space,s);
  1136. write (space,' Type symbol : ');
  1137. readderef('');
  1138. write (space,' DefOptions : ');
  1139. ppufile.getsmallset(defoptions);
  1140. if defoptions<>[] then
  1141. begin
  1142. first:=true;
  1143. for i:=1to high(defopt) do
  1144. if (defopt[i].mask in defoptions) then
  1145. begin
  1146. if first then
  1147. first:=false
  1148. else
  1149. write(', ');
  1150. write(defopt[i].str);
  1151. end;
  1152. end;
  1153. writeln;
  1154. write (space,' DefStates : ');
  1155. ppufile.getsmallset(defstates);
  1156. if defstates<>[] then
  1157. begin
  1158. first:=true;
  1159. for i:=1 to high(defstate) do
  1160. if (defstate[i].mask in defstates) then
  1161. begin
  1162. if first then
  1163. first:=false
  1164. else
  1165. write(', ');
  1166. write(defstate[i].str);
  1167. end;
  1168. end;
  1169. writeln;
  1170. if df_generic in defoptions then
  1171. begin
  1172. tokenbufsize:=ppufile.getlongint;
  1173. writeln(space,' Tokenbuffer size : ',tokenbufsize);
  1174. tokenbuf:=allocmem(tokenbufsize);
  1175. ppufile.getdata(tokenbuf^,tokenbufsize);
  1176. i:=0;
  1177. write(space,' Tokens: ');
  1178. while i<tokenbufsize do
  1179. begin
  1180. token:=readtoken;
  1181. if token<>_GENERICSPECIALTOKEN then
  1182. begin
  1183. if token <= high(ttoken) then
  1184. write(arraytokeninfo[token].str)
  1185. else
  1186. begin
  1187. HasMoreInfos;
  1188. write('Error in Token List');
  1189. break;
  1190. end;
  1191. idtoken:=readtoken;
  1192. end;
  1193. case token of
  1194. _CWCHAR,
  1195. _CWSTRING :
  1196. begin
  1197. len:=gettokenbufsizeint;
  1198. setlength(wstring,len);
  1199. move(tokenbuf[i],wstring[1],len*2);
  1200. write(' ',wstring);
  1201. inc(i,len*2);
  1202. end;
  1203. _CSTRING:
  1204. begin
  1205. len:=gettokenbufsizeint;
  1206. setlength(astring,len);
  1207. move(tokenbuf[i],astring[1],len);
  1208. write(' ',astring);
  1209. inc(i,len);
  1210. end;
  1211. _CCHAR,
  1212. _INTCONST,
  1213. _REALNUMBER :
  1214. begin
  1215. write(' ',pshortstring(@tokenbuf[i])^);
  1216. inc(i,tokenbuf[i]+1);
  1217. end;
  1218. _ID :
  1219. begin
  1220. write(' ',pshortstring(@tokenbuf[i])^);
  1221. inc(i,tokenbuf[i]+1);
  1222. end;
  1223. _GENERICSPECIALTOKEN:
  1224. begin
  1225. { Short version of column change,
  1226. byte or $80 used }
  1227. if (tokenbuf[i] and $80)<>0 then
  1228. begin
  1229. write('Col: ',tokenbuf[i] and $7f);
  1230. inc(i);
  1231. end
  1232. else
  1233. case tspecialgenerictoken(tokenbuf[i]) of
  1234. ST_LOADSETTINGS:
  1235. begin
  1236. inc(i);
  1237. write('Settings');
  1238. { This does not load pmessage pointer }
  1239. new_settings.pmessage:=nil;
  1240. { TSettings size depends in target...
  1241. We first read the size of the copied part }
  1242. { Still not cross endian ready :( }
  1243. copy_size:=gettokenbufsizeint;
  1244. if copy_size < sizeof(tsettings)-sizeof(pointer) then
  1245. min_size:=copy_size
  1246. else
  1247. min_size:= sizeof(tsettings)-sizeof(pointer);
  1248. move(tokenbuf[i],new_settings, min_size);
  1249. inc(i,copy_size);
  1250. end;
  1251. ST_LOADMESSAGES:
  1252. begin
  1253. inc(i);
  1254. write('Messages:');
  1255. mesgnb:=tokenbuf[i];
  1256. inc(i);
  1257. for nb:=1 to mesgnb do
  1258. begin
  1259. msgvalue:=gettokenbufsizeint;
  1260. inc(i,sizeof(sizeint));
  1261. state:=tmsgstate(gettokenbufsizeint);
  1262. end;
  1263. end;
  1264. ST_LINE:
  1265. begin
  1266. inc(i);
  1267. write('Line: ',gettokenbufdword);
  1268. end;
  1269. ST_COLUMN:
  1270. begin
  1271. inc(i);
  1272. write('Col: ',gettokenbufword);
  1273. end;
  1274. ST_FILEINDEX:
  1275. begin
  1276. inc(i);
  1277. write('File: ',gettokenbufword);
  1278. end;
  1279. end;
  1280. end;
  1281. end;
  1282. if i<tokenbufsize then
  1283. write(',');
  1284. end;
  1285. writeln;
  1286. freemem(tokenbuf);
  1287. end;
  1288. if df_specialization in defoptions then
  1289. begin
  1290. write (space,' Orig. GenericDef : ');
  1291. readderef('');
  1292. end;
  1293. current_defoptions:=defoptions;
  1294. end;
  1295. { Read abstract procdef and return if inline procdef }
  1296. { type tproccalloption is in globtype unit }
  1297. { type tproctypeoption is in globtype unit }
  1298. { type tprocoption is in globtype unit }
  1299. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions);
  1300. type
  1301. tproccallopt=record
  1302. mask : tproccalloption;
  1303. str : string[30];
  1304. end;
  1305. tproctypeopt=record
  1306. mask : tproctypeoption;
  1307. str : string[30];
  1308. end;
  1309. tprocopt=record
  1310. mask : tprocoption;
  1311. str : string[30];
  1312. end;
  1313. const
  1314. {proccalloptionStr is also in globtype unit }
  1315. proctypeopt : array[1..ord(high(tproctypeoption))] of tproctypeopt=(
  1316. (mask:potype_proginit; str:'ProgInit'),
  1317. (mask:potype_unitinit; str:'UnitInit'),
  1318. (mask:potype_unitfinalize; str:'UnitFinalize'),
  1319. (mask:potype_constructor; str:'Constructor'),
  1320. (mask:potype_destructor; str:'Destructor'),
  1321. (mask:potype_operator; str:'Operator'),
  1322. (mask:potype_procedure; str:'Procedure'),
  1323. (mask:potype_function; str:'Function'),
  1324. (mask:potype_class_constructor; str:'Class Constructor'),
  1325. (mask:potype_class_destructor; str:'Class Destructor'),
  1326. { Dispinterface property accessors }
  1327. (mask:potype_propgetter; str:'Property Getter'),
  1328. (mask:potype_propsetter; str:'Property Setter')
  1329. );
  1330. procopt : array[1..ord(high(tprocoption))] of tprocopt=(
  1331. (mask:po_classmethod; str:'ClassMethod'),
  1332. (mask:po_virtualmethod; str:'VirtualMethod'),
  1333. (mask:po_abstractmethod; str:'AbstractMethod'),
  1334. (mask:po_finalmethod; str:'FinalMethod'),
  1335. (mask:po_staticmethod; str:'StaticMethod'),
  1336. (mask:po_overridingmethod;str:'OverridingMethod'),
  1337. (mask:po_methodpointer; str:'MethodPointer'),
  1338. (mask:po_interrupt; str:'Interrupt'),
  1339. (mask:po_iocheck; str:'IOCheck'),
  1340. (mask:po_assembler; str:'Assembler'),
  1341. (mask:po_msgstr; str:'MsgStr'),
  1342. (mask:po_msgint; str:'MsgInt'),
  1343. (mask:po_exports; str:'Exports'),
  1344. (mask:po_external; str:'External'),
  1345. (mask:po_overload; str:'Overload'),
  1346. (mask:po_varargs; str:'VarArgs'),
  1347. (mask:po_internconst; str:'InternConst'),
  1348. (mask:po_addressonly; str:'AddressOnly'),
  1349. (mask:po_public; str:'Public'),
  1350. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  1351. (mask:po_reintroduce; str:'ReIntroduce'),
  1352. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  1353. (mask:po_nostackframe; str:'NoStackFrame'),
  1354. (mask:po_has_mangledname; str:'HasMangledName'),
  1355. (mask:po_has_public_name; str:'HasPublicName'),
  1356. (mask:po_forward; str:'Forward'),
  1357. (mask:po_global; str:'Global'),
  1358. (mask:po_has_inlininginfo;str:'HasInliningInfo'),
  1359. (mask:po_syscall_legacy; str:'SyscallLegacy'),
  1360. (mask:po_syscall_sysv; str:'SyscallSysV'),
  1361. (mask:po_syscall_basesysv;str:'SyscallBaseSysV'),
  1362. (mask:po_syscall_sysvbase;str:'SyscallSysVBase'),
  1363. (mask:po_syscall_r12base; str:'SyscallR12Base'),
  1364. (mask:po_inline; str:'Inline'),
  1365. (mask:po_compilerproc; str:'CompilerProc'),
  1366. (mask:po_has_importdll; str:'HasImportDLL'),
  1367. (mask:po_has_importname; str:'HasImportName'),
  1368. (mask:po_kylixlocal; str:'KylixLocal'),
  1369. (mask:po_dispid; str:'DispId'),
  1370. (mask:po_weakexternal; str:'WeakExternal'),
  1371. (mask:po_objc; str:'ObjC'),
  1372. (mask:po_enumerator_movenext; str:'EnumeratorMoveNext'),
  1373. (mask:po_optional; str: 'Optional'),
  1374. (mask:po_delphi_nested_cc;str: 'Delphi-style nested frameptr')
  1375. );
  1376. var
  1377. proctypeoption : tproctypeoption;
  1378. i : longint;
  1379. first : boolean;
  1380. tempbuf : array[0..255] of byte;
  1381. begin
  1382. write(space,' Return type : ');
  1383. readderef('');
  1384. writeln(space,' Fpu used : ',ppufile.getbyte);
  1385. proctypeoption:=tproctypeoption(ppufile.getbyte);
  1386. write(space,' TypeOption : ');
  1387. first:=true;
  1388. for i:=1 to high(proctypeopt) do
  1389. if (proctypeopt[i].mask=proctypeoption) then
  1390. begin
  1391. if first then
  1392. first:=false
  1393. else
  1394. write(', ');
  1395. write(proctypeopt[i].str);
  1396. end;
  1397. writeln;
  1398. proccalloption:=tproccalloption(ppufile.getbyte);
  1399. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  1400. ppufile.getnormalset(procoptions);
  1401. if procoptions<>[] then
  1402. begin
  1403. write(space,' Options : ');
  1404. first:=true;
  1405. for i:=1 to high(procopt) do
  1406. if (procopt[i].mask in procoptions) then
  1407. begin
  1408. if first then
  1409. first:=false
  1410. else
  1411. write(', ');
  1412. write(procopt[i].str);
  1413. end;
  1414. writeln;
  1415. end;
  1416. if (po_explicitparaloc in procoptions) then
  1417. begin
  1418. i:=ppufile.getbyte;
  1419. ppufile.getdata(tempbuf,i);
  1420. end;
  1421. end;
  1422. { type tvaroption is in unit symconst }
  1423. { register variable }
  1424. { type tvarregable is in unit symconst }
  1425. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions);
  1426. type
  1427. tvaropt=record
  1428. mask : tvaroption;
  1429. str : string[30];
  1430. end;
  1431. const
  1432. varopt : array[1..ord(high(tvaroption))] of tvaropt=(
  1433. (mask:vo_is_external; str:'External'),
  1434. (mask:vo_is_dll_var; str:'DLLVar'),
  1435. (mask:vo_is_thread_var; str:'ThreadVar'),
  1436. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  1437. (mask:vo_is_const; str:'Constant'),
  1438. (mask:vo_is_public; str:'Public'),
  1439. (mask:vo_is_high_para; str:'HighValue'),
  1440. (mask:vo_is_funcret; str:'Funcret'),
  1441. (mask:vo_is_self; str:'Self'),
  1442. (mask:vo_is_vmt; str:'VMT'),
  1443. (mask:vo_is_result; str:'Result'),
  1444. (mask:vo_is_parentfp; str:'ParentFP'),
  1445. (mask:vo_is_loop_counter; str:'LoopCounter'),
  1446. (mask:vo_is_hidden_para; str:'Hidden'),
  1447. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  1448. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  1449. (mask:vo_has_mangledname; str:'HasMangledName'),
  1450. (mask:vo_is_typed_const; str:'TypedConst'),
  1451. (mask:vo_is_range_check; str:'RangeCheckSwitch'),
  1452. (mask:vo_is_overflow_check; str:'OverflowCheckSwitch'),
  1453. (mask:vo_is_typinfo_para; str:'TypeInfo'),
  1454. (mask:vo_is_msgsel;str:'MsgSel'),
  1455. (mask:vo_is_weak_external;str:'WeakExternal'),
  1456. (mask:vo_is_first_field;str:'IsFirstField'),
  1457. (mask:vo_volatile;str:'Volatile'),
  1458. (mask:vo_has_section;str:'HasSection'),
  1459. (mask:vo_force_finalize;str:'ForceFinalize')
  1460. );
  1461. var
  1462. i : longint;
  1463. first : boolean;
  1464. begin
  1465. readcommonsym(s);
  1466. writeln(space,' Spez : ',Varspez2Str(ppufile.getbyte));
  1467. writeln(space,' Regable : ',Varregable2Str(ppufile.getbyte));
  1468. writeln(space,' Addr Taken : ',(ppufile.getbyte<>0));
  1469. write (space,' Var Type : ');
  1470. readderef('');
  1471. ppufile.getsmallset(varoptions);
  1472. if varoptions<>[] then
  1473. begin
  1474. write(space,' Options : ');
  1475. first:=true;
  1476. for i:=1 to high(varopt) do
  1477. if (varopt[i].mask in varoptions) then
  1478. begin
  1479. if first then
  1480. first:=false
  1481. else
  1482. write(', ');
  1483. write(varopt[i].str);
  1484. if varopt[i].mask = vo_has_section then
  1485. writeln('Section name:',ppufile.getansistring);
  1486. end;
  1487. writeln;
  1488. end;
  1489. end;
  1490. procedure readobjectdefoptions;
  1491. type
  1492. tsymopt=record
  1493. mask : tobjectoption;
  1494. str : string[30];
  1495. end;
  1496. const
  1497. symopt : array[1..ord(high(tobjectoption))] of tsymopt=(
  1498. (mask:oo_is_forward; str:'IsForward'),
  1499. (mask:oo_is_abstract; str:'IsAbstract'),
  1500. (mask:oo_is_sealed; str:'IsSealed'),
  1501. (mask:oo_has_virtual; str:'HasVirtual'),
  1502. (mask:oo_has_private; str:'HasPrivate'),
  1503. (mask:oo_has_protected; str:'HasProtected'),
  1504. (mask:oo_has_strictprivate; str:'HasStrictPrivate'),
  1505. (mask:oo_has_strictprotected;str:'HasStrictProtected'),
  1506. (mask:oo_has_constructor; str:'HasConstructor'),
  1507. (mask:oo_has_destructor; str:'HasDestructor'),
  1508. (mask:oo_has_vmt; str:'HasVMT'),
  1509. (mask:oo_has_msgstr; str:'HasMsgStr'),
  1510. (mask:oo_has_msgint; str:'HasMsgInt'),
  1511. (mask:oo_can_have_published; str:'CanHavePublished'),
  1512. (mask:oo_has_default_property;str:'HasDefaultProperty'),
  1513. (mask:oo_has_valid_guid; str:'HasValidGUID'),
  1514. (mask:oo_has_enumerator_movenext; str:'HasEnumeratorMoveNext'),
  1515. (mask:oo_has_enumerator_current; str:'HasEnumeratorCurrent'),
  1516. (mask:oo_is_external; str:'External'),
  1517. (mask:oo_is_formal; str:'Formal'),
  1518. (mask:oo_is_classhelper; str:'Class Helper/Category'),
  1519. (mask:oo_has_class_constructor; str:'HasClassConstructor'),
  1520. (mask:oo_has_class_destructor; str:'HasClassDestructor')
  1521. );
  1522. var
  1523. i : longint;
  1524. first : boolean;
  1525. begin
  1526. ppufile.getsmallset(current_objectoptions);
  1527. if current_objectoptions<>[] then
  1528. begin
  1529. first:=true;
  1530. for i:=1 to high(symopt) do
  1531. if (symopt[i].mask in current_objectoptions) then
  1532. begin
  1533. if first then
  1534. first:=false
  1535. else
  1536. write(', ');
  1537. write(symopt[i].str);
  1538. end;
  1539. end;
  1540. writeln;
  1541. end;
  1542. procedure readarraydefoptions;
  1543. { type tarraydefoption is in unit symconst }
  1544. type
  1545. tsymopt=record
  1546. mask : tarraydefoption;
  1547. str : string[30];
  1548. end;
  1549. const
  1550. symopt : array[1..ord(high(tarraydefoption))] of tsymopt=(
  1551. (mask:ado_IsConvertedPointer;str:'ConvertedPointer'),
  1552. (mask:ado_IsDynamicArray; str:'IsDynamicArray'),
  1553. (mask:ado_IsVariant; str:'IsVariant'),
  1554. (mask:ado_IsConstructor; str:'IsConstructor'),
  1555. (mask:ado_IsArrayOfConst; str:'ArrayOfConst'),
  1556. (mask:ado_IsConstString; str:'ConstString'),
  1557. (mask:ado_IsBitPacked; str:'BitPacked')
  1558. );
  1559. var
  1560. symoptions : tarraydefoptions;
  1561. i : longint;
  1562. first : boolean;
  1563. begin
  1564. ppufile.getsmallset(symoptions);
  1565. if symoptions<>[] then
  1566. begin
  1567. first:=true;
  1568. for i:=1 to high(symopt) do
  1569. if (symopt[i].mask in symoptions) then
  1570. begin
  1571. if first then
  1572. first:=false
  1573. else
  1574. write(', ');
  1575. write(symopt[i].str);
  1576. end;
  1577. end;
  1578. writeln;
  1579. end;
  1580. (* options for properties
  1581. tpropertyoption=(ppo_none,
  1582. ppo_indexed,
  1583. ppo_defaultproperty,
  1584. ppo_stored,
  1585. ppo_hasparameters,
  1586. ppo_implements,
  1587. ppo_enumerator_current,
  1588. ppo_dispid_read, { no longer used }
  1589. ppo_dispid_write { no longer used }
  1590. );
  1591. tpropertyoptions=set of tpropertyoption;
  1592. *)
  1593. procedure readpropertyoptions;
  1594. { type tarraydefoption is in unit symconst }
  1595. type
  1596. tpropopt=record
  1597. mask : tpropertyoption;
  1598. str : string[30];
  1599. end;
  1600. const
  1601. symopt : array[1..ord(high(tpropertyoption))] of tpropopt=(
  1602. (mask:ppo_indexed;str:'indexed'),
  1603. (mask:ppo_defaultproperty;str:'default'),
  1604. (mask:ppo_stored;str:'stored'),
  1605. (mask:ppo_hasparameters;str:'has parameters'),
  1606. (mask:ppo_implements;str:'implements'),
  1607. (mask:ppo_enumerator_current;str:'enumerator current'),
  1608. (mask:ppo_dispid_read;str:'dispid read'), { no longer used }
  1609. (mask:ppo_dispid_write;str:'dispid write') { no longer used }
  1610. );
  1611. var
  1612. propoptions : tpropertyoptions;
  1613. i : longint;
  1614. first : boolean;
  1615. begin
  1616. ppufile.getsmallset(propoptions);
  1617. if propoptions<>[] then
  1618. begin
  1619. first:=true;
  1620. for i:=1 to high(symopt) do
  1621. if (symopt[i].mask in propoptions) then
  1622. begin
  1623. if first then
  1624. first:=false
  1625. else
  1626. write(', ');
  1627. write(symopt[i].str);
  1628. end;
  1629. end;
  1630. writeln;
  1631. end;
  1632. procedure readnodetree;
  1633. var
  1634. l : longint;
  1635. p : pointer;
  1636. begin
  1637. with ppufile do
  1638. begin
  1639. if space<>'' then
  1640. Writeln(space,'------ nodetree ------');
  1641. if readentry=ibnodetree then
  1642. begin
  1643. l:=entrysize;
  1644. Writeln(space,'Tree size : ',l);
  1645. { Read data to prevent error that entry is not completly read }
  1646. getmem(p,l);
  1647. getdata(p^,l);
  1648. freemem(p);
  1649. end
  1650. else
  1651. begin
  1652. WriteError('!! ibnodetree not found');
  1653. end;
  1654. end;
  1655. end;
  1656. procedure ReadCreatedObjTypes;
  1657. var
  1658. i,j,
  1659. len,
  1660. bssize: longint;
  1661. bs: pbyte;
  1662. begin
  1663. if ppufile.readentry<>ibcreatedobjtypes then
  1664. begin
  1665. writeln('!! ibcreatedobjtypes entry not found');
  1666. ppufile.skipdata(ppufile.entrysize);
  1667. has_errors:=true;
  1668. exit
  1669. end;
  1670. writeln;
  1671. writeln(space,'WPO info');
  1672. writeln(space,'--------');
  1673. len:=ppufile.getlongint;
  1674. writeln(space,'** Instantiated Object/Class types: ',len,' **');
  1675. space:=space+' ';
  1676. for i:=0 to len-1 do
  1677. readderef(space);
  1678. setlength(space,length(space)-2);
  1679. len:=ppufile.getlongint;
  1680. writeln(space,'** Instantiated ClassRef types: ',len,' **');
  1681. space:=space+' ';
  1682. for i:=0 to len-1 do
  1683. readderef(space);
  1684. setlength(space,length(space)-2);
  1685. len:=ppufile.getlongint;
  1686. writeln(space,'** Possibly instantiated ClassRef types : ',len,' **');
  1687. space:=space+' ';
  1688. for i:=0 to len-1 do
  1689. readderef(space);
  1690. setlength(space,length(space)-2);
  1691. len:=ppufile.getlongint;
  1692. writeln(space,'** Class types with called virtual methods info : ',len,' **');
  1693. space:=space+' ';
  1694. for i:=0 to len-1 do
  1695. begin
  1696. write(space,'Class def : ');
  1697. readderef('');
  1698. write(space+' ','Called vmtentries : ');
  1699. bssize:=ppufile.getlongint;
  1700. getmem(bs,bssize);
  1701. ppufile.readdata(bs^,bssize);
  1702. for j:=0 to bssize*8-1 do
  1703. if (((bs+j shr 3)^ shr (j and 7)) and 1) <> 0 then
  1704. write(j,', ');
  1705. writeln;
  1706. freemem(bs);
  1707. end;
  1708. setlength(space,length(space)-2);
  1709. end;
  1710. {****************************************************************************
  1711. Read Symbols Part
  1712. ****************************************************************************}
  1713. procedure readsymbols(const s:string);
  1714. type
  1715. pguid = ^tguid;
  1716. tguid = packed record
  1717. D1: LongWord;
  1718. D2: Word;
  1719. D3: Word;
  1720. D4: array[0..7] of Byte;
  1721. end;
  1722. var
  1723. b : byte;
  1724. pc : pchar;
  1725. ch : dword;
  1726. startnewline : boolean;
  1727. i,j,len : longint;
  1728. prettyname : ansistring;
  1729. guid : tguid;
  1730. realvalue : ppureal;
  1731. doublevalue : double;
  1732. singlevalue : single;
  1733. extended : TSplit80bitReal;
  1734. tempbuf : array[0..127] of char;
  1735. pw : pcompilerwidestring;
  1736. varoptions : tvaroptions;
  1737. begin
  1738. with ppufile do
  1739. begin
  1740. if space<>'' then
  1741. Writeln(space,'------ ',s,' ------');
  1742. if readentry=ibstartsyms then
  1743. begin
  1744. Writeln(space,'Symtable datasize : ',getlongint);
  1745. Writeln(space,'Symtable alignment: ',getlongint);
  1746. end
  1747. else
  1748. Writeln('!! ibstartsym not found');
  1749. repeat
  1750. b:=readentry;
  1751. case b of
  1752. ibunitsym :
  1753. readcommonsym('Unit symbol ');
  1754. ibnamespacesym :
  1755. begin
  1756. readcommonsym('NameSpace symbol ');
  1757. write(space,' Hidden Unit : ');
  1758. readderef('');
  1759. end;
  1760. iblabelsym :
  1761. readcommonsym('Label symbol ');
  1762. ibtypesym :
  1763. begin
  1764. readcommonsym('Type symbol ');
  1765. write(space,' Result Type : ');
  1766. readderef('');
  1767. prettyname:=getansistring;
  1768. if prettyname<>'' then
  1769. begin
  1770. write(space,' Pretty Name : ');
  1771. Writeln(prettyname);
  1772. end;
  1773. end;
  1774. ibprocsym :
  1775. begin
  1776. readcommonsym('Procedure symbol ');
  1777. len:=ppufile.getword;
  1778. for i:=1 to len do
  1779. begin
  1780. write(space,' Definition : ');
  1781. readderef('');
  1782. end;
  1783. end;
  1784. ibconstsym :
  1785. begin
  1786. readcommonsym('Constant symbol ');
  1787. b:=getbyte;
  1788. case tconsttyp(b) of
  1789. constord :
  1790. begin
  1791. write (space,' OrdinalType : ');
  1792. readderef('');
  1793. writeln(space,' Value : ',constexp.tostr(getexprint));
  1794. end;
  1795. constpointer :
  1796. begin
  1797. write (space,' PointerType : ');
  1798. readderef('');
  1799. writeln(space,' Value : ',getaint)
  1800. end;
  1801. conststring,
  1802. constresourcestring :
  1803. begin
  1804. len:=getlongint;
  1805. getmem(pc,len+1);
  1806. getdata(pc^,len);
  1807. (pc+len)^:= #0;
  1808. writeln(space,' Length : ',len);
  1809. writeln(space,' Value : "',pc,'"');
  1810. freemem(pc,len+1);
  1811. end;
  1812. constreal :
  1813. begin
  1814. write(space,' Value : ');
  1815. if entryleft=sizeof(ppureal) then
  1816. begin
  1817. realvalue:=getrealsize(sizeof(ppureal));
  1818. writeln(realvalue);
  1819. end
  1820. else if entryleft=sizeof(double) then
  1821. begin
  1822. doublevalue:=getrealsize(sizeof(double));
  1823. writeln(doublevalue);
  1824. end
  1825. else if entryleft=sizeof(single) then
  1826. begin
  1827. singlevalue:=getrealsize(sizeof(single));
  1828. writeln(singlevalue);
  1829. end
  1830. else if entryleft=10 then
  1831. begin
  1832. getdata(extended,entryleft);
  1833. writeln(Real80bitToStr(extended));
  1834. end
  1835. else
  1836. begin
  1837. realvalue:=0.0;
  1838. writeln(realvalue,' Error reading real value');
  1839. has_errors:=true;
  1840. end;
  1841. end;
  1842. constset :
  1843. begin
  1844. write (space,' Set Type : ');
  1845. readderef('');
  1846. for i:=1to 4 do
  1847. begin
  1848. write (space,' Value : ');
  1849. for j:=1to 8 do
  1850. begin
  1851. if j>1 then
  1852. write(',');
  1853. write(hexstr(getbyte,2));
  1854. end;
  1855. writeln;
  1856. end;
  1857. end;
  1858. constnil:
  1859. writeln(space,' NIL pointer.');
  1860. constwstring :
  1861. begin
  1862. initwidestring(pw);
  1863. setlengthwidestring(pw,getlongint);
  1864. if widecharsize=2 then
  1865. { don't use getdata, because the compilerwidechars may have to
  1866. be byteswapped
  1867. }
  1868. begin
  1869. for i:=0 to pw^.len-1 do
  1870. pw^.data[i]:=ppufile.getword;
  1871. end
  1872. else if widecharsize=4 then
  1873. begin
  1874. for i:=0 to pw^.len-1 do
  1875. pw^.data[i]:=cardinal(ppufile.getlongint);
  1876. end
  1877. else
  1878. begin
  1879. WriteError('Unsupported tcompilerwidechar size');
  1880. end;
  1881. Writeln(space,'Wide string type');
  1882. startnewline:=true;
  1883. for i:=0 to pw^.len-1 do
  1884. begin
  1885. if startnewline then
  1886. begin
  1887. write(space);
  1888. startnewline:=false;
  1889. end;
  1890. ch:=pw^.data[i];
  1891. if widecharsize=2 then
  1892. write(hexstr(ch,4))
  1893. else
  1894. write(hexstr(ch,8));
  1895. if (i mod 8)= 0 then
  1896. startnewline:=true
  1897. else
  1898. write(', ');
  1899. end;
  1900. donewidestring(pw);
  1901. end;
  1902. constguid:
  1903. begin
  1904. getdata(guid,sizeof(guid));
  1905. write (space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-');
  1906. for i:=0 to 7 do
  1907. begin
  1908. write(hexstr(guid.d4[i],2));
  1909. if i=1 then write('-');
  1910. end;
  1911. writeln('}');
  1912. end
  1913. else
  1914. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  1915. end;
  1916. end;
  1917. ibabsolutevarsym :
  1918. begin
  1919. readabstractvarsym('Absolute variable symbol ',varoptions);
  1920. Write (space,' Relocated to ');
  1921. b:=getbyte;
  1922. case absolutetyp(b) of
  1923. tovar :
  1924. readpropaccesslist(space+' Sym : ');
  1925. toasm :
  1926. Writeln('Assembler name : ',getstring);
  1927. toaddr :
  1928. begin
  1929. Write('Address : ',getlongint);
  1930. if tsystemcpu(ppufile.header.cpu)=cpu_i386 then
  1931. WriteLn(' (Far: ',getbyte<>0,')');
  1932. end;
  1933. else
  1934. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  1935. end;
  1936. end;
  1937. ibfieldvarsym :
  1938. begin
  1939. readabstractvarsym('Field Variable symbol ',varoptions);
  1940. writeln(space,' Address : ',getaint);
  1941. end;
  1942. ibstaticvarsym :
  1943. begin
  1944. readabstractvarsym('Global Variable symbol ',varoptions);
  1945. write (space,' DefaultConst : ');
  1946. readderef('');
  1947. if (vo_has_mangledname in varoptions) then
  1948. writeln(space,' Mangledname : ',getstring);
  1949. end;
  1950. iblocalvarsym :
  1951. begin
  1952. readabstractvarsym('Local Variable symbol ',varoptions);
  1953. write (space,' DefaultConst : ');
  1954. readderef('');
  1955. end;
  1956. ibparavarsym :
  1957. begin
  1958. readabstractvarsym('Parameter Variable symbol ',varoptions);
  1959. write (space,' DefaultConst : ');
  1960. readderef('');
  1961. writeln(space,' ParaNr : ',getword);
  1962. writeln(space,' Univ : ',boolean(getbyte));
  1963. writeln(space,' VarState : ',getbyte);
  1964. if (vo_has_explicit_paraloc in varoptions) then
  1965. begin
  1966. i:=getbyte;
  1967. getdata(tempbuf,i);
  1968. end;
  1969. end;
  1970. ibenumsym :
  1971. begin
  1972. readcommonsym('Enumeration symbol ');
  1973. write (space,' Definition : ');
  1974. readderef('');
  1975. writeln(space,' Value : ',getlongint);
  1976. end;
  1977. ibsyssym :
  1978. begin
  1979. readcommonsym('Internal system symbol ');
  1980. writeln(space,' Internal Nr : ',getlongint);
  1981. end;
  1982. ibmacrosym :
  1983. begin
  1984. readcommonsym('Macro symbol ');
  1985. writeln(space,' Name: ',getstring);
  1986. writeln(space,' Defined: ',getbyte);
  1987. writeln(space,' Compiler var: ',getbyte);
  1988. len:=getlongint;
  1989. writeln(space,' Value length: ',len);
  1990. if len > 0 then
  1991. begin
  1992. getmem(pc,len+1);
  1993. getdata(pc^,len);
  1994. (pc+len)^:= #0;
  1995. writeln(space,' Value: "',pc,'"');
  1996. freemem(pc,len+1);
  1997. end;
  1998. end;
  1999. ibpropertysym :
  2000. begin
  2001. readcommonsym('Property ');
  2002. readpropertyoptions;
  2003. write (space,' OverrideProp : ');
  2004. readderef('');
  2005. write (space,' Prop Type : ');
  2006. readderef('');
  2007. writeln(space,' Index : ',getlongint);
  2008. writeln(space,' Default : ',getlongint);
  2009. write (space,' Index Type : ');
  2010. readderef('');
  2011. { palt_none }
  2012. readpropaccesslist('');
  2013. write (space,' Readaccess : ');
  2014. readpropaccesslist(space+' Sym: ');
  2015. write (space,' Writeaccess : ');
  2016. readpropaccesslist(space+' Sym: ');
  2017. write (space,' Storedaccess : ');
  2018. readpropaccesslist(space+' Sym: ');
  2019. end;
  2020. iberror :
  2021. begin
  2022. WriteError('!! Error in PPU');
  2023. exit;
  2024. end;
  2025. ibendsyms :
  2026. break;
  2027. else
  2028. begin
  2029. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  2030. has_errors:=true;
  2031. end;
  2032. end;
  2033. if not EndOfEntry then
  2034. HasMoreInfos;
  2035. until false;
  2036. end;
  2037. end;
  2038. {****************************************************************************
  2039. Read defintions Part
  2040. ****************************************************************************}
  2041. procedure readdefinitions(const s:string);
  2042. { type tordtype is in symconst unit }
  2043. {
  2044. uvoid,
  2045. u8bit,u16bit,u32bit,u64bit,
  2046. s8bit,s16bit,s32bit,s64bit,
  2047. bool8bit,bool16bit,bool32bit,bool64bit,
  2048. uchar,uwidechar,scurrency
  2049. ); }
  2050. { type tobjecttyp is in symconst unit }
  2051. { type tvarianttype is in symconst unit }
  2052. var
  2053. b : byte;
  2054. l,j : longint;
  2055. calloption : tproccalloption;
  2056. procoptions : tprocoptions;
  2057. defoptions: tdefoptions;
  2058. begin
  2059. with ppufile do
  2060. begin
  2061. if space<>'' then
  2062. Writeln(space,'------ ',s,' ------');
  2063. if readentry<>ibstartdefs then
  2064. Writeln('!! ibstartdefs not found');
  2065. repeat
  2066. b:=readentry;
  2067. case b of
  2068. ibpointerdef :
  2069. begin
  2070. readcommondef('Pointer definition',defoptions);
  2071. write (space,' Pointed Type : ');
  2072. readderef('');
  2073. writeln(space,' Is Far : ',(getbyte<>0));
  2074. writeln(space,' Has Pointer Math : ',(getbyte<>0));
  2075. end;
  2076. iborddef :
  2077. begin
  2078. readcommondef('Ordinal definition',defoptions);
  2079. write (space,' Base type : ');
  2080. b:=getbyte;
  2081. case tordtype(b) of
  2082. uvoid : writeln('uvoid');
  2083. u8bit : writeln('u8bit');
  2084. u16bit : writeln('u16bit');
  2085. u32bit : writeln('s32bit');
  2086. u64bit : writeln('u64bit');
  2087. s8bit : writeln('s8bit');
  2088. s16bit : writeln('s16bit');
  2089. s32bit : writeln('s32bit');
  2090. s64bit : writeln('s64bit');
  2091. bool8bit : writeln('bool8bit');
  2092. bool16bit : writeln('bool16bit');
  2093. bool32bit : writeln('bool32bit');
  2094. bool64bit : writeln('bool64bit');
  2095. uchar : writeln('uchar');
  2096. uwidechar : writeln('uwidechar');
  2097. scurrency : writeln('ucurrency');
  2098. else writeln('!! Warning: Invalid base type ',b);
  2099. end;
  2100. writeln(space,' Range : ',constexp.tostr(getexprint),' to ',constexp.tostr(getexprint));
  2101. end;
  2102. ibfloatdef :
  2103. begin
  2104. readcommondef('Float definition',defoptions);
  2105. writeln(space,' Float type : ',getbyte);
  2106. end;
  2107. ibarraydef :
  2108. begin
  2109. readcommondef('Array definition',defoptions);
  2110. write (space,' Element type : ');
  2111. readderef('');
  2112. write (space,' Range Type : ');
  2113. readderef('');
  2114. writeln(space,' Range : ',getaint,' to ',getaint);
  2115. write (space,' Options : ');
  2116. readarraydefoptions;
  2117. readsymtableoptions('symbols');
  2118. readdefinitions('symbols');
  2119. readsymbols('symbols');
  2120. end;
  2121. ibprocdef :
  2122. begin
  2123. readcommondef('Procedure definition',defoptions);
  2124. read_abstract_proc_def(calloption,procoptions);
  2125. if (po_has_mangledname in procoptions) then
  2126. writeln(space,' Mangled name : ',getstring);
  2127. writeln(space,' Number : ',getword);
  2128. writeln(space,' Level : ',getbyte);
  2129. write (space,' Class : ');
  2130. readderef('');
  2131. write (space,' Procsym : ');
  2132. readderef('');
  2133. write (space,' File Pos : ');
  2134. readposinfo;
  2135. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  2136. write (space,' SymOptions : ');
  2137. readsymoptions(space+' ');
  2138. if tsystemcpu(ppufile.header.cpu)=cpu_powerpc then
  2139. begin
  2140. { library symbol for AmigaOS/MorphOS }
  2141. write (space,' Library symbol : ');
  2142. readderef('');
  2143. end;
  2144. if (po_has_importdll in procoptions) then
  2145. writeln(space,' Import DLL : ',getstring);
  2146. if (po_has_importname in procoptions) then
  2147. writeln(space,' Import Name : ',getstring);
  2148. writeln(space,' Import Nr : ',getword);
  2149. if (po_msgint in procoptions) then
  2150. writeln(space,' MsgInt : ',getlongint);
  2151. if (po_msgstr in procoptions) then
  2152. writeln(space,' MsgStr : ',getstring);
  2153. if (po_dispid in procoptions) then
  2154. writeln(space,' DispID: ',ppufile.getlongint);
  2155. if (po_has_inlininginfo in procoptions) then
  2156. begin
  2157. write (space,' FuncretSym : ');
  2158. readderef('');
  2159. readprocinfooptions(space);
  2160. end;
  2161. b:=ppufile.getbyte;
  2162. if b<>0 then
  2163. begin
  2164. write (space,' Alias names : ');
  2165. for j:=1 to b do
  2166. begin
  2167. write(ppufile.getstring);
  2168. if j<b then
  2169. write(', ');
  2170. end;
  2171. writeln;
  2172. end;
  2173. if not EndOfEntry then
  2174. HasMoreInfos;
  2175. space:=' '+space;
  2176. { parast }
  2177. readsymtableoptions('parast');
  2178. readdefinitions('parast');
  2179. readsymbols('parast');
  2180. { localst }
  2181. if (po_has_inlininginfo in procoptions) then
  2182. begin
  2183. readsymtableoptions('localst');
  2184. readdefinitions('localst');
  2185. readsymbols('localst');
  2186. end;
  2187. if (po_has_inlininginfo in procoptions) then
  2188. readnodetree;
  2189. delete(space,1,4);
  2190. end;
  2191. ibprocvardef :
  2192. begin
  2193. readcommondef('Procedural type (ProcVar) definition',defoptions);
  2194. read_abstract_proc_def(calloption,procoptions);
  2195. writeln(space,' Symtable level :',ppufile.getbyte);
  2196. if not EndOfEntry then
  2197. HasMoreInfos;
  2198. space:=' '+space;
  2199. { parast }
  2200. readsymtableoptions('parast');
  2201. readdefinitions('parast');
  2202. readsymbols('parast');
  2203. delete(space,1,4);
  2204. end;
  2205. ibshortstringdef :
  2206. begin
  2207. readcommondef('ShortString definition',defoptions);
  2208. writeln(space,' Length : ',getbyte);
  2209. end;
  2210. ibwidestringdef :
  2211. begin
  2212. readcommondef('WideString definition',defoptions);
  2213. writeln(space,' Length : ',getaint);
  2214. end;
  2215. ibunicodestringdef :
  2216. begin
  2217. readcommondef('UnicodeString definition',defoptions);
  2218. writeln(space,' Length : ',getaint);
  2219. end;
  2220. ibansistringdef :
  2221. begin
  2222. readcommondef('AnsiString definition',defoptions);
  2223. writeln(space,' Length : ',getaint);
  2224. end;
  2225. iblongstringdef :
  2226. begin
  2227. readcommondef('Longstring definition',defoptions);
  2228. writeln(space,' Length : ',getaint);
  2229. end;
  2230. ibrecorddef :
  2231. begin
  2232. readcommondef('Record definition',defoptions);
  2233. writeln(space,' Name of Record : ',getstring);
  2234. write (space,' Options : ');
  2235. readobjectdefoptions;
  2236. writeln(space,' FieldAlign : ',shortint(getbyte));
  2237. writeln(space,' RecordAlign : ',shortint(getbyte));
  2238. writeln(space,' PadAlign : ',shortint(getbyte));
  2239. writeln(space,'UseFieldAlignment : ',shortint(getbyte));
  2240. writeln(space,' DataSize : ',getasizeint);
  2241. writeln(space,' PaddingSize : ',getword);
  2242. if df_copied_def in current_defoptions then
  2243. begin
  2244. writeln(' Copy of def: ');
  2245. readderef('');
  2246. end;
  2247. if not EndOfEntry then
  2248. HasMoreInfos;
  2249. {read the record definitions and symbols}
  2250. if not(df_copied_def in current_defoptions) then
  2251. begin
  2252. space:=' '+space;
  2253. readrecsymtableoptions;
  2254. readsymtableoptions('fields');
  2255. readdefinitions('fields');
  2256. readsymbols('fields');
  2257. Delete(space,1,4);
  2258. end;
  2259. end;
  2260. ibobjectdef :
  2261. begin
  2262. readcommondef('Object/Class definition',defoptions);
  2263. writeln(space,' Name of Class : ',getstring);
  2264. write (space,' Options : ');
  2265. readobjectdefoptions;
  2266. b:=getbyte;
  2267. write (space,' Type : ');
  2268. case tobjecttyp(b) of
  2269. odt_class : writeln('class');
  2270. odt_object : writeln('object');
  2271. odt_interfacecom : writeln('interfacecom');
  2272. odt_interfacecorba : writeln('interfacecorba');
  2273. odt_cppclass : writeln('cppclass');
  2274. odt_dispinterface : writeln('dispinterface');
  2275. odt_objcclass : writeln('objcclass');
  2276. odt_objcprotocol : writeln('objcprotocol');
  2277. odt_helper : writeln('helper');
  2278. else writeln('!! Warning: Invalid object type ',b);
  2279. end;
  2280. writeln(space,' External name : ',getstring);
  2281. writeln(space,' Import lib : ',getstring);
  2282. writeln(space,' DataSize : ',getasizeint);
  2283. writeln(space,' PaddingSize : ',getword);
  2284. writeln(space,' FieldAlign : ',shortint(getbyte));
  2285. writeln(space,' RecordAlign : ',shortint(getbyte));
  2286. writeln(space,' Vmt offset : ',getlongint);
  2287. write (space, ' Ancestor Class : ');
  2288. readderef('');
  2289. if tobjecttyp(b) in [odt_interfacecom,odt_interfacecorba,odt_dispinterface] then
  2290. begin
  2291. { IIDGUID }
  2292. for j:=1to 16 do
  2293. getbyte;
  2294. writeln(space,' IID String : ',getstring);
  2295. end;
  2296. if (tobjecttyp(b)=odt_helper) or
  2297. (oo_is_classhelper in current_objectoptions) then
  2298. begin
  2299. write(space,' Helper parent : ');
  2300. readderef('');
  2301. end;
  2302. l:=getlongint;
  2303. writeln(space,' VMT entries: ',l);
  2304. for j:=1 to l do
  2305. begin
  2306. write(space,' ');
  2307. readderef('');
  2308. writeln(space,' Visibility: ',Visibility2Str(getbyte));
  2309. end;
  2310. if tobjecttyp(b) in [odt_class,odt_interfacecorba,odt_objcclass,odt_objcprotocol] then
  2311. begin
  2312. l:=getlongint;
  2313. writeln(space,' Impl Intf Count : ',l);
  2314. for j:=1 to l do
  2315. begin
  2316. write (space,' - Definition : ');
  2317. readderef('');
  2318. writeln(space,' IOffset : ',getlongint);
  2319. end;
  2320. end;
  2321. if df_copied_def in current_defoptions then
  2322. begin
  2323. writeln(' Copy of def: ');
  2324. readderef('');
  2325. end;
  2326. if not EndOfEntry then
  2327. HasMoreInfos;
  2328. if not(df_copied_def in current_defoptions) then
  2329. begin
  2330. {read the record definitions and symbols}
  2331. space:=' '+space;
  2332. readrecsymtableoptions;
  2333. readsymtableoptions('fields');
  2334. readdefinitions('fields');
  2335. readsymbols('fields');
  2336. Delete(space,1,4);
  2337. end;
  2338. end;
  2339. ibfiledef :
  2340. begin
  2341. ReadCommonDef('File definition',defoptions);
  2342. write (space,' Type : ');
  2343. case getbyte of
  2344. 0 : writeln('Text');
  2345. 1 : begin
  2346. writeln('Typed');
  2347. write (space,' File of Type : ');
  2348. readderef('');
  2349. end;
  2350. 2 : writeln('Untyped');
  2351. end;
  2352. end;
  2353. ibformaldef :
  2354. begin
  2355. readcommondef('Generic definition (void-typ)',defoptions);
  2356. writeln(space,' Is Typed : ',(getbyte<>0));
  2357. end;
  2358. ibundefineddef :
  2359. readcommondef('Undefined definition (generic parameter)',defoptions);
  2360. ibenumdef :
  2361. begin
  2362. readcommondef('Enumeration type definition',defoptions);
  2363. writeln(space,' Smallest element : ',getaint);
  2364. writeln(space,' Largest element : ',getaint);
  2365. writeln(space,' Size : ',getaint);
  2366. if df_copied_def in defoptions then
  2367. begin
  2368. write(space,'Base enumeration type : ');
  2369. readderef('');
  2370. end
  2371. else
  2372. begin
  2373. space:=' '+space;
  2374. readsymtableoptions('elements');
  2375. readdefinitions('elements');
  2376. readsymbols('elements');
  2377. delete(space,1,4);
  2378. end;
  2379. end;
  2380. ibclassrefdef :
  2381. begin
  2382. readcommondef('Class reference definition',defoptions);
  2383. write (space,' Pointed Type : ');
  2384. readderef('');
  2385. end;
  2386. ibsetdef :
  2387. begin
  2388. readcommondef('Set definition',defoptions);
  2389. write (space,' Element type : ');
  2390. readderef('');
  2391. writeln(space,' Size : ',getaint);
  2392. writeln(space,' Set Base : ',getaint);
  2393. writeln(space,' Set Max : ',getaint);
  2394. end;
  2395. ibvariantdef :
  2396. begin
  2397. readcommondef('Variant definition',defoptions);
  2398. write (space,' Varianttype : ');
  2399. b:=getbyte;
  2400. case tvarianttype(b) of
  2401. vt_normalvariant :
  2402. writeln('Normal');
  2403. vt_olevariant :
  2404. writeln('OLE');
  2405. else
  2406. writeln('!! Warning: Invalid varianttype ',b);
  2407. end;
  2408. end;
  2409. iberror :
  2410. begin
  2411. WriteError('!! Error in PPU');
  2412. exit;
  2413. end;
  2414. ibenddefs :
  2415. break;
  2416. else
  2417. begin
  2418. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  2419. has_errors:=true;
  2420. end;
  2421. end;
  2422. if not EndOfEntry then
  2423. HasMoreInfos;
  2424. until false;
  2425. end;
  2426. end;
  2427. procedure readmoduleoptions(space : string);
  2428. type
  2429. { tmoduleoption type is in unit fmodule }
  2430. tmoduleoption = (mo_none,
  2431. mo_hint_deprecated,
  2432. mo_hint_platform,
  2433. mo_hint_library,
  2434. mo_hint_unimplemented,
  2435. mo_hint_experimental,
  2436. mo_has_deprecated_msg
  2437. );
  2438. tmoduleoptions = set of tmoduleoption;
  2439. tmoduleopt=record
  2440. mask : tmoduleoption;
  2441. str : string[30];
  2442. end;
  2443. const
  2444. moduleopts=ord(high(tmoduleoption));
  2445. moduleopt : array[1..moduleopts] of tmoduleopt=(
  2446. (mask:mo_hint_deprecated; str:'Hint Deprecated'),
  2447. (mask:mo_hint_platform; str:'Hint Platform'),
  2448. (mask:mo_hint_library; str:'Hint Library'),
  2449. (mask:mo_hint_unimplemented; str:'Hint Unimplemented'),
  2450. (mask:mo_hint_experimental; str:'Hint Experimental'),
  2451. (mask:mo_has_deprecated_msg; str:'Has Deprecated Message')
  2452. );
  2453. var
  2454. moduleoptions : tmoduleoptions;
  2455. i : longint;
  2456. first : boolean;
  2457. begin
  2458. ppufile.getsmallset(moduleoptions);
  2459. if moduleoptions<>[] then
  2460. begin
  2461. first:=true;
  2462. for i:=1to moduleopts do
  2463. if (moduleopt[i].mask in moduleoptions) then
  2464. begin
  2465. if first then
  2466. first:=false
  2467. else
  2468. write(', ');
  2469. write(moduleopt[i].str);
  2470. end;
  2471. end;
  2472. writeln;
  2473. if mo_has_deprecated_msg in moduleoptions then
  2474. writeln(space,'Deprecated : ', ppufile.getstring);
  2475. end;
  2476. {****************************************************************************
  2477. Read General Part
  2478. ****************************************************************************}
  2479. procedure readinterface;
  2480. var
  2481. b : byte;
  2482. sourcenumber : longint;
  2483. begin
  2484. with ppufile do
  2485. begin
  2486. repeat
  2487. b:=readentry;
  2488. case b of
  2489. ibmodulename :
  2490. Writeln('Module Name: ',getstring);
  2491. ibmoduleoptions:
  2492. readmoduleoptions(' ');
  2493. ibsourcefiles :
  2494. begin
  2495. sourcenumber:=1;
  2496. while not EndOfEntry do
  2497. begin
  2498. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  2499. inc(sourcenumber);
  2500. end;
  2501. end;
  2502. {$IFDEF MACRO_DIFF_HINT}
  2503. ibusedmacros :
  2504. begin
  2505. while not EndOfEntry do
  2506. begin
  2507. Write('Conditional ',getstring);
  2508. b:=getbyte;
  2509. if boolean(b)=true then
  2510. write(' defined at startup')
  2511. else
  2512. write(' not defined at startup');
  2513. b:=getbyte;
  2514. if boolean(b)=true then
  2515. writeln(' was used')
  2516. else
  2517. writeln;
  2518. end;
  2519. end;
  2520. {$ENDIF}
  2521. ibloadunit :
  2522. ReadLoadUnit;
  2523. iblinkunitofiles :
  2524. ReadLinkContainer('Link unit object file: ');
  2525. iblinkunitstaticlibs :
  2526. ReadLinkContainer('Link unit static lib: ');
  2527. iblinkunitsharedlibs :
  2528. ReadLinkContainer('Link unit shared lib: ');
  2529. iblinkotherofiles :
  2530. ReadLinkContainer('Link other object file: ');
  2531. iblinkotherstaticlibs :
  2532. ReadLinkContainer('Link other static lib: ');
  2533. iblinkothersharedlibs :
  2534. ReadLinkContainer('Link other shared lib: ');
  2535. iblinkotherframeworks:
  2536. ReadLinkContainer('Link framework: ');
  2537. ibmainname:
  2538. Writeln('Specified main program symbol name: ',getstring);
  2539. ibImportSymbols :
  2540. ReadImportSymbols;
  2541. ibderefdata :
  2542. ReadDerefData;
  2543. ibderefmap :
  2544. ReadDerefMap;
  2545. ibwpofile :
  2546. ReadWpoFileInfo;
  2547. ibresources :
  2548. ReadLinkContainer('Resource file: ');
  2549. iberror :
  2550. begin
  2551. WriteError('Error in PPU');
  2552. exit;
  2553. end;
  2554. ibendinterface :
  2555. break;
  2556. else
  2557. begin
  2558. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  2559. has_errors:=true;
  2560. end;
  2561. end;
  2562. until false;
  2563. end;
  2564. end;
  2565. {****************************************************************************
  2566. Read Implementation Part
  2567. ****************************************************************************}
  2568. procedure readimplementation;
  2569. var
  2570. b : byte;
  2571. begin
  2572. with ppufile do
  2573. begin
  2574. repeat
  2575. b:=readentry;
  2576. case b of
  2577. ibasmsymbols :
  2578. ReadAsmSymbols;
  2579. ibloadunit :
  2580. ReadLoadUnit;
  2581. iberror :
  2582. begin
  2583. WriteError('Error in PPU');
  2584. exit;
  2585. end;
  2586. ibendimplementation :
  2587. break;
  2588. else
  2589. begin
  2590. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  2591. has_errors:=true;
  2592. end;
  2593. end;
  2594. until false;
  2595. end;
  2596. end;
  2597. procedure dofile (filename : string);
  2598. begin
  2599. { reset }
  2600. space:='';
  2601. { fix filename }
  2602. if pos('.',filename)=0 then
  2603. filename:=filename+'.ppu';
  2604. ppufile:=tppufile.create(filename);
  2605. if not ppufile.openfile then
  2606. begin
  2607. WriteError('IO-Error when opening : '+filename+', Skipping');
  2608. exit;
  2609. end;
  2610. { PPU File is open, check for PPU Id }
  2611. if not ppufile.CheckPPUID then
  2612. begin
  2613. writeln(Filename,' : Not a valid PPU file, Skipping');
  2614. has_errors:=true;
  2615. exit;
  2616. end;
  2617. { Check PPU Version }
  2618. ppuversion:=ppufile.GetPPUVersion;
  2619. Writeln('Analyzing ',filename,' (v',PPUVersion,')');
  2620. if PPUVersion<16 then
  2621. begin
  2622. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  2623. has_errors:=true;
  2624. exit;
  2625. end;
  2626. { Write PPU Header Information }
  2627. if (verbose and v_header)<>0 then
  2628. begin
  2629. Writeln;
  2630. Writeln('Header');
  2631. Writeln('-------');
  2632. with ppufile.header do
  2633. begin
  2634. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  2635. (ppufile.header.compiler shr 7) and $7f,'.',
  2636. ppufile.header.compiler and $7f);
  2637. WriteLn('Target processor : ',Cpu2Str(cpu));
  2638. WriteLn('Target operating system : ',Target2Str(target));
  2639. Writeln('Unit flags : ',PPUFlags2Str(flags));
  2640. Writeln('FileSize (w/o header) : ',size);
  2641. Writeln('Checksum : ',hexstr(checksum,8));
  2642. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  2643. Writeln('Indirect Checksum : ',hexstr(indirect_checksum,8));
  2644. Writeln('Definitions stored : ',tostr(deflistsize));
  2645. Writeln('Symbols stored : ',tostr(symlistsize));
  2646. end;
  2647. end;
  2648. {read the general stuff}
  2649. if (verbose and v_interface)<>0 then
  2650. begin
  2651. Writeln;
  2652. Writeln('Interface section');
  2653. Writeln('------------------');
  2654. readinterface;
  2655. end
  2656. else
  2657. ppufile.skipuntilentry(ibendinterface);
  2658. Writeln;
  2659. Writeln('Interface symtable');
  2660. Writeln('----------------------');
  2661. readsymtableoptions('interface');
  2662. {read the definitions}
  2663. if (verbose and v_defs)<>0 then
  2664. begin
  2665. Writeln;
  2666. Writeln('Interface definitions');
  2667. Writeln('----------------------');
  2668. readdefinitions('interface');
  2669. end
  2670. else
  2671. ppufile.skipuntilentry(ibenddefs);
  2672. {read the symbols}
  2673. if (verbose and v_syms)<>0 then
  2674. begin
  2675. Writeln;
  2676. Writeln('Interface Symbols');
  2677. Writeln('------------------');
  2678. readsymbols('interface');
  2679. end
  2680. else
  2681. ppufile.skipuntilentry(ibendsyms);
  2682. {read the macro symbols}
  2683. if (verbose and v_syms)<>0 then
  2684. begin
  2685. Writeln;
  2686. Writeln('Interface Macro Symbols');
  2687. Writeln('-----------------------');
  2688. end;
  2689. if ppufile.readentry<>ibexportedmacros then
  2690. begin
  2691. WriteError('!! Error in PPU');
  2692. exit;
  2693. end;
  2694. if boolean(ppufile.getbyte) then
  2695. begin
  2696. readsymtableoptions('interface macro');
  2697. {skip the definition section for macros (since they are never used) }
  2698. ppufile.skipuntilentry(ibenddefs);
  2699. {read the macro symbols}
  2700. if (verbose and v_syms)<>0 then
  2701. readsymbols('interface macro')
  2702. else
  2703. ppufile.skipuntilentry(ibendsyms);
  2704. end
  2705. else
  2706. Writeln('(no exported macros)');
  2707. {read the implementation stuff}
  2708. if (verbose and v_implementation)<>0 then
  2709. begin
  2710. Writeln;
  2711. Writeln('Implementation section');
  2712. Writeln('-----------------------');
  2713. readimplementation;
  2714. end
  2715. else
  2716. ppufile.skipuntilentry(ibendimplementation);
  2717. {read the static symtable}
  2718. Writeln;
  2719. Writeln('Implementation symtable');
  2720. Writeln('----------------------');
  2721. readsymtableoptions('implementation');
  2722. if (ppufile.header.flags and uf_local_symtable)<>0 then
  2723. begin
  2724. if (verbose and v_defs)<>0 then
  2725. begin
  2726. Writeln;
  2727. Writeln('Static definitions');
  2728. Writeln('----------------------');
  2729. readdefinitions('implementation');
  2730. end
  2731. else
  2732. ppufile.skipuntilentry(ibenddefs);
  2733. {read the symbols}
  2734. if (verbose and v_syms)<>0 then
  2735. begin
  2736. Writeln;
  2737. Writeln('Static Symbols');
  2738. Writeln('------------------');
  2739. readsymbols('implementation');
  2740. end
  2741. else
  2742. ppufile.skipuntilentry(ibendsyms);
  2743. end;
  2744. ReadCreatedObjTypes;
  2745. FreeDerefdata;
  2746. {shutdown ppufile}
  2747. ppufile.closefile;
  2748. ppufile.free;
  2749. Writeln;
  2750. end;
  2751. procedure help;
  2752. begin
  2753. writeln('usage: ppudump [options] <filename1> <filename2>...');
  2754. writeln;
  2755. writeln('[options] can be:');
  2756. writeln(' -M Exit with ExitCode=2 if more information is available');
  2757. writeln(' -V<verbose> Set verbosity to <verbose>');
  2758. writeln(' H - Show header info');
  2759. writeln(' I - Show interface');
  2760. writeln(' M - Show implementation');
  2761. writeln(' S - Show interface symbols');
  2762. writeln(' D - Show interface definitions');
  2763. // writeln(' B - Show browser info');
  2764. writeln(' A - Show all');
  2765. writeln(' -h, -? This helpscreen');
  2766. halt;
  2767. end;
  2768. var
  2769. startpara,
  2770. nrfile,i : longint;
  2771. para : string;
  2772. const
  2773. error_on_more : boolean = false;
  2774. begin
  2775. writeln(Title+' '+Version);
  2776. writeln(Copyright);
  2777. writeln;
  2778. if paramcount<1 then
  2779. begin
  2780. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  2781. halt(1);
  2782. end;
  2783. { turn verbose on by default }
  2784. verbose:=v_all;
  2785. { read options }
  2786. startpara:=1;
  2787. while copy(paramstr(startpara),1,1)='-' do
  2788. begin
  2789. para:=paramstr(startpara);
  2790. case upcase(para[2]) of
  2791. 'M' : error_on_more:=true;
  2792. 'V' : begin
  2793. verbose:=0;
  2794. for i:=3 to length(para) do
  2795. case upcase(para[i]) of
  2796. 'H' : verbose:=verbose or v_header;
  2797. 'I' : verbose:=verbose or v_interface;
  2798. 'M' : verbose:=verbose or v_implementation;
  2799. 'D' : verbose:=verbose or v_defs;
  2800. 'S' : verbose:=verbose or v_syms;
  2801. 'A' : verbose:=verbose or v_all;
  2802. end;
  2803. end;
  2804. 'H' : help;
  2805. '?' : help;
  2806. end;
  2807. inc(startpara);
  2808. end;
  2809. { process files }
  2810. for nrfile:=startpara to paramcount do
  2811. dofile (paramstr(nrfile));
  2812. if has_errors then
  2813. Halt(1);
  2814. if error_on_more and has_more_infos then
  2815. Halt(2);
  2816. end.