ppudump.pp 89 KB

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