ppudump.pp 83 KB

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