ppudump.pp 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480
  1. {
  2. Copyright (c) 1998-2002 by the FPC Development Team
  3. Dumps the contents of a FPC unit file (PPU File)
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************}
  16. program ppudump;
  17. {$mode objfpc}
  18. {$H+}
  19. uses
  20. { do NOT add symconst or globtype to make merging easier }
  21. { do include symconst and globtype now before splitting 2.5 PM 2011-06-15 }
  22. SysUtils,
  23. constexp,
  24. symconst,
  25. ppu,
  26. globals,
  27. globtype,
  28. tokens;
  29. const
  30. Version = 'Version 2.5.1';
  31. Title = 'PPU-Analyser';
  32. Copyright = 'Copyright (c) 1998-2010 by the Free Pascal Development Team';
  33. { verbosity }
  34. v_none = $0;
  35. v_header = $1;
  36. v_defs = $2;
  37. v_syms = $4;
  38. v_interface = $8;
  39. v_implementation = $10;
  40. // v_browser = $20;
  41. v_all = $ff;
  42. {$i systems.inc }
  43. { List of all supported cpus }
  44. const
  45. CpuTxt : array[tsystemcpu] of string[9]=
  46. (
  47. { 0 } 'none',
  48. { 1 } 'i386',
  49. { 2 } 'm68k',
  50. { 3 } 'alpha',
  51. { 4 } 'powerpc',
  52. { 5 } 'sparc',
  53. { 6 } 'vis',
  54. { 7 } 'ia64',
  55. { 8 } 'x86_64',
  56. { 9 } 'mips',
  57. { 10 } 'arm',
  58. { 11 } 'powerpc64',
  59. { 12 } 'avr',
  60. { 13 } 'mipsel'
  61. );
  62. { List of all supported system-cpu couples }
  63. const
  64. Targets : array[tsystem] of string[18]=(
  65. { 0 } 'none',
  66. { 1 } 'GO32V1 (obsolete)',
  67. { 2 } 'GO32V2',
  68. { 3 } 'Linux-i386',
  69. { 4 } 'OS/2',
  70. { 5 } 'Win32',
  71. { 6 } 'FreeBSD-i386',
  72. { 7 } 'Amiga',
  73. { 8 } 'Atari',
  74. { 9 } 'MacOS-m68k',
  75. { 10 } 'Linux-m68k',
  76. { 11 } 'PalmOS-m68k',
  77. { 12 } 'Linux-alpha',
  78. { 13 } 'Linux-ppc',
  79. { 14 } 'MacOS-ppc',
  80. { 15 } 'Solaris-i386',
  81. { 16 } 'BeOS-i386',
  82. { 17 } 'NetBSD-i386',
  83. { 18 } 'NetBSD-m68k',
  84. { 19 } 'Netware-i386-clib',
  85. { 20 } 'Qnx-i386',
  86. { 21 } 'WDOSX-i386',
  87. { 22 } 'Solaris-sparc',
  88. { 23 } 'Linux-sparc',
  89. { 24 } 'OpenBSD-i386',
  90. { 25 } 'OpenBSD-m68k',
  91. { 26 } 'Linux-x86-64',
  92. { 27 } 'MacOSX-ppc',
  93. { 28 } 'OS/2 via EMX',
  94. { 29 } 'NetBSD-powerpc',
  95. { 30 } 'OpenBSD-powerpc',
  96. { 31 } 'Linux-arm',
  97. { 32 } 'Watcom-i386',
  98. { 33 } 'MorphOS-powerpc',
  99. { 34 } 'FreeBSD-x86-64',
  100. { 35 } 'Netware-i386-libc',
  101. { 36 } 'Amiga-PowerPC',
  102. { 37 } 'Win64-x64',
  103. { 38 } 'WinCE-ARM',
  104. { 39 } 'Win64-iA64',
  105. { 40 } 'WinCE-i386',
  106. { 41 } 'Linux-x64',
  107. { 42 } 'GBA-arm',
  108. { 43 } 'Linux-powerpc64',
  109. { 44 } 'Darwin-i386',
  110. { 45 } 'PalmOS-arm',
  111. { 46 } 'MacOSX-powerpc64',
  112. { 47 } 'NDS-arm',
  113. { 48 } 'Embedded-i386',
  114. { 49 } 'Embedded-m68k',
  115. { 50 } 'Embedded-alpha',
  116. { 51 } 'Embedded-powerpc',
  117. { 52 } 'Embedded-sparc',
  118. { 53 } 'Embedded-vm',
  119. { 54 } 'Embedded-iA64',
  120. { 55 } 'Embedded-x64',
  121. { 56 } 'Embedded-mips',
  122. { 57 } 'Embedded-arm',
  123. { 58 } 'Embedded-powerpc64',
  124. { 59 } 'Symbian-i386',
  125. { 60 } 'Symbian-arm',
  126. { 61 } 'MacOSX-x64',
  127. { 62 } 'Embedded-avr',
  128. { 63 } 'Haiku-i386',
  129. { 64 } 'Darwin-ARM',
  130. { 65 } 'Solaris-x86-64',
  131. { 66 } 'Linux-MIPS',
  132. { 67 } 'Linux-MIPSel',
  133. { 68 } 'NativeNT-i386',
  134. { 69 } 'iPhoneSim-i386',
  135. { 70 } 'Wii-powerpc'
  136. );
  137. type
  138. tspecialgenerictoken = (ST_LOADSETTINGS,ST_LINE,ST_COLUMN,ST_FILEINDEX);
  139. var
  140. ppufile : tppufile;
  141. ppuversion : dword;
  142. space : string;
  143. verbose : longint;
  144. derefdata : pbyte;
  145. derefdatalen : longint;
  146. {****************************************************************************
  147. Helper Routines
  148. ****************************************************************************}
  149. const has_errors : boolean = false;
  150. Procedure Error(const S : string);
  151. Begin
  152. Writeln(S);
  153. has_errors:=true;
  154. End;
  155. function Unknown(const st : string; val :longint) : string;
  156. Begin
  157. Unknown:='<!! Unknown'+st+' value '+tostr(val)+'>';
  158. has_errors:=true;
  159. end;
  160. function ToStr(w:longint):String;
  161. begin
  162. Str(w,ToStr);
  163. end;
  164. Function Target2Str(w:longint):string;
  165. begin
  166. if w<=ord(high(tsystem)) then
  167. Target2Str:=Targets[tsystem(w)]
  168. else
  169. Target2Str:=Unknown('target',w);
  170. end;
  171. Function Cpu2Str(w:longint):string;
  172. begin
  173. if w<=ord(high(tsystemcpu)) then
  174. Cpu2Str:=CpuTxt[tsystemcpu(w)]
  175. else
  176. Cpu2Str:=Unknown('cpu',w);
  177. end;
  178. Function Varspez2Str(w:longint):string;
  179. const
  180. { in symconst unit
  181. tvarspez = (vs_value,vs_const,vs_var,vs_out,vs_constref); }
  182. varspezstr : array[tvarspez] of string[6]=('Value','Const','Var','Out','Hidden');
  183. begin
  184. if w<=ord(high(varspezstr)) then
  185. Varspez2Str:=varspezstr[tvarspez(w)]
  186. else
  187. Varspez2Str:=Unknown('varspez',w);
  188. end;
  189. Function VarRegable2Str(w:longint):string;
  190. { tvarregable type is defined in symconst unit }
  191. const
  192. varregableStr : array[tvarregable] of string[6]=('None','IntReg','FPUReg','MMReg','Addr');
  193. begin
  194. if w<=ord(high(varregablestr)) then
  195. Varregable2Str:=varregablestr[tvarregable(w)]
  196. else
  197. Varregable2Str:=Unknown('regable',w);
  198. end;
  199. Function Visibility2Str(w:longint):string;
  200. const
  201. { tvisibility type is defined in symconst unit }
  202. visibilityName : array[tvisibility] of string[16] = (
  203. 'hidden','strict private','private','strict protected','protected',
  204. 'public','published'
  205. );
  206. begin
  207. if w<=ord(high(visibilityName)) then
  208. result:=visibilityName[tvisibility(w)]
  209. else
  210. result:=Unknown('visibility',w);
  211. end;
  212. function PPUFlags2Str(flags:longint):string;
  213. type
  214. tflagopt=record
  215. mask : longint;
  216. str : string[30];
  217. end;
  218. const
  219. flagopts=23;
  220. flagopt : array[1..flagopts] of tflagopt=(
  221. (mask: $1 ;str:'init'),
  222. (mask: $2 ;str:'final'),
  223. (mask: $4 ;str:'big_endian'),
  224. (mask: $8 ;str:'dbx'),
  225. // (mask: $10 ;str:'browser'),
  226. (mask: $20 ;str:'in_library'),
  227. (mask: $40 ;str:'smart_linked'),
  228. (mask: $80 ;str:'static_linked'),
  229. (mask: $100 ;str:'shared_linked'),
  230. // (mask: $200 ;str:'local_browser'),
  231. (mask: $400 ;str:'no_link'),
  232. (mask: $800 ;str:'has_resources'),
  233. (mask: $1000 ;str:'little_endian'),
  234. (mask: $2000 ;str:'release'),
  235. (mask: $4000 ;str:'local_threadvars'),
  236. (mask: $8000 ;str:'fpu_emulation_on'),
  237. (mask: $210000 ;str:'has_debug_info'),
  238. (mask: $10000 ;str:'stabs_debug_info'),
  239. (mask: $200000 ;str:'dwarf_debug_info'),
  240. (mask: $20000 ;str:'local_symtable'),
  241. (mask: $40000 ;str:'uses_variants'),
  242. (mask: $80000 ;str:'has_resourcefiles'),
  243. (mask: $100000 ;str:'has_exports'),
  244. (mask: $400000 ;str:'has_wideinits'),
  245. (mask: $800000 ;str:'has_classinits')
  246. );
  247. var
  248. i,ntflags : longint;
  249. first : boolean;
  250. s : string;
  251. begin
  252. s:='';
  253. if flags<>0 then
  254. begin
  255. ntflags:=flags;
  256. first:=true;
  257. for i:=1to flagopts do
  258. if (flags and flagopt[i].mask)<>0 then
  259. begin
  260. if first then
  261. first:=false
  262. else
  263. s:=s+', ';
  264. s:=s+flagopt[i].str;
  265. ntflags:=ntflags and (not flagopt[i].mask);
  266. end;
  267. end
  268. else
  269. s:='none';
  270. if ntflags<>0 then
  271. begin
  272. s:=s+' unknown '+hexstr(ntflags,8);
  273. has_errors:=true;
  274. end;
  275. PPUFlags2Str:=s;
  276. end;
  277. Function L0(l:longint):string;
  278. {
  279. return the string of value l, if l<10 then insert a zero, so
  280. the string is always at least 2 chars '01','02',etc
  281. }
  282. var
  283. s : string;
  284. begin
  285. Str(l,s);
  286. if l<10 then
  287. s:='0'+s;
  288. L0:=s;
  289. end;
  290. function filetimestring( t : longint) : string;
  291. {
  292. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  293. }
  294. var
  295. DT : TDateTime;
  296. hsec : word;
  297. Year,Month,Day: Word;
  298. hour,min,sec : word;
  299. begin
  300. if t=-1 then
  301. begin
  302. Result := 'Not Found';
  303. exit;
  304. end;
  305. DT := FileDateToDateTime(t);
  306. DecodeTime(DT,hour,min,sec,hsec);
  307. DecodeDate(DT,year,month,day);
  308. Result := L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  309. end;
  310. {****************************************************************************
  311. Read Routines
  312. ****************************************************************************}
  313. procedure readsymtableoptions(const s: string);
  314. type
  315. tsymtblopt=record
  316. mask : tsymtableoption;
  317. str : string[30];
  318. end;
  319. const
  320. symtblopts=ord(high(tsymtableoption)) + 1;
  321. symtblopt : array[1..symtblopts] of tsymtblopt=(
  322. (mask:sto_has_helper; str:'Has helper')
  323. );
  324. var
  325. options : tsymtableoptions;
  326. first : boolean;
  327. i : integer;
  328. begin
  329. if ppufile.readentry<>ibsymtableoptions then
  330. exit;
  331. ppufile.getsmallset(options);
  332. if space<>'' then
  333. writeln(space,'------ ',s,' ------');
  334. write(space,'Symtable options: ');
  335. if options<>[] then
  336. begin
  337. first:=true;
  338. for i:=1 to symtblopts do
  339. if (symtblopt[i].mask in options) then
  340. begin
  341. if first then
  342. first:=false
  343. else
  344. write(', ');
  345. write(symtblopt[i].str);
  346. end;
  347. end
  348. else
  349. write('none');
  350. writeln;
  351. end;
  352. Procedure ReadLinkContainer(const prefix:string);
  353. {
  354. Read a serie of strings and write to the screen starting every line
  355. with prefix
  356. }
  357. function maskstr(m:longint):string;
  358. { link options are in globtype unit
  359. const
  360. link_none = $0;
  361. link_always = $1;
  362. link_static = $2;
  363. link_smart = $4;
  364. link_shared = $8; }
  365. var
  366. s : string;
  367. begin
  368. s:='';
  369. if (m and link_always)<>0 then
  370. s:=s+'always ';
  371. if (m and link_static)<>0 then
  372. s:=s+'static ';
  373. if (m and link_smart)<>0 then
  374. s:=s+'smart ';
  375. if (m and link_shared)<>0 then
  376. s:=s+'shared ';
  377. maskstr:=s;
  378. end;
  379. var
  380. s : string;
  381. m : longint;
  382. begin
  383. while not ppufile.endofentry do
  384. begin
  385. s:=ppufile.getstring;
  386. m:=ppufile.getlongint;
  387. WriteLn(prefix,s,' (',maskstr(m),')');
  388. end;
  389. end;
  390. Procedure ReadContainer(const prefix:string);
  391. {
  392. Read a serie of strings and write to the screen starting every line
  393. with prefix
  394. }
  395. begin
  396. while not ppufile.endofentry do
  397. WriteLn(prefix,ppufile.getstring);
  398. end;
  399. procedure ReadLoadUnit;
  400. var
  401. ucrc,uintfcrc, indcrc : cardinal;
  402. begin
  403. while not ppufile.EndOfEntry do
  404. begin
  405. write('Uses unit: ',ppufile.getstring);
  406. ucrc:=cardinal(ppufile.getlongint);
  407. uintfcrc:=cardinal(ppufile.getlongint);
  408. indcrc:=cardinal(ppufile.getlongint);
  409. writeln(' (Crc: ',hexstr(ucrc,8),', IntfcCrc: ',hexstr(uintfcrc,8),', IndCrc: ',hexstr(indcrc,8),')');
  410. end;
  411. end;
  412. Procedure ReadDerefmap;
  413. var
  414. i,mapsize : longint;
  415. begin
  416. mapsize:=ppufile.getlongint;
  417. writeln('DerefMapsize: ',mapsize);
  418. for i:=0 to mapsize-1 do
  419. writeln('DerefMap[',i,'] = ',ppufile.getstring);
  420. end;
  421. Procedure ReadImportSymbols;
  422. var
  423. extlibname : string;
  424. j,
  425. extsymcnt : longint;
  426. extsymname : string;
  427. extsymmangledname : string;
  428. extsymordnr : longint;
  429. extsymisvar : boolean;
  430. begin
  431. while not ppufile.endofentry do
  432. begin
  433. extlibname:=ppufile.getstring;
  434. extsymcnt:=ppufile.getlongint;
  435. writeln('External Library: ',extlibname,' (',extsymcnt,' imports)');
  436. for j:=0 to extsymcnt-1 do
  437. begin
  438. extsymname:=ppufile.getstring;
  439. if ppuversion>130 then
  440. extsymmangledname:=ppufile.getstring
  441. else
  442. extsymmangledname:=extsymname;
  443. extsymordnr:=ppufile.getlongint;
  444. extsymisvar:=ppufile.getbyte<>0;
  445. writeln(' ',extsymname,' as ',extsymmangledname,
  446. '(OrdNr: ',extsymordnr,' IsVar: ',extsymisvar,')');
  447. end;
  448. end;
  449. end;
  450. Procedure ReadDerefdata;
  451. begin
  452. derefdatalen:=ppufile.entrysize;
  453. if derefdatalen=0 then
  454. begin
  455. writeln('!! Error: derefdatalen=0');
  456. exit;
  457. end;
  458. Writeln('Derefdata length: ',derefdatalen);
  459. derefdata:=allocmem(derefdatalen);
  460. ppufile.getdata(derefdata^,derefdatalen);
  461. end;
  462. Procedure ReadWpoFileInfo;
  463. begin
  464. Writeln('Compiled with input whole-program optimisation from ',ppufile.getstring,' ',filetimestring(ppufile.getlongint));
  465. end;
  466. Procedure ReadAsmSymbols;
  467. type
  468. { Copied from aasmbase.pas }
  469. TAsmsymbind=(
  470. AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL,AB_WEAK_EXTERNAL,
  471. { global in the current program/library, but not visible outside it }
  472. AB_PRIVATE_EXTERN,AB_LAZY,AB_IMPORT);
  473. TAsmsymtype=(
  474. AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL,
  475. {
  476. the address of this code label is taken somewhere in the code
  477. so it must be taken care of it when creating pic
  478. }
  479. AT_ADDR
  480. );
  481. var
  482. s,
  483. bindstr,
  484. typestr : string;
  485. i : longint;
  486. begin
  487. writeln(space,'Number of AsmSymbols: ',ppufile.getlongint);
  488. i:=0;
  489. while (not ppufile.endofentry) and (not ppufile.error) do
  490. begin
  491. s:=ppufile.getstring;
  492. case tasmsymbind(ppufile.getbyte) of
  493. AB_EXTERNAL :
  494. bindstr:='External';
  495. AB_COMMON :
  496. bindstr:='Common';
  497. AB_LOCAL :
  498. bindstr:='Local';
  499. AB_GLOBAL :
  500. bindstr:='Global';
  501. AB_WEAK_EXTERNAL :
  502. bindstr:='Weak external';
  503. AB_PRIVATE_EXTERN :
  504. bindstr:='Private extern';
  505. AB_LAZY :
  506. bindstr:='Lazy';
  507. AB_IMPORT :
  508. bindstr:='Import';
  509. else
  510. bindstr:='<Error !!>'
  511. end;
  512. case tasmsymtype(ppufile.getbyte) of
  513. AT_FUNCTION :
  514. typestr:='Function';
  515. AT_DATA :
  516. typestr:='Data';
  517. AT_SECTION :
  518. typestr:='Section';
  519. AT_LABEL :
  520. typestr:='Label';
  521. AT_ADDR :
  522. typestr:='Label (with address taken)';
  523. else
  524. typestr:='<Error !!>'
  525. end;
  526. Writeln(space,' ',i,' : ',s,' [',bindstr,',',typestr,']');
  527. inc(i);
  528. end;
  529. end;
  530. function getexprint:Tconstexprint;
  531. begin
  532. getexprint.overflow:=false;
  533. getexprint.signed:=boolean(ppufile.getbyte);
  534. getexprint.svalue:=ppufile.getint64;
  535. end;
  536. Procedure ReadPosInfo;
  537. var
  538. info : byte;
  539. fileindex,line,column : longint;
  540. begin
  541. with ppufile do
  542. begin
  543. {
  544. info byte layout in bits:
  545. 0-1 - amount of bytes for fileindex
  546. 2-3 - amount of bytes for line
  547. 4-5 - amount of bytes for column
  548. }
  549. info:=getbyte;
  550. case (info and $03) of
  551. 0 : fileindex:=getbyte;
  552. 1 : fileindex:=getword;
  553. 2 : fileindex:=(getbyte shl 16) or getword;
  554. 3 : fileindex:=getlongint;
  555. end;
  556. case ((info shr 2) and $03) of
  557. 0 : line:=getbyte;
  558. 1 : line:=getword;
  559. 2 : line:=(getbyte shl 16) or getword;
  560. 3 : line:=getlongint;
  561. end;
  562. case ((info shr 4) and $03) of
  563. 0 : column:=getbyte;
  564. 1 : column:=getword;
  565. 2 : column:=(getbyte shl 16) or getword;
  566. 3 : column:=getlongint;
  567. end;
  568. Writeln(fileindex,' (',line,',',column,')');
  569. end;
  570. end;
  571. procedure readderef(const derefspace: string);
  572. type
  573. tdereftype = (deref_nil,
  574. deref_unit,
  575. deref_symid,
  576. deref_defid
  577. );
  578. var
  579. b : tdereftype;
  580. first : boolean;
  581. idx : longint;
  582. i,n : byte;
  583. pdata : pbyte;
  584. begin
  585. if not assigned(derefdata) then
  586. exit;
  587. first:=true;
  588. idx:=ppufile.getlongint;
  589. if (idx>derefdatalen) then
  590. begin
  591. writeln('!! Error: Deref idx ',idx,' > ',derefdatalen);
  592. exit;
  593. end;
  594. write(derefspace,'(',idx,') ');
  595. pdata:=@derefdata[idx];
  596. i:=0;
  597. n:=pdata[i];
  598. inc(i);
  599. if n<1 then
  600. begin
  601. writeln('!! Error: Deref len < 1');
  602. exit;
  603. end;
  604. while (i<=n) do
  605. begin
  606. if not first then
  607. write(', ')
  608. else
  609. first:=false;
  610. b:=tdereftype(pdata[i]);
  611. inc(i);
  612. case b of
  613. deref_nil :
  614. write('Nil');
  615. deref_symid :
  616. begin
  617. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  618. inc(i,4);
  619. write('SymId ',idx);
  620. end;
  621. deref_defid :
  622. begin
  623. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  624. inc(i,4);
  625. write('DefId ',idx);
  626. end;
  627. deref_unit :
  628. begin
  629. idx:=pdata[i] shl 8 or pdata[i+1];
  630. inc(i,2);
  631. write('Unit ',idx);
  632. end;
  633. else
  634. begin
  635. writeln('!! unsupported dereftyp: ',ord(b));
  636. break;
  637. end;
  638. end;
  639. end;
  640. writeln;
  641. end;
  642. procedure readpropaccesslist(const s:string);
  643. { type tsltype is in symconst unit }
  644. const
  645. slstr : array[tsltype] of string[12] = (
  646. '',
  647. 'load',
  648. 'call',
  649. 'subscript',
  650. 'vec',
  651. 'typeconv',
  652. 'absolutetype'
  653. );
  654. var
  655. sl : tsltype;
  656. begin
  657. readderef('');
  658. repeat
  659. sl:=tsltype(ppufile.getbyte);
  660. if sl=sl_none then
  661. break;
  662. write(s,'(',slstr[sl],') ');
  663. case sl of
  664. sl_call,
  665. sl_load,
  666. sl_subscript :
  667. readderef('');
  668. sl_absolutetype,
  669. sl_typeconv :
  670. readderef('');
  671. sl_vec :
  672. begin
  673. writeln(ppufile.getlongint);
  674. readderef('');
  675. end;
  676. end;
  677. until false;
  678. end;
  679. procedure readsymoptions(space : string);
  680. type
  681. tsymopt=record
  682. mask : tsymoption;
  683. str : string[30];
  684. end;
  685. const
  686. symopts=ord(high(tsymoption)) - ord(low(tsymoption));
  687. { sp_none = 0 corresponds to nothing }
  688. symopt : array[1..symopts] of tsymopt=(
  689. (mask:sp_static; str:'Static'),
  690. (mask:sp_hint_deprecated; str:'Hint Deprecated'),
  691. (mask:sp_hint_platform; str:'Hint Platform'),
  692. (mask:sp_hint_library; str:'Hint Library'),
  693. (mask:sp_hint_unimplemented; str:'Hint Unimplemented'),
  694. (mask:sp_hint_experimental; str:'Hint Experimental'),
  695. (mask:sp_has_overloaded; str:'Has overloaded'),
  696. (mask:sp_internal; str:'Internal'),
  697. (mask:sp_implicitrename; str:'Implicit Rename'),
  698. (mask:sp_generic_para; str:'Generic Parameter'),
  699. (mask:sp_has_deprecated_msg; str:'Has Deprecated Message')
  700. );
  701. var
  702. symoptions : tsymoptions;
  703. i : longint;
  704. first : boolean;
  705. begin
  706. ppufile.getsmallset(symoptions);
  707. if symoptions<>[] then
  708. begin
  709. first:=true;
  710. for i:=1to symopts do
  711. if (symopt[i].mask in symoptions) then
  712. begin
  713. if first then
  714. first:=false
  715. else
  716. write(', ');
  717. write(symopt[i].str);
  718. end;
  719. end;
  720. writeln;
  721. if sp_has_deprecated_msg in symoptions then
  722. writeln(space,'Deprecated : ', ppufile.getstring);
  723. end;
  724. procedure readcommonsym(const s:string);
  725. begin
  726. writeln(space,'** Symbol Id ',ppufile.getlongint,' **');
  727. writeln(space,s,ppufile.getstring);
  728. write (space,' File Pos : ');
  729. readposinfo;
  730. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  731. write (space,' SymOptions : ');
  732. readsymoptions(space+' ');
  733. end;
  734. var
  735. { needed during tobjectdef parsing... }
  736. current_defoptions : tdefoptions;
  737. current_objectoptions : tobjectoptions;
  738. procedure readcommondef(const s:string; out defoptions: tdefoptions);
  739. type
  740. tdefopt=record
  741. mask : tdefoption;
  742. str : string[30];
  743. end;
  744. tdefstateinfo=record
  745. mask : tdefstate;
  746. str : string[30];
  747. end;
  748. ptoken=^ttoken;
  749. const
  750. defopt : array[1..ord(high(tdefoption))] of tdefopt=(
  751. (mask:df_unique; str:'Unique Type'),
  752. (mask:df_generic; str:'Generic'),
  753. (mask:df_specialization; str:'Specialization'),
  754. (mask:df_copied_def; str:'Copied Typedef')
  755. );
  756. defstate : array[1..ord(high(tdefstate))] of tdefstateinfo=(
  757. (mask:ds_vmt_written; str:'VMT Written'),
  758. (mask:ds_rtti_table_used; str:'RTTITable Used'),
  759. (mask:ds_init_table_used; str:'InitTable Used'),
  760. (mask:ds_rtti_table_written; str:'RTTITable Written'),
  761. (mask:ds_init_table_written; str:'InitTable Written'),
  762. (mask:ds_dwarf_dbg_info_used; str:'Dwarf DbgInfo Used'),
  763. (mask:ds_dwarf_dbg_info_written;str:'Dwarf DbgInfo Written')
  764. );
  765. var
  766. defstates : tdefstates;
  767. i : longint;
  768. first : boolean;
  769. tokenbufsize : longint;
  770. tokenbuf : pbyte;
  771. idtoken,
  772. token : ttoken;
  773. len : sizeint;
  774. wstring : widestring;
  775. astring : ansistring;
  776. function readtoken: ttoken;
  777. var
  778. b,b2 : byte;
  779. begin
  780. b:=tokenbuf[i];
  781. inc(i);
  782. if (b and $80)<>0 then
  783. begin
  784. b2:=tokenbuf[i];
  785. inc(i);
  786. result:=ttoken(((b and $7f) shl 8) or b2);
  787. end
  788. else
  789. result:=ttoken(b);
  790. end;
  791. begin
  792. writeln(space,'** Definition Id ',ppufile.getlongint,' **');
  793. writeln(space,s);
  794. write (space,' Type symbol : ');
  795. readderef('');
  796. write (space,' DefOptions : ');
  797. ppufile.getsmallset(defoptions);
  798. if defoptions<>[] then
  799. begin
  800. first:=true;
  801. for i:=1to high(defopt) do
  802. if (defopt[i].mask in defoptions) then
  803. begin
  804. if first then
  805. first:=false
  806. else
  807. write(', ');
  808. write(defopt[i].str);
  809. end;
  810. end;
  811. writeln;
  812. write (space,' DefStates : ');
  813. ppufile.getsmallset(defstates);
  814. if defstates<>[] then
  815. begin
  816. first:=true;
  817. for i:=1 to high(defstate) do
  818. if (defstate[i].mask in defstates) then
  819. begin
  820. if first then
  821. first:=false
  822. else
  823. write(', ');
  824. write(defstate[i].str);
  825. end;
  826. end;
  827. writeln;
  828. if df_generic in defoptions then
  829. begin
  830. tokenbufsize:=ppufile.getlongint;
  831. writeln(space,' Tokenbuffer size : ',tokenbufsize);
  832. tokenbuf:=allocmem(tokenbufsize);
  833. ppufile.getdata(tokenbuf^,tokenbufsize);
  834. i:=0;
  835. write(space,' Tokens: ');
  836. while i<tokenbufsize do
  837. begin
  838. token:=readtoken;
  839. if token<>_GENERICSPECIALTOKEN then
  840. begin
  841. write(arraytokeninfo[token].str);
  842. idtoken:=readtoken;
  843. end;
  844. case token of
  845. _CWCHAR,
  846. _CWSTRING :
  847. begin
  848. len:=psizeint(@tokenbuf[i])^;
  849. inc(i,sizeof(sizeint));
  850. setlength(wstring,len);
  851. move(tokenbuf[i],wstring[1],len*2);
  852. write(' ',wstring);
  853. inc(i,len*2);
  854. end;
  855. _CSTRING:
  856. begin
  857. len:=psizeint(@tokenbuf[i])^;
  858. inc(i,sizeof(sizeint));
  859. setlength(astring,len);
  860. move(tokenbuf[i],astring[1],len);
  861. write(' ',astring);
  862. inc(i,len);
  863. end;
  864. _CCHAR,
  865. _INTCONST,
  866. _REALNUMBER :
  867. begin
  868. write(' ',pshortstring(@tokenbuf[i])^);
  869. inc(i,tokenbuf[i]+1);
  870. end;
  871. _ID :
  872. begin
  873. write(' ',pshortstring(@tokenbuf[i])^);
  874. inc(i,tokenbuf[i]+1);
  875. {
  876. replaytokenbuf.read(orgpattern[0],1);
  877. replaytokenbuf.read(orgpattern[1],length(orgpattern));
  878. pattern:=upper(orgpattern);
  879. }
  880. end;
  881. _GENERICSPECIALTOKEN:
  882. begin
  883. if (tokenbuf[i] and $80)<>0 then
  884. begin
  885. write('Col: ',tokenbuf[i] and $7f);
  886. inc(i);
  887. end
  888. else
  889. case tspecialgenerictoken(tokenbuf[i]) of
  890. ST_LOADSETTINGS:
  891. begin
  892. inc(i);
  893. write('Settings');
  894. inc(i,sizeof(tsettings));
  895. end;
  896. ST_LINE:
  897. begin
  898. inc(i);
  899. write('Line: ',pdword(@tokenbuf[i])^);
  900. inc(i,4);
  901. end;
  902. ST_COLUMN:
  903. begin
  904. inc(i);
  905. write('Col: ',pword(@tokenbuf[i])^);
  906. inc(i,2);
  907. end;
  908. ST_FILEINDEX:
  909. begin
  910. inc(i);
  911. write('File: ',pword(@tokenbuf[i])^);
  912. inc(i,2);
  913. end;
  914. end;
  915. {
  916. replaytokenbuf.read(specialtoken,1);
  917. case specialtoken of
  918. ST_LOADSETTINGS:
  919. begin
  920. replaytokenbuf.read(current_settings,sizeof(current_settings));
  921. end
  922. else
  923. internalerror(2006103010);
  924. end;
  925. continue;
  926. }
  927. end;
  928. end;
  929. if i<tokenbufsize then
  930. write(',');
  931. end;
  932. writeln;
  933. freemem(tokenbuf);
  934. end;
  935. if df_specialization in defoptions then
  936. begin
  937. write (space,' Orig. GenericDef : ');
  938. readderef('');
  939. end;
  940. current_defoptions:=defoptions;
  941. end;
  942. { Read abstract procdef and return if inline procdef }
  943. { type tproccalloption is in globtype unit }
  944. { type tproctypeoption is in globtype unit }
  945. { type tprocoption is in globtype unit }
  946. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions);
  947. type
  948. tproccallopt=record
  949. mask : tproccalloption;
  950. str : string[30];
  951. end;
  952. tproctypeopt=record
  953. mask : tproctypeoption;
  954. str : string[30];
  955. end;
  956. tprocopt=record
  957. mask : tprocoption;
  958. str : string[30];
  959. end;
  960. const
  961. {proccalloptionStr is also in globtype unit }
  962. proctypeopt : array[1..ord(high(tproctypeoption))] of tproctypeopt=(
  963. (mask:potype_proginit; str:'ProgInit'),
  964. (mask:potype_unitinit; str:'UnitInit'),
  965. (mask:potype_unitfinalize; str:'UnitFinalize'),
  966. (mask:potype_constructor; str:'Constructor'),
  967. (mask:potype_destructor; str:'Destructor'),
  968. (mask:potype_operator; str:'Operator'),
  969. (mask:potype_procedure; str:'Procedure'),
  970. (mask:potype_function; str:'Function'),
  971. (mask:potype_class_constructor; str:'Class Constructor'),
  972. (mask:potype_class_destructor; str:'Class Destructor'),
  973. { Dispinterface property accessors }
  974. (mask:potype_propgetter; str:'Property Getter'),
  975. (mask:potype_propsetter; str:'Property Setter')
  976. );
  977. procopt : array[1..ord(high(tprocoption))] of tprocopt=(
  978. (mask:po_classmethod; str:'ClassMethod'),
  979. (mask:po_virtualmethod; str:'VirtualMethod'),
  980. (mask:po_abstractmethod; str:'AbstractMethod'),
  981. (mask:po_finalmethod; str:'FinalMethod'),
  982. (mask:po_staticmethod; str:'StaticMethod'),
  983. (mask:po_overridingmethod;str:'OverridingMethod'),
  984. (mask:po_methodpointer; str:'MethodPointer'),
  985. (mask:po_interrupt; str:'Interrupt'),
  986. (mask:po_iocheck; str:'IOCheck'),
  987. (mask:po_assembler; str:'Assembler'),
  988. (mask:po_msgstr; str:'MsgStr'),
  989. (mask:po_msgint; str:'MsgInt'),
  990. (mask:po_exports; str:'Exports'),
  991. (mask:po_external; str:'External'),
  992. (mask:po_overload; str:'Overload'),
  993. (mask:po_varargs; str:'VarArgs'),
  994. (mask:po_internconst; str:'InternConst'),
  995. (mask:po_addressonly; str:'AddressOnly'),
  996. (mask:po_public; str:'Public'),
  997. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  998. (mask:po_reintroduce; str:'ReIntroduce'),
  999. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  1000. (mask:po_nostackframe; str:'NoStackFrame'),
  1001. (mask:po_has_mangledname; str:'HasMangledName'),
  1002. (mask:po_has_public_name; str:'HasPublicName'),
  1003. (mask:po_forward; str:'Forward'),
  1004. (mask:po_global; str:'Global'),
  1005. (mask:po_has_inlininginfo;str:'HasInliningInfo'),
  1006. (mask:po_syscall_legacy; str:'SyscallLegacy'),
  1007. (mask:po_syscall_sysv; str:'SyscallSysV'),
  1008. (mask:po_syscall_basesysv;str:'SyscallBaseSysV'),
  1009. (mask:po_syscall_sysvbase;str:'SyscallSysVBase'),
  1010. (mask:po_syscall_r12base; str:'SyscallR12Base'),
  1011. (mask:po_inline; str:'Inline'),
  1012. (mask:po_compilerproc; str:'CompilerProc'),
  1013. (mask:po_has_importdll; str:'HasImportDLL'),
  1014. (mask:po_has_importname; str:'HasImportName'),
  1015. (mask:po_kylixlocal; str:'KylixLocal'),
  1016. (mask:po_dispid; str:'DispId'),
  1017. (mask:po_weakexternal; str:'WeakExternal'),
  1018. (mask:po_objc; str:'ObjC'),
  1019. (mask:po_enumerator_movenext; str:'EnumeratorMoveNext'),
  1020. (mask:po_optional; str: 'Optional'),
  1021. (mask:po_delphi_nested_cc;str: 'Delphi-style nested frameptr')
  1022. );
  1023. var
  1024. proctypeoption : tproctypeoption;
  1025. i : longint;
  1026. first : boolean;
  1027. tempbuf : array[0..255] of byte;
  1028. begin
  1029. write(space,' Return type : ');
  1030. readderef('');
  1031. writeln(space,' Fpu used : ',ppufile.getbyte);
  1032. proctypeoption:=tproctypeoption(ppufile.getbyte);
  1033. write(space,' TypeOption : ');
  1034. first:=true;
  1035. for i:=1 to high(proctypeopt) do
  1036. if (proctypeopt[i].mask=proctypeoption) then
  1037. begin
  1038. if first then
  1039. first:=false
  1040. else
  1041. write(', ');
  1042. write(proctypeopt[i].str);
  1043. end;
  1044. writeln;
  1045. proccalloption:=tproccalloption(ppufile.getbyte);
  1046. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  1047. ppufile.getnormalset(procoptions);
  1048. if procoptions<>[] then
  1049. begin
  1050. write(space,' Options : ');
  1051. first:=true;
  1052. for i:=1 to high(procopt) do
  1053. if (procopt[i].mask in procoptions) then
  1054. begin
  1055. if first then
  1056. first:=false
  1057. else
  1058. write(', ');
  1059. write(procopt[i].str);
  1060. end;
  1061. writeln;
  1062. end;
  1063. if (po_explicitparaloc in procoptions) then
  1064. begin
  1065. i:=ppufile.getbyte;
  1066. ppufile.getdata(tempbuf,i);
  1067. end;
  1068. end;
  1069. { type tvaroption is in unit symconst }
  1070. { register variable }
  1071. { type tvarregable is in unit symconst }
  1072. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions);
  1073. type
  1074. tvaropt=record
  1075. mask : tvaroption;
  1076. str : string[30];
  1077. end;
  1078. const
  1079. varopt : array[1..ord(high(tvaroption))] of tvaropt=(
  1080. (mask:vo_is_external; str:'External'),
  1081. (mask:vo_is_dll_var; str:'DLLVar'),
  1082. (mask:vo_is_thread_var; str:'ThreadVar'),
  1083. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  1084. (mask:vo_is_const; str:'Constant'),
  1085. (mask:vo_is_public; str:'Public'),
  1086. (mask:vo_is_high_para; str:'HighValue'),
  1087. (mask:vo_is_funcret; str:'Funcret'),
  1088. (mask:vo_is_self; str:'Self'),
  1089. (mask:vo_is_vmt; str:'VMT'),
  1090. (mask:vo_is_result; str:'Result'),
  1091. (mask:vo_is_parentfp; str:'ParentFP'),
  1092. (mask:vo_is_loop_counter; str:'LoopCounter'),
  1093. (mask:vo_is_hidden_para; str:'Hidden'),
  1094. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  1095. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  1096. (mask:vo_has_mangledname; str:'HasMangledName'),
  1097. (mask:vo_is_typed_const; str:'TypedConst'),
  1098. (mask:vo_is_range_check; str:'RangeCheckSwitch'),
  1099. (mask:vo_is_overflow_check; str:'OverflowCheckSwitch'),
  1100. (mask:vo_is_typinfo_para; str:'TypeInfo'),
  1101. (mask:vo_is_msgsel;str:'MsgSel'),
  1102. (mask:vo_is_weak_external;str:'WeakExternal'),
  1103. (mask:vo_is_first_field;str:'IsFirstField'),
  1104. (mask:vo_volatile;str:'Volatile'),
  1105. (mask:vo_has_section;str:'HasSection')
  1106. );
  1107. var
  1108. i : longint;
  1109. first : boolean;
  1110. begin
  1111. readcommonsym(s);
  1112. writeln(space,' Spez : ',Varspez2Str(ppufile.getbyte));
  1113. writeln(space,' Regable : ',Varregable2Str(ppufile.getbyte));
  1114. writeln(space,' Addr Taken : ',(ppufile.getbyte<>0));
  1115. write (space,' Var Type : ');
  1116. readderef('');
  1117. ppufile.getsmallset(varoptions);
  1118. if varoptions<>[] then
  1119. begin
  1120. write(space,' Options : ');
  1121. first:=true;
  1122. for i:=1 to high(varopt) do
  1123. if (varopt[i].mask in varoptions) then
  1124. begin
  1125. if first then
  1126. first:=false
  1127. else
  1128. write(', ');
  1129. write(varopt[i].str);
  1130. if varopt[i].mask = vo_has_section then
  1131. writeln('Section name:',ppufile.getansistring);
  1132. end;
  1133. writeln;
  1134. end;
  1135. end;
  1136. procedure readobjectdefoptions;
  1137. type
  1138. tsymopt=record
  1139. mask : tobjectoption;
  1140. str : string[30];
  1141. end;
  1142. const
  1143. symopt : array[1..ord(high(tobjectoption))] of tsymopt=(
  1144. (mask:oo_is_forward; str:'IsForward'),
  1145. (mask:oo_is_abstract; str:'IsAbstract'),
  1146. (mask:oo_is_sealed; str:'IsSealed'),
  1147. (mask:oo_has_virtual; str:'HasVirtual'),
  1148. (mask:oo_has_private; str:'HasPrivate'),
  1149. (mask:oo_has_protected; str:'HasProtected'),
  1150. (mask:oo_has_strictprivate; str:'HasStrictPrivate'),
  1151. (mask:oo_has_strictprotected;str:'HasStrictProtected'),
  1152. (mask:oo_has_constructor; str:'HasConstructor'),
  1153. (mask:oo_has_destructor; str:'HasDestructor'),
  1154. (mask:oo_has_vmt; str:'HasVMT'),
  1155. (mask:oo_has_msgstr; str:'HasMsgStr'),
  1156. (mask:oo_has_msgint; str:'HasMsgInt'),
  1157. (mask:oo_can_have_published; str:'CanHavePublished'),
  1158. (mask:oo_has_default_property;str:'HasDefaultProperty'),
  1159. (mask:oo_has_valid_guid; str:'HasValidGUID'),
  1160. (mask:oo_has_enumerator_movenext; str:'HasEnumeratorMoveNext'),
  1161. (mask:oo_has_enumerator_current; str:'HasEnumeratorCurrent'),
  1162. (mask:oo_is_external; str:'External'),
  1163. (mask:oo_is_formal; str:'Formal'),
  1164. (mask:oo_is_classhelper; str:'Class Helper/Category'),
  1165. (mask:oo_has_class_constructor; str:'HasClassConstructor'),
  1166. (mask:oo_has_class_destructor; str:'HasClassDestructor')
  1167. );
  1168. var
  1169. i : longint;
  1170. first : boolean;
  1171. begin
  1172. ppufile.getsmallset(current_objectoptions);
  1173. if current_objectoptions<>[] then
  1174. begin
  1175. first:=true;
  1176. for i:=1 to high(symopt) do
  1177. if (symopt[i].mask in current_objectoptions) then
  1178. begin
  1179. if first then
  1180. first:=false
  1181. else
  1182. write(', ');
  1183. write(symopt[i].str);
  1184. end;
  1185. end;
  1186. writeln;
  1187. end;
  1188. procedure readarraydefoptions;
  1189. { type tarraydefoption is in unit symconst }
  1190. type
  1191. tsymopt=record
  1192. mask : tarraydefoption;
  1193. str : string[30];
  1194. end;
  1195. const
  1196. symopt : array[1..ord(high(tarraydefoption))] of tsymopt=(
  1197. (mask:ado_IsConvertedPointer;str:'ConvertedPointer'),
  1198. (mask:ado_IsDynamicArray; str:'IsDynamicArray'),
  1199. (mask:ado_IsVariant; str:'IsVariant'),
  1200. (mask:ado_IsConstructor; str:'IsConstructor'),
  1201. (mask:ado_IsArrayOfConst; str:'ArrayOfConst'),
  1202. (mask:ado_IsConstString; str:'ConstString'),
  1203. (mask:ado_IsBitPacked; str:'BitPacked')
  1204. );
  1205. var
  1206. symoptions : tarraydefoptions;
  1207. i : longint;
  1208. first : boolean;
  1209. begin
  1210. ppufile.getsmallset(symoptions);
  1211. if symoptions<>[] then
  1212. begin
  1213. first:=true;
  1214. for i:=1 to high(symopt) do
  1215. if (symopt[i].mask in symoptions) then
  1216. begin
  1217. if first then
  1218. first:=false
  1219. else
  1220. write(', ');
  1221. write(symopt[i].str);
  1222. end;
  1223. end;
  1224. writeln;
  1225. end;
  1226. procedure readnodetree;
  1227. var
  1228. l : longint;
  1229. p : pointer;
  1230. begin
  1231. with ppufile do
  1232. begin
  1233. if space<>'' then
  1234. Writeln(space,'------ nodetree ------');
  1235. if readentry=ibnodetree then
  1236. begin
  1237. l:=entrysize;
  1238. Writeln(space,'Tree size : ',l);
  1239. { Read data to prevent error that entry is not completly read }
  1240. getmem(p,l);
  1241. getdata(p^,l);
  1242. freemem(p);
  1243. end
  1244. else
  1245. begin
  1246. Writeln('!! ibnodetree not found');
  1247. end;
  1248. end;
  1249. end;
  1250. procedure ReadCreatedObjTypes;
  1251. var
  1252. i,j,
  1253. len,
  1254. bssize: longint;
  1255. bs: pbyte;
  1256. begin
  1257. if ppufile.readentry<>ibcreatedobjtypes then
  1258. begin
  1259. writeln('!! ibcreatedobjtypes entry not found');
  1260. ppufile.skipdata(ppufile.entrysize);
  1261. exit
  1262. end;
  1263. writeln;
  1264. writeln(space,'WPO info');
  1265. writeln(space,'--------');
  1266. len:=ppufile.getlongint;
  1267. writeln(space,'** Instantiated Object/Class types: ',len,' **');
  1268. space:=space+' ';
  1269. for i:=0 to len-1 do
  1270. readderef(space);
  1271. setlength(space,length(space)-2);
  1272. len:=ppufile.getlongint;
  1273. writeln(space,'** Instantiated ClassRef types: ',len,' **');
  1274. space:=space+' ';
  1275. for i:=0 to len-1 do
  1276. readderef(space);
  1277. setlength(space,length(space)-2);
  1278. len:=ppufile.getlongint;
  1279. writeln(space,'** Possibly instantiated ClassRef types : ',len,' **');
  1280. space:=space+' ';
  1281. for i:=0 to len-1 do
  1282. readderef(space);
  1283. setlength(space,length(space)-2);
  1284. len:=ppufile.getlongint;
  1285. writeln(space,'** Class types with called virtual methods info : ',len,' **');
  1286. space:=space+' ';
  1287. for i:=0 to len-1 do
  1288. begin
  1289. write(space,'Class def : ');
  1290. readderef('');
  1291. write(space+' ','Called vmtentries : ');
  1292. bssize:=ppufile.getlongint;
  1293. getmem(bs,bssize);
  1294. ppufile.readdata(bs^,bssize);
  1295. for j:=0 to bssize*8-1 do
  1296. if (((bs+j shr 3)^ shr (j and 7)) and 1) <> 0 then
  1297. write(j,', ');
  1298. writeln;
  1299. freemem(bs);
  1300. end;
  1301. setlength(space,length(space)-2);
  1302. end;
  1303. {****************************************************************************
  1304. Read Symbols Part
  1305. ****************************************************************************}
  1306. procedure readsymbols(const s:string);
  1307. type
  1308. pguid = ^tguid;
  1309. tguid = packed record
  1310. D1: LongWord;
  1311. D2: Word;
  1312. D3: Word;
  1313. D4: array[0..7] of Byte;
  1314. end;
  1315. absolutetyp = (tovar,toasm,toaddr);
  1316. tconsttyp = (constnone,
  1317. constord,conststring,constreal,
  1318. constset,constpointer,constnil,
  1319. constresourcestring,constwstring,constguid
  1320. );
  1321. var
  1322. b : byte;
  1323. pc : pchar;
  1324. i,j,len : longint;
  1325. guid : tguid;
  1326. tempbuf : array[0..127] of char;
  1327. varoptions : tvaroptions;
  1328. begin
  1329. with ppufile do
  1330. begin
  1331. if space<>'' then
  1332. Writeln(space,'------ ',s,' ------');
  1333. if readentry=ibstartsyms then
  1334. begin
  1335. Writeln(space,'Symtable datasize : ',getlongint);
  1336. Writeln(space,'Symtable alignment: ',getlongint);
  1337. end
  1338. else
  1339. Writeln('!! ibstartsym not found');
  1340. repeat
  1341. b:=readentry;
  1342. case b of
  1343. ibunitsym :
  1344. readcommonsym('Unit symbol ');
  1345. iblabelsym :
  1346. readcommonsym('Label symbol ');
  1347. ibtypesym :
  1348. begin
  1349. readcommonsym('Type symbol ');
  1350. write(space,' Result Type : ');
  1351. readderef('');
  1352. end;
  1353. ibprocsym :
  1354. begin
  1355. readcommonsym('Procedure symbol ');
  1356. len:=ppufile.getword;
  1357. for i:=1 to len do
  1358. begin
  1359. write(space,' Definition : ');
  1360. readderef('');
  1361. end;
  1362. end;
  1363. ibconstsym :
  1364. begin
  1365. readcommonsym('Constant symbol ');
  1366. b:=getbyte;
  1367. case tconsttyp(b) of
  1368. constord :
  1369. begin
  1370. write (space,' OrdinalType : ');
  1371. readderef('');
  1372. writeln(space,' Value : ',constexp.tostr(getexprint));
  1373. end;
  1374. constpointer :
  1375. begin
  1376. write (space,' PointerType : ');
  1377. readderef('');
  1378. writeln(space,' Value : ',getlongint)
  1379. end;
  1380. conststring,
  1381. constresourcestring :
  1382. begin
  1383. len:=getlongint;
  1384. getmem(pc,len+1);
  1385. getdata(pc^,len);
  1386. (pc+len)^:= #0;
  1387. writeln(space,' Length : ',len);
  1388. writeln(space,' Value : "',pc,'"');
  1389. freemem(pc,len+1);
  1390. end;
  1391. constreal :
  1392. writeln(space,' Value : ',getreal);
  1393. constset :
  1394. begin
  1395. write (space,' Set Type : ');
  1396. readderef('');
  1397. for i:=1to 4 do
  1398. begin
  1399. write (space,' Value : ');
  1400. for j:=1to 8 do
  1401. begin
  1402. if j>1 then
  1403. write(',');
  1404. write(hexstr(getbyte,2));
  1405. end;
  1406. writeln;
  1407. end;
  1408. end;
  1409. constwstring:
  1410. begin
  1411. end;
  1412. constguid:
  1413. begin
  1414. getdata(guid,sizeof(guid));
  1415. write (space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-');
  1416. for i:=0 to 7 do
  1417. begin
  1418. write(hexstr(guid.d4[i],2));
  1419. if i=1 then write('-');
  1420. end;
  1421. writeln('}');
  1422. end
  1423. else
  1424. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  1425. end;
  1426. end;
  1427. ibabsolutevarsym :
  1428. begin
  1429. readabstractvarsym('Absolute variable symbol ',varoptions);
  1430. Write (space,' Relocated to ');
  1431. b:=getbyte;
  1432. case absolutetyp(b) of
  1433. tovar :
  1434. readpropaccesslist(space+' Sym : ');
  1435. toasm :
  1436. Writeln('Assembler name : ',getstring);
  1437. toaddr :
  1438. begin
  1439. Write('Address : ',getlongint);
  1440. if tsystemcpu(ppufile.header.cpu)=cpu_i386 then
  1441. WriteLn(' (Far: ',getbyte<>0,')');
  1442. end;
  1443. else
  1444. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  1445. end;
  1446. end;
  1447. ibfieldvarsym :
  1448. begin
  1449. readabstractvarsym('Field Variable symbol ',varoptions);
  1450. writeln(space,' Address : ',getaint);
  1451. end;
  1452. ibstaticvarsym :
  1453. begin
  1454. readabstractvarsym('Global Variable symbol ',varoptions);
  1455. write (space,' DefaultConst : ');
  1456. readderef('');
  1457. if (vo_has_mangledname in varoptions) then
  1458. writeln(space,' Mangledname : ',getstring);
  1459. end;
  1460. iblocalvarsym :
  1461. begin
  1462. readabstractvarsym('Local Variable symbol ',varoptions);
  1463. write (space,' DefaultConst : ');
  1464. readderef('');
  1465. end;
  1466. ibparavarsym :
  1467. begin
  1468. readabstractvarsym('Parameter Variable symbol ',varoptions);
  1469. write (space,' DefaultConst : ');
  1470. readderef('');
  1471. writeln(space,' ParaNr : ',getword);
  1472. writeln(space,' Univ : ',boolean(getbyte));
  1473. writeln(space,' VarState : ',getbyte);
  1474. if (vo_has_explicit_paraloc in varoptions) then
  1475. begin
  1476. i:=getbyte;
  1477. getdata(tempbuf,i);
  1478. end;
  1479. end;
  1480. ibenumsym :
  1481. begin
  1482. readcommonsym('Enumeration symbol ');
  1483. write (space,' Definition : ');
  1484. readderef('');
  1485. writeln(space,' Value : ',getlongint);
  1486. end;
  1487. ibsyssym :
  1488. begin
  1489. readcommonsym('Internal system symbol ');
  1490. writeln(space,' Internal Nr : ',getlongint);
  1491. end;
  1492. ibmacrosym :
  1493. begin
  1494. readcommonsym('Macro symbol ');
  1495. writeln(space,' Name: ',getstring);
  1496. writeln(space,' Defined: ',getbyte);
  1497. writeln(space,' Compiler var: ',getbyte);
  1498. len:=getlongint;
  1499. writeln(space,' Value length: ',len);
  1500. if len > 0 then
  1501. begin
  1502. getmem(pc,len+1);
  1503. getdata(pc^,len);
  1504. (pc+len)^:= #0;
  1505. writeln(space,' Value: "',pc,'"');
  1506. freemem(pc,len+1);
  1507. end;
  1508. end;
  1509. ibpropertysym :
  1510. begin
  1511. readcommonsym('Property ');
  1512. i:=getlongint;
  1513. writeln(space,' PropOptions : ',i);
  1514. write (space,' OverrideProp : ');
  1515. readderef('');
  1516. write (space,' Prop Type : ');
  1517. readderef('');
  1518. writeln(space,' Index : ',getlongint);
  1519. writeln(space,' Default : ',getlongint);
  1520. write (space,' Index Type : ');
  1521. readderef('');
  1522. { palt_none }
  1523. readpropaccesslist('');
  1524. write (space,' Readaccess : ');
  1525. readpropaccesslist(space+' Sym: ');
  1526. write (space,' Writeaccess : ');
  1527. readpropaccesslist(space+' Sym: ');
  1528. write (space,' Storedaccess : ');
  1529. readpropaccesslist(space+' Sym: ');
  1530. end;
  1531. iberror :
  1532. begin
  1533. Writeln('!! Error in PPU');
  1534. exit;
  1535. end;
  1536. ibendsyms :
  1537. break;
  1538. else
  1539. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  1540. end;
  1541. if not EndOfEntry then
  1542. Writeln('!! Entry has more information stored');
  1543. until false;
  1544. end;
  1545. end;
  1546. {****************************************************************************
  1547. Read defintions Part
  1548. ****************************************************************************}
  1549. procedure readdefinitions(const s:string);
  1550. { type tordtype is in symconst unit }
  1551. {
  1552. uvoid,
  1553. u8bit,u16bit,u32bit,u64bit,
  1554. s8bit,s16bit,s32bit,s64bit,
  1555. bool8bit,bool16bit,bool32bit,bool64bit,
  1556. uchar,uwidechar,scurrency
  1557. ); }
  1558. { type tobjecttyp is in symconst unit }
  1559. { type tvarianttype is in symconst unit }
  1560. var
  1561. b : byte;
  1562. l,j : longint;
  1563. calloption : tproccalloption;
  1564. procoptions : tprocoptions;
  1565. procinfooptions : tprocinfoflag;
  1566. defoptions: tdefoptions;
  1567. begin
  1568. with ppufile do
  1569. begin
  1570. if space<>'' then
  1571. Writeln(space,'------ ',s,' ------');
  1572. if readentry<>ibstartdefs then
  1573. Writeln('!! ibstartdefs not found');
  1574. repeat
  1575. b:=readentry;
  1576. case b of
  1577. ibpointerdef :
  1578. begin
  1579. readcommondef('Pointer definition',defoptions);
  1580. write (space,' Pointed Type : ');
  1581. readderef('');
  1582. writeln(space,' Is Far : ',(getbyte<>0));
  1583. writeln(space,' Has Pointer Math : ',(getbyte<>0));
  1584. end;
  1585. iborddef :
  1586. begin
  1587. readcommondef('Ordinal definition',defoptions);
  1588. write (space,' Base type : ');
  1589. b:=getbyte;
  1590. case tordtype(b) of
  1591. uvoid : writeln('uvoid');
  1592. u8bit : writeln('u8bit');
  1593. u16bit : writeln('u16bit');
  1594. u32bit : writeln('s32bit');
  1595. u64bit : writeln('u64bit');
  1596. s8bit : writeln('s8bit');
  1597. s16bit : writeln('s16bit');
  1598. s32bit : writeln('s32bit');
  1599. s64bit : writeln('s64bit');
  1600. bool8bit : writeln('bool8bit');
  1601. bool16bit : writeln('bool16bit');
  1602. bool32bit : writeln('bool32bit');
  1603. bool64bit : writeln('bool64bit');
  1604. uchar : writeln('uchar');
  1605. uwidechar : writeln('uwidechar');
  1606. scurrency : writeln('ucurrency');
  1607. else writeln('!! Warning: Invalid base type ',b);
  1608. end;
  1609. writeln(space,' Range : ',constexp.tostr(getexprint),' to ',constexp.tostr(getexprint));
  1610. end;
  1611. ibfloatdef :
  1612. begin
  1613. readcommondef('Float definition',defoptions);
  1614. writeln(space,' Float type : ',getbyte);
  1615. end;
  1616. ibarraydef :
  1617. begin
  1618. readcommondef('Array definition',defoptions);
  1619. write (space,' Element type : ');
  1620. readderef('');
  1621. write (space,' Range Type : ');
  1622. readderef('');
  1623. writeln(space,' Range : ',getaint,' to ',getaint);
  1624. write (space,' Options : ');
  1625. readarraydefoptions;
  1626. readsymtableoptions('symbols');
  1627. readdefinitions('symbols');
  1628. readsymbols('symbols');
  1629. end;
  1630. ibprocdef :
  1631. begin
  1632. readcommondef('Procedure definition',defoptions);
  1633. read_abstract_proc_def(calloption,procoptions);
  1634. if (po_has_mangledname in procoptions) then
  1635. writeln(space,' Mangled name : ',getstring);
  1636. writeln(space,' Number : ',getword);
  1637. writeln(space,' Level : ',getbyte);
  1638. write (space,' Class : ');
  1639. readderef('');
  1640. write (space,' Procsym : ');
  1641. readderef('');
  1642. write (space,' File Pos : ');
  1643. readposinfo;
  1644. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  1645. write (space,' SymOptions : ');
  1646. readsymoptions(space+' ');
  1647. if tsystemcpu(ppufile.header.cpu)=cpu_powerpc then
  1648. begin
  1649. { library symbol for AmigaOS/MorphOS }
  1650. write (space,' Library symbol : ');
  1651. readderef('');
  1652. end;
  1653. if (po_has_importdll in procoptions) then
  1654. writeln(space,' Import DLL : ',getstring);
  1655. if (po_has_importname in procoptions) then
  1656. writeln(space,' Import Name : ',getstring);
  1657. writeln(space,' Import Nr : ',getword);
  1658. if (po_msgint in procoptions) then
  1659. writeln(space,' MsgInt : ',getlongint);
  1660. if (po_msgstr in procoptions) then
  1661. writeln(space,' MsgStr : ',getstring);
  1662. if (po_dispid in procoptions) then
  1663. writeln(space,' DispID: ',ppufile.getlongint);
  1664. if (po_has_inlininginfo in procoptions) then
  1665. begin
  1666. write (space,' FuncretSym : ');
  1667. readderef('');
  1668. ppufile.getsmallset(procinfooptions);
  1669. writeln(space,' ProcInfoOptions : ',dword(procinfooptions));
  1670. end;
  1671. b:=ppufile.getbyte;
  1672. if b<>0 then
  1673. begin
  1674. write (space,' Alias names : ');
  1675. for j:=1 to b do
  1676. begin
  1677. write(ppufile.getstring);
  1678. if j<b then
  1679. write(', ');
  1680. end;
  1681. writeln;
  1682. end;
  1683. if not EndOfEntry then
  1684. Writeln('!! Entry has more information stored');
  1685. space:=' '+space;
  1686. { parast }
  1687. readsymtableoptions('parast');
  1688. readdefinitions('parast');
  1689. readsymbols('parast');
  1690. { localst }
  1691. if (po_has_inlininginfo in procoptions) then
  1692. begin
  1693. readsymtableoptions('localst');
  1694. readdefinitions('localst');
  1695. readsymbols('localst');
  1696. end;
  1697. if (po_has_inlininginfo in procoptions) then
  1698. readnodetree;
  1699. delete(space,1,4);
  1700. end;
  1701. ibprocvardef :
  1702. begin
  1703. readcommondef('Procedural type (ProcVar) definition',defoptions);
  1704. read_abstract_proc_def(calloption,procoptions);
  1705. writeln(space,' Symtable level :',ppufile.getbyte);
  1706. if not EndOfEntry then
  1707. Writeln('!! Entry has more information stored');
  1708. space:=' '+space;
  1709. { parast }
  1710. readsymtableoptions('parast');
  1711. readdefinitions('parast');
  1712. readsymbols('parast');
  1713. delete(space,1,4);
  1714. end;
  1715. ibshortstringdef :
  1716. begin
  1717. readcommondef('ShortString definition',defoptions);
  1718. writeln(space,' Length : ',getbyte);
  1719. end;
  1720. ibwidestringdef :
  1721. begin
  1722. readcommondef('WideString definition',defoptions);
  1723. writeln(space,' Length : ',getlongint);
  1724. end;
  1725. ibunicodestringdef :
  1726. begin
  1727. readcommondef('UnicodeString definition',defoptions);
  1728. writeln(space,' Length : ',getlongint);
  1729. end;
  1730. ibansistringdef :
  1731. begin
  1732. readcommondef('AnsiString definition',defoptions);
  1733. writeln(space,' Length : ',getlongint);
  1734. end;
  1735. iblongstringdef :
  1736. begin
  1737. readcommondef('Longstring definition',defoptions);
  1738. writeln(space,' Length : ',getlongint);
  1739. end;
  1740. ibrecorddef :
  1741. begin
  1742. readcommondef('Record definition',defoptions);
  1743. writeln(space,' Name of Record : ',getstring);
  1744. write (space,' Options : ');
  1745. readobjectdefoptions;
  1746. writeln(space,' FieldAlign : ',getbyte);
  1747. writeln(space,' RecordAlign : ',getbyte);
  1748. writeln(space,' PadAlign : ',getbyte);
  1749. writeln(space,'UseFieldAlignment : ',getbyte);
  1750. writeln(space,' DataSize : ',getaint);
  1751. if not EndOfEntry then
  1752. Writeln('!! Entry has more information stored');
  1753. {read the record definitions and symbols}
  1754. space:=' '+space;
  1755. readsymtableoptions('fields');
  1756. readdefinitions('fields');
  1757. readsymbols('fields');
  1758. Delete(space,1,4);
  1759. end;
  1760. ibobjectdef :
  1761. begin
  1762. readcommondef('Object/Class definition',defoptions);
  1763. writeln(space,' Name of Class : ',getstring);
  1764. write (space,' Options : ');
  1765. readobjectdefoptions;
  1766. b:=getbyte;
  1767. write (space,' Type : ');
  1768. case tobjecttyp(b) of
  1769. odt_class : writeln('class');
  1770. odt_object : writeln('object');
  1771. odt_interfacecom : writeln('interfacecom');
  1772. odt_interfacecorba : writeln('interfacecorba');
  1773. odt_cppclass : writeln('cppclass');
  1774. odt_dispinterface : writeln('dispinterface');
  1775. odt_objcclass : writeln('objcclass');
  1776. odt_objcprotocol : writeln('objcprotocol');
  1777. odt_helper : writeln('helper');
  1778. else writeln('!! Warning: Invalid object type ',b);
  1779. end;
  1780. writeln(space,' External name : ',getstring);
  1781. writeln(space,' Import lib : ',getstring);
  1782. writeln(space,' DataSize : ',getaint);
  1783. writeln(space,' FieldAlign : ',getbyte);
  1784. writeln(space,' RecordAlign : ',getbyte);
  1785. writeln(space,' Vmt offset : ',getlongint);
  1786. write (space, ' Ancestor Class : ');
  1787. readderef('');
  1788. if tobjecttyp(b) in [odt_interfacecom,odt_interfacecorba,odt_dispinterface] then
  1789. begin
  1790. { IIDGUID }
  1791. for j:=1to 16 do
  1792. getbyte;
  1793. writeln(space,' IID String : ',getstring);
  1794. end;
  1795. if (tobjecttyp(b)=odt_helper) or
  1796. (oo_is_classhelper in current_objectoptions) then
  1797. begin
  1798. write(space,' Helper parent : ');
  1799. readderef('');
  1800. end;
  1801. l:=getlongint;
  1802. writeln(space,' VMT entries: ',l);
  1803. for j:=1 to l do
  1804. begin
  1805. write(space,' ');
  1806. readderef('');
  1807. writeln(space,' Visibility: ',Visibility2Str(getbyte));
  1808. end;
  1809. if tobjecttyp(b) in [odt_class,odt_interfacecorba,odt_objcclass,odt_objcprotocol] then
  1810. begin
  1811. l:=getlongint;
  1812. writeln(space,' Impl Intf Count : ',l);
  1813. for j:=1 to l do
  1814. begin
  1815. write (space,' - Definition : ');
  1816. readderef('');
  1817. writeln(space,' IOffset : ',getlongint);
  1818. end;
  1819. end;
  1820. if df_copied_def in current_defoptions then
  1821. begin
  1822. writeln(' Copy of def: ');
  1823. readderef('');
  1824. end;
  1825. if not EndOfEntry then
  1826. Writeln('!! Entry has more information stored');
  1827. if not(df_copied_def in current_defoptions) then
  1828. begin
  1829. {read the record definitions and symbols}
  1830. space:=' '+space;
  1831. readsymtableoptions('fields');
  1832. readdefinitions('fields');
  1833. readsymbols('fields');
  1834. Delete(space,1,4);
  1835. end;
  1836. end;
  1837. ibfiledef :
  1838. begin
  1839. ReadCommonDef('File definition',defoptions);
  1840. write (space,' Type : ');
  1841. case getbyte of
  1842. 0 : writeln('Text');
  1843. 1 : begin
  1844. writeln('Typed');
  1845. write (space,' File of Type : ');
  1846. readderef('');
  1847. end;
  1848. 2 : writeln('Untyped');
  1849. end;
  1850. end;
  1851. ibformaldef :
  1852. begin
  1853. readcommondef('Generic definition (void-typ)',defoptions);
  1854. writeln(space,' Is Typed : ',(getbyte<>0));
  1855. end;
  1856. ibundefineddef :
  1857. readcommondef('Undefined definition (generic parameter)',defoptions);
  1858. ibenumdef :
  1859. begin
  1860. readcommondef('Enumeration type definition',defoptions);
  1861. writeln(space,' Smallest element : ',getaint);
  1862. writeln(space,' Largest element : ',getaint);
  1863. writeln(space,' Size : ',getaint);
  1864. if df_copied_def in defoptions then
  1865. begin
  1866. write(space,'Base enumeration type : ');
  1867. readderef('');
  1868. end
  1869. else
  1870. begin
  1871. space:=' '+space;
  1872. readsymtableoptions('elements');
  1873. readdefinitions('elements');
  1874. readsymbols('elements');
  1875. delete(space,1,4);
  1876. end;
  1877. end;
  1878. ibclassrefdef :
  1879. begin
  1880. readcommondef('Class reference definition',defoptions);
  1881. write (space,' Pointed Type : ');
  1882. readderef('');
  1883. end;
  1884. ibsetdef :
  1885. begin
  1886. readcommondef('Set definition',defoptions);
  1887. write (space,' Element type : ');
  1888. readderef('');
  1889. writeln(space,' Size : ',getaint);
  1890. writeln(space,' Set Base : ',getaint);
  1891. writeln(space,' Set Max : ',getaint);
  1892. end;
  1893. ibvariantdef :
  1894. begin
  1895. readcommondef('Variant definition',defoptions);
  1896. write (space,' Varianttype : ');
  1897. b:=getbyte;
  1898. case tvarianttype(b) of
  1899. vt_normalvariant :
  1900. writeln('Normal');
  1901. vt_olevariant :
  1902. writeln('OLE');
  1903. else
  1904. writeln('!! Warning: Invalid varianttype ',b);
  1905. end;
  1906. end;
  1907. iberror :
  1908. begin
  1909. Writeln('!! Error in PPU');
  1910. exit;
  1911. end;
  1912. ibenddefs :
  1913. break;
  1914. else
  1915. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  1916. end;
  1917. if not EndOfEntry then
  1918. Writeln('!! Entry has more information stored');
  1919. until false;
  1920. end;
  1921. end;
  1922. procedure readmoduleoptions(space : string);
  1923. type
  1924. { tmoduleoption type is in unit fmodule }
  1925. tmoduleoption = (mo_none,
  1926. mo_hint_deprecated,
  1927. mo_hint_platform,
  1928. mo_hint_library,
  1929. mo_hint_unimplemented,
  1930. mo_hint_experimental,
  1931. mo_has_deprecated_msg
  1932. );
  1933. tmoduleoptions = set of tmoduleoption;
  1934. tmoduleopt=record
  1935. mask : tmoduleoption;
  1936. str : string[30];
  1937. end;
  1938. const
  1939. moduleopts=ord(high(tmoduleoption));
  1940. moduleopt : array[1..moduleopts] of tmoduleopt=(
  1941. (mask:mo_hint_deprecated; str:'Hint Deprecated'),
  1942. (mask:mo_hint_platform; str:'Hint Platform'),
  1943. (mask:mo_hint_library; str:'Hint Library'),
  1944. (mask:mo_hint_unimplemented; str:'Hint Unimplemented'),
  1945. (mask:mo_hint_experimental; str:'Hint Experimental'),
  1946. (mask:mo_has_deprecated_msg; str:'Has Deprecated Message')
  1947. );
  1948. var
  1949. moduleoptions : tmoduleoptions;
  1950. i : longint;
  1951. first : boolean;
  1952. begin
  1953. ppufile.getsmallset(moduleoptions);
  1954. if moduleoptions<>[] then
  1955. begin
  1956. first:=true;
  1957. for i:=1to moduleopts do
  1958. if (moduleopt[i].mask in moduleoptions) then
  1959. begin
  1960. if first then
  1961. first:=false
  1962. else
  1963. write(', ');
  1964. write(moduleopt[i].str);
  1965. end;
  1966. end;
  1967. writeln;
  1968. if mo_has_deprecated_msg in moduleoptions then
  1969. writeln(space,'Deprecated : ', ppufile.getstring);
  1970. end;
  1971. {****************************************************************************
  1972. Read General Part
  1973. ****************************************************************************}
  1974. procedure readinterface;
  1975. var
  1976. b : byte;
  1977. sourcenumber : longint;
  1978. begin
  1979. with ppufile do
  1980. begin
  1981. repeat
  1982. b:=readentry;
  1983. case b of
  1984. ibmodulename :
  1985. Writeln('Module Name: ',getstring);
  1986. ibmoduleoptions:
  1987. readmoduleoptions(' ');
  1988. ibsourcefiles :
  1989. begin
  1990. sourcenumber:=1;
  1991. while not EndOfEntry do
  1992. begin
  1993. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  1994. inc(sourcenumber);
  1995. end;
  1996. end;
  1997. {$IFDEF MACRO_DIFF_HINT}
  1998. ibusedmacros :
  1999. begin
  2000. while not EndOfEntry do
  2001. begin
  2002. Write('Conditional ',getstring);
  2003. b:=getbyte;
  2004. if boolean(b)=true then
  2005. write(' defined at startup')
  2006. else
  2007. write(' not defined at startup');
  2008. b:=getbyte;
  2009. if boolean(b)=true then
  2010. writeln(' was used')
  2011. else
  2012. writeln;
  2013. end;
  2014. end;
  2015. {$ENDIF}
  2016. ibloadunit :
  2017. ReadLoadUnit;
  2018. iblinkunitofiles :
  2019. ReadLinkContainer('Link unit object file: ');
  2020. iblinkunitstaticlibs :
  2021. ReadLinkContainer('Link unit static lib: ');
  2022. iblinkunitsharedlibs :
  2023. ReadLinkContainer('Link unit shared lib: ');
  2024. iblinkotherofiles :
  2025. ReadLinkContainer('Link other object file: ');
  2026. iblinkotherstaticlibs :
  2027. ReadLinkContainer('Link other static lib: ');
  2028. iblinkothersharedlibs :
  2029. ReadLinkContainer('Link other shared lib: ');
  2030. iblinkotherframeworks:
  2031. ReadLinkContainer('Link framework: ');
  2032. ibmainname:
  2033. Writeln('Specified main program symbol name: ',getstring);
  2034. ibImportSymbols :
  2035. ReadImportSymbols;
  2036. ibderefdata :
  2037. ReadDerefData;
  2038. ibderefmap :
  2039. ReadDerefMap;
  2040. ibwpofile :
  2041. ReadWpoFileInfo;
  2042. ibresources :
  2043. ReadLinkContainer('Resource file: ');
  2044. iberror :
  2045. begin
  2046. Writeln('Error in PPU');
  2047. exit;
  2048. end;
  2049. ibendinterface :
  2050. break;
  2051. else
  2052. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  2053. end;
  2054. until false;
  2055. end;
  2056. end;
  2057. {****************************************************************************
  2058. Read Implementation Part
  2059. ****************************************************************************}
  2060. procedure readimplementation;
  2061. var
  2062. b : byte;
  2063. begin
  2064. with ppufile do
  2065. begin
  2066. repeat
  2067. b:=readentry;
  2068. case b of
  2069. ibasmsymbols :
  2070. ReadAsmSymbols;
  2071. ibloadunit :
  2072. ReadLoadUnit;
  2073. iberror :
  2074. begin
  2075. Writeln('Error in PPU');
  2076. exit;
  2077. end;
  2078. ibendimplementation :
  2079. break;
  2080. else
  2081. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  2082. end;
  2083. until false;
  2084. end;
  2085. end;
  2086. procedure dofile (filename : string);
  2087. begin
  2088. { reset }
  2089. space:='';
  2090. { fix filename }
  2091. if pos('.',filename)=0 then
  2092. filename:=filename+'.ppu';
  2093. ppufile:=tppufile.create(filename);
  2094. if not ppufile.openfile then
  2095. begin
  2096. writeln ('IO-Error when opening : ',filename,', Skipping');
  2097. exit;
  2098. end;
  2099. { PPU File is open, check for PPU Id }
  2100. if not ppufile.CheckPPUID then
  2101. begin
  2102. writeln(Filename,' : Not a valid PPU file, Skipping');
  2103. exit;
  2104. end;
  2105. { Check PPU Version }
  2106. ppuversion:=ppufile.GetPPUVersion;
  2107. Writeln('Analyzing ',filename,' (v',PPUVersion,')');
  2108. if PPUVersion<16 then
  2109. begin
  2110. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  2111. exit;
  2112. end;
  2113. { Write PPU Header Information }
  2114. if (verbose and v_header)<>0 then
  2115. begin
  2116. Writeln;
  2117. Writeln('Header');
  2118. Writeln('-------');
  2119. with ppufile.header do
  2120. begin
  2121. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  2122. (ppufile.header.compiler shr 7) and $7f,'.',
  2123. ppufile.header.compiler and $7f);
  2124. WriteLn('Target processor : ',Cpu2Str(cpu));
  2125. WriteLn('Target operating system : ',Target2Str(target));
  2126. Writeln('Unit flags : ',PPUFlags2Str(flags));
  2127. Writeln('FileSize (w/o header) : ',size);
  2128. Writeln('Checksum : ',hexstr(checksum,8));
  2129. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  2130. Writeln('Indirect Checksum : ',hexstr(indirect_checksum,8));
  2131. Writeln('Definitions stored : ',tostr(deflistsize));
  2132. Writeln('Symbols stored : ',tostr(symlistsize));
  2133. end;
  2134. end;
  2135. {read the general stuff}
  2136. if (verbose and v_interface)<>0 then
  2137. begin
  2138. Writeln;
  2139. Writeln('Interface section');
  2140. Writeln('------------------');
  2141. readinterface;
  2142. end
  2143. else
  2144. ppufile.skipuntilentry(ibendinterface);
  2145. Writeln;
  2146. Writeln('Interface symtable');
  2147. Writeln('----------------------');
  2148. readsymtableoptions('interface');
  2149. {read the definitions}
  2150. if (verbose and v_defs)<>0 then
  2151. begin
  2152. Writeln;
  2153. Writeln('Interface definitions');
  2154. Writeln('----------------------');
  2155. readdefinitions('interface');
  2156. end
  2157. else
  2158. ppufile.skipuntilentry(ibenddefs);
  2159. {read the symbols}
  2160. if (verbose and v_syms)<>0 then
  2161. begin
  2162. Writeln;
  2163. Writeln('Interface Symbols');
  2164. Writeln('------------------');
  2165. readsymbols('interface');
  2166. end
  2167. else
  2168. ppufile.skipuntilentry(ibendsyms);
  2169. {read the macro symbols}
  2170. if (verbose and v_syms)<>0 then
  2171. begin
  2172. Writeln;
  2173. Writeln('Interface Macro Symbols');
  2174. Writeln('-----------------------');
  2175. end;
  2176. if ppufile.readentry<>ibexportedmacros then
  2177. begin
  2178. Writeln('!! Error in PPU');
  2179. exit;
  2180. end;
  2181. if boolean(ppufile.getbyte) then
  2182. begin
  2183. readsymtableoptions('interface macro');
  2184. {skip the definition section for macros (since they are never used) }
  2185. ppufile.skipuntilentry(ibenddefs);
  2186. {read the macro symbols}
  2187. if (verbose and v_syms)<>0 then
  2188. readsymbols('interface macro')
  2189. else
  2190. ppufile.skipuntilentry(ibendsyms);
  2191. end
  2192. else
  2193. Writeln('(no exported macros)');
  2194. {read the implementation stuff}
  2195. if (verbose and v_implementation)<>0 then
  2196. begin
  2197. Writeln;
  2198. Writeln('Implementation section');
  2199. Writeln('-----------------------');
  2200. readimplementation;
  2201. end
  2202. else
  2203. ppufile.skipuntilentry(ibendimplementation);
  2204. {read the static symtable}
  2205. Writeln;
  2206. Writeln('Implementation symtable');
  2207. Writeln('----------------------');
  2208. readsymtableoptions('implementation');
  2209. if (ppufile.header.flags and uf_local_symtable)<>0 then
  2210. begin
  2211. if (verbose and v_defs)<>0 then
  2212. begin
  2213. Writeln;
  2214. Writeln('Static definitions');
  2215. Writeln('----------------------');
  2216. readdefinitions('implementation');
  2217. end
  2218. else
  2219. ppufile.skipuntilentry(ibenddefs);
  2220. {read the symbols}
  2221. if (verbose and v_syms)<>0 then
  2222. begin
  2223. Writeln;
  2224. Writeln('Static Symbols');
  2225. Writeln('------------------');
  2226. readsymbols('implementation');
  2227. end
  2228. else
  2229. ppufile.skipuntilentry(ibendsyms);
  2230. end;
  2231. ReadCreatedObjTypes;
  2232. {shutdown ppufile}
  2233. ppufile.closefile;
  2234. ppufile.free;
  2235. Writeln;
  2236. end;
  2237. procedure help;
  2238. begin
  2239. writeln('usage: ppudump [options] <filename1> <filename2>...');
  2240. writeln;
  2241. writeln('[options] can be:');
  2242. writeln(' -V<verbose> Set verbosity to <verbose>');
  2243. writeln(' H - Show header info');
  2244. writeln(' I - Show interface');
  2245. writeln(' M - Show implementation');
  2246. writeln(' S - Show interface symbols');
  2247. writeln(' D - Show interface definitions');
  2248. // writeln(' B - Show browser info');
  2249. writeln(' A - Show all');
  2250. writeln(' -h, -? This helpscreen');
  2251. halt;
  2252. end;
  2253. var
  2254. startpara,
  2255. nrfile,i : longint;
  2256. para : string;
  2257. begin
  2258. writeln(Title+' '+Version);
  2259. writeln(Copyright);
  2260. writeln;
  2261. if paramcount<1 then
  2262. begin
  2263. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  2264. halt(1);
  2265. end;
  2266. { turn verbose on by default }
  2267. verbose:=v_all;
  2268. { read options }
  2269. startpara:=1;
  2270. while copy(paramstr(startpara),1,1)='-' do
  2271. begin
  2272. para:=paramstr(startpara);
  2273. case upcase(para[2]) of
  2274. 'V' : begin
  2275. verbose:=0;
  2276. for i:=3 to length(para) do
  2277. case upcase(para[i]) of
  2278. 'H' : verbose:=verbose or v_header;
  2279. 'I' : verbose:=verbose or v_interface;
  2280. 'M' : verbose:=verbose or v_implementation;
  2281. 'D' : verbose:=verbose or v_defs;
  2282. 'S' : verbose:=verbose or v_syms;
  2283. 'A' : verbose:=verbose or v_all;
  2284. end;
  2285. end;
  2286. 'H' : help;
  2287. '?' : help;
  2288. end;
  2289. inc(startpara);
  2290. end;
  2291. { process files }
  2292. for nrfile:=startpara to paramcount do
  2293. dofile (paramstr(nrfile));
  2294. if has_errors then
  2295. Halt(1);
  2296. end.