ppudump.pp 87 KB

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