ppudump.pp 88 KB

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