ppudump.pp 81 KB

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