ppudump.pp 93 KB

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