ppudump.pp 81 KB

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