ppudump.pp 83 KB

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