ppudump.pp 98 KB

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