ppudump.pp 87 KB

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