ppudump.pp 78 KB

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