ppudump.pp 87 KB

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