ppudump.pp 78 KB

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