ppudump.pp 86 KB

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