ppudump.pp 81 KB

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