ppudump.pp 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067
  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. ); *)
  915. type
  916. tprocinfoopt=record
  917. mask : tprocinfoflag;
  918. str : string[80];
  919. end;
  920. const
  921. procinfoopts=ord(high(tprocinfoflag)) - ord(low(tprocinfoflag));
  922. procinfoopt : array[0..procinfoopts] of tprocinfoopt=(
  923. (mask:pi_has_assembler_block;
  924. str:' has at least one assembler block'),
  925. (mask:pi_do_call;
  926. str:' does a call'),
  927. (mask:pi_uses_exceptions;
  928. str:' has a try statement = no register optimization '),
  929. (mask:pi_is_assembler;
  930. str:' is declared as @var(assembler), don''t optimize'),
  931. (mask:pi_needs_implicit_finally;
  932. str:' contains data which needs to be finalized '),
  933. (mask:pi_has_implicit_finally;
  934. str:' has the implicit try..finally generated '),
  935. (mask:pi_uses_fpu;
  936. str:' uses fpu'),
  937. (mask:pi_needs_got;
  938. str:' uses GOT for PIC code '),
  939. (mask:pi_uses_static_symtable;
  940. str:' references var/proc/type/const in static symtable'),
  941. (mask:pi_has_stackparameter;
  942. str:' set if the procedure has to push parameters onto the stack '),
  943. (mask:pi_has_label;
  944. str:' set if the procedure has at least one label '),
  945. (mask:pi_is_recursive;
  946. str:' calls itself recursive '),
  947. (mask:pi_needs_stackframe;
  948. str:' stack frame optimization not possible (only on x86 probably) '),
  949. (mask:pi_has_saved_regs;
  950. str:' set if the procedure has at least one register saved on the stack '),
  951. (mask:pi_dfaavailable;
  952. str:' dfa was generated for this proc '),
  953. (mask:pi_has_interproclabel;
  954. str:' subroutine contains interprocedural used labels '),
  955. (mask:pi_has_unwind_info;
  956. str:' unwinding info was generated for this proc ')
  957. );
  958. var
  959. procinfooptions : tprocinfoflags;
  960. i : longint;
  961. first : boolean;
  962. begin
  963. ppufile.getsmallset(procinfooptions);
  964. if procinfooptions<>[] then
  965. begin
  966. first:=true;
  967. for i:=0 to procinfoopts do
  968. if (procinfoopt[i].mask in procinfooptions) then
  969. begin
  970. if first then
  971. first:=false
  972. else
  973. write(', ');
  974. write(procinfoopt[i].str);
  975. end;
  976. end;
  977. writeln;
  978. end;
  979. procedure readsymoptions(space : string);
  980. type
  981. tsymopt=record
  982. mask : tsymoption;
  983. str : string[30];
  984. end;
  985. const
  986. symopts=ord(high(tsymoption)) - ord(low(tsymoption));
  987. { sp_none = 0 corresponds to nothing }
  988. symopt : array[1..symopts] of tsymopt=(
  989. (mask:sp_static; str:'Static'),
  990. (mask:sp_hint_deprecated; str:'Hint Deprecated'),
  991. (mask:sp_hint_platform; str:'Hint Platform'),
  992. (mask:sp_hint_library; str:'Hint Library'),
  993. (mask:sp_hint_unimplemented; str:'Hint Unimplemented'),
  994. (mask:sp_hint_experimental; str:'Hint Experimental'),
  995. (mask:sp_has_overloaded; str:'Has overloaded'),
  996. (mask:sp_internal; str:'Internal'),
  997. (mask:sp_implicitrename; str:'Implicit Rename'),
  998. (mask:sp_generic_para; str:'Generic Parameter'),
  999. (mask:sp_has_deprecated_msg; str:'Has Deprecated Message'),
  1000. (mask:sp_generic_dummy; str:'Generic Dummy'),
  1001. (mask:sp_explicitrename; str:'Explicit Rename')
  1002. );
  1003. var
  1004. symoptions : tsymoptions;
  1005. i : longint;
  1006. first : boolean;
  1007. begin
  1008. ppufile.getsmallset(symoptions);
  1009. if symoptions<>[] then
  1010. begin
  1011. first:=true;
  1012. for i:=1to symopts do
  1013. if (symopt[i].mask in symoptions) then
  1014. begin
  1015. if first then
  1016. first:=false
  1017. else
  1018. write(', ');
  1019. write(symopt[i].str);
  1020. end;
  1021. end;
  1022. writeln;
  1023. if sp_has_deprecated_msg in symoptions then
  1024. writeln(space,'Deprecated : ', ppufile.getstring);
  1025. end;
  1026. procedure readcommonsym(const s:string);
  1027. begin
  1028. writeln(space,'** Symbol Id ',ppufile.getlongint,' **');
  1029. writeln(space,s,ppufile.getstring);
  1030. write (space,' File Pos : ');
  1031. readposinfo;
  1032. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  1033. write (space,' SymOptions : ');
  1034. readsymoptions(space+' ');
  1035. end;
  1036. var
  1037. { needed during tobjectdef parsing... }
  1038. current_defoptions : tdefoptions;
  1039. current_objectoptions : tobjectoptions;
  1040. procedure readcommondef(const s:string; out defoptions: tdefoptions);
  1041. type
  1042. tdefopt=record
  1043. mask : tdefoption;
  1044. str : string[30];
  1045. end;
  1046. tdefstateinfo=record
  1047. mask : tdefstate;
  1048. str : string[30];
  1049. end;
  1050. ptoken=^ttoken;
  1051. pmsgstate =^tmsgstate;
  1052. const
  1053. defopt : array[1..ord(high(tdefoption))] of tdefopt=(
  1054. (mask:df_unique; str:'Unique Type'),
  1055. (mask:df_generic; str:'Generic'),
  1056. (mask:df_specialization; str:'Specialization'),
  1057. (mask:df_copied_def; str:'Copied Typedef')
  1058. );
  1059. defstate : array[1..ord(high(tdefstate))] of tdefstateinfo=(
  1060. (mask:ds_vmt_written; str:'VMT Written'),
  1061. (mask:ds_rtti_table_used; str:'RTTITable Used'),
  1062. (mask:ds_init_table_used; str:'InitTable Used'),
  1063. (mask:ds_rtti_table_written; str:'RTTITable Written'),
  1064. (mask:ds_init_table_written; str:'InitTable Written'),
  1065. (mask:ds_dwarf_dbg_info_used; str:'Dwarf DbgInfo Used'),
  1066. (mask:ds_dwarf_dbg_info_written;str:'Dwarf DbgInfo Written')
  1067. );
  1068. var
  1069. defstates : tdefstates;
  1070. i, nb, msgvalue, mesgnb : longint;
  1071. first : boolean;
  1072. copy_size, min_size, tokenbufsize : longint;
  1073. tokenbuf : pbyte;
  1074. idtoken,
  1075. token : ttoken;
  1076. state : tmsgstate;
  1077. new_settings : Tsettings;
  1078. len : sizeint;
  1079. wstring : widestring;
  1080. astring : ansistring;
  1081. function readtoken: ttoken;
  1082. var
  1083. b,b2 : byte;
  1084. begin
  1085. b:=tokenbuf[i];
  1086. inc(i);
  1087. if (b and $80)<>0 then
  1088. begin
  1089. b2:=tokenbuf[i];
  1090. inc(i);
  1091. result:=ttoken(((b and $7f) shl 8) or b2);
  1092. end
  1093. else
  1094. result:=ttoken(b);
  1095. end;
  1096. function gettokenbufdword : dword;
  1097. var
  1098. var32 : dword;
  1099. begin
  1100. var32:=pdword(@tokenbuf[i])^;
  1101. inc(i,sizeof(dword));
  1102. if ppufile.change_endian then
  1103. var32:=swapendian(var32);
  1104. result:=var32;
  1105. end;
  1106. function gettokenbufword : word;
  1107. var
  1108. var16 : word;
  1109. begin
  1110. var16:=pword(@tokenbuf[i])^;
  1111. inc(i,sizeof(word));
  1112. if ppufile.change_endian then
  1113. var16:=swapendian(var16);
  1114. result:=var16;
  1115. end;
  1116. function gettokenbufsizeint : int64;
  1117. var
  1118. var64 : int64;
  1119. var32 : longint;
  1120. var16 : smallint;
  1121. begin
  1122. if CpuAddrBitSize[cpu]=64 then
  1123. begin
  1124. var64:=pint64(@tokenbuf[i])^;
  1125. inc(i,sizeof(int64));
  1126. if ppufile.change_endian then
  1127. var64:=swapendian(var64);
  1128. result:=var64;
  1129. end
  1130. else if CpuAddrBitSize[cpu]=32 then
  1131. begin
  1132. var32:=plongint(@tokenbuf[i])^;
  1133. inc(i,sizeof(longint));
  1134. if ppufile.change_endian then
  1135. var32:=swapendian(var32);
  1136. result:=var32;
  1137. end
  1138. else if CpuAddrBitSize[cpu]=16 then
  1139. begin
  1140. var16:=psmallint(@tokenbuf[i])^;
  1141. inc(i,sizeof(smallint));
  1142. if ppufile.change_endian then
  1143. var16:=swapendian(var16);
  1144. result:=var16;
  1145. end
  1146. else
  1147. begin
  1148. WriteError('Wrong CpuAddrBitSize');
  1149. result:=0;
  1150. end;
  1151. end;
  1152. begin
  1153. writeln(space,'** Definition Id ',ppufile.getlongint,' **');
  1154. writeln(space,s);
  1155. write (space,' Type symbol : ');
  1156. readderef('');
  1157. write (space,' DefOptions : ');
  1158. ppufile.getsmallset(defoptions);
  1159. if defoptions<>[] then
  1160. begin
  1161. first:=true;
  1162. for i:=1to high(defopt) do
  1163. if (defopt[i].mask in defoptions) then
  1164. begin
  1165. if first then
  1166. first:=false
  1167. else
  1168. write(', ');
  1169. write(defopt[i].str);
  1170. end;
  1171. end;
  1172. writeln;
  1173. write (space,' DefStates : ');
  1174. ppufile.getsmallset(defstates);
  1175. if defstates<>[] then
  1176. begin
  1177. first:=true;
  1178. for i:=1 to high(defstate) do
  1179. if (defstate[i].mask in defstates) then
  1180. begin
  1181. if first then
  1182. first:=false
  1183. else
  1184. write(', ');
  1185. write(defstate[i].str);
  1186. end;
  1187. end;
  1188. writeln;
  1189. if df_generic in defoptions then
  1190. begin
  1191. tokenbufsize:=ppufile.getlongint;
  1192. writeln(space,' Tokenbuffer size : ',tokenbufsize);
  1193. tokenbuf:=allocmem(tokenbufsize);
  1194. ppufile.getdata(tokenbuf^,tokenbufsize);
  1195. i:=0;
  1196. write(space,' Tokens: ');
  1197. while i<tokenbufsize do
  1198. begin
  1199. token:=readtoken;
  1200. if token<>_GENERICSPECIALTOKEN then
  1201. begin
  1202. if token <= high(ttoken) then
  1203. write(arraytokeninfo[token].str)
  1204. else
  1205. begin
  1206. HasMoreInfos;
  1207. write('Error in Token List');
  1208. break;
  1209. end;
  1210. idtoken:=readtoken;
  1211. end;
  1212. case token of
  1213. _CWCHAR,
  1214. _CWSTRING :
  1215. begin
  1216. len:=gettokenbufsizeint;
  1217. setlength(wstring,len);
  1218. move(tokenbuf[i],wstring[1],len*2);
  1219. write(' ',wstring);
  1220. inc(i,len*2);
  1221. end;
  1222. _CSTRING:
  1223. begin
  1224. len:=gettokenbufsizeint;
  1225. setlength(astring,len);
  1226. move(tokenbuf[i],astring[1],len);
  1227. write(' ',astring);
  1228. inc(i,len);
  1229. end;
  1230. _CCHAR,
  1231. _INTCONST,
  1232. _REALNUMBER :
  1233. begin
  1234. write(' ',pshortstring(@tokenbuf[i])^);
  1235. inc(i,tokenbuf[i]+1);
  1236. end;
  1237. _ID :
  1238. begin
  1239. write(' ',pshortstring(@tokenbuf[i])^);
  1240. inc(i,tokenbuf[i]+1);
  1241. end;
  1242. _GENERICSPECIALTOKEN:
  1243. begin
  1244. { Short version of column change,
  1245. byte or $80 used }
  1246. if (tokenbuf[i] and $80)<>0 then
  1247. begin
  1248. write('Col: ',tokenbuf[i] and $7f);
  1249. inc(i);
  1250. end
  1251. else
  1252. case tspecialgenerictoken(tokenbuf[i]) of
  1253. ST_LOADSETTINGS:
  1254. begin
  1255. inc(i);
  1256. write('Settings');
  1257. { This does not load pmessage pointer }
  1258. new_settings.pmessage:=nil;
  1259. { TSettings size depends in target...
  1260. We first read the size of the copied part }
  1261. { Still not cross endian ready :( }
  1262. copy_size:=gettokenbufsizeint;
  1263. if copy_size < sizeof(tsettings)-sizeof(pointer) then
  1264. min_size:=copy_size
  1265. else
  1266. min_size:= sizeof(tsettings)-sizeof(pointer);
  1267. move(tokenbuf[i],new_settings, min_size);
  1268. inc(i,copy_size);
  1269. end;
  1270. ST_LOADMESSAGES:
  1271. begin
  1272. inc(i);
  1273. write('Messages:');
  1274. mesgnb:=tokenbuf[i];
  1275. inc(i);
  1276. for nb:=1 to mesgnb do
  1277. begin
  1278. msgvalue:=gettokenbufsizeint;
  1279. inc(i,sizeof(sizeint));
  1280. state:=tmsgstate(gettokenbufsizeint);
  1281. end;
  1282. end;
  1283. ST_LINE:
  1284. begin
  1285. inc(i);
  1286. write('Line: ',gettokenbufdword);
  1287. end;
  1288. ST_COLUMN:
  1289. begin
  1290. inc(i);
  1291. write('Col: ',gettokenbufword);
  1292. end;
  1293. ST_FILEINDEX:
  1294. begin
  1295. inc(i);
  1296. write('File: ',gettokenbufword);
  1297. end;
  1298. end;
  1299. end;
  1300. end;
  1301. if i<tokenbufsize then
  1302. write(',');
  1303. end;
  1304. writeln;
  1305. freemem(tokenbuf);
  1306. end;
  1307. if df_specialization in defoptions then
  1308. begin
  1309. write (space,' Orig. GenericDef : ');
  1310. readderef('');
  1311. end;
  1312. current_defoptions:=defoptions;
  1313. end;
  1314. { Read abstract procdef and return if inline procdef }
  1315. { type tproccalloption is in globtype unit }
  1316. { type tproctypeoption is in globtype unit }
  1317. { type tprocoption is in globtype unit }
  1318. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions);
  1319. type
  1320. tproccallopt=record
  1321. mask : tproccalloption;
  1322. str : string[30];
  1323. end;
  1324. tproctypeopt=record
  1325. mask : tproctypeoption;
  1326. str : string[30];
  1327. end;
  1328. tprocopt=record
  1329. mask : tprocoption;
  1330. str : string[31];
  1331. end;
  1332. const
  1333. {proccalloptionStr is also in globtype unit }
  1334. proctypeopt : array[1..ord(high(tproctypeoption))] of tproctypeopt=(
  1335. (mask:potype_proginit; str:'ProgInit'),
  1336. (mask:potype_unitinit; str:'UnitInit'),
  1337. (mask:potype_unitfinalize; str:'UnitFinalize'),
  1338. (mask:potype_constructor; str:'Constructor'),
  1339. (mask:potype_destructor; str:'Destructor'),
  1340. (mask:potype_operator; str:'Operator'),
  1341. (mask:potype_procedure; str:'Procedure'),
  1342. (mask:potype_function; str:'Function'),
  1343. (mask:potype_class_constructor; str:'Class Constructor'),
  1344. (mask:potype_class_destructor; str:'Class Destructor'),
  1345. { Dispinterface property accessors }
  1346. (mask:potype_propgetter; str:'Property Getter'),
  1347. (mask:potype_propsetter; str:'Property Setter'),
  1348. (mask:potype_exceptfilter; str:'SEH filter')
  1349. );
  1350. procopt : array[1..ord(high(tprocoption))] of tprocopt=(
  1351. (mask:po_classmethod; str:'ClassMethod'),
  1352. (mask:po_virtualmethod; str:'VirtualMethod'),
  1353. (mask:po_abstractmethod; str:'AbstractMethod'),
  1354. (mask:po_finalmethod; str:'FinalMethod'),
  1355. (mask:po_staticmethod; str:'StaticMethod'),
  1356. (mask:po_overridingmethod;str:'OverridingMethod'),
  1357. (mask:po_methodpointer; str:'MethodPointer'),
  1358. (mask:po_interrupt; str:'Interrupt'),
  1359. (mask:po_iocheck; str:'IOCheck'),
  1360. (mask:po_assembler; str:'Assembler'),
  1361. (mask:po_msgstr; str:'MsgStr'),
  1362. (mask:po_msgint; str:'MsgInt'),
  1363. (mask:po_exports; str:'Exports'),
  1364. (mask:po_external; str:'External'),
  1365. (mask:po_overload; str:'Overload'),
  1366. (mask:po_varargs; str:'VarArgs'),
  1367. (mask:po_internconst; str:'InternConst'),
  1368. (mask:po_addressonly; str:'AddressOnly'),
  1369. (mask:po_public; str:'Public'),
  1370. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  1371. (mask:po_reintroduce; str:'ReIntroduce'),
  1372. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  1373. (mask:po_nostackframe; str:'NoStackFrame'),
  1374. (mask:po_has_mangledname; str:'HasMangledName'),
  1375. (mask:po_has_public_name; str:'HasPublicName'),
  1376. (mask:po_forward; str:'Forward'),
  1377. (mask:po_global; str:'Global'),
  1378. (mask:po_has_inlininginfo;str:'HasInliningInfo'),
  1379. (mask:po_syscall_legacy; str:'SyscallLegacy'),
  1380. (mask:po_syscall_sysv; str:'SyscallSysV'),
  1381. (mask:po_syscall_basesysv;str:'SyscallBaseSysV'),
  1382. (mask:po_syscall_sysvbase;str:'SyscallSysVBase'),
  1383. (mask:po_syscall_r12base; str:'SyscallR12Base'),
  1384. (mask:po_inline; str:'Inline'),
  1385. (mask:po_compilerproc; str:'CompilerProc'),
  1386. (mask:po_has_importdll; str:'HasImportDLL'),
  1387. (mask:po_has_importname; str:'HasImportName'),
  1388. (mask:po_kylixlocal; str:'KylixLocal'),
  1389. (mask:po_dispid; str:'DispId'),
  1390. (mask:po_weakexternal; str:'WeakExternal'),
  1391. (mask:po_objc; str:'ObjC'),
  1392. (mask:po_enumerator_movenext; str:'EnumeratorMoveNext'),
  1393. (mask:po_optional; str: 'Optional'),
  1394. (mask:po_delphi_nested_cc;str: 'Delphi-style nested frameptr'),
  1395. (mask:po_java_nonvirtual; str: 'Java non-virtual method'),
  1396. (mask:po_ignore_for_overload_resolution;str: 'Ignored for overload resolution'),
  1397. (mask:po_rtlproc; str: 'RTL procedure')
  1398. );
  1399. var
  1400. proctypeoption : tproctypeoption;
  1401. i : longint;
  1402. first : boolean;
  1403. tempbuf : array[0..255] of byte;
  1404. begin
  1405. write(space,' Return type : ');
  1406. readderef('');
  1407. writeln(space,' Fpu used : ',ppufile.getbyte);
  1408. proctypeoption:=tproctypeoption(ppufile.getbyte);
  1409. write(space,' TypeOption : ');
  1410. first:=true;
  1411. for i:=1 to high(proctypeopt) do
  1412. if (proctypeopt[i].mask=proctypeoption) then
  1413. begin
  1414. if first then
  1415. first:=false
  1416. else
  1417. write(', ');
  1418. write(proctypeopt[i].str);
  1419. end;
  1420. writeln;
  1421. proccalloption:=tproccalloption(ppufile.getbyte);
  1422. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  1423. ppufile.getnormalset(procoptions);
  1424. if procoptions<>[] then
  1425. begin
  1426. write(space,' Options : ');
  1427. first:=true;
  1428. for i:=1 to high(procopt) do
  1429. if (procopt[i].mask in procoptions) then
  1430. begin
  1431. if first then
  1432. first:=false
  1433. else
  1434. write(', ');
  1435. write(procopt[i].str);
  1436. end;
  1437. writeln;
  1438. end;
  1439. if (po_explicitparaloc in procoptions) then
  1440. begin
  1441. i:=ppufile.getbyte;
  1442. ppufile.getdata(tempbuf,i);
  1443. end;
  1444. end;
  1445. { type tvaroption is in unit symconst }
  1446. { register variable }
  1447. { type tvarregable is in unit symconst }
  1448. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions);
  1449. type
  1450. tvaropt=record
  1451. mask : tvaroption;
  1452. str : string[30];
  1453. end;
  1454. const
  1455. varopt : array[1..ord(high(tvaroption))] of tvaropt=(
  1456. (mask:vo_is_external; str:'External'),
  1457. (mask:vo_is_dll_var; str:'DLLVar'),
  1458. (mask:vo_is_thread_var; str:'ThreadVar'),
  1459. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  1460. (mask:vo_is_const; str:'Constant'),
  1461. (mask:vo_is_public; str:'Public'),
  1462. (mask:vo_is_high_para; str:'HighValue'),
  1463. (mask:vo_is_funcret; str:'Funcret'),
  1464. (mask:vo_is_self; str:'Self'),
  1465. (mask:vo_is_vmt; str:'VMT'),
  1466. (mask:vo_is_result; str:'Result'),
  1467. (mask:vo_is_parentfp; str:'ParentFP'),
  1468. (mask:vo_is_loop_counter; str:'LoopCounter'),
  1469. (mask:vo_is_hidden_para; str:'Hidden'),
  1470. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  1471. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  1472. (mask:vo_has_mangledname; str:'HasMangledName'),
  1473. (mask:vo_is_typed_const; str:'TypedConst'),
  1474. (mask:vo_is_range_check; str:'RangeCheckSwitch'),
  1475. (mask:vo_is_overflow_check; str:'OverflowCheckSwitch'),
  1476. (mask:vo_is_typinfo_para; str:'TypeInfo'),
  1477. (mask:vo_is_msgsel;str:'MsgSel'),
  1478. (mask:vo_is_weak_external;str:'WeakExternal'),
  1479. (mask:vo_is_first_field;str:'IsFirstField'),
  1480. (mask:vo_volatile;str:'Volatile'),
  1481. (mask:vo_has_section;str:'HasSection'),
  1482. (mask:vo_force_finalize;str:'ForceFinalize'),
  1483. (mask:vo_is_default_var;str:'DefaultIntrinsicVar')
  1484. );
  1485. var
  1486. i : longint;
  1487. first : boolean;
  1488. begin
  1489. readcommonsym(s);
  1490. writeln(space,' Spez : ',Varspez2Str(ppufile.getbyte));
  1491. writeln(space,' Regable : ',Varregable2Str(ppufile.getbyte));
  1492. writeln(space,' Addr Taken : ',(ppufile.getbyte<>0));
  1493. write (space,' Var Type : ');
  1494. readderef('');
  1495. ppufile.getsmallset(varoptions);
  1496. if varoptions<>[] then
  1497. begin
  1498. write(space,' Options : ');
  1499. first:=true;
  1500. for i:=1 to high(varopt) do
  1501. if (varopt[i].mask in varoptions) then
  1502. begin
  1503. if first then
  1504. first:=false
  1505. else
  1506. write(', ');
  1507. write(varopt[i].str);
  1508. if varopt[i].mask = vo_has_section then
  1509. writeln('Section name:',ppufile.getansistring);
  1510. end;
  1511. writeln;
  1512. end;
  1513. end;
  1514. procedure readobjectdefoptions;
  1515. type
  1516. tsymopt=record
  1517. mask : tobjectoption;
  1518. str : string[30];
  1519. end;
  1520. const
  1521. symopt : array[1..ord(high(tobjectoption))] of tsymopt=(
  1522. (mask:oo_is_forward; str:'IsForward'),
  1523. (mask:oo_is_abstract; str:'IsAbstract'),
  1524. (mask:oo_is_sealed; str:'IsSealed'),
  1525. (mask:oo_has_virtual; str:'HasVirtual'),
  1526. (mask:oo_has_private; str:'HasPrivate'),
  1527. (mask:oo_has_protected; str:'HasProtected'),
  1528. (mask:oo_has_strictprivate; str:'HasStrictPrivate'),
  1529. (mask:oo_has_strictprotected;str:'HasStrictProtected'),
  1530. (mask:oo_has_constructor; str:'HasConstructor'),
  1531. (mask:oo_has_destructor; str:'HasDestructor'),
  1532. (mask:oo_has_vmt; str:'HasVMT'),
  1533. (mask:oo_has_msgstr; str:'HasMsgStr'),
  1534. (mask:oo_has_msgint; str:'HasMsgInt'),
  1535. (mask:oo_can_have_published; str:'CanHavePublished'),
  1536. (mask:oo_has_default_property;str:'HasDefaultProperty'),
  1537. (mask:oo_has_valid_guid; str:'HasValidGUID'),
  1538. (mask:oo_has_enumerator_movenext; str:'HasEnumeratorMoveNext'),
  1539. (mask:oo_has_enumerator_current; str:'HasEnumeratorCurrent'),
  1540. (mask:oo_is_external; str:'External'),
  1541. (mask:oo_is_formal; str:'Formal'),
  1542. (mask:oo_is_classhelper; str:'Class Helper/Category'),
  1543. (mask:oo_has_class_constructor; str:'HasClassConstructor'),
  1544. (mask:oo_has_class_destructor; str:'HasClassDestructor'),
  1545. (mask:oo_is_enum_class; str:'JvmEnumClass'),
  1546. (mask:oo_has_new_destructor; str:'HasNewDestructor')
  1547. );
  1548. var
  1549. i : longint;
  1550. first : boolean;
  1551. begin
  1552. ppufile.getsmallset(current_objectoptions);
  1553. if current_objectoptions<>[] then
  1554. begin
  1555. first:=true;
  1556. for i:=1 to high(symopt) do
  1557. if (symopt[i].mask in current_objectoptions) then
  1558. begin
  1559. if first then
  1560. first:=false
  1561. else
  1562. write(', ');
  1563. write(symopt[i].str);
  1564. end;
  1565. end;
  1566. writeln;
  1567. end;
  1568. procedure readarraydefoptions;
  1569. { type tarraydefoption is in unit symconst }
  1570. type
  1571. tsymopt=record
  1572. mask : tarraydefoption;
  1573. str : string[30];
  1574. end;
  1575. const
  1576. symopt : array[1..ord(high(tarraydefoption))] of tsymopt=(
  1577. (mask:ado_IsConvertedPointer;str:'ConvertedPointer'),
  1578. (mask:ado_IsDynamicArray; str:'IsDynamicArray'),
  1579. (mask:ado_IsVariant; str:'IsVariant'),
  1580. (mask:ado_IsConstructor; str:'IsConstructor'),
  1581. (mask:ado_IsArrayOfConst; str:'ArrayOfConst'),
  1582. (mask:ado_IsConstString; str:'ConstString'),
  1583. (mask:ado_IsBitPacked; str:'BitPacked')
  1584. );
  1585. var
  1586. symoptions : tarraydefoptions;
  1587. i : longint;
  1588. first : boolean;
  1589. begin
  1590. ppufile.getsmallset(symoptions);
  1591. if symoptions<>[] then
  1592. begin
  1593. first:=true;
  1594. for i:=1 to high(symopt) do
  1595. if (symopt[i].mask in symoptions) then
  1596. begin
  1597. if first then
  1598. first:=false
  1599. else
  1600. write(', ');
  1601. write(symopt[i].str);
  1602. end;
  1603. end;
  1604. writeln;
  1605. end;
  1606. (* options for properties
  1607. tpropertyoption=(ppo_none,
  1608. ppo_indexed,
  1609. ppo_defaultproperty,
  1610. ppo_stored,
  1611. ppo_hasparameters,
  1612. ppo_implements,
  1613. ppo_enumerator_current,
  1614. ppo_overrides,
  1615. ppo_dispid_write { no longer used }
  1616. );
  1617. tpropertyoptions=set of tpropertyoption;
  1618. *)
  1619. function readpropertyoptions:tpropertyoptions;
  1620. { type tarraydefoption is in unit symconst }
  1621. type
  1622. tpropopt=record
  1623. mask : tpropertyoption;
  1624. str : string[30];
  1625. end;
  1626. const
  1627. symopt : array[1..ord(high(tpropertyoption))] of tpropopt=(
  1628. (mask:ppo_indexed;str:'indexed'),
  1629. (mask:ppo_defaultproperty;str:'default'),
  1630. (mask:ppo_stored;str:'stored'),
  1631. (mask:ppo_hasparameters;str:'has parameters'),
  1632. (mask:ppo_implements;str:'implements'),
  1633. (mask:ppo_enumerator_current;str:'enumerator current'),
  1634. (mask:ppo_overrides;str:'overrides'),
  1635. (mask:ppo_dispid_write;str:'dispid write') { no longer used }
  1636. );
  1637. var
  1638. i : longint;
  1639. first : boolean;
  1640. begin
  1641. ppufile.getsmallset(result);
  1642. if result<>[] then
  1643. begin
  1644. first:=true;
  1645. for i:=1 to high(symopt) do
  1646. if (symopt[i].mask in result) then
  1647. begin
  1648. if first then
  1649. first:=false
  1650. else
  1651. write(', ');
  1652. write(symopt[i].str);
  1653. end;
  1654. end;
  1655. writeln;
  1656. end;
  1657. procedure readnodetree;
  1658. var
  1659. l : longint;
  1660. p : pointer;
  1661. begin
  1662. with ppufile do
  1663. begin
  1664. if space<>'' then
  1665. Writeln(space,'------ nodetree ------');
  1666. if readentry=ibnodetree then
  1667. begin
  1668. l:=entrysize;
  1669. Writeln(space,'Tree size : ',l);
  1670. { Read data to prevent error that entry is not completly read }
  1671. getmem(p,l);
  1672. getdata(p^,l);
  1673. freemem(p);
  1674. end
  1675. else
  1676. begin
  1677. WriteError('!! ibnodetree not found');
  1678. end;
  1679. end;
  1680. end;
  1681. procedure ReadCreatedObjTypes;
  1682. var
  1683. i,j,
  1684. len,
  1685. bssize: longint;
  1686. bs: pbyte;
  1687. begin
  1688. if ppufile.readentry<>ibcreatedobjtypes then
  1689. begin
  1690. writeln('!! ibcreatedobjtypes entry not found');
  1691. ppufile.skipdata(ppufile.entrysize);
  1692. has_errors:=true;
  1693. exit
  1694. end;
  1695. writeln;
  1696. writeln(space,'WPO info');
  1697. writeln(space,'--------');
  1698. len:=ppufile.getlongint;
  1699. writeln(space,'** Instantiated Object/Class types: ',len,' **');
  1700. space:=space+' ';
  1701. for i:=0 to len-1 do
  1702. readderef(space);
  1703. setlength(space,length(space)-2);
  1704. len:=ppufile.getlongint;
  1705. writeln(space,'** Instantiated ClassRef 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,'** Possibly 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,'** Class types with called virtual methods info : ',len,' **');
  1718. space:=space+' ';
  1719. for i:=0 to len-1 do
  1720. begin
  1721. write(space,'Class def : ');
  1722. readderef('');
  1723. write(space+' ','Called vmtentries : ');
  1724. bssize:=ppufile.getlongint;
  1725. getmem(bs,bssize);
  1726. ppufile.readdata(bs^,bssize);
  1727. for j:=0 to bssize*8-1 do
  1728. if (((bs+j shr 3)^ shr (j and 7)) and 1) <> 0 then
  1729. write(j,', ');
  1730. writeln;
  1731. freemem(bs);
  1732. end;
  1733. setlength(space,length(space)-2);
  1734. end;
  1735. {****************************************************************************
  1736. Read Symbols Part
  1737. ****************************************************************************}
  1738. procedure readsymbols(const s:string);
  1739. type
  1740. pguid = ^tguid;
  1741. tguid = packed record
  1742. D1: LongWord;
  1743. D2: Word;
  1744. D3: Word;
  1745. D4: array[0..7] of Byte;
  1746. end;
  1747. var
  1748. b : byte;
  1749. pc : pchar;
  1750. ch : dword;
  1751. startnewline : boolean;
  1752. i,j,len : longint;
  1753. prettyname : ansistring;
  1754. guid : tguid;
  1755. realvalue : ppureal;
  1756. doublevalue : double;
  1757. singlevalue : single;
  1758. extended : TSplit80bitReal;
  1759. tempbuf : array[0..127] of char;
  1760. pw : pcompilerwidestring;
  1761. varoptions : tvaroptions;
  1762. propoptions : tpropertyoptions;
  1763. begin
  1764. with ppufile do
  1765. begin
  1766. if space<>'' then
  1767. Writeln(space,'------ ',s,' ------');
  1768. if readentry=ibstartsyms then
  1769. begin
  1770. Writeln(space,'Symtable datasize : ',getlongint);
  1771. Writeln(space,'Symtable alignment: ',getlongint);
  1772. end
  1773. else
  1774. Writeln('!! ibstartsym not found');
  1775. repeat
  1776. b:=readentry;
  1777. case b of
  1778. ibunitsym :
  1779. readcommonsym('Unit symbol ');
  1780. ibnamespacesym :
  1781. begin
  1782. readcommonsym('NameSpace symbol ');
  1783. write(space,' Hidden Unit : ');
  1784. readderef('');
  1785. end;
  1786. iblabelsym :
  1787. readcommonsym('Label symbol ');
  1788. ibtypesym :
  1789. begin
  1790. readcommonsym('Type symbol ');
  1791. write(space,' Result Type : ');
  1792. readderef('');
  1793. prettyname:=getansistring;
  1794. if prettyname<>'' then
  1795. begin
  1796. write(space,' Pretty Name : ');
  1797. Writeln(prettyname);
  1798. end;
  1799. end;
  1800. ibprocsym :
  1801. begin
  1802. readcommonsym('Procedure symbol ');
  1803. len:=ppufile.getword;
  1804. for i:=1 to len do
  1805. begin
  1806. write(space,' Definition : ');
  1807. readderef('');
  1808. end;
  1809. end;
  1810. ibconstsym :
  1811. begin
  1812. readcommonsym('Constant symbol ');
  1813. b:=getbyte;
  1814. case tconsttyp(b) of
  1815. constord :
  1816. begin
  1817. write (space,' OrdinalType : ');
  1818. readderef('');
  1819. writeln(space,' Value : ',constexp.tostr(getexprint));
  1820. end;
  1821. constpointer :
  1822. begin
  1823. write (space,' PointerType : ');
  1824. readderef('');
  1825. writeln(space,' Value : ',getaint)
  1826. end;
  1827. conststring,
  1828. constresourcestring :
  1829. begin
  1830. len:=getlongint;
  1831. getmem(pc,len+1);
  1832. getdata(pc^,len);
  1833. (pc+len)^:= #0;
  1834. writeln(space,' Length : ',len);
  1835. writeln(space,' Value : "',pc,'"');
  1836. freemem(pc,len+1);
  1837. end;
  1838. constreal :
  1839. begin
  1840. write(space,' Value : ');
  1841. if entryleft=sizeof(ppureal) then
  1842. begin
  1843. realvalue:=getrealsize(sizeof(ppureal));
  1844. writeln(realvalue);
  1845. end
  1846. else if entryleft=sizeof(double) then
  1847. begin
  1848. doublevalue:=getrealsize(sizeof(double));
  1849. writeln(doublevalue);
  1850. end
  1851. else if entryleft=sizeof(single) then
  1852. begin
  1853. singlevalue:=getrealsize(sizeof(single));
  1854. writeln(singlevalue);
  1855. end
  1856. else if entryleft=10 then
  1857. begin
  1858. getdata(extended,entryleft);
  1859. writeln(Real80bitToStr(extended));
  1860. end
  1861. else
  1862. begin
  1863. realvalue:=0.0;
  1864. writeln(realvalue,' Error reading real value');
  1865. has_errors:=true;
  1866. end;
  1867. end;
  1868. constset :
  1869. begin
  1870. write (space,' Set Type : ');
  1871. readderef('');
  1872. for i:=1to 4 do
  1873. begin
  1874. write (space,' Value : ');
  1875. for j:=1to 8 do
  1876. begin
  1877. if j>1 then
  1878. write(',');
  1879. write(hexstr(getbyte,2));
  1880. end;
  1881. writeln;
  1882. end;
  1883. end;
  1884. constnil:
  1885. writeln(space,' NIL pointer.');
  1886. constwstring :
  1887. begin
  1888. initwidestring(pw);
  1889. setlengthwidestring(pw,getlongint);
  1890. if widecharsize=2 then
  1891. { don't use getdata, because the compilerwidechars may have to
  1892. be byteswapped
  1893. }
  1894. begin
  1895. for i:=0 to pw^.len-1 do
  1896. pw^.data[i]:=ppufile.getword;
  1897. end
  1898. else if widecharsize=4 then
  1899. begin
  1900. for i:=0 to pw^.len-1 do
  1901. pw^.data[i]:=cardinal(ppufile.getlongint);
  1902. end
  1903. else
  1904. begin
  1905. WriteError('Unsupported tcompilerwidechar size');
  1906. end;
  1907. Writeln(space,'Wide string type');
  1908. startnewline:=true;
  1909. for i:=0 to pw^.len-1 do
  1910. begin
  1911. if startnewline then
  1912. begin
  1913. write(space);
  1914. startnewline:=false;
  1915. end;
  1916. ch:=pw^.data[i];
  1917. if widecharsize=2 then
  1918. write(hexstr(ch,4))
  1919. else
  1920. write(hexstr(ch,8));
  1921. if (i mod 8)= 0 then
  1922. startnewline:=true
  1923. else
  1924. write(', ');
  1925. end;
  1926. donewidestring(pw);
  1927. end;
  1928. constguid:
  1929. begin
  1930. getdata(guid,sizeof(guid));
  1931. write (space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-');
  1932. for i:=0 to 7 do
  1933. begin
  1934. write(hexstr(guid.d4[i],2));
  1935. if i=1 then write('-');
  1936. end;
  1937. writeln('}');
  1938. end
  1939. else
  1940. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  1941. end;
  1942. end;
  1943. ibabsolutevarsym :
  1944. begin
  1945. readabstractvarsym('Absolute variable symbol ',varoptions);
  1946. Write (space,' Relocated to ');
  1947. b:=getbyte;
  1948. case absolutetyp(b) of
  1949. tovar :
  1950. readpropaccesslist(space+' Sym : ');
  1951. toasm :
  1952. Writeln('Assembler name : ',getstring);
  1953. toaddr :
  1954. begin
  1955. Write('Address : ',getlongint);
  1956. if tsystemcpu(ppufile.header.cpu)=cpu_i386 then
  1957. WriteLn(' (Far: ',getbyte<>0,')');
  1958. end;
  1959. else
  1960. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  1961. end;
  1962. end;
  1963. ibfieldvarsym :
  1964. begin
  1965. readabstractvarsym('Field Variable symbol ',varoptions);
  1966. writeln(space,' Address : ',getaint);
  1967. end;
  1968. ibstaticvarsym :
  1969. begin
  1970. readabstractvarsym('Global Variable symbol ',varoptions);
  1971. write (space,' DefaultConst : ');
  1972. readderef('');
  1973. if (vo_has_mangledname in varoptions) then
  1974. {$ifdef symansistr}
  1975. writeln(space,' Mangledname : ',getansistring);
  1976. {$else symansistr}
  1977. writeln(space,' Mangledname : ',getstring);
  1978. {$endif symansistr}
  1979. end;
  1980. iblocalvarsym :
  1981. begin
  1982. readabstractvarsym('Local Variable symbol ',varoptions);
  1983. write (space,' DefaultConst : ');
  1984. readderef('');
  1985. end;
  1986. ibparavarsym :
  1987. begin
  1988. readabstractvarsym('Parameter Variable symbol ',varoptions);
  1989. write (space,' DefaultConst : ');
  1990. readderef('');
  1991. writeln(space,' ParaNr : ',getword);
  1992. writeln(space,' Univ : ',boolean(getbyte));
  1993. writeln(space,' VarState : ',getbyte);
  1994. if (vo_has_explicit_paraloc in varoptions) then
  1995. begin
  1996. i:=getbyte;
  1997. getdata(tempbuf,i);
  1998. end;
  1999. end;
  2000. ibenumsym :
  2001. begin
  2002. readcommonsym('Enumeration symbol ');
  2003. write (space,' Definition : ');
  2004. readderef('');
  2005. writeln(space,' Value : ',getlongint);
  2006. end;
  2007. ibsyssym :
  2008. begin
  2009. readcommonsym('Internal system symbol ');
  2010. writeln(space,' Internal Nr : ',getlongint);
  2011. end;
  2012. ibmacrosym :
  2013. begin
  2014. readcommonsym('Macro symbol ');
  2015. writeln(space,' Name: ',getstring);
  2016. writeln(space,' Defined: ',getbyte);
  2017. writeln(space,' Compiler var: ',getbyte);
  2018. len:=getlongint;
  2019. writeln(space,' Value length: ',len);
  2020. if len > 0 then
  2021. begin
  2022. getmem(pc,len+1);
  2023. getdata(pc^,len);
  2024. (pc+len)^:= #0;
  2025. writeln(space,' Value: "',pc,'"');
  2026. freemem(pc,len+1);
  2027. end;
  2028. end;
  2029. ibpropertysym :
  2030. begin
  2031. readcommonsym('Property ');
  2032. propoptions:=readpropertyoptions;
  2033. if ppo_overrides in propoptions then
  2034. begin
  2035. write (space,' OverrideProp : ');
  2036. readderef('');
  2037. end;
  2038. write (space,' Prop Type : ');
  2039. readderef('');
  2040. writeln(space,' Index : ',getlongint);
  2041. writeln(space,' Default : ',getlongint);
  2042. write (space,' Index Type : ');
  2043. readderef('');
  2044. { palt_none }
  2045. readpropaccesslist('');
  2046. write (space,' Readaccess : ');
  2047. readpropaccesslist(space+' Sym: ');
  2048. write (space,' Writeaccess : ');
  2049. readpropaccesslist(space+' Sym: ');
  2050. write (space,' Storedaccess : ');
  2051. readpropaccesslist(space+' Sym: ');
  2052. if [ppo_hasparameters,ppo_overrides]*propoptions=[ppo_hasparameters] then
  2053. begin
  2054. space:=' '+space;
  2055. readsymtable('parast');
  2056. delete(space,1,4);
  2057. end;
  2058. end;
  2059. iberror :
  2060. begin
  2061. WriteError('!! Error in PPU');
  2062. exit;
  2063. end;
  2064. ibendsyms :
  2065. break;
  2066. else
  2067. begin
  2068. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  2069. has_errors:=true;
  2070. end;
  2071. end;
  2072. if not EndOfEntry then
  2073. HasMoreInfos;
  2074. until false;
  2075. end;
  2076. end;
  2077. {****************************************************************************
  2078. Read defintions Part
  2079. ****************************************************************************}
  2080. procedure readdefinitions(const s:string);
  2081. { type tordtype is in symconst unit }
  2082. {
  2083. uvoid,
  2084. u8bit,u16bit,u32bit,u64bit,
  2085. s8bit,s16bit,s32bit,s64bit,
  2086. bool8bit,bool16bit,bool32bit,bool64bit,
  2087. uchar,uwidechar,scurrency
  2088. ); }
  2089. { type tobjecttyp is in symconst unit }
  2090. { type tvarianttype is in symconst unit }
  2091. var
  2092. b : byte;
  2093. l,j : longint;
  2094. calloption : tproccalloption;
  2095. procoptions : tprocoptions;
  2096. defoptions: tdefoptions;
  2097. begin
  2098. with ppufile do
  2099. begin
  2100. if space<>'' then
  2101. Writeln(space,'------ ',s,' ------');
  2102. if readentry<>ibstartdefs then
  2103. Writeln('!! ibstartdefs not found');
  2104. repeat
  2105. b:=readentry;
  2106. case b of
  2107. ibpointerdef :
  2108. begin
  2109. readcommondef('Pointer definition',defoptions);
  2110. write (space,' Pointed Type : ');
  2111. readderef('');
  2112. writeln(space,' Is Far : ',(getbyte<>0));
  2113. writeln(space,' Has Pointer Math : ',(getbyte<>0));
  2114. end;
  2115. iborddef :
  2116. begin
  2117. readcommondef('Ordinal definition',defoptions);
  2118. write (space,' Base type : ');
  2119. b:=getbyte;
  2120. case tordtype(b) of
  2121. uvoid : writeln('uvoid');
  2122. u8bit : writeln('u8bit');
  2123. u16bit : writeln('u16bit');
  2124. u32bit : writeln('s32bit');
  2125. u64bit : writeln('u64bit');
  2126. s8bit : writeln('s8bit');
  2127. s16bit : writeln('s16bit');
  2128. s32bit : writeln('s32bit');
  2129. s64bit : writeln('s64bit');
  2130. bool8bit : writeln('bool8bit');
  2131. bool16bit : writeln('bool16bit');
  2132. bool32bit : writeln('bool32bit');
  2133. bool64bit : writeln('bool64bit');
  2134. uchar : writeln('uchar');
  2135. uwidechar : writeln('uwidechar');
  2136. scurrency : writeln('ucurrency');
  2137. else writeln('!! Warning: Invalid base type ',b);
  2138. end;
  2139. writeln(space,' Range : ',constexp.tostr(getexprint),' to ',constexp.tostr(getexprint));
  2140. end;
  2141. ibfloatdef :
  2142. begin
  2143. readcommondef('Float definition',defoptions);
  2144. writeln(space,' Float type : ',getbyte);
  2145. end;
  2146. ibarraydef :
  2147. begin
  2148. readcommondef('Array definition',defoptions);
  2149. write (space,' Element type : ');
  2150. readderef('');
  2151. write (space,' Range Type : ');
  2152. readderef('');
  2153. writeln(space,' Range : ',getaint,' to ',getaint);
  2154. write (space,' Options : ');
  2155. readarraydefoptions;
  2156. readsymtable('symbols');
  2157. end;
  2158. ibprocdef :
  2159. begin
  2160. readcommondef('Procedure definition',defoptions);
  2161. read_abstract_proc_def(calloption,procoptions);
  2162. if (po_has_mangledname in procoptions) then
  2163. {$ifdef symansistr}
  2164. writeln(space,' Mangled name : ',getansistring);
  2165. {$else symansistr}
  2166. writeln(space,' Mangled name : ',getstring);
  2167. {$endif symansistr}
  2168. writeln(space,' Number : ',getword);
  2169. writeln(space,' Level : ',getbyte);
  2170. write (space,' Class : ');
  2171. readderef('');
  2172. write (space,' Procsym : ');
  2173. readderef('');
  2174. write (space,' File Pos : ');
  2175. readposinfo;
  2176. writeln(space,' Visibility : ',Visibility2Str(ppufile.getbyte));
  2177. write (space,' SymOptions : ');
  2178. readsymoptions(space+' ');
  2179. if tsystemcpu(ppufile.header.cpu)=cpu_powerpc then
  2180. begin
  2181. { library symbol for AmigaOS/MorphOS }
  2182. write (space,' Library symbol : ');
  2183. readderef('');
  2184. end;
  2185. if (po_has_importdll in procoptions) then
  2186. writeln(space,' Import DLL : ',getstring);
  2187. if (po_has_importname in procoptions) then
  2188. writeln(space,' Import Name : ',getstring);
  2189. writeln(space,' Import Nr : ',getword);
  2190. if (po_msgint in procoptions) then
  2191. writeln(space,' MsgInt : ',getlongint);
  2192. if (po_msgstr in procoptions) then
  2193. writeln(space,' MsgStr : ',getstring);
  2194. if (po_dispid in procoptions) then
  2195. writeln(space,' DispID: ',ppufile.getlongint);
  2196. if (po_has_inlininginfo in procoptions) then
  2197. begin
  2198. write (space,' FuncretSym : ');
  2199. readderef('');
  2200. readprocinfooptions(space);
  2201. end;
  2202. b:=ppufile.getbyte;
  2203. if b<>0 then
  2204. begin
  2205. write (space,' Alias names : ');
  2206. for j:=1 to b do
  2207. begin
  2208. write(ppufile.getstring);
  2209. if j<b then
  2210. write(', ');
  2211. end;
  2212. writeln;
  2213. end;
  2214. if not EndOfEntry then
  2215. HasMoreInfos;
  2216. space:=' '+space;
  2217. { parast }
  2218. readsymtable('parast');
  2219. { localst }
  2220. if (po_has_inlininginfo in procoptions) then
  2221. readsymtable('localst');
  2222. if (po_has_inlininginfo in procoptions) then
  2223. readnodetree;
  2224. delete(space,1,4);
  2225. end;
  2226. ibprocvardef :
  2227. begin
  2228. readcommondef('Procedural type (ProcVar) definition',defoptions);
  2229. read_abstract_proc_def(calloption,procoptions);
  2230. writeln(space,' Symtable level :',ppufile.getbyte);
  2231. if not EndOfEntry then
  2232. HasMoreInfos;
  2233. space:=' '+space;
  2234. { parast }
  2235. readsymtable('parast');
  2236. delete(space,1,4);
  2237. end;
  2238. ibshortstringdef :
  2239. begin
  2240. readcommondef('ShortString definition',defoptions);
  2241. writeln(space,' Length : ',getbyte);
  2242. end;
  2243. ibwidestringdef :
  2244. begin
  2245. readcommondef('WideString definition',defoptions);
  2246. writeln(space,' Length : ',getaint);
  2247. end;
  2248. ibunicodestringdef :
  2249. begin
  2250. readcommondef('UnicodeString definition',defoptions);
  2251. writeln(space,' Length : ',getaint);
  2252. end;
  2253. ibansistringdef :
  2254. begin
  2255. readcommondef('AnsiString definition',defoptions);
  2256. writeln(space,' Length : ',getaint);
  2257. end;
  2258. iblongstringdef :
  2259. begin
  2260. readcommondef('Longstring definition',defoptions);
  2261. writeln(space,' Length : ',getaint);
  2262. end;
  2263. ibrecorddef :
  2264. begin
  2265. readcommondef('Record definition',defoptions);
  2266. writeln(space,' Name of Record : ',getstring);
  2267. writeln(space,' Import lib/pkg : ',getstring);
  2268. write (space,' Options : ');
  2269. readobjectdefoptions;
  2270. if (df_copied_def in defoptions) then
  2271. begin
  2272. write(space,' Copied from : ');
  2273. readderef('');
  2274. end
  2275. else
  2276. begin
  2277. writeln(space,' FieldAlign : ',shortint(getbyte));
  2278. writeln(space,' RecordAlign : ',shortint(getbyte));
  2279. writeln(space,' PadAlign : ',shortint(getbyte));
  2280. writeln(space,'UseFieldAlignment : ',shortint(getbyte));
  2281. writeln(space,' DataSize : ',getasizeint);
  2282. writeln(space,' PaddingSize : ',getword);
  2283. end;
  2284. if not EndOfEntry then
  2285. HasMoreInfos;
  2286. {read the record definitions and symbols}
  2287. if not(df_copied_def in current_defoptions) then
  2288. begin
  2289. space:=' '+space;
  2290. readrecsymtableoptions;
  2291. readsymtable('fields');
  2292. Delete(space,1,4);
  2293. end;
  2294. end;
  2295. ibobjectdef :
  2296. begin
  2297. readcommondef('Object/Class definition',defoptions);
  2298. writeln(space,' Name of Class : ',getstring);
  2299. writeln(space,' Import lib/pkg : ',getstring);
  2300. write (space,' Options : ');
  2301. readobjectdefoptions;
  2302. b:=getbyte;
  2303. write (space,' Type : ');
  2304. case tobjecttyp(b) of
  2305. odt_class : writeln('class');
  2306. odt_object : writeln('object');
  2307. odt_interfacecom : writeln('interfacecom');
  2308. odt_interfacecorba : writeln('interfacecorba');
  2309. odt_cppclass : writeln('cppclass');
  2310. odt_dispinterface : writeln('dispinterface');
  2311. odt_objcclass : writeln('objcclass');
  2312. odt_objcprotocol : writeln('objcprotocol');
  2313. odt_helper : writeln('helper');
  2314. odt_objccategory : writeln('objccategory');
  2315. odt_javaclass : writeln('Java class');
  2316. odt_interfacejava : writeln('Java interface');
  2317. else writeln('!! Warning: Invalid object type ',b);
  2318. end;
  2319. writeln(space,' External name : ',getstring);
  2320. writeln(space,' DataSize : ',getasizeint);
  2321. writeln(space,' PaddingSize : ',getword);
  2322. writeln(space,' FieldAlign : ',shortint(getbyte));
  2323. writeln(space,' RecordAlign : ',shortint(getbyte));
  2324. writeln(space,' Vmt offset : ',getlongint);
  2325. write (space, ' Ancestor Class : ');
  2326. readderef('');
  2327. if tobjecttyp(b) in [odt_interfacecom,odt_interfacecorba,odt_dispinterface] then
  2328. begin
  2329. { IIDGUID }
  2330. for j:=1to 16 do
  2331. getbyte;
  2332. writeln(space,' IID String : ',getstring);
  2333. end;
  2334. writeln(space,' Abstract methods : ',getlongint);
  2335. if (tobjecttyp(b)=odt_helper) or
  2336. (oo_is_classhelper in current_objectoptions) then
  2337. begin
  2338. write(space,' Helper parent : ');
  2339. readderef('');
  2340. end;
  2341. l:=getlongint;
  2342. writeln(space,' VMT entries: ',l);
  2343. for j:=1 to l do
  2344. begin
  2345. write(space,' ');
  2346. readderef('');
  2347. writeln(space,' Visibility: ',Visibility2Str(getbyte));
  2348. end;
  2349. if tobjecttyp(b) in [odt_class,odt_interfacecorba,odt_objcclass,odt_objcprotocol,odt_javaclass,odt_interfacejava] then
  2350. begin
  2351. l:=getlongint;
  2352. writeln(space,' Impl Intf Count : ',l);
  2353. for j:=1 to l do
  2354. begin
  2355. write (space,' - Definition : ');
  2356. readderef('');
  2357. writeln(space,' IOffset : ',getlongint);
  2358. end;
  2359. end;
  2360. if df_copied_def in current_defoptions then
  2361. begin
  2362. writeln(' Copy of def: ');
  2363. readderef('');
  2364. end;
  2365. if not EndOfEntry then
  2366. HasMoreInfos;
  2367. if not(df_copied_def in current_defoptions) then
  2368. begin
  2369. {read the record definitions and symbols}
  2370. space:=' '+space;
  2371. readrecsymtableoptions;
  2372. readsymtable('fields');
  2373. Delete(space,1,4);
  2374. end;
  2375. end;
  2376. ibfiledef :
  2377. begin
  2378. ReadCommonDef('File definition',defoptions);
  2379. write (space,' Type : ');
  2380. case getbyte of
  2381. 0 : writeln('Text');
  2382. 1 : begin
  2383. writeln('Typed');
  2384. write (space,' File of Type : ');
  2385. readderef('');
  2386. end;
  2387. 2 : writeln('Untyped');
  2388. end;
  2389. end;
  2390. ibformaldef :
  2391. begin
  2392. readcommondef('Generic definition (void-typ)',defoptions);
  2393. writeln(space,' Is Typed : ',(getbyte<>0));
  2394. end;
  2395. ibundefineddef :
  2396. readcommondef('Undefined definition (generic parameter)',defoptions);
  2397. ibenumdef :
  2398. begin
  2399. readcommondef('Enumeration type definition',defoptions);
  2400. writeln(space,' Smallest element : ',getaint);
  2401. writeln(space,' Largest element : ',getaint);
  2402. writeln(space,' Size : ',getaint);
  2403. {$ifdef jvm}
  2404. write(space,' Class def : ');
  2405. readderef('');
  2406. {$endif}
  2407. if df_copied_def in defoptions then
  2408. begin
  2409. write(space,'Base enumeration type : ');
  2410. readderef('');
  2411. end
  2412. else
  2413. begin
  2414. space:=' '+space;
  2415. readsymtable('elements');
  2416. delete(space,1,4);
  2417. end;
  2418. end;
  2419. ibclassrefdef :
  2420. begin
  2421. readcommondef('Class reference definition',defoptions);
  2422. write (space,' Pointed Type : ');
  2423. readderef('');
  2424. end;
  2425. ibsetdef :
  2426. begin
  2427. readcommondef('Set definition',defoptions);
  2428. write (space,' Element type : ');
  2429. readderef('');
  2430. writeln(space,' Size : ',getaint);
  2431. writeln(space,' Set Base : ',getaint);
  2432. writeln(space,' Set Max : ',getaint);
  2433. end;
  2434. ibvariantdef :
  2435. begin
  2436. readcommondef('Variant definition',defoptions);
  2437. write (space,' Varianttype : ');
  2438. b:=getbyte;
  2439. case tvarianttype(b) of
  2440. vt_normalvariant :
  2441. writeln('Normal');
  2442. vt_olevariant :
  2443. writeln('OLE');
  2444. else
  2445. writeln('!! Warning: Invalid varianttype ',b);
  2446. end;
  2447. end;
  2448. iberror :
  2449. begin
  2450. WriteError('!! Error in PPU');
  2451. exit;
  2452. end;
  2453. ibenddefs :
  2454. break;
  2455. else
  2456. begin
  2457. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  2458. has_errors:=true;
  2459. end;
  2460. end;
  2461. if not EndOfEntry then
  2462. HasMoreInfos;
  2463. until false;
  2464. end;
  2465. end;
  2466. procedure readmoduleoptions(space : string);
  2467. type
  2468. { tmoduleoption type is in unit fmodule }
  2469. tmoduleoption = (mo_none,
  2470. mo_hint_deprecated,
  2471. mo_hint_platform,
  2472. mo_hint_library,
  2473. mo_hint_unimplemented,
  2474. mo_hint_experimental,
  2475. mo_has_deprecated_msg
  2476. );
  2477. tmoduleoptions = set of tmoduleoption;
  2478. tmoduleopt=record
  2479. mask : tmoduleoption;
  2480. str : string[30];
  2481. end;
  2482. const
  2483. moduleopts=ord(high(tmoduleoption));
  2484. moduleopt : array[1..moduleopts] of tmoduleopt=(
  2485. (mask:mo_hint_deprecated; str:'Hint Deprecated'),
  2486. (mask:mo_hint_platform; str:'Hint Platform'),
  2487. (mask:mo_hint_library; str:'Hint Library'),
  2488. (mask:mo_hint_unimplemented; str:'Hint Unimplemented'),
  2489. (mask:mo_hint_experimental; str:'Hint Experimental'),
  2490. (mask:mo_has_deprecated_msg; str:'Has Deprecated Message')
  2491. );
  2492. var
  2493. moduleoptions : tmoduleoptions;
  2494. i : longint;
  2495. first : boolean;
  2496. begin
  2497. ppufile.getsmallset(moduleoptions);
  2498. if moduleoptions<>[] then
  2499. begin
  2500. first:=true;
  2501. for i:=1to moduleopts do
  2502. if (moduleopt[i].mask in moduleoptions) then
  2503. begin
  2504. if first then
  2505. first:=false
  2506. else
  2507. write(', ');
  2508. write(moduleopt[i].str);
  2509. end;
  2510. end;
  2511. writeln;
  2512. if mo_has_deprecated_msg in moduleoptions then
  2513. writeln(space,'Deprecated : ', ppufile.getstring);
  2514. end;
  2515. {****************************************************************************
  2516. Read General Part
  2517. ****************************************************************************}
  2518. procedure readinterface;
  2519. var
  2520. b : byte;
  2521. sourcenumber : longint;
  2522. begin
  2523. with ppufile do
  2524. begin
  2525. repeat
  2526. b:=readentry;
  2527. case b of
  2528. ibmodulename :
  2529. Writeln('Module Name: ',getstring);
  2530. ibmoduleoptions:
  2531. readmoduleoptions(' ');
  2532. ibsourcefiles :
  2533. begin
  2534. sourcenumber:=1;
  2535. while not EndOfEntry do
  2536. begin
  2537. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  2538. inc(sourcenumber);
  2539. end;
  2540. end;
  2541. {$IFDEF MACRO_DIFF_HINT}
  2542. ibusedmacros :
  2543. begin
  2544. while not EndOfEntry do
  2545. begin
  2546. Write('Conditional ',getstring);
  2547. b:=getbyte;
  2548. if boolean(b)=true then
  2549. write(' defined at startup')
  2550. else
  2551. write(' not defined at startup');
  2552. b:=getbyte;
  2553. if boolean(b)=true then
  2554. writeln(' was used')
  2555. else
  2556. writeln;
  2557. end;
  2558. end;
  2559. {$ENDIF}
  2560. ibloadunit :
  2561. ReadLoadUnit;
  2562. iblinkunitofiles :
  2563. ReadLinkContainer('Link unit object file: ');
  2564. iblinkunitstaticlibs :
  2565. ReadLinkContainer('Link unit static lib: ');
  2566. iblinkunitsharedlibs :
  2567. ReadLinkContainer('Link unit shared lib: ');
  2568. iblinkotherofiles :
  2569. ReadLinkContainer('Link other object file: ');
  2570. iblinkotherstaticlibs :
  2571. ReadLinkContainer('Link other static lib: ');
  2572. iblinkothersharedlibs :
  2573. ReadLinkContainer('Link other shared lib: ');
  2574. iblinkotherframeworks:
  2575. ReadLinkContainer('Link framework: ');
  2576. ibmainname:
  2577. Writeln('Specified main program symbol name: ',getstring);
  2578. ibImportSymbols :
  2579. ReadImportSymbols;
  2580. ibderefdata :
  2581. ReadDerefData;
  2582. ibderefmap :
  2583. ReadDerefMap;
  2584. ibwpofile :
  2585. ReadWpoFileInfo;
  2586. ibresources :
  2587. ReadLinkContainer('Resource file: ');
  2588. iberror :
  2589. begin
  2590. WriteError('Error in PPU');
  2591. exit;
  2592. end;
  2593. ibendinterface :
  2594. break;
  2595. else
  2596. begin
  2597. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  2598. has_errors:=true;
  2599. end;
  2600. end;
  2601. until false;
  2602. end;
  2603. end;
  2604. {****************************************************************************
  2605. Read Implementation Part
  2606. ****************************************************************************}
  2607. procedure readimplementation;
  2608. var
  2609. b : byte;
  2610. begin
  2611. with ppufile do
  2612. begin
  2613. repeat
  2614. b:=readentry;
  2615. case b of
  2616. ibasmsymbols :
  2617. ReadAsmSymbols;
  2618. ibloadunit :
  2619. ReadLoadUnit;
  2620. iberror :
  2621. begin
  2622. WriteError('Error in PPU');
  2623. exit;
  2624. end;
  2625. ibendimplementation :
  2626. break;
  2627. else
  2628. begin
  2629. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  2630. has_errors:=true;
  2631. end;
  2632. end;
  2633. until false;
  2634. end;
  2635. end;
  2636. procedure dofile (filename : string);
  2637. begin
  2638. { reset }
  2639. space:='';
  2640. { fix filename }
  2641. if pos('.',filename)=0 then
  2642. filename:=filename+'.ppu';
  2643. ppufile:=tppufile.create(filename);
  2644. if not ppufile.openfile then
  2645. begin
  2646. WriteError('IO-Error when opening : '+filename+', Skipping');
  2647. exit;
  2648. end;
  2649. { PPU File is open, check for PPU Id }
  2650. if not ppufile.CheckPPUID then
  2651. begin
  2652. writeln(Filename,' : Not a valid PPU file, Skipping');
  2653. has_errors:=true;
  2654. exit;
  2655. end;
  2656. { Check PPU Version }
  2657. ppuversion:=ppufile.GetPPUVersion;
  2658. Writeln('Analyzing ',filename,' (v',PPUVersion,')');
  2659. if PPUVersion<16 then
  2660. begin
  2661. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  2662. has_errors:=true;
  2663. exit;
  2664. end;
  2665. { Write PPU Header Information }
  2666. if (verbose and v_header)<>0 then
  2667. begin
  2668. Writeln;
  2669. Writeln('Header');
  2670. Writeln('-------');
  2671. with ppufile.header do
  2672. begin
  2673. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  2674. (ppufile.header.compiler shr 7) and $7f,'.',
  2675. ppufile.header.compiler and $7f);
  2676. WriteLn('Target processor : ',Cpu2Str(cpu));
  2677. WriteLn('Target operating system : ',Target2Str(target));
  2678. Writeln('Unit flags : ',PPUFlags2Str(flags));
  2679. Writeln('FileSize (w/o header) : ',size);
  2680. Writeln('Checksum : ',hexstr(checksum,8));
  2681. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  2682. Writeln('Indirect Checksum : ',hexstr(indirect_checksum,8));
  2683. Writeln('Definitions stored : ',tostr(deflistsize));
  2684. Writeln('Symbols stored : ',tostr(symlistsize));
  2685. end;
  2686. end;
  2687. {read the general stuff}
  2688. if (verbose and v_interface)<>0 then
  2689. begin
  2690. Writeln;
  2691. Writeln('Interface section');
  2692. Writeln('------------------');
  2693. readinterface;
  2694. end
  2695. else
  2696. ppufile.skipuntilentry(ibendinterface);
  2697. Writeln;
  2698. Writeln('Interface symtable');
  2699. Writeln('----------------------');
  2700. readsymtableoptions('interface');
  2701. {read the definitions}
  2702. if (verbose and v_defs)<>0 then
  2703. begin
  2704. Writeln;
  2705. Writeln('Interface definitions');
  2706. Writeln('----------------------');
  2707. readdefinitions('interface');
  2708. end
  2709. else
  2710. ppufile.skipuntilentry(ibenddefs);
  2711. {read the symbols}
  2712. if (verbose and v_syms)<>0 then
  2713. begin
  2714. Writeln;
  2715. Writeln('Interface Symbols');
  2716. Writeln('------------------');
  2717. readsymbols('interface');
  2718. end
  2719. else
  2720. ppufile.skipuntilentry(ibendsyms);
  2721. {read the macro symbols}
  2722. if (verbose and v_syms)<>0 then
  2723. begin
  2724. Writeln;
  2725. Writeln('Interface Macro Symbols');
  2726. Writeln('-----------------------');
  2727. end;
  2728. if ppufile.readentry<>ibexportedmacros then
  2729. begin
  2730. WriteError('!! Error in PPU');
  2731. exit;
  2732. end;
  2733. if boolean(ppufile.getbyte) then
  2734. begin
  2735. readsymtableoptions('interface macro');
  2736. {skip the definition section for macros (since they are never used) }
  2737. ppufile.skipuntilentry(ibenddefs);
  2738. {read the macro symbols}
  2739. if (verbose and v_syms)<>0 then
  2740. readsymbols('interface macro')
  2741. else
  2742. ppufile.skipuntilentry(ibendsyms);
  2743. end
  2744. else
  2745. Writeln('(no exported macros)');
  2746. {read the implementation stuff}
  2747. if (verbose and v_implementation)<>0 then
  2748. begin
  2749. Writeln;
  2750. Writeln('Implementation section');
  2751. Writeln('-----------------------');
  2752. readimplementation;
  2753. end
  2754. else
  2755. ppufile.skipuntilentry(ibendimplementation);
  2756. {read the static symtable}
  2757. Writeln;
  2758. Writeln('Implementation symtable');
  2759. Writeln('----------------------');
  2760. readsymtableoptions('implementation');
  2761. if (ppufile.header.flags and uf_local_symtable)<>0 then
  2762. begin
  2763. if (verbose and v_defs)<>0 then
  2764. begin
  2765. Writeln;
  2766. Writeln('Static definitions');
  2767. Writeln('----------------------');
  2768. readdefinitions('implementation');
  2769. end
  2770. else
  2771. ppufile.skipuntilentry(ibenddefs);
  2772. {read the symbols}
  2773. if (verbose and v_syms)<>0 then
  2774. begin
  2775. Writeln;
  2776. Writeln('Static Symbols');
  2777. Writeln('------------------');
  2778. readsymbols('implementation');
  2779. end
  2780. else
  2781. ppufile.skipuntilentry(ibendsyms);
  2782. end;
  2783. ReadCreatedObjTypes;
  2784. FreeDerefdata;
  2785. {shutdown ppufile}
  2786. ppufile.closefile;
  2787. ppufile.free;
  2788. Writeln;
  2789. end;
  2790. procedure help;
  2791. begin
  2792. writeln('usage: ppudump [options] <filename1> <filename2>...');
  2793. writeln;
  2794. writeln('[options] can be:');
  2795. writeln(' -M Exit with ExitCode=2 if more information is available');
  2796. writeln(' -V<verbose> Set verbosity to <verbose>');
  2797. writeln(' H - Show header info');
  2798. writeln(' I - Show interface');
  2799. writeln(' M - Show implementation');
  2800. writeln(' S - Show interface symbols');
  2801. writeln(' D - Show interface definitions');
  2802. // writeln(' B - Show browser info');
  2803. writeln(' A - Show all');
  2804. writeln(' -h, -? This helpscreen');
  2805. halt;
  2806. end;
  2807. var
  2808. startpara,
  2809. nrfile,i : longint;
  2810. para : string;
  2811. const
  2812. error_on_more : boolean = false;
  2813. begin
  2814. writeln(Title+' '+Version);
  2815. writeln(Copyright);
  2816. writeln;
  2817. if paramcount<1 then
  2818. begin
  2819. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  2820. halt(1);
  2821. end;
  2822. { turn verbose on by default }
  2823. verbose:=v_all;
  2824. { read options }
  2825. startpara:=1;
  2826. while copy(paramstr(startpara),1,1)='-' do
  2827. begin
  2828. para:=paramstr(startpara);
  2829. case upcase(para[2]) of
  2830. 'M' : error_on_more:=true;
  2831. 'V' : begin
  2832. verbose:=0;
  2833. for i:=3 to length(para) do
  2834. case upcase(para[i]) of
  2835. 'H' : verbose:=verbose or v_header;
  2836. 'I' : verbose:=verbose or v_interface;
  2837. 'M' : verbose:=verbose or v_implementation;
  2838. 'D' : verbose:=verbose or v_defs;
  2839. 'S' : verbose:=verbose or v_syms;
  2840. 'A' : verbose:=verbose or v_all;
  2841. end;
  2842. end;
  2843. 'H' : help;
  2844. '?' : help;
  2845. end;
  2846. inc(startpara);
  2847. end;
  2848. { process files }
  2849. for nrfile:=startpara to paramcount do
  2850. dofile (paramstr(nrfile));
  2851. if has_errors then
  2852. Halt(1);
  2853. if error_on_more and has_more_infos then
  2854. Halt(2);
  2855. end.