ppudump.pp 94 KB

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