ppudump.pp 165 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220
  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. {$packenum 1}
  20. {$define IN_PPUDUMP}
  21. uses
  22. { do NOT add symconst or globtype to make merging easier }
  23. { do include symconst and globtype now before splitting 2.5 PM 2011-06-15 }
  24. cutils,
  25. SysUtils,
  26. constexp,
  27. symconst,
  28. ppu,
  29. entfile,
  30. systems,
  31. cpuinfo,
  32. globals,
  33. globtype,
  34. widestr,
  35. tokens,
  36. version,
  37. ppuout,
  38. ppujson,
  39. ppuxml;
  40. const
  41. Title = 'PPU-Analyser';
  42. Copyright = 'Copyright (c) 1998-2013 by the Free Pascal Development Team';
  43. { verbosity }
  44. v_none = $0;
  45. v_header = $1;
  46. v_defs = $2;
  47. v_syms = $4;
  48. v_interface = $8;
  49. v_implementation = $10;
  50. // v_browser = $20;
  51. v_all = $ff;
  52. { not needed anymore $i systems.inc }
  53. { List of all supported cpus }
  54. const
  55. CpuTxt : array[tsystemcpu] of string[16]=
  56. (
  57. { 0 } 'none',
  58. { 1 } 'i386',
  59. { 2 } 'm68k',
  60. { 3 } 'alpha (obsolete)',
  61. { 4 } 'powerpc',
  62. { 5 } 'sparc',
  63. { 6 } 'vis (obsolete)',
  64. { 7 } 'ia64 (obsolete)',
  65. { 8 } 'x86_64',
  66. { 9 } 'mipseb',
  67. { 10 } 'arm',
  68. { 11 } 'powerpc64',
  69. { 12 } 'avr',
  70. { 13 } 'mipsel',
  71. { 14 } 'jvm',
  72. { 15 } 'i8086',
  73. { 16 } 'aarch64',
  74. { 17 } 'wasm',
  75. { 18 } 'sparc64',
  76. { 19 } 'riscv32',
  77. { 20 } 'riscv64',
  78. { 21 } 'xtensa'
  79. );
  80. CpuHasController : array[tsystemcpu] of boolean =
  81. (
  82. { 0 } false {'none'},
  83. { 1 } false {'i386'},
  84. { 2 } false {'m68k'},
  85. { 3 } false {'alpha (obsolete)'},
  86. { 4 } false {'powerpc'},
  87. { 5 } false {'sparc'},
  88. { 6 } false {'vis (obsolete)'},
  89. { 7 } false {'ia64 (obsolete)'},
  90. { 8 } false {'x86_64'},
  91. { 9 } false {'mipseb'},
  92. { 10 } true {'arm'},
  93. { 11 } false {'powerpc64'},
  94. { 12 } true {'avr'},
  95. { 13 } true {'mipsel'},
  96. { 14 } false {'jvm'},
  97. { 15 } false {'i8086'},
  98. { 16 } false {'aarch64'},
  99. { 17 } false {'wasm'},
  100. { 18 } false {'sparc64'},
  101. { 19 } false {'riscv32'},
  102. { 20 } false {'riscv64'},
  103. { 21 } true {'xtensa'}
  104. );
  105. { List of all supported system-cpu couples }
  106. const
  107. Targets : array[tsystem] of string[26]=(
  108. { 0 } 'none',
  109. { 1 } 'GO32V1 (obsolete)',
  110. { 2 } 'GO32V2',
  111. { 3 } 'Linux-i386',
  112. { 4 } 'OS/2',
  113. { 5 } 'Win32',
  114. { 6 } 'FreeBSD-i386',
  115. { 7 } 'Amiga',
  116. { 8 } 'Atari',
  117. { 9 } 'MacOS-m68k',
  118. { 10 } 'Linux-m68k',
  119. { 11 } 'PalmOS-m68k',
  120. { 12 } 'Linux-alpha (obsolete)',
  121. { 13 } 'Linux-ppc',
  122. { 14 } 'MacOS-ppc',
  123. { 15 } 'Solaris-i386',
  124. { 16 } 'BeOS-i386',
  125. { 17 } 'NetBSD-i386',
  126. { 18 } 'NetBSD-m68k',
  127. { 19 } 'Netware-i386-clib',
  128. { 20 } 'Qnx-i386',
  129. { 21 } 'WDOSX-i386',
  130. { 22 } 'Solaris-sparc',
  131. { 23 } 'Linux-sparc',
  132. { 24 } 'OpenBSD-i386',
  133. { 25 } 'OpenBSD-m68k (obsolete)',
  134. { 26 } 'Linux-x86-64',
  135. { 27 } 'Darwin-ppc',
  136. { 28 } 'OS/2 via EMX',
  137. { 29 } 'NetBSD-powerpc',
  138. { 30 } 'OpenBSD-powerpc',
  139. { 31 } 'Linux-arm',
  140. { 32 } 'Watcom-i386',
  141. { 33 } 'MorphOS-powerpc',
  142. { 34 } 'FreeBSD-x86-64',
  143. { 35 } 'Netware-i386-libc',
  144. { 36 } 'Amiga-PowerPC',
  145. { 37 } 'Win64-x64',
  146. { 38 } 'WinCE-ARM',
  147. { 39 } 'Win64-iA64 (obsolete)',
  148. { 40 } 'WinCE-i386',
  149. { 41 } 'Linux-x64',
  150. { 42 } 'GBA-arm',
  151. { 43 } 'Linux-powerpc64',
  152. { 44 } 'Darwin-i386',
  153. { 45 } 'PalmOS-arm',
  154. { 46 } 'Darwin-powerpc64',
  155. { 47 } 'NDS-arm',
  156. { 48 } 'Embedded-i386',
  157. { 49 } 'Embedded-m68k',
  158. { 50 } 'Embedded-alpha (obsolete)',
  159. { 51 } 'Embedded-powerpc',
  160. { 52 } 'Embedded-sparc',
  161. { 53 } 'Embedded-vm (obsolete)',
  162. { 54 } 'Embedded-iA64 (obsolete)',
  163. { 55 } 'Embedded-x64',
  164. { 56 } 'Embedded-mips',
  165. { 57 } 'Embedded-arm',
  166. { 58 } 'Embedded-powerpc64',
  167. { 59 } 'Symbian-i386',
  168. { 60 } 'Symbian-arm',
  169. { 61 } 'Darwin-x64',
  170. { 62 } 'Embedded-avr',
  171. { 63 } 'Haiku-i386',
  172. { 64 } 'Darwin-ARM',
  173. { 65 } 'Solaris-x86-64',
  174. { 66 } 'Linux-MIPS',
  175. { 67 } 'Linux-MIPSel',
  176. { 68 } 'NativeNT-i386',
  177. { 69 } 'iPhoneSim-i386',
  178. { 70 } 'Wii-powerpc',
  179. { 71 } 'OpenBSD-x86-64',
  180. { 72 } 'NetBSD-x86-64',
  181. { 73 } 'AIX-powerpc',
  182. { 74 } 'AIX-powerpc64',
  183. { 75 } 'Java-JVM',
  184. { 76 } 'Android-JVM',
  185. { 77 } 'Android-arm',
  186. { 78 } 'Android-i386',
  187. { 79 } 'MSDOS-i8086',
  188. { 80 } 'Android-MIPSel',
  189. { 81 } 'Embedded-mipseb',
  190. { 82 } 'Embedded-mipsel',
  191. { 83 } 'AROS-i386',
  192. { 84 } 'AROS-x86-64',
  193. { 85 } 'DragonFly-x86-64',
  194. { 86 } 'Darwin-AArch64',
  195. { 87 } 'iPhoneSim-x86-64',
  196. { 88 } 'Linux-AArch64',
  197. { 89 } 'Win16',
  198. { 90 } 'Embedded-i8086',
  199. { 91 } 'AROS-arm',
  200. { 92 } 'WebAssembly-wasm',
  201. { 93 } 'Linux-sparc64',
  202. { 94 } 'Solaris-sparc64',
  203. { 95 } 'NetBSD-arm',
  204. { 96 } 'Linux-RiscV32',
  205. { 97 } 'Linux-RiscV64',
  206. { 98 } 'Embedded-RiscV32',
  207. { 99 } 'Embedded-RiscV64',
  208. { 100 } 'Android-AArch64',
  209. { 101 } 'Android-x86-64',
  210. { 102 } 'Haiku-x86-64',
  211. { 103 } 'Embedded-Xtensa',
  212. { 104 } 'FreeRTos-Xtensa',
  213. { 105 } 'Linux-Xtensa',
  214. { 106 } 'FreeRTos-arm',
  215. { 107 } 'Win64-AArch64'
  216. );
  217. const
  218. { in widestr, we have the following definition
  219. type
  220. tcompilerwidechar = word;
  221. thus widecharsize seems to always be 2 bytes }
  222. widecharsize : longint = 2;
  223. cpu : tsystemcpu = cpu_no;
  224. { This type is defined in scanner.pas unit }
  225. type
  226. tspecialgenerictoken = (
  227. ST_LOADSETTINGS,
  228. ST_LINE,
  229. ST_COLUMN,
  230. ST_FILEINDEX,
  231. ST_LOADMESSAGES,
  232. ST_INVALID);
  233. type
  234. tcpu_i386 = (
  235. cpu_variant_i386_none,
  236. cpu_variant_386,
  237. cpu_variant_486,
  238. cpu_variant_Pentium,
  239. cpu_variant_Pentium2,
  240. cpu_variant_Pentium3,
  241. cpu_variant_Pentium4,
  242. cpu_variant_PentiumM,
  243. cpu_variant_core_i,
  244. cpu_variant_core_avx,
  245. cpu_variant_core_avx2);
  246. tcpu_m68k = (
  247. cpu_variant_m68k_none,
  248. cpu_variant_MC68000,
  249. cpu_variant_MC68020,
  250. cpu_variant_MC68040,
  251. cpu_variant_MC68060,
  252. cpu_variant_isa_a,
  253. cpu_variant_isa_a_p,
  254. cpu_variant_isa_b,
  255. cpu_variant_isa_c,
  256. cpu_variant_cfv4e
  257. );
  258. tcpu_powerpc = (
  259. cpu_variant_powerpc_none,
  260. cpu_variant_ppc604,
  261. cpu_variant_ppc750,
  262. cpu_variant_ppc7400,
  263. cpu_variant_ppc970
  264. );
  265. tcpu_sparc = (
  266. cpu_variant_sparc_none,
  267. cpu_variant_SPARC_V7,
  268. cpu_variant_SPARC_V8,
  269. cpu_variant_SPARC_V9
  270. );
  271. tcpu_x86_64 = (
  272. cpu_variant_x86_64_none,
  273. cpu_variant_athlon64,
  274. cpu_variant_x86_64_core_i,
  275. cpu_variant_x86_64_core_avx,
  276. cpu_variant_x86_64_core_avx2
  277. );
  278. tcpu_mipseb = (
  279. cpu_variant_mipseb_none,
  280. cpu_variant_mips1,
  281. cpu_variant_mips2,
  282. cpu_variant_mips3,
  283. cpu_variant_mips4,
  284. cpu_variant_mips5,
  285. cpu_variant_mips32,
  286. cpu_variant_mips32r2,
  287. cpu_variant_pic32mx
  288. );
  289. tcpu_arm = (
  290. cpu_variant_arm_none,
  291. cpu_variant_armv3,
  292. cpu_variant_armv4,
  293. cpu_variant_armv4t,
  294. cpu_variant_armv5,
  295. cpu_variant_armv5t,
  296. cpu_variant_armv5te,
  297. cpu_variant_armv5tej,
  298. cpu_variant_armv6,
  299. cpu_variant_armv6k,
  300. cpu_variant_armv6t2,
  301. cpu_variant_armv6z,
  302. cpu_variant_armv6m,
  303. cpu_variant_armv7,
  304. cpu_variant_armv7a,
  305. cpu_variant_armv7r,
  306. cpu_variant_armv7m,
  307. cpu_variant_armv7em
  308. );
  309. tcpu_powerpc64 = (
  310. cpu_variant_powerpc64_none,
  311. cpu_variant_powerpc64_ppc970
  312. );
  313. tcpu_avr = (
  314. cpu_variant_avr_none,
  315. cpu_variant_avr1,
  316. cpu_variant_avr2,
  317. cpu_variant_avr25,
  318. cpu_variant_avr3,
  319. cpu_variant_avr31,
  320. cpu_variant_avr35,
  321. cpu_variant_avr4,
  322. cpu_variant_avr5,
  323. cpu_variant_avr51,
  324. cpu_variant_avr6
  325. );
  326. tcpu_mipsel = tcpu_mipseb;
  327. tcpu_jvm = (
  328. cpu_variant_jvm_none,
  329. { jvm, same as cpu_none }
  330. cpu_variant_jvm,
  331. { jvm byte code to be translated into Dalvik bytecode: more type-
  332. sensitive }
  333. cpu_variant_dalvik
  334. );
  335. tcpu_i8086 = (
  336. cpu_variant_i8086_none,
  337. cpu_variant_8086,
  338. cpu_variant_186,
  339. cpu_variant_286,
  340. cpu_variant_i8086_386,
  341. cpu_variant_i8086_486,
  342. cpu_variant_i8086_Pentium,
  343. cpu_variant_i8086_Pentium2,
  344. cpu_variant_i8086_Pentium3,
  345. cpu_variant_i8086_Pentium4,
  346. cpu_variant_i8086_PentiumM
  347. );
  348. tcpu_aarch64 = (
  349. cpu_variant_aarch64_none,
  350. cpu_variant_armv8
  351. );
  352. tcpu_wasm = (
  353. cpu_variant_wasm_none);
  354. tcpu_sparc64 = (
  355. cpu_variant_sparc64_none,
  356. cpu_variant_SPARC64_V9
  357. );
  358. tcpu_riscv32 = (
  359. cpu_variant_riscv32_none,
  360. cpu_variant_rv32imafd,
  361. cpu_variant_rv32ima,
  362. cpu_variant_rv32im,
  363. cpu_variant_rv32i
  364. );
  365. tcpu_riscv64 = (
  366. cpu_variant_riscv64_none,
  367. cpu_variant_rv64imafdc,
  368. cpu_variant_rv64imafd,
  369. cpu_variant_rv64ima,
  370. cpu_variant_rv64im,
  371. cpu_variant_rv64i
  372. );
  373. tcpu_type = record
  374. case tsystemcpu of
  375. cpu_no: { 0 }
  376. ();
  377. cpu_i386: { 1 }
  378. (cpu_i386 : tcpu_i386;);
  379. cpu_m68k: { 2 }
  380. (cpu_m68k : tcpu_m68k;);
  381. obsolete_cpu_alpha: { 3 }
  382. ();
  383. cpu_powerpc: { 4 }
  384. (cpu_powerpc : tcpu_powerpc;);
  385. cpu_sparc: { 5 }
  386. (cpu_sparc : tcpu_sparc;);
  387. obsolete_cpu_vm: { 6 }
  388. ();
  389. obsolete_cpu_ia64: { 7 }
  390. ();
  391. cpu_x86_64: { 8 }
  392. (cpu_x86_64 : tcpu_x86_64;);
  393. cpu_mipseb: { 9 }
  394. (cpu_mipseb : tcpu_mipseb;);
  395. cpu_arm: { 10 }
  396. (cpu_arm : tcpu_arm;);
  397. cpu_powerpc64: { 11 }
  398. (cpu_powerpc64 : tcpu_powerpc64;);
  399. cpu_avr: { 12 }
  400. (cpu_avr : tcpu_avr;);
  401. cpu_mipsel: { 13 }
  402. (cpu_mipsel : tcpu_mipsel;);
  403. cpu_jvm: { 14 }
  404. (cpu_jvm : tcpu_jvm;);
  405. cpu_i8086: { 15 }
  406. (cpu_i8086 : tcpu_i8086;);
  407. cpu_aarch64: { 16 }
  408. (cpu_aarch64 : tcpu_aarch64;);
  409. cpu_wasm: { 17 }
  410. (cpu_wasm : tcpu_wasm;);
  411. cpu_sparc64: { 18 }
  412. (cpu_sparc64 : tcpu_sparc64;);
  413. cpu_riscv32: { 19 }
  414. (cpu_riscv32 : tcpu_riscv32;);
  415. cpu_riscv64: { 20 }
  416. (cpu_riscv64 : tcpu_riscv64;);
  417. end;
  418. TPpuModuleDef = class(TPpuUnitDef)
  419. ModuleFlags: tmoduleflags;
  420. end;
  421. type
  422. tppudumpfile = class(tppufile)
  423. protected
  424. procedure RaiseAssertion(Code: Longint); override;
  425. end;
  426. var
  427. ppufile : tppudumpfile;
  428. ppuversion : dword;
  429. space : string;
  430. verbose : longint;
  431. derefdata : pbyte;
  432. derefdatalen : longint;
  433. pout: TPpuOutput;
  434. nostdout: boolean;
  435. UnitList: TPpuContainerDef;
  436. CurUnit: TPpuModuleDef;
  437. SkipVersionCheck: boolean;
  438. SymAnsiStr: boolean;
  439. var
  440. { needed during tobjectdef parsing... }
  441. current_defoptions : tdefoptions;
  442. current_objectoptions : tobjectoptions;
  443. current_symtable_options : tsymtableoptions;
  444. {****************************************************************************
  445. Helper Routines
  446. ****************************************************************************}
  447. {****************************************************************************
  448. Routine to read 80-bit reals
  449. ****************************************************************************
  450. }
  451. {$PUSH}
  452. {$WARN 6018 OFF} { Turn off unreachable code warning }
  453. { On platforms with sizeof(ext) <> 10 the code below will cause an unreachable
  454. code warning, which will cause compilation failures with -Sew (KB) }
  455. type
  456. TSplit80bitReal = packed record
  457. case byte of
  458. 0: (bytes: Array[0..9] of byte);
  459. 1: (words: Array[0..4] of word);
  460. {$ifdef FPC_LITTLE_ENDIAN}
  461. 2: (cards: Array[0..1] of cardinal; w: word);
  462. {$else not FPC_LITTLE_ENDIAN}
  463. 2: (w:word; cards: Array[0..1] of cardinal);
  464. {$endif not FPC_LITTLE_ENDIAN}
  465. end;
  466. const
  467. maxDigits = 17;
  468. function Real80bitToStr(var e : TSplit80bitReal;var ext : extended) : string;
  469. var
  470. Temp : string;
  471. new : TSplit80bitReal;
  472. fraczero, expmaximal, sign, outside_double : boolean;
  473. exp : smallint;
  474. d : double;
  475. i : longint;
  476. mantval : qword;
  477. begin
  478. if ppufile.change_endian then
  479. begin
  480. for i:=0 to 9 do
  481. new.bytes[i]:=e.bytes[9-i];
  482. e:=new;
  483. end;
  484. if sizeof(ext)=10 then
  485. begin
  486. ext:=pextended(@e)^;
  487. str(ext,result);
  488. exit;
  489. end;
  490. { extended, format (MSB): 1 Sign bit, 15 bit exponent, 64 bit mantissa }
  491. sign := (e.w and $8000) <> 0;
  492. expMaximal := (e.w and $7fff) = 32767;
  493. exp:=(e.w and $7fff) - 16383 - 63;
  494. fraczero := (e.cards[0] = 0) and
  495. ((e.cards[1] and $7fffffff) = 0);
  496. {$ifdef FPC_LITTLE_ENDIAN}
  497. mantval := qword(e.cards[0]) or (qword(e.cards[1]) shl 32);
  498. {$else not FPC_LITTLE_ENDIAN}
  499. mantval := (qword(e.cards[0]) shl 32) or qword(e.cards[1]);
  500. {$endif not FPC_LITTLE_ENDIAN}
  501. if expMaximal then
  502. if fraczero then
  503. if sign then
  504. temp := '-Inf'
  505. else temp := '+Inf'
  506. else temp := 'Nan'
  507. else
  508. begin
  509. d:=double(mantval);
  510. if sign then
  511. d:=-d;
  512. outside_double:=false;
  513. Try
  514. if exp > 0 then
  515. begin
  516. for i:=1 to exp do
  517. d:=d *2.0;
  518. end
  519. else if exp < 0 then
  520. begin
  521. for i:=1 to -exp do
  522. d:=d /2.0;
  523. end;
  524. Except
  525. outside_double:=true;
  526. end;
  527. if (mantval<>0) and (d=0.0) then
  528. outside_double:=true;
  529. if outside_double then
  530. begin
  531. Temp:='Extended value outside double bound';
  532. ext:=0.0;
  533. end
  534. else
  535. begin
  536. ext:=d;
  537. system.str(d,temp);
  538. end;
  539. end;
  540. result:=temp;
  541. end;
  542. {$POP}
  543. const has_errors : boolean = false;
  544. has_warnings : boolean = false;
  545. has_more_infos : boolean = false;
  546. procedure SetHasErrors;
  547. begin
  548. has_errors:=true;
  549. end;
  550. Procedure WriteError(const S : string);
  551. Begin
  552. system.Writeln(StdErr, S);
  553. SetHasErrors;
  554. End;
  555. procedure StrAppend(var st : string; const st2 : string);
  556. begin
  557. st:=st+st2;
  558. end;
  559. procedure tppudumpfile.RaiseAssertion(Code: Longint);
  560. begin
  561. WriteError('Internal Error ' + ToStr(Code));
  562. inherited RaiseAssertion(Code);
  563. end;
  564. Procedure WriteWarning(const S : string);
  565. var
  566. ss: string;
  567. Begin
  568. ss:='!! Warning: ' + S;
  569. if nostdout then
  570. system.Writeln(StdErr, ss)
  571. else
  572. system.Writeln(ss);
  573. has_warnings:=true;
  574. End;
  575. procedure Write(const s: string);
  576. begin
  577. if nostdout then exit;
  578. system.write(s);
  579. end;
  580. procedure Write(const params: array of const);
  581. var
  582. i: integer;
  583. { Last vtType define in rtl/inc/objpash.inc }
  584. const
  585. max_vttype = vtUnicodeString;
  586. begin
  587. if nostdout then exit;
  588. for i:=Low(params) to High(params) do
  589. { All vtType in
  590. vtInteger = 0;
  591. vtBoolean = 1;
  592. vtChar = 2;
  593. vtExtended = 3;
  594. vtString = 4;
  595. vtPointer = 5;
  596. vtPChar = 6;
  597. vtObject = 7;
  598. vtClass = 8;
  599. vtWideChar = 9;
  600. vtPWideChar = 10;
  601. vtAnsiString32 = 11; called vtAnsiString in objpas unit
  602. vtCurrency = 12;
  603. vtVariant = 13;
  604. vtInterface = 14;
  605. vtWideString = 15;
  606. vtInt64 = 16;
  607. vtQWord = 17;
  608. vtUnicodeString = 18;
  609. // vtAnsiString16 = 19; not yet used
  610. // vtAnsiString64 = 20; not yet used
  611. }
  612. with TVarRec(params[i]) do
  613. case VType of
  614. vtInteger: system.write(VInteger);
  615. vtBoolean: system.write(VBoolean);
  616. vtChar: system.write(VChar);
  617. vtExtended: system.write(VExtended^);
  618. vtString: system.write(VString^);
  619. vtPointer:
  620. begin
  621. { Not sure the display will be correct
  622. if sizeof pointer is not native }
  623. WriteWarning('Pointer constant');
  624. end;
  625. vtPChar: system.write(VPChar);
  626. vtObject:
  627. begin
  628. { Not sure the display will be correct
  629. if sizeof pointer is not native }
  630. WriteWarning('Object constant');
  631. end;
  632. vtClass:
  633. begin
  634. { Not sure the display will be correct
  635. if sizeof pointer is not native }
  636. WriteWarning('Class constant');
  637. end;
  638. vtWideChar: system.write(VWideChar);
  639. vtPWideChar:
  640. begin
  641. WriteWarning('PWideChar constant');
  642. end;
  643. vtAnsiString: system.write(ansistring(VAnsiString));
  644. vtCurrency : system.write(VCurrency^);
  645. vtVariant :
  646. begin
  647. { Not sure the display will be correct
  648. if sizeof pointer is not native }
  649. WriteWarning('Variant constant');
  650. end;
  651. vtInterface :
  652. begin
  653. { Not sure the display will be correct
  654. if sizeof pointer is not native }
  655. WriteWarning('Interface constant');
  656. end;
  657. vtWideString : system.write(widestring(VWideString));
  658. vtInt64: system.write(VInt64^);
  659. vtQWord: system.write(VQWord^);
  660. vtUnicodeString : system.write(unicodestring(VUnicodeString));
  661. else
  662. begin
  663. system.writeln;
  664. system.writeln('Unsupported var type: ', VType);
  665. Halt(10);
  666. end;
  667. end;
  668. end;
  669. procedure Writeln(const s: string = '');
  670. begin
  671. if nostdout then exit;
  672. system.writeln(s);
  673. end;
  674. procedure Writeln(const params: array of const);
  675. begin
  676. if nostdout then exit;
  677. Write(params);
  678. system.writeln;
  679. end;
  680. Procedure HasMoreInfos;
  681. begin
  682. Writeln('!! Entry has more information stored');
  683. has_more_infos:=true;
  684. end;
  685. function Unknown(const st : string; val :longint) : string;
  686. Begin
  687. Unknown:='<!! Unknown'+st+' value '+tostr(val)+'>';
  688. SetHasErrors;
  689. end;
  690. function ToStr(w:longint):String;
  691. begin
  692. Str(w,ToStr);
  693. end;
  694. Function Target2Str(w:longint):string;
  695. begin
  696. if w<=ord(high(tsystem)) then
  697. Target2Str:=Targets[tsystem(w)]
  698. else
  699. Target2Str:=Unknown('target',w);
  700. end;
  701. Function Cpu2Str(w:longint):string;
  702. begin
  703. if w<=ord(high(tsystemcpu)) then
  704. begin
  705. cpu:=tsystemcpu(w);
  706. Cpu2Str:=CpuTxt[cpu];
  707. end
  708. else
  709. Cpu2Str:=Unknown('cpu',w);
  710. end;
  711. Function Varspez2Str(w:longint):string;
  712. const
  713. { in symconst unit
  714. tvarspez = (vs_value,vs_const,vs_var,vs_out,vs_constref); }
  715. varspezstr : array[tvarspez] of string[8]=('Value','Const','Var','Out','ConstRef','Final');
  716. begin
  717. if w<=ord(high(varspezstr)) then
  718. Varspez2Str:=varspezstr[tvarspez(w)]
  719. else
  720. Varspez2Str:=Unknown('varspez',w);
  721. end;
  722. Function VarRegable2Str(w:longint):string;
  723. { tvarregable type is defined in symconst unit }
  724. const
  725. varregableStr : array[tvarregable] of string[6]=('None','IntReg','FPUReg','MMReg','Addr');
  726. begin
  727. if w<=ord(high(varregablestr)) then
  728. Varregable2Str:=varregablestr[tvarregable(w)]
  729. else
  730. Varregable2Str:=Unknown('regable',w);
  731. end;
  732. Function Visibility2Str(w:longint):string;
  733. const
  734. { tvisibility type is defined in symconst unit }
  735. visibilityName : array[tvisibility] of string[16] = (
  736. 'hidden','strict private','private','strict protected','protected',
  737. 'public','published','<none>'
  738. );
  739. begin
  740. if w<=ord(high(visibilityName)) then
  741. result:=visibilityName[tvisibility(w)]
  742. else
  743. result:=Unknown('visibility',w);
  744. end;
  745. Function IntfEntryType2Str(w:longint):string;
  746. const
  747. { tinterfaceentrytype type is defined in symconst unit }
  748. Name : array[tinterfaceentrytype] of string = (
  749. 'standard','virtual method result','static method result','field value','virtual method class',
  750. 'static method class','field value class'
  751. );
  752. begin
  753. if w<=ord(high(Name)) then
  754. result:=Name[tinterfaceentrytype(w)]
  755. else
  756. result:=Unknown('entry type',w);
  757. end;
  758. function PPUFlags2Str(flags:dword):string;
  759. type
  760. tflagopt=record
  761. mask : dword;
  762. str : string[30];
  763. end;
  764. const
  765. flagopts=8;
  766. flagopt : array[1..flagopts] of tflagopt=(
  767. (mask: $4 ;str:'big_endian'),
  768. // (mask: $10 ;str:'browser'),
  769. (mask: $20 ;str:'in_library'),
  770. (mask: $40 ;str:'smart_linked'),
  771. (mask: $80 ;str:'static_linked'),
  772. (mask: $100 ;str:'shared_linked'),
  773. (mask: $400 ;str:'no_link'),
  774. (mask: $1000 ;str:'little_endian'),
  775. (mask: $8000 ;str:'fpu_emulation_on')
  776. );
  777. var
  778. i : longint;
  779. ntflags : dword;
  780. first : boolean;
  781. s : string;
  782. begin
  783. s:='';
  784. ntflags:=flags;
  785. if flags<>0 then
  786. begin
  787. first:=true;
  788. for i:=1to flagopts do
  789. if (flags and flagopt[i].mask)<>0 then
  790. begin
  791. if first then
  792. first:=false
  793. else
  794. s:=s+', ';
  795. s:=s+flagopt[i].str;
  796. ntflags:=ntflags and (not flagopt[i].mask);
  797. end;
  798. end
  799. else
  800. s:='none';
  801. if ntflags<>0 then
  802. begin
  803. s:=s+' unknown '+hexstr(ntflags,8);
  804. SetHasErrors;
  805. end;
  806. PPUFlags2Str:=s;
  807. end;
  808. Function L0(l:longint):string;
  809. {
  810. return the string of value l, if l<10 then insert a zero, so
  811. the string is always at least 2 chars '01','02',etc
  812. }
  813. var
  814. s : string;
  815. begin
  816. Str(l,s);
  817. if l<10 then
  818. s:='0'+s;
  819. L0:=s;
  820. end;
  821. function filetimestring( t : longint) : string;
  822. {
  823. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  824. }
  825. var
  826. DT : TDateTime;
  827. hsec : word;
  828. Year,Month,Day: Word;
  829. hour,min,sec : word;
  830. begin
  831. if t=-1 then
  832. begin
  833. Result := 'Not Found';
  834. SetHasErrors;
  835. exit;
  836. end;
  837. DT := FileDateToDateTime(t);
  838. DecodeTime(DT,hour,min,sec,hsec);
  839. DecodeDate(DT,year,month,day);
  840. Result := L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  841. end;
  842. {****************************************************************************
  843. Read Routines
  844. ****************************************************************************}
  845. function readsymstr(ppufile: tppufile): ansistring;
  846. begin
  847. if not(mf_symansistr in CurUnit.ModuleFlags) then
  848. result:=ppufile.getstring
  849. else
  850. result:=ppufile.getansistring;
  851. end;
  852. function readmanagementoperatoroptions(const space : string;const name : string):tmanagementoperators;forward;
  853. procedure readrecsymtableoptions;
  854. var
  855. usefieldalignment : shortint;
  856. begin
  857. if ppufile.readentry<>ibrecsymtableoptions then
  858. begin
  859. SetHasErrors;
  860. exit;
  861. end;
  862. writeln([space,' recordalignment: ',shortint(ppufile.getbyte)]);
  863. usefieldalignment:=shortint(ppufile.getbyte);
  864. writeln([space,' usefieldalignment: ',usefieldalignment]);
  865. writeln([space,' recordalignmin: ',shortint(ppufile.getbyte)]);
  866. if (usefieldalignment=C_alignment) then
  867. writeln([space,' fieldalignment: ',shortint(ppufile.getbyte)]);
  868. readmanagementoperatoroptions(space,'Fields have MOPs');
  869. end;
  870. function readsymtableoptions(const s: string) : tsymtableoptions;
  871. type
  872. tsymtblopt=record
  873. mask : tsymtableoption;
  874. str : string[30];
  875. end;
  876. const
  877. symtblopts=ord(high(tsymtableoption)) + 1;
  878. symtblopt : array[1..symtblopts] of tsymtblopt=(
  879. (mask:sto_has_helper; str:'Has helper'),
  880. (mask:sto_has_generic; str:'Has generic'),
  881. (mask:sto_has_operator; str:'Has operator'),
  882. (mask:sto_needs_init_final;str:'Needs init final table'),
  883. (mask:sto_has_non_trivial_init;str:'Has non trivial init')
  884. );
  885. var
  886. options : tsymtableoptions;
  887. first : boolean;
  888. i : integer;
  889. begin
  890. if ppufile.readentry<>ibsymtableoptions then
  891. begin
  892. SetHasErrors;
  893. exit;
  894. end;
  895. ppufile.getset(tppuset1(options));
  896. if space<>'' then
  897. writeln([space,'------ ',s,' ------']);
  898. write([space,'Symtable options: ']);
  899. if options<>[] then
  900. begin
  901. first:=true;
  902. for i:=1 to symtblopts do
  903. if (symtblopt[i].mask in options) then
  904. begin
  905. if first then
  906. first:=false
  907. else
  908. write(', ');
  909. write(symtblopt[i].str);
  910. end;
  911. end
  912. else
  913. write('none');
  914. writeln;
  915. readsymtableoptions:=options;
  916. end;
  917. procedure readdefinitions(const s:string; ParentDef: TPpuContainerDef); forward;
  918. procedure readsymbols(const s:string; ParentDef: TPpuContainerDef = nil); forward;
  919. procedure readsymtable(const s: string; ParentDef: TPpuContainerDef = nil);
  920. var
  921. stored_symtable_options : tsymtableoptions;
  922. begin
  923. stored_symtable_options:=current_symtable_options;
  924. current_symtable_options:=readsymtableoptions(s);
  925. readdefinitions(s, ParentDef);
  926. readsymbols(s, ParentDef);
  927. current_symtable_options:=stored_symtable_options;
  928. end;
  929. procedure readrecordsymtable(const s: string; ParentDef: TPpuContainerDef = nil);
  930. begin
  931. readrecsymtableoptions;
  932. readsymtable(s, ParentDef);
  933. end;
  934. Procedure ReadLinkContainer(const prefix:string);
  935. {
  936. Read a serie of strings and write to the screen starting every line
  937. with prefix
  938. }
  939. function maskstr(m:longint):string;
  940. { link options are in globtype unit
  941. const
  942. link_none = $0;
  943. link_always = $1;
  944. link_static = $2;
  945. link_smart = $4;
  946. link_shared = $8; }
  947. var
  948. s : string;
  949. begin
  950. s:='';
  951. if (m and link_always)<>0 then
  952. s:=s+'always ';
  953. if (m and link_static)<>0 then
  954. s:=s+'static ';
  955. if (m and link_smart)<>0 then
  956. s:=s+'smart ';
  957. if (m and link_shared)<>0 then
  958. s:=s+'shared ';
  959. maskstr:=s;
  960. end;
  961. var
  962. s : string;
  963. m : longint;
  964. begin
  965. while not ppufile.endofentry do
  966. begin
  967. s:=ppufile.getstring;
  968. m:=ppufile.getlongint;
  969. WriteLn([prefix,s,' (',maskstr(m),')']);
  970. end;
  971. end;
  972. Procedure ReadContainer(const prefix:string);
  973. {
  974. Read a series of strings and write to the screen starting every line
  975. with prefix
  976. }
  977. begin
  978. while not ppufile.endofentry do
  979. WriteLn([prefix,ppufile.getstring]);
  980. end;
  981. procedure ReadLoadUnit;
  982. var
  983. ucrc,uintfcrc, indcrc : cardinal;
  984. un: TPpuUnitDef;
  985. begin
  986. while not ppufile.EndOfEntry do
  987. begin
  988. un:=TPpuUnitDef.Create(CurUnit.UsedUnits);
  989. un.Name:=ppufile.getstring;
  990. write(['Uses unit: ',un.Name]);
  991. ucrc:=cardinal(ppufile.getlongint);
  992. uintfcrc:=cardinal(ppufile.getlongint);
  993. indcrc:=cardinal(ppufile.getlongint);
  994. writeln([' (Crc: ',hexstr(ucrc,8),', IntfcCrc: ',hexstr(uintfcrc,8),', IndCrc: ',hexstr(indcrc,8),')']);
  995. un.Crc:=ucrc;
  996. un.IntfCrc:=uintfcrc;
  997. end;
  998. end;
  999. Procedure ReadDerefmap;
  1000. var
  1001. i,mapsize : longint;
  1002. s: string;
  1003. begin
  1004. mapsize:=ppufile.getlongint;
  1005. writeln(['DerefMapsize: ',mapsize]);
  1006. SetLength(CurUnit.RefUnits, mapsize);
  1007. for i:=0 to mapsize-1 do
  1008. begin
  1009. s:=ppufile.getstring;
  1010. writeln(['DerefMap[',i,'] = ',s]);
  1011. CurUnit.RefUnits[i]:=LowerCase(s);
  1012. end;
  1013. end;
  1014. Procedure ReadImportSymbols;
  1015. var
  1016. extlibname : string;
  1017. j,
  1018. extsymcnt : longint;
  1019. extsymname : string;
  1020. extsymmangledname : string;
  1021. extsymordnr : longint;
  1022. extsymisvar : boolean;
  1023. begin
  1024. while not ppufile.endofentry do
  1025. begin
  1026. extlibname:=ppufile.getstring;
  1027. extsymcnt:=ppufile.getlongint;
  1028. writeln(['External Library: ',extlibname,' (',extsymcnt,' imports)']);
  1029. for j:=0 to extsymcnt-1 do
  1030. begin
  1031. extsymname:=ppufile.getstring;
  1032. extsymmangledname:=ppufile.getstring;
  1033. extsymordnr:=ppufile.getlongint;
  1034. extsymisvar:=ppufile.getbyte<>0;
  1035. writeln([' ',extsymname,' as ',extsymmangledname,
  1036. '(OrdNr: ',extsymordnr,' IsVar: ',extsymisvar,')']);
  1037. end;
  1038. end;
  1039. end;
  1040. Procedure ReadDerefdata;
  1041. begin
  1042. derefdatalen:=ppufile.entrysize;
  1043. if derefdatalen=0 then
  1044. begin
  1045. Writeln(['No Derefdata length=0']);
  1046. derefdata:=nil;
  1047. exit;
  1048. end;
  1049. Writeln(['Derefdata length: ',derefdatalen]);
  1050. derefdata:=allocmem(derefdatalen);
  1051. ppufile.getdata(derefdata^,derefdatalen);
  1052. end;
  1053. Procedure FreeDerefdata;
  1054. begin
  1055. if assigned(derefdata) then
  1056. begin
  1057. FreeMem(derefdata);
  1058. derefdata:=nil;
  1059. derefdatalen:=0;
  1060. end;
  1061. end;
  1062. Procedure ReadWpoFileInfo;
  1063. begin
  1064. Writeln(['Compiled with input whole-program optimisation from ',ppufile.getstring,' ',filetimestring(ppufile.getlongint)]);
  1065. end;
  1066. Procedure ReadAsmSymbols;
  1067. const
  1068. unitasmlisttype: array[tunitasmlisttype] of string[6]=(
  1069. 'PUBLIC',
  1070. 'EXTERN'
  1071. );
  1072. type
  1073. { Copied from aasmbase.pas }
  1074. TAsmsymbind=(
  1075. AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL,AB_WEAK_EXTERNAL,
  1076. { global in the current program/library, but not visible outside it }
  1077. AB_PRIVATE_EXTERN,AB_LAZY,AB_IMPORT,
  1078. { a symbol that's internal to the compiler and used as a temp }
  1079. AB_TEMP,
  1080. { a global symbol that points to another global symbol and is only used
  1081. to allow indirect loading in case of packages and indirect imports }
  1082. AB_INDIRECT,AB_EXTERNAL_INDIRECT);
  1083. TAsmsymtype=(
  1084. AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL,
  1085. {
  1086. the address of this code label is taken somewhere in the code
  1087. so it must be taken care of it when creating pic
  1088. }
  1089. AT_ADDR,
  1090. { Label for debug or other non-program information }
  1091. AT_METADATA,
  1092. { label for data that must always be accessed indirectly, because it
  1093. is handled explcitely in the system unit or (e.g. RTTI and threadvar
  1094. tables) -- never seen in an assembler/assembler writer, always
  1095. changed to AT_DATA }
  1096. AT_DATA_FORCEINDIRECT,
  1097. { don't generate an implicit indirect symbol as that might be provided
  1098. by other means (e.g. the typed const builder) to ensure a correct
  1099. section name }
  1100. AT_DATA_NOINDIRECT,
  1101. { Thread-local symbol (ELF targets) }
  1102. AT_TLS,
  1103. { GNU indirect function (ELF targets) }
  1104. AT_GNU_IFUNC
  1105. );
  1106. var
  1107. s,
  1108. bindstr,
  1109. typestr : string;
  1110. i : longint;
  1111. t: tunitasmlisttype;
  1112. begin
  1113. writeln([space,'Assembler Symbols']);
  1114. writeln([space,'-----------------']);
  1115. t:=tunitasmlisttype(ppufile.getbyte);
  1116. if (t>=Low(tunitasmlisttype)) and (t<=High(tunitasmlisttype)) then
  1117. typestr:=unitasmlisttype[t]
  1118. else
  1119. typestr:='UNKNOWN';
  1120. writeln([space,'Type: ',typestr]);
  1121. writeln([space,'Count: ',ppufile.getlongint]);
  1122. i:=0;
  1123. while (not ppufile.endofentry) and (not ppufile.error) do
  1124. begin
  1125. s:=ppufile.getstring;
  1126. case tasmsymbind(ppufile.getbyte) of
  1127. AB_EXTERNAL :
  1128. bindstr:='External';
  1129. AB_COMMON :
  1130. bindstr:='Common';
  1131. AB_LOCAL :
  1132. bindstr:='Local';
  1133. AB_GLOBAL :
  1134. bindstr:='Global';
  1135. AB_WEAK_EXTERNAL :
  1136. bindstr:='Weak external';
  1137. AB_PRIVATE_EXTERN :
  1138. bindstr:='Private extern';
  1139. AB_LAZY :
  1140. bindstr:='Lazy';
  1141. AB_IMPORT :
  1142. bindstr:='Import';
  1143. AB_TEMP :
  1144. bindstr:='Temp';
  1145. AB_INDIRECT :
  1146. bindstr:='Indirect';
  1147. AB_EXTERNAL_INDIRECT :
  1148. bindstr:='Indirect external';
  1149. else
  1150. begin
  1151. bindstr:='<Error !!>';
  1152. SetHasErrors;
  1153. end;
  1154. end;
  1155. case tasmsymtype(ppufile.getbyte) of
  1156. AT_FUNCTION :
  1157. typestr:='Function';
  1158. AT_DATA :
  1159. typestr:='Data';
  1160. AT_SECTION :
  1161. typestr:='Section';
  1162. AT_LABEL :
  1163. typestr:='Label';
  1164. AT_ADDR :
  1165. typestr:='Label (with address taken)';
  1166. AT_METADATA :
  1167. typestr:='Metadata';
  1168. { this shouldn't appear in a PPU }
  1169. AT_DATA_FORCEINDIRECT :
  1170. typestr:='Data (ForceIndirect)';
  1171. { this shouldn't appear in a PPU }
  1172. AT_DATA_NOINDIRECT:
  1173. typestr:='Data (NoIndirect)';
  1174. AT_TLS :
  1175. typestr:='TLS';
  1176. AT_GNU_IFUNC :
  1177. typestr:='GNU IFUNC';
  1178. else
  1179. begin
  1180. typestr:='<Error !!>';
  1181. SetHasErrors;
  1182. end;
  1183. end;
  1184. Writeln([space,' ',i,' : ',s,' [',bindstr,',',typestr,']']);
  1185. inc(i);
  1186. end;
  1187. writeln([space]);
  1188. end;
  1189. function getexprint:Tconstexprint;
  1190. begin
  1191. getexprint.overflow:=false;
  1192. getexprint.signed:=ppufile.getboolean;
  1193. getexprint.svalue:=ppufile.getint64;
  1194. end;
  1195. Procedure ReadPosInfo(Def: TPpuDef = nil);
  1196. var
  1197. info : byte;
  1198. fileindex,line,column : longint;
  1199. begin
  1200. with ppufile do
  1201. begin
  1202. fileindex:=0;
  1203. line:=0;
  1204. column:=0;
  1205. {
  1206. info byte layout in bits:
  1207. 0-1 - amount of bytes for fileindex
  1208. 2-3 - amount of bytes for line
  1209. 4-5 - amount of bytes for column
  1210. }
  1211. info:=getbyte;
  1212. case (info and $03) of
  1213. 0 : fileindex:=getbyte;
  1214. 1 : fileindex:=getword;
  1215. 2 : fileindex:=(getbyte shl 16) or getword;
  1216. 3 : fileindex:=getlongint;
  1217. end;
  1218. case ((info shr 2) and $03) of
  1219. 0 : line:=getbyte;
  1220. 1 : line:=getword;
  1221. 2 : line:=(getbyte shl 16) or getword;
  1222. 3 : line:=getlongint;
  1223. end;
  1224. case ((info shr 4) and $03) of
  1225. 0 : column:=getbyte;
  1226. 1 : column:=getword;
  1227. 2 : column:=(getbyte shl 16) or getword;
  1228. 3 : column:=getlongint;
  1229. end;
  1230. Writeln([fileindex,' (',line,',',column,')']);
  1231. if Def <> nil then
  1232. begin
  1233. Def.FilePos.FileIndex:=fileindex;
  1234. Def.FilePos.Line:=line;
  1235. Def.FilePos.Col:=column;
  1236. end;
  1237. end;
  1238. end;
  1239. procedure readderef(const derefspace: string; Ref: TPpuRef = nil);
  1240. var
  1241. b : tdereftype;
  1242. first : boolean;
  1243. idx : longint;
  1244. i,n : byte;
  1245. pdata : pbyte;
  1246. begin
  1247. if not assigned(derefdata) then
  1248. exit;
  1249. first:=true;
  1250. idx:=ppufile.getlongint;
  1251. if idx = -1 then
  1252. begin
  1253. writeln('Nil');
  1254. exit;
  1255. end;
  1256. if (idx>derefdatalen) then
  1257. begin
  1258. WriteError('!! Error: Deref idx '+IntToStr(idx)+' > '+IntToStr(derefdatalen));
  1259. exit;
  1260. end;
  1261. write([derefspace,'(',idx,') ']);
  1262. pdata:=@derefdata[idx];
  1263. i:=0;
  1264. n:=pdata[i];
  1265. inc(i);
  1266. if n<1 then
  1267. begin
  1268. WriteError('!! Error: Deref len < 1');
  1269. exit;
  1270. end;
  1271. while (i<=n) do
  1272. begin
  1273. if not first then
  1274. write(', ')
  1275. else
  1276. first:=false;
  1277. b:=tdereftype(pdata[i]);
  1278. inc(i);
  1279. case b of
  1280. deref_nil :
  1281. write('Nil');
  1282. deref_symid :
  1283. begin
  1284. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  1285. inc(i,4);
  1286. write(['SymId ',idx]);
  1287. if Ref <> nil then
  1288. Ref.Id:=idx;
  1289. end;
  1290. deref_defid :
  1291. begin
  1292. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  1293. inc(i,4);
  1294. write(['DefId ',idx]);
  1295. if Ref <> nil then
  1296. Ref.Id:=idx;
  1297. end;
  1298. deref_unit :
  1299. begin
  1300. idx:=pdata[i] shl 8 or pdata[i+1];
  1301. inc(i,2);
  1302. write(['Unit ',idx]);
  1303. if Ref <> nil then
  1304. Ref.UnitIndex:=idx;
  1305. end;
  1306. else
  1307. begin
  1308. WriteError('!! unsupported dereftyp: '+IntToStr(ord(b)));
  1309. break;
  1310. end;
  1311. end;
  1312. end;
  1313. writeln;
  1314. end;
  1315. Procedure ReadUnitImportSyms;
  1316. var
  1317. c,i : longint;
  1318. begin
  1319. writeln([space,'Imported Symbols']);
  1320. writeln([space,'----------------']);
  1321. c:=ppufile.getlongint;
  1322. for i:=0 to c-1 do
  1323. readderef(space);
  1324. writeln([space]);
  1325. end;
  1326. procedure readpropaccesslist(const s:string; Ref: TPpuRef = nil);
  1327. { type tsltype is in symconst unit }
  1328. const
  1329. slstr : array[tsltype] of string[12] = (
  1330. '',
  1331. 'load',
  1332. 'call',
  1333. 'subscript',
  1334. 'vec',
  1335. 'typeconv',
  1336. 'absolutetype'
  1337. );
  1338. var
  1339. sl : tsltype;
  1340. begin
  1341. readderef('',Ref);
  1342. repeat
  1343. sl:=tsltype(ppufile.getbyte);
  1344. if sl=sl_none then
  1345. break;
  1346. write([s,'(',slstr[sl],') ']);
  1347. case sl of
  1348. sl_none : ;
  1349. sl_call,
  1350. sl_load,
  1351. sl_subscript :
  1352. if (Ref <> nil) and (Ref.IsNull) then
  1353. begin
  1354. readderef('',Ref);
  1355. Ref.IsSymId:=True;
  1356. end
  1357. else
  1358. readderef('');
  1359. sl_absolutetype,
  1360. sl_typeconv :
  1361. readderef('');
  1362. sl_vec :
  1363. begin
  1364. writeln([ppufile.getlongint]);
  1365. readderef('');
  1366. end;
  1367. end;
  1368. until false;
  1369. end;
  1370. (*
  1371. talignmentinfo = packed record
  1372. procalign,
  1373. loopalign,
  1374. jumpalign,
  1375. constalignmin,
  1376. constalignmax,
  1377. varalignmin,
  1378. varalignmax,
  1379. localalignmin,
  1380. localalignmax,
  1381. recordalignmin,
  1382. recordalignmax,
  1383. maxCrecordalign : longint;
  1384. end;
  1385. tsettings = packed record
  1386. alignment : talignmentinfo;
  1387. globalswitches : tglobalswitches;
  1388. moduleswitches : tmoduleswitches;
  1389. localswitches : tlocalswitches;
  1390. modeswitches : tmodeswitches;
  1391. optimizerswitches : toptimizerswitches;
  1392. { generate information necessary to perform these wpo's during a subsequent compilation }
  1393. genwpoptimizerswitches: twpoptimizerswitches;
  1394. { perform these wpo's using information generated during a previous compilation }
  1395. dowpoptimizerswitches: twpoptimizerswitches;
  1396. debugswitches : tdebugswitches;
  1397. { 0: old behaviour for sets <=256 elements
  1398. >0: round to this size }
  1399. setalloc,
  1400. packenum : shortint;
  1401. packrecords : shortint;
  1402. maxfpuregisters : shortint;
  1403. cputype,
  1404. optimizecputype : tcputype;
  1405. fputype : tfputype;
  1406. asmmode : tasmmode;
  1407. interfacetype : tinterfacetypes;
  1408. defproccall : tproccalloption;
  1409. sourcecodepage : tcodepagestring;
  1410. minfpconstprec : tfloattype;
  1411. disabledircache : boolean;
  1412. { CPU targets with microcontroller support can add a controller specific unit }
  1413. controllertype : tcontrollertype;
  1414. { WARNING: this pointer cannot be written as such in record token }
  1415. pmessage : pmessagestaterecord;
  1416. end;
  1417. *)
  1418. procedure readprocinfooptions(space : string);
  1419. (*
  1420. tprocinfoflag=(
  1421. { procedure has at least one assembler block }
  1422. pi_has_assembler_block,
  1423. { procedure does a call }
  1424. pi_do_call,
  1425. { procedure has a try statement = no register optimization }
  1426. pi_uses_exceptions,
  1427. { procedure is declared as @var(assembler), don't optimize}
  1428. pi_is_assembler,
  1429. { procedure contains data which needs to be finalized }
  1430. pi_needs_implicit_finally,
  1431. { procedure has the implicit try..finally generated }
  1432. pi_has_implicit_finally,
  1433. { procedure uses fpu}
  1434. pi_uses_fpu,
  1435. { procedure uses GOT for PIC code }
  1436. pi_needs_got,
  1437. { references var/proc/type/const in static symtable,
  1438. i.e. not allowed for inlining from other units }
  1439. pi_uses_static_symtable,
  1440. { set if the procedure has to push parameters onto the stack }
  1441. pi_has_stackparameter,
  1442. { set if the procedure has at least one label }
  1443. pi_has_label,
  1444. { calls itself recursive }
  1445. pi_is_recursive,
  1446. { stack frame optimization not possible (only on x86 probably) }
  1447. pi_needs_stackframe,
  1448. { set if the procedure has at least one register saved on the stack }
  1449. pi_has_saved_regs,
  1450. { dfa was generated for this proc }
  1451. pi_dfaavailable,
  1452. { subroutine contains interprocedural used labels }
  1453. pi_has_interproclabel,
  1454. { subroutine contains interprocedural gotos }
  1455. pi_has_global_goto
  1456. ); *)
  1457. type
  1458. tprocinfoopt=record
  1459. mask : tprocinfoflag;
  1460. str : string[81];
  1461. end;
  1462. const
  1463. procinfoopts=ord(high(tprocinfoflag)) - ord(low(tprocinfoflag));
  1464. procinfoopt : array[0..procinfoopts] of tprocinfoopt=(
  1465. (mask:pi_has_assembler_block;
  1466. str:' has at least one assembler block'),
  1467. (mask:pi_do_call;
  1468. str:' does a call'),
  1469. (mask:pi_uses_exceptions;
  1470. str:' has a try statement = no register optimization '),
  1471. (mask:pi_is_assembler;
  1472. str:' is declared as @var(assembler), don''t optimize'),
  1473. (mask:pi_needs_implicit_finally;
  1474. str:' contains data which needs to be finalized '),
  1475. (mask:pi_has_implicit_finally;
  1476. str:' has the implicit try..finally generated '),
  1477. (mask:pi_uses_fpu;
  1478. str:' uses fpu'),
  1479. (mask:pi_needs_got;
  1480. str:' uses GOT for PIC code '),
  1481. (mask:pi_uses_static_symtable;
  1482. str:' references var/proc/type/const in static symtable'),
  1483. (mask:pi_has_stackparameter;
  1484. str:' set if the procedure has to push parameters onto the stack '),
  1485. (mask:pi_has_label;
  1486. str:' set if the procedure has at least one label '),
  1487. (mask:pi_is_recursive;
  1488. str:' calls itself recursive '),
  1489. (mask:pi_needs_stackframe;
  1490. str:' stack frame optimization not possible (only on x86 probably) '),
  1491. (mask:pi_has_saved_regs;
  1492. str:' set if the procedure has at least one register saved on the stack '),
  1493. (mask:pi_dfaavailable;
  1494. str:' dfa was generated for this proc '),
  1495. (mask:pi_has_interproclabel;
  1496. str:' subroutine contains interprocedural used labels '),
  1497. (mask:pi_has_unwind_info;
  1498. str:' unwinding info was generated for this proc '),
  1499. (mask:pi_has_global_goto;
  1500. str:' subroutine contains interprocedural goto '),
  1501. (mask:pi_has_inherited;
  1502. str:' subroutine contains inherited call '),
  1503. (mask:pi_has_nested_exit;
  1504. str:' subroutine contains a nested subroutine which calls the exit of the current one '),
  1505. (mask:pi_has_stack_allocs;
  1506. str:' allocates memory on stack, so stack may be unbalanced on exit '),
  1507. (mask:pi_estimatestacksize;
  1508. str:' stack size is estimated before subroutine is compiled '),
  1509. (mask:pi_calls_c_varargs;
  1510. str:' calls function with C-style varargs '),
  1511. (mask:pi_has_open_array_parameter;
  1512. str:' has open array parameter '),
  1513. (mask:pi_uses_threadvar;
  1514. str:' uses threadvars '),
  1515. (mask:pi_has_except_table_data;
  1516. str:' has except table data '),
  1517. (mask:pi_needs_tls;
  1518. str:' uses TLS data pointer '),
  1519. (mask:pi_uses_get_frame;
  1520. str:' uses get_frame')
  1521. );
  1522. var
  1523. procinfooptions : tprocinfoflags;
  1524. i : longint;
  1525. first : boolean;
  1526. begin
  1527. ppufile.getset(tppuset4(procinfooptions));
  1528. if procinfooptions<>[] then
  1529. begin
  1530. first:=true;
  1531. for i:=0 to procinfoopts do
  1532. if (procinfoopt[i].mask in procinfooptions) then
  1533. begin
  1534. if first then
  1535. first:=false
  1536. else
  1537. write(', ');
  1538. write(procinfoopt[i].str);
  1539. end;
  1540. end;
  1541. writeln;
  1542. end;
  1543. procedure readsymoptions(space : string; Def: TPpuDef = nil);
  1544. type
  1545. tsymopt=record
  1546. mask : tsymoption;
  1547. str : string[30];
  1548. end;
  1549. const
  1550. symopts=ord(high(tsymoption)) - ord(low(tsymoption));
  1551. { sp_none = 0 corresponds to nothing }
  1552. symopt : array[1..symopts] of tsymopt=(
  1553. (mask:sp_static; str:'Static'),
  1554. (mask:sp_hint_deprecated; str:'Hint Deprecated'),
  1555. (mask:sp_hint_platform; str:'Hint Platform'),
  1556. (mask:sp_hint_library; str:'Hint Library'),
  1557. (mask:sp_hint_unimplemented; str:'Hint Unimplemented'),
  1558. (mask:sp_hint_experimental; str:'Hint Experimental'),
  1559. (mask:sp_has_overloaded; str:'Has overloaded'),
  1560. (mask:sp_internal; str:'Internal'),
  1561. (mask:sp_implicitrename; str:'Implicit Rename'),
  1562. (mask:sp_generic_para; str:'Generic Parameter'),
  1563. (mask:sp_has_deprecated_msg; str:'Has Deprecated Message'),
  1564. (mask:sp_generic_dummy; str:'Generic Dummy'),
  1565. (mask:sp_explicitrename; str:'Explicit Rename'),
  1566. (mask:sp_generic_const; str:'Generic Constant Parameter')
  1567. );
  1568. var
  1569. symoptions : tsymoptions;
  1570. i : longint;
  1571. first : boolean;
  1572. begin
  1573. ppufile.getset(tppuset2(symoptions));
  1574. if symoptions<>[] then
  1575. begin
  1576. if Def <> nil then
  1577. if sp_internal in symoptions then
  1578. Def.Visibility:=dvHidden;
  1579. first:=true;
  1580. for i:=1to symopts do
  1581. if (symopt[i].mask in symoptions) then
  1582. begin
  1583. if first then
  1584. first:=false
  1585. else
  1586. write(', ');
  1587. write(symopt[i].str);
  1588. end;
  1589. end;
  1590. writeln;
  1591. if sp_has_deprecated_msg in symoptions then
  1592. writeln([space,'Deprecated : ', ppufile.getstring]);
  1593. end;
  1594. procedure readvisibility(Def: TPpuDef = nil);
  1595. var
  1596. i: byte;
  1597. begin
  1598. i:=ppufile.getbyte;
  1599. if Def <> nil then
  1600. case tvisibility(i) of
  1601. vis_public: Def.Visibility:=dvPublic;
  1602. vis_published: Def.Visibility:=dvPublished;
  1603. vis_protected, vis_strictprotected: Def.Visibility:=dvProtected;
  1604. else Def.Visibility:=dvPrivate;
  1605. end;
  1606. writeln(Visibility2Str(i));
  1607. end;
  1608. procedure readattrs(def: TPpuDef);
  1609. var
  1610. i,cnt,paras: longint;
  1611. begin
  1612. cnt:=ppufile.getlongint;
  1613. if cnt>0 then
  1614. begin
  1615. writeln([space,' Attributes : ']);
  1616. space:=' '+space;
  1617. if assigned(def) then
  1618. SetLength(def.Attrs,cnt);
  1619. for i:=0 to cnt-1 do
  1620. begin
  1621. writeln([space,'** Custom Attribute ',i,' **']);
  1622. write ([space,' Type symbol : ']);
  1623. if assigned(def) then
  1624. begin
  1625. def.Attrs[i].TypeSym:=TPpuRef.Create;
  1626. readderef('',def.Attrs[i].TypeSym);
  1627. end
  1628. else
  1629. readderef('');
  1630. write ([space,' Type constructor : ']);
  1631. if assigned(def) then
  1632. begin
  1633. def.Attrs[i].TypeConstr:=TPpuRef.Create;
  1634. readderef('',def.Attrs[i].TypeConstr);
  1635. end
  1636. else
  1637. readderef('');
  1638. paras:=ppufile.getlongint;
  1639. writeln([space,' Parameters : ',paras]);
  1640. if assigned(def) then
  1641. def.Attrs[i].ParaCount:=paras;
  1642. end;
  1643. delete(space,1,4);
  1644. end;
  1645. end;
  1646. procedure readnodetree; forward;
  1647. procedure readattrparas(def: TPpuDef);
  1648. var
  1649. attr,para: LongInt;
  1650. begin
  1651. if Length(def.Attrs) > 0 then
  1652. writeln([space,' Attr Paras : ']);
  1653. space:=' '+space;
  1654. for attr:=0 to High(def.Attrs) do
  1655. begin
  1656. writeln([space,'** Custom Attribute ',attr,' Arguments **']);
  1657. space:=' '+space;
  1658. for para:=0 to def.Attrs[attr].ParaCount-1 do
  1659. begin
  1660. readnodetree;
  1661. end;
  1662. delete(space,1,4);
  1663. end;
  1664. delete(space,1,4);
  1665. end;
  1666. procedure readdefsubentries(def: TPpuDef);
  1667. begin
  1668. space:=' '+space;
  1669. readattrparas(def);
  1670. delete(space,1,4);
  1671. end;
  1672. procedure readsymsubentries(def: TPpuDef);
  1673. begin
  1674. readattrparas(def);
  1675. end;
  1676. procedure readcommonsym(const s:string; Def: TPpuDef = nil);
  1677. var
  1678. i: integer;
  1679. n: string;
  1680. begin
  1681. n:=ppufile.getstring;
  1682. if Def <> nil then
  1683. Def.Name:=n;
  1684. i:=ppufile.getlongint;
  1685. if Def <> nil then
  1686. Def.SetSymId(i);
  1687. writeln([space,'** Symbol Id ',i,' **']);
  1688. writeln([space,s,n]);
  1689. write ([space,' File Pos : ']);
  1690. readposinfo(Def);
  1691. write ([space,' Visibility : ']);
  1692. readvisibility(Def);
  1693. write ([space,' SymOptions : ']);
  1694. readsymoptions(space+' ',Def);
  1695. readattrs(Def);
  1696. end;
  1697. procedure readcgpara(const space:string);
  1698. { this is originally in cgbase.pas }
  1699. type
  1700. TCGLoc=(LOC_INVALID, LOC_VOID, LOC_CONSTANT, LOC_JUMP, LOC_FLAGS,
  1701. LOC_REGISTER, LOC_CREGISTER, LOC_FPUREGISTER, LOC_CFPUREGISTER,
  1702. LOC_MMXREGISTER, LOC_CMMXREGISTER, LOC_MMREGISTER, LOC_CMMREGISTER,
  1703. LOC_SUBSETREG, LOC_CSUBSETREG, LOC_SUBSETREF, LOC_CSUBSETREF,
  1704. LOC_CREFERENCE, LOC_REFERENCE);
  1705. const
  1706. tcgloc2str : array[TCGLoc] of string[12] = (
  1707. 'LOC_INVALID', 'LOC_VOID', 'LOC_CONST', 'LOC_JUMP', 'LOC_FLAGS',
  1708. 'LOC_REG', 'LOC_CREG', 'LOC_FPUREG', 'LOC_CFPUREG',
  1709. 'LOC_MMXREG', 'LOC_CMMXREG', 'LOC_MMREG', 'LOC_CMMREG',
  1710. 'LOC_SSETREG', 'LOC_CSSETREG', 'LOC_SSETREF', 'LOC_CSSETREF',
  1711. 'LOC_CREF', 'LOC_REF');
  1712. var
  1713. i: byte;
  1714. ii: longint;
  1715. np: byte;
  1716. loc: tcgloc;
  1717. begin
  1718. i:=ppufile.getbyte;
  1719. writeln([space,' Alignment : ',i]);
  1720. i:=ppufile.getbyte;
  1721. writeln([space,' Size : ',i]);
  1722. ii:=ppufile.getaint;
  1723. writeln([space,' IntSize : ',ii]);
  1724. readderef(space+' ');
  1725. np:=ppufile.getbyte;
  1726. writeln([space,' NumParaloc : ',np]);
  1727. while np > 0 do
  1728. begin
  1729. i:=ppufile.getbyte;
  1730. writeln([space,' Paraloc Size : ',i]);
  1731. loc:=tcgloc(ppufile.getbyte);
  1732. if loc > high(tcgloc) then
  1733. begin
  1734. WriteError('!! Location is out of range! '+IntToStr(ord(loc)));
  1735. loc:=LOC_INVALID;
  1736. end;
  1737. writeln([space,' Paraloc Loc : (',ord(loc),') ',tcgloc2str[loc]]);
  1738. case loc of
  1739. LOC_REFERENCE:
  1740. begin
  1741. writeln([space,' RegIndex : $',hexstr(ppufile.getdword,8)]);
  1742. writeln([space,' Offset : ',ppufile.getaint]);
  1743. end;
  1744. LOC_FPUREGISTER,
  1745. LOC_CFPUREGISTER,
  1746. LOC_MMREGISTER,
  1747. LOC_CMMREGISTER,
  1748. LOC_REGISTER,
  1749. LOC_CREGISTER :
  1750. begin
  1751. writeln([space,' ShiftVal : ',ppufile.getbyte]);
  1752. writeln([space,' Register : $',hexstr(ppufile.getdword,8)]);
  1753. end;
  1754. LOC_VOID:
  1755. begin end
  1756. else
  1757. WriteError('!! Invalid location error')
  1758. end;
  1759. dec(np);
  1760. end;
  1761. end;
  1762. procedure displaytokenbuffer(tokenbuf : pbyte;tokenbufsize : longint);
  1763. type
  1764. ptoken=^ttoken;
  1765. pmsgstate =^tmsgstate;
  1766. var
  1767. tbi : longint;
  1768. state : tmsgstate;
  1769. prev_settings, new_settings : Tsettings;
  1770. nb, msgvalue, mesgnb : longint;
  1771. function readtoken: ttoken;
  1772. var
  1773. b,b2 : byte;
  1774. begin
  1775. b:=tokenbuf[tbi];
  1776. inc(tbi);
  1777. if (b and $80)<>0 then
  1778. begin
  1779. b2:=tokenbuf[tbi];
  1780. inc(tbi);
  1781. result:=ttoken(((b and $7f) shl 8) or b2);
  1782. end
  1783. else
  1784. result:=ttoken(b);
  1785. end;
  1786. function gettokenbufdword : dword;
  1787. var
  1788. var32 : dword;
  1789. begin
  1790. var32:=unaligned(pdword(@tokenbuf[tbi])^);
  1791. inc(tbi,sizeof(dword));
  1792. if ppufile.change_endian then
  1793. var32:=swapendian(var32);
  1794. result:=var32;
  1795. end;
  1796. function gettokenbufword : word;
  1797. var
  1798. var16 : word;
  1799. begin
  1800. var16:=unaligned(pword(@tokenbuf[tbi])^);
  1801. inc(tbi,sizeof(word));
  1802. if ppufile.change_endian then
  1803. var16:=swapendian(var16);
  1804. result:=var16;
  1805. end;
  1806. function gettokenbuflongint : longint;
  1807. var
  1808. var32 : longint;
  1809. begin
  1810. var32:=unaligned(plongint(@tokenbuf[tbi])^);
  1811. inc(tbi,sizeof(longint));
  1812. if ppufile.change_endian then
  1813. var32:=swapendian(var32);
  1814. result:=var32;
  1815. end;
  1816. function gettokenbufshortint : shortint;
  1817. var
  1818. var8 : shortint;
  1819. begin
  1820. var8:=pshortint(@tokenbuf[tbi])^;
  1821. inc(tbi,sizeof(shortint));
  1822. result:=var8;
  1823. end;
  1824. procedure tokenreadset(var b;size : longint);
  1825. var
  1826. i : longint;
  1827. begin
  1828. move(tokenbuf[tbi],b,size);
  1829. inc(tbi,size);
  1830. if ppufile.change_endian then
  1831. for i:=0 to size-1 do
  1832. Pbyte(@b)[i]:=reverse_byte(Pbyte(@b)[i]);
  1833. end;
  1834. function gettokenbufbyte : byte;
  1835. begin
  1836. result:=pbyte(@tokenbuf[tbi])^;
  1837. inc(tbi);
  1838. end;
  1839. function tokenreadenum(size : longint) : longword;
  1840. begin
  1841. if size=1 then
  1842. result:=gettokenbufbyte
  1843. else if size=2 then
  1844. result:=gettokenbufword
  1845. else if size=4 then
  1846. result:=gettokenbufdword;
  1847. end;
  1848. function gettokenbufsizeint : int64;
  1849. var
  1850. var64 : int64;
  1851. var32 : longint;
  1852. var16 : smallint;
  1853. begin
  1854. if CpuAddrBitSize[cpu]=64 then
  1855. begin
  1856. var64:=unaligned(pint64(@tokenbuf[tbi])^);
  1857. inc(tbi,sizeof(int64));
  1858. if ppufile.change_endian then
  1859. var64:=swapendian(var64);
  1860. result:=var64;
  1861. end
  1862. else if CpuAddrBitSize[cpu]=32 then
  1863. begin
  1864. var32:=unaligned(plongint(@tokenbuf[tbi])^);
  1865. inc(tbi,sizeof(longint));
  1866. if ppufile.change_endian then
  1867. var32:=swapendian(var32);
  1868. result:=var32;
  1869. end
  1870. else if CpuAddrBitSize[cpu]=16 then
  1871. begin
  1872. { ASizeInt is still a longint, see globtype.pas unit }
  1873. var32:=unaligned(plongint(@tokenbuf[tbi])^);
  1874. inc(tbi,sizeof(longint));
  1875. if ppufile.change_endian then
  1876. var32:=swapendian(var32);
  1877. result:=var32;
  1878. end
  1879. else
  1880. begin
  1881. WriteError('Wrong CpuAddrBitSize');
  1882. result:=0;
  1883. end;
  1884. end;
  1885. procedure tokenreadsettings(var asettings : tsettings; expected_size : asizeint);
  1886. { This procedure
  1887. needs to be changed whenever
  1888. globals.tsettings type is changed,
  1889. the problem is that no error will appear
  1890. before tests with generics are tested. PM }
  1891. var
  1892. startpos, endpos : longword;
  1893. begin
  1894. { WARNING all those fields need to be in the correct
  1895. order otherwise cross_endian PPU reading will fail }
  1896. startpos:=tbi;
  1897. with asettings do
  1898. begin
  1899. alignment.procalign:=gettokenbuflongint;
  1900. alignment.loopalign:=gettokenbuflongint;
  1901. alignment.jumpalign:=gettokenbuflongint;
  1902. alignment.jumpalignskipmax:=gettokenbuflongint;
  1903. alignment.coalescealign:=gettokenbuflongint;
  1904. alignment.coalescealignskipmax:=gettokenbuflongint;
  1905. alignment.constalignmin:=gettokenbuflongint;
  1906. alignment.constalignmax:=gettokenbuflongint;
  1907. alignment.varalignmin:=gettokenbuflongint;
  1908. alignment.varalignmax:=gettokenbuflongint;
  1909. alignment.localalignmin:=gettokenbuflongint;
  1910. alignment.localalignmax:=gettokenbuflongint;
  1911. alignment.recordalignmin:=gettokenbuflongint;
  1912. alignment.recordalignmax:=gettokenbuflongint;
  1913. alignment.maxCrecordalign:=gettokenbuflongint;
  1914. tokenreadset(globalswitches,sizeof(globalswitches));
  1915. tokenreadset(targetswitches,sizeof(targetswitches));
  1916. tokenreadset(moduleswitches,sizeof(moduleswitches));
  1917. tokenreadset(localswitches,sizeof(localswitches));
  1918. tokenreadset(modeswitches,sizeof(modeswitches));
  1919. tokenreadset(optimizerswitches,sizeof(optimizerswitches));
  1920. tokenreadset(genwpoptimizerswitches,sizeof(genwpoptimizerswitches));
  1921. tokenreadset(dowpoptimizerswitches,sizeof(dowpoptimizerswitches));
  1922. tokenreadset(debugswitches,sizeof(debugswitches));
  1923. { 0: old behaviour for sets <=256 elements
  1924. >0: round to this size }
  1925. setalloc:=gettokenbufshortint;
  1926. packenum:=gettokenbufshortint;
  1927. packrecords:=gettokenbufshortint;
  1928. maxfpuregisters:=gettokenbufshortint;
  1929. cputype:=tcputype(tokenreadenum(sizeof(tcputype)));
  1930. optimizecputype:=tcputype(tokenreadenum(sizeof(tcputype)));
  1931. fputype:=tfputype(tokenreadenum(sizeof(tfputype)));
  1932. asmmode:=tasmmode(tokenreadenum(sizeof(tasmmode)));
  1933. interfacetype:=tinterfacetypes(tokenreadenum(sizeof(tinterfacetypes)));
  1934. defproccall:=tproccalloption(tokenreadenum(sizeof(tproccalloption)));
  1935. { tstringencoding is word type,
  1936. thus this should be OK here }
  1937. sourcecodepage:=tstringEncoding(gettokenbufword);
  1938. minfpconstprec:=tfloattype(tokenreadenum(sizeof(tfloattype)));
  1939. disabledircache:=boolean(gettokenbufbyte);
  1940. tlsmodel:=ttlsmodel(tokenreadenum(sizeof(ttlsmodel)));
  1941. { TH: Since the field was conditional originally, it was not stored in PPUs. }
  1942. { While adding ControllerSupport constant, I decided not to store ct_none }
  1943. { on targets not supporting controllers, but this might be changed here and }
  1944. { in tokenwritesettings in the future to unify the PPU structure and handling }
  1945. { of this field in the compiler. }
  1946. {$PUSH}
  1947. {$WARN 6018 OFF} (* Unreachable code due to compile time evaluation *)
  1948. if CpuHasController[cpu] then
  1949. controllertype:=tcontrollertype(tokenreadenum(sizeof(tcontrollertype)))
  1950. else
  1951. ControllerType:=ct_none;
  1952. {$POP}
  1953. endpos:=tbi;
  1954. if endpos-startpos<>expected_size then
  1955. Writeln(['Wrong size of Settings read-in: ',expected_size,' expected, but got ',endpos-startpos]);
  1956. end;
  1957. end;
  1958. procedure dump_new_settings;
  1959. (* tsettings = record
  1960. alignment : talignmentinfo;
  1961. globalswitches : tglobalswitches;
  1962. targetswitches : ttargetswitches;
  1963. moduleswitches : tmoduleswitches;
  1964. localswitches : tlocalswitches;
  1965. modeswitches : tmodeswitches;
  1966. optimizerswitches : toptimizerswitches;
  1967. { generate information necessary to perform these wpo's during a subsequent compilation }
  1968. genwpoptimizerswitches: twpoptimizerswitches;
  1969. { perform these wpo's using information generated during a previous compilation }
  1970. dowpoptimizerswitches: twpoptimizerswitches;
  1971. debugswitches : tdebugswitches;
  1972. { 0: old behaviour for sets <=256 elements
  1973. >0: round to this size }
  1974. setalloc,
  1975. packenum : shortint;
  1976. packrecords : shortint;
  1977. maxfpuregisters : shortint;
  1978. cputype,
  1979. optimizecputype,
  1980. asmcputype : tcputype;
  1981. fputype : tfputype;
  1982. asmmode : tasmmode;
  1983. interfacetype : tinterfacetypes;
  1984. defproccall : tproccalloption;
  1985. sourcecodepage : tstringencoding;
  1986. minfpconstprec : tfloattype;
  1987. disabledircache : boolean;
  1988. tlsmodel : ttlsmodel;
  1989. {$if defined(i8086)}
  1990. x86memorymodel : tx86memorymodel;
  1991. {$endif defined(i8086)}
  1992. {$if defined(ARM)}
  1993. instructionset : tinstructionset;
  1994. {$endif defined(ARM)}
  1995. {$if defined(LLVM) and not defined(GENERIC_CPU)}
  1996. llvmversion: tllvmversion;
  1997. {$endif defined(LLVM) and not defined(GENERIC_CPU)}
  1998. { CPU targets with microcontroller support can add a controller specific unit }
  1999. controllertype : tcontrollertype;
  2000. { WARNING: this pointer cannot be written as such in record token }
  2001. pmessage : pmessagestaterecord;
  2002. end; *)
  2003. const
  2004. targetswitchname : array[ttargetswitch] of string[30] =
  2005. { global target-specific switches }
  2006. ('Target None', {ts_none}
  2007. { generate code that results in smaller TOCs than normal (AIX) }
  2008. 'Small TOC', {ts_small_toc}
  2009. { for the JVM target: generate integer array initializations via string
  2010. constants in order to reduce the generated code size (Java routines
  2011. are limited to 64kb of bytecode) }
  2012. 'JVM compact int array init', {ts_compact_int_array_init}
  2013. { for the JVM target: intialize enum fields in constructors with the
  2014. enum class instance corresponding to ordinal value 0 (not done by
  2015. default because this initialization can only be performed after the
  2016. inherited constructors have run, and if they call a virtual method
  2017. of the current class, then this virtual method may already have
  2018. initialized that field with another value and the constructor
  2019. initialization will result in data loss }
  2020. 'JVM enum field init', {ts_jvm_enum_field_init}
  2021. { when automatically generating getters/setters for properties, use
  2022. these strings as prefixes for the generated getters/setter names }
  2023. 'Auto getter prefix', {ts_auto_getter_prefix}
  2024. 'Auto setter prefix', {ts_auto_setter_predix}
  2025. 'Thumb interworking', {ts_thumb_interworking,}
  2026. { lowercase the first character of routine names, used to generate
  2027. names that are compliant with Java coding standards from code
  2028. written according to Delphi coding standards }
  2029. 'LowerCase proc start', {ts_lowercase_proc_start,}
  2030. { initialise local variables on the JVM target so you won't get
  2031. accidental uses of uninitialised values }
  2032. 'Init locals', {ts_init_locals}
  2033. { emit a CLD instruction before using the x86 string instructions }
  2034. 'Emit CLD instruction', {ts_cld}
  2035. { increment BP before pushing it in the function prologue and decrement
  2036. it after popping it in the function epilogue, iff the function is
  2037. going to terminate with a far ret. Thus, the BP value pushed on the
  2038. stack becomes odd if the function is far and even if the function is
  2039. near. This allows walking the BP chain on the stack and e.g.
  2040. obtaining a stack trace even if the program uses a mixture of near
  2041. and far calls. This is also required for Win16 real mode, because it
  2042. allows Windows to move code segments around (in order to defragment
  2043. memory) and then walk through the stacks of all running programs and
  2044. update the segment values of the segment that has moved. }
  2045. 'Use odd BP for far procs' {ts_x86_far_procs_push_odd_bp}
  2046. );
  2047. moduleswitchname : array[tmoduleswitch] of string[40] =
  2048. ('Module None', {cs_modulenone,}
  2049. { parser }
  2050. 'Floating Point Emulation',{ cs_fp_emulation}
  2051. 'Extended syntax', {cs_extsyntax}
  2052. 'Open string', {cs_openstring}
  2053. { support }
  2054. 'Goto allowed', {cs_support_goto}
  2055. 'Macro support', {cs_support_macro}
  2056. 'C operator support', {cs_support_c_operators}
  2057. { generation }
  2058. 'Profile', {cs_profile}
  2059. 'Debug information', {cs_debuginfo}
  2060. 'Compilation of System unit', {cs_compilesystem}
  2061. 'Line information', {cs_lineinfo}
  2062. 'Implicit exceptions', {cs_implicit_exceptions}
  2063. 'Explicit CodePage', {cs_explicit_codepage}
  2064. 'System CodePage', {cs_system_codepage}
  2065. { linking }
  2066. 'Create smart units', {cs_create_smart}
  2067. 'Create dynamic', {cs_create_dynamic}
  2068. 'Create PIC code', {cs_create_pic}
  2069. { browser switches are back }
  2070. 'Browser', {cs_browser}
  2071. 'Local Browser', {cs_local_browser}
  2072. { target specific }
  2073. 'Executable Stack', {cs_executable_stack}
  2074. { i8086 specific }
  2075. 'Hude code', {cs_huge_code}
  2076. 'Win16 smart callbacks', {cs_win16_smartcallbacks}
  2077. { Record usage of checkpointer experimental feature }
  2078. 'CheckPointer used', {cs_checkpointer_called}
  2079. 'Supports LLVM Link-Time Optimization' {cs_lto}
  2080. );
  2081. globalswitchname : array[tglobalswitch] of string[50] =
  2082. ('Global None',{cs_globalnone}
  2083. { parameter switches }
  2084. 'Check unit name', {cs_check_unit_name}
  2085. 'Constructor name', {cs_constructor_name}
  2086. 'Support exceptions',{cs_support_exceptions}
  2087. 'Support Objective-C pas',{ cs_support_c_objectivepas}
  2088. 'Transparent file names', {cs_transparent_file_names}
  2089. { units }
  2090. 'Load Objpas Unit', {cs_load_objpas_unit}
  2091. 'Load GPC unit', {cs_load_gpc_unit}
  2092. 'Load FPCKylix unit', {cs_load_fpcylix_unit}
  2093. 'Support Vectors', {cs_support_vectors}
  2094. { debuginfo }
  2095. 'Use HeapTRc unit', {cs_use_heaptrc}
  2096. 'Use line information', {cs_use_lineinfo}
  2097. 'Use GDB Valgrind', {cs_gdb_valgrind}
  2098. 'No regalloc', {cs_no_regalloc}
  2099. 'Stabs preserve cases', {cs_stabs_preservecase}
  2100. { assembling }
  2101. 'Leave assembler file', {cs_asm_leave}
  2102. 'Use external assembler', {cs_asm_extern}
  2103. 'Use pipes to call assembler', {cs_asm_pipe}
  2104. 'Add source infos into assembler files', {cs_asm_source}
  2105. 'Add register allocation into assembler files', {cs_asm_regalloc}
  2106. 'Add temporary allocation into assmebler files', {cs_asm_tempalloc}
  2107. 'Add node information into assembler files', {cs_asm_nodes}
  2108. 'Adapt assembler call to GNU version <= 2.25', {cs_asm_pre_binutils_2_25}
  2109. { linking }
  2110. 'Skip linking stage', {cs_link_nolink}
  2111. 'Link static', {cs_link_static}
  2112. 'Link smart', {cs_link_smart}
  2113. 'Link shared', {cs_link_shared}
  2114. 'Link deffile', {cs_link_deffile}
  2115. 'Strip after linking', {cs_link_strip}
  2116. 'Use linker static flag',{cs_link_staticflag}
  2117. 'Link on target OS',{cs_link_on_target}
  2118. 'Use external linker', {cs_link_extern}
  2119. 'Link opt vtable', {cs_link_opt_vtable}
  2120. 'Link opt used sections', {cs_link_opt_used_sections}
  2121. 'Link debug to separate file',{cs_link_separate_dbg_file}
  2122. 'Create linker map', {cs_link_map}
  2123. 'Link to pthread', {cs_link_pthread}
  2124. 'Link no default lib order', {cs_link_no_default_lib_order}
  2125. 'Link using native linker', {cs_link_native}
  2126. 'Link for GNU linker version <=2.19', {cs_link_pre_binutils_2_19}
  2127. 'Link using vlink', {cs_link_vlink}
  2128. 'Link-Time Optimization disabled for system unit' {cs_lto_nosystem}
  2129. );
  2130. localswitchname : array[tlocalswitch] of string[50] =
  2131. { Switches which can be changed locally }
  2132. ('Local None', {cs_localnone}
  2133. { codegen }
  2134. 'Check overflow', {cs_check_overflow}
  2135. 'Check range', {cs_check_range}
  2136. 'Check object error', {cs_check_object}
  2137. 'Check I/O error', {cs_check_io}
  2138. 'Check stack', {cs_check_stack}
  2139. 'Check pointer', {cs_checkpointer}
  2140. 'Check ordinal size', {cs_check_ordinal_size}
  2141. 'Generate stackframes', {cs_generate_stackframes}
  2142. 'Do assertions', {cs_do_assertion}
  2143. 'Generate RTTI', {cs_generate_rtti}
  2144. 'Full boolean evaluaion', {cs_full_boolean_eval}
  2145. 'Typed constant are writable', {cs_typed_const_writable}
  2146. 'Allow calcuation on enum types', {cs_allow_enum_calc}
  2147. 'Do inline', {cs_do_inline}
  2148. 'Add FWAIT instruction for FPU 8087', {cs_fpu_fwait}
  2149. 'IEEE errors', {cs_ieee_errors}
  2150. 'Check low address loading', {cs_check_low_addr_load}
  2151. 'Imported data', {cs_imported_data}
  2152. 'Excess precision', {cs_excessprecision}
  2153. 'Check fpu exceptions', {cs_check_fpu_exceptions}
  2154. 'Check all case coverage', {cs_check_all_case_coverage}
  2155. { mmx }
  2156. 'Allow MMX instructions', {cs_mmx}
  2157. 'Use MMX saturation', {cs_mmx_saturation}
  2158. { parser }
  2159. 'Use typed addresses', {cs_typed_addresses}
  2160. 'Use strict var strings', {cs_strict_var_strings}
  2161. 'Use reference counted strings', {cs_refcountedstrings}
  2162. 'Use bit-packing', {cs_bitpacking}
  2163. 'Use var property setter', {cs_varpropsetter}
  2164. 'Use scoped enums',{cs_scopedenums}
  2165. 'Use pointer math', {cs_pointermath}
  2166. { macpas specific}
  2167. 'MACPAS exteranl variable', {cs_external_var}
  2168. 'MACPAS externally visible', {cs_externally_visible}
  2169. { jvm specific }
  2170. 'JVM check var copyout', {cs_check_var_copyout}
  2171. 'Zero based strings', {cs_zerobasedstrings}
  2172. { i8086 specific }
  2173. 'i8086 force FAR calls', {cs_force_far_calls}
  2174. 'i8086 huge pointer arithmetic', {cs_hugeptr_arithmetic_normalization}
  2175. 'i8086 huge pointer comparison' {cs_hugeptr_comparison_normalization}
  2176. );
  2177. { Switches which can be changed by a mode (fpc,tp7,delphi) }
  2178. modeswitchname : array[tmodeswitch] of string[50] =
  2179. ('m_none',
  2180. { generic }
  2181. 'm_fpc','m_objfpc','m_delphi','m_tp7','m_mac','m_iso','m_extpas',
  2182. {$ifdef gpc_mode}'m_gpc',{$endif}
  2183. { more specific }
  2184. 'm_class', { delphi class model }
  2185. 'm_objpas', { load objpas unit }
  2186. 'm_result', { result in functions }
  2187. 'm_string_pchar', { pchar 2 string conversion }
  2188. 'm_cvar_support', { cvar variable directive }
  2189. 'm_nested_comment', { nested comments }
  2190. 'm_tp_procvar', { tp style procvars (no @ needed) }
  2191. 'm_mac_procvar', { macpas style procvars }
  2192. 'm_repeat_forward', { repeating forward declarations is needed }
  2193. 'm_pointer_2_procedure', { allows the assignement of pointers to
  2194. procedure variables }
  2195. 'm_autoderef', { does auto dereferencing of struct. vars }
  2196. 'm_initfinal', { initialization/finalization for units }
  2197. 'm_default_ansistring', { ansistring turned on by default }
  2198. 'm_out', { support the calling convention OUT }
  2199. 'm_default_para', { support default parameters }
  2200. 'm_hintdirective', { support hint directives }
  2201. 'm_duplicate_names', { allow locals/paras to have duplicate names of globals }
  2202. 'm_property', { allow properties }
  2203. 'm_default_inline', { allow inline proc directive }
  2204. 'm_except', { allow exception-related keywords }
  2205. 'm_objectivec1', { support interfacing with Objective-C (1.0) }
  2206. 'm_objectivec2', { support interfacing with Objective-C (2.0) }
  2207. 'm_nested_procvars', { support nested procedural variables }
  2208. 'm_non_local_goto', { support non local gotos (like iso pascal) }
  2209. 'm_advanced_records', { advanced record syntax with visibility sections, methods and properties }
  2210. 'm_isolike_unary_minus', { unary minus like in iso pascal: same precedence level as binary minus/plus }
  2211. 'm_systemcodepage', { use system codepage as compiler codepage by default, emit ansistrings with system codepage }
  2212. 'm_final_fields', { allows declaring fields as "final", which means they must be initialised
  2213. in the (class) constructor and are constant from then on (same as final
  2214. fields in Java) }
  2215. 'm_default_unicodestring', { makes the default string type in $h+ mode unicodestring rather than
  2216. ansistring; similarly, char becomes unicodechar rather than ansichar }
  2217. 'm_type_helpers', { allows the declaration of "type helper" for all supported types
  2218. (primitive types, records, classes, interfaces) }
  2219. 'm_blocks', { support for http://en.wikipedia.org/wiki/Blocks_(C_language_extension) }
  2220. 'm_isolike_io', { I/O as it required by an ISO compatible compiler }
  2221. 'm_isolike_program_para',{ program parameters as it required by an ISO compatible compiler }
  2222. 'm_isolike_mod', { mod operation as it is required by an iso compatible compiler }
  2223. 'm_array_operators', { use Delphi compatible array operators instead of custom ones ("+") }
  2224. 'm_multi_helpers', { helpers can appear in multiple scopes simultaneously }
  2225. 'm_array2dynarray', { regular arrays can be implicitly converted to dynamic arrays }
  2226. 'm_prefixed_attributes' { enable attributes that are defined before the type they belong to }
  2227. );
  2228. { optimizer }
  2229. optimizerswitchname : array[toptimizerswitch] of string[50] =
  2230. ('cs_opt_none',
  2231. 'cs_opt_level1',
  2232. 'cs_opt_level2',
  2233. 'cs_opt_level3',
  2234. 'cs_opt_level4',
  2235. 'cs_opt_regvar',
  2236. 'cs_opt_uncertain',
  2237. 'cs_opt_size',
  2238. 'cs_opt_stackframe',
  2239. 'cs_opt_peephole',
  2240. 'cs_opt_loopunroll',
  2241. 'cs_opt_tailrecursion',
  2242. 'cs_opt_nodecse',
  2243. 'cs_opt_nodedfa',
  2244. 'cs_opt_loopstrength',
  2245. 'cs_opt_scheduler',
  2246. 'cs_opt_autoinline',
  2247. 'cs_useebp',
  2248. 'cs_userbp',
  2249. 'cs_opt_reorder_fields',
  2250. 'cs_opt_fastmath',
  2251. { Allow removing expressions whose result is not used, even when this
  2252. can change program behaviour (range check errors disappear',
  2253. access violations due to invalid pointer derefences disappear, ...).
  2254. Note: it does not (and must not) remove expressions that have
  2255. explicit side-effects, only implicit side-effects (like the ones
  2256. mentioned before) can disappear.
  2257. }
  2258. 'cs_opt_dead_values',
  2259. { compiler checks for empty procedures/methods and removes calls to them if possible }
  2260. 'cs_opt_remove_empty_proc',
  2261. 'cs_opt_constant_propagate',
  2262. 'cs_opt_dead_store_eliminate',
  2263. 'cs_opt_forcenostackframe',
  2264. 'cs_opt_use_load_modify_store'
  2265. );
  2266. var
  2267. globalswitch : tglobalswitch;
  2268. targetswitch : ttargetswitch;
  2269. moduleswitch : tmoduleswitch;
  2270. localswitch : tlocalswitch;
  2271. modeswitch : tmodeswitch;
  2272. optimizerswitch : toptimizerswitch;
  2273. globalswitches : tglobalswitches;
  2274. targetswitches : ttargetswitches;
  2275. moduleswitches : tmoduleswitches;
  2276. localswitches : tlocalswitches;
  2277. modeswitches : tmodeswitches;
  2278. optimizerswitches : toptimizerswitches;
  2279. begin
  2280. {alignment : talignmentinfo;}
  2281. {talignmentinfo = packed record}
  2282. writeln('Procedure alignment: '+tostr(new_settings.alignment.procalign));
  2283. writeln('Loop alignment: '+tostr(new_settings.alignment.loopalign));
  2284. { alignment for labels after unconditional jumps, this must be a power of two }
  2285. writeln('Jump alignment: '+tostr(new_settings.alignment.jumpalign));
  2286. { max. alignment for labels after unconditional jumps:
  2287. the compiler tries to align jumpalign, however, to do so it inserts at maximum jumpalignskipmax bytes or uses
  2288. the next smaller power of two of jumpalign }
  2289. writeln('Jump skip max alignment: '+tostr(new_settings.alignment.jumpalignskipmax));
  2290. { alignment for labels where two flows of the program flow coalesce, this must be a power of two }
  2291. writeln('Coalescence alignment: '+tostr(new_settings.alignment.coalescealign));
  2292. { max. alignment for labels where two flows of the program flow coalesce
  2293. the compiler tries to align to coalescealign, however, to do so it inserts at maximum coalescealignskipmax bytes or uses
  2294. the next smaller power of two of coalescealign }
  2295. writeln('Coalescence skip max alignment: '+tostr(new_settings.alignment.coalescealignskipmax));
  2296. writeln('Const min alignment: '+tostr(new_settings.alignment.constalignmin));
  2297. writeln('Const max alignment: '+tostr(new_settings.alignment.constalignmax));
  2298. writeln('Var min alignment: '+tostr(new_settings.alignment.varalignmin));
  2299. writeln('Var max alignment: '+tostr(new_settings.alignment.varalignmax));
  2300. writeln('Local min alignment: '+tostr(new_settings.alignment.localalignmin));
  2301. writeln('Local max alignment: '+tostr(new_settings.alignment.localalignmax));
  2302. writeln('Min record alignment: '+tostr(new_settings.alignment.recordalignmin));
  2303. writeln('Max record alignment: '+tostr(new_settings.alignment.recordalignmax));
  2304. writeln('Max C record alignment: '+tostr(new_settings.alignment.maxCrecordalign));
  2305. globalswitches:=new_settings.globalswitches;
  2306. for globalswitch:=low(tglobalswitch) to high(tglobalswitch) do
  2307. if globalswitch in globalswitches then
  2308. begin
  2309. writeln('global switch: '+globalswitchname[globalswitch]);
  2310. exclude(globalswitches,globalswitch);
  2311. end;
  2312. if (globalswitches <> []) then
  2313. writeln('Unknown global switch');
  2314. targetswitches:=new_settings.targetswitches;
  2315. for targetswitch:=low(ttargetswitch) to high(ttargetswitch) do
  2316. if targetswitch in targetswitches then
  2317. begin
  2318. writeln('target switch: '+targetswitchname[targetswitch]);
  2319. exclude(targetswitches,targetswitch);
  2320. end;
  2321. if (targetswitches <> []) then
  2322. writeln('Unknown target switch');
  2323. moduleswitches:=new_settings.moduleswitches;
  2324. for moduleswitch:=low(tmoduleswitch) to high(tmoduleswitch) do
  2325. if moduleswitch in moduleswitches then
  2326. begin
  2327. writeln('module switch: '+moduleswitchname[moduleswitch]);
  2328. exclude(moduleswitches,moduleswitch);
  2329. end;
  2330. if (moduleswitches <> []) then
  2331. writeln('Unknown module switch');
  2332. localswitches:=new_settings.localswitches;
  2333. for localswitch:=low(tlocalswitch) to high(tlocalswitch) do
  2334. if localswitch in localswitches then
  2335. begin
  2336. writeln('local switch: '+localswitchname[localswitch]);
  2337. exclude(localswitches,localswitch);
  2338. end;
  2339. if (localswitches <> []) then
  2340. writeln('Unknown local switch');
  2341. modeswitches:=new_settings.modeswitches;
  2342. for modeswitch:=low(tmodeswitch) to high(tmodeswitch) do
  2343. if modeswitch in modeswitches then
  2344. begin
  2345. writeln(['mode switch: ',modeswitchname[modeswitch]]);
  2346. exclude(modeswitches,modeswitch);
  2347. end;
  2348. if (modeswitches <> []) then
  2349. writeln('Unknown mode switch');
  2350. optimizerswitches:=new_settings.optimizerswitches;
  2351. for optimizerswitch:=low(toptimizerswitch) to high(toptimizerswitch) do
  2352. if optimizerswitch in optimizerswitches then
  2353. begin
  2354. writeln(['optimizer switch: ',optimizerswitchname[optimizerswitch]]);
  2355. exclude(optimizerswitches,optimizerswitch);
  2356. end;
  2357. if (optimizerswitches <> []) then
  2358. writeln('Unknown optimizer switch');
  2359. writeln(['Set allocation size ',new_settings.setalloc]);
  2360. writeln(['Pack enums ',new_settings.packenum]);
  2361. writeln(['Pack records ',new_settings.packrecords]);
  2362. writeln(['Max FPU registers ',new_settings.maxfpuregisters]);
  2363. writeln(['CPU type ',new_settings.cputype]);
  2364. writeln(['CPU optimize type ',new_settings.optimizecputype]);
  2365. writeln(['FPU type ',new_settings.fputype]);
  2366. writeln(['ASM mode ',new_settings.asmmode]);
  2367. end;
  2368. var
  2369. linestr,genstr : string;
  2370. token : ttoken;
  2371. copy_size, stbi, last_col, new_col : longint;
  2372. last_line,new_line : dword;
  2373. len : sizeint;
  2374. wstring : widestring;
  2375. astring : ansistring;
  2376. begin
  2377. tbi:=0;
  2378. last_line:=0;
  2379. last_col:=0;
  2380. linestr:='';
  2381. genstr:='';
  2382. fillchar(new_settings,sizeof(new_settings),#0);
  2383. fillchar(prev_settings,sizeof(prev_settings),#0);
  2384. write([space,' Tokens: ']);
  2385. while tbi<tokenbufsize do
  2386. begin
  2387. token:=readtoken;
  2388. if token<>_GENERICSPECIALTOKEN then
  2389. begin
  2390. if token <= high(ttoken) then
  2391. begin
  2392. write(arraytokeninfo[token].str);
  2393. if not (token in [_CWCHAR, _CWSTRING, _CSTRING, _CCHAR,
  2394. _INTCONST,_REALNUMBER, _ID]) then
  2395. StrAppend(linestr,lowercase(arraytokeninfo[token].str));
  2396. end
  2397. else
  2398. begin
  2399. HasMoreInfos;
  2400. write('Error in Token List');
  2401. break;
  2402. end;
  2403. {idtoken:=}readtoken;
  2404. end;
  2405. case token of
  2406. _CWCHAR,
  2407. _CWSTRING :
  2408. begin
  2409. len:=gettokenbufsizeint;
  2410. setlength(wstring,len);
  2411. move(tokenbuf[tbi],wstring[1],len*2);
  2412. write([' ''',wstring,'''']);
  2413. StrAppend(linestr,' ''');
  2414. StrAppend(linestr,wstring);
  2415. StrAppend(linestr,'''');
  2416. inc(tbi,len*2);
  2417. end;
  2418. _CSTRING:
  2419. begin
  2420. len:=gettokenbufsizeint;
  2421. setlength(astring,len);
  2422. if len>0 then
  2423. move(tokenbuf[tbi],astring[1],len);
  2424. write([' ''',astring,'''']);
  2425. StrAppend(linestr,' ''');
  2426. StrAppend(linestr,astring);
  2427. StrAppend(linestr,'''');
  2428. inc(tbi,len);
  2429. end;
  2430. _CCHAR:
  2431. begin
  2432. write([' ''',unaligned(pshortstring(@tokenbuf[tbi])^),'''']);
  2433. StrAppend(linestr,' ''');
  2434. StrAppend(linestr,unaligned(pshortstring(@tokenbuf[tbi])^));
  2435. StrAppend(linestr,'''');
  2436. inc(tbi,tokenbuf[tbi]+1);
  2437. end;
  2438. _INTCONST,
  2439. _REALNUMBER :
  2440. begin
  2441. write([' ',unaligned(pshortstring(@tokenbuf[tbi])^)]);
  2442. StrAppend(linestr,unaligned(pshortstring(@tokenbuf[tbi])^));
  2443. inc(tbi,tokenbuf[tbi]+1);
  2444. end;
  2445. _ID :
  2446. begin
  2447. write([' ',unaligned(pshortstring(@tokenbuf[tbi])^)]);
  2448. StrAppend(linestr,unaligned(pshortstring(@tokenbuf[tbi])^));
  2449. inc(tbi,tokenbuf[tbi]+1);
  2450. end;
  2451. _GENERICSPECIALTOKEN:
  2452. begin
  2453. { Short version of column change,
  2454. byte or $80 used }
  2455. if (tokenbuf[tbi] and $80)<>0 then
  2456. begin
  2457. new_col:=tokenbuf[tbi] and $7f;
  2458. write(['Col: ',new_col]);
  2459. if length(linestr)<new_col-1 then
  2460. StrAppend(linestr,StringOfChar(' ',new_col - 1 - length(linestr)));
  2461. inc(tbi);
  2462. last_col:=new_col;
  2463. end
  2464. else
  2465. case tspecialgenerictoken(tokenbuf[tbi]) of
  2466. ST_LOADSETTINGS:
  2467. begin
  2468. inc(tbi);
  2469. write([space,'Settings: ']);
  2470. fillchar(new_settings,sizeof(new_settings),#0);
  2471. { This does not load pmessage pointer }
  2472. new_settings.pmessage:=nil;
  2473. { TSettings size depends in target...
  2474. We first read the size of the copied part }
  2475. { Still not cross endian ready :( }
  2476. copy_size:=gettokenbufsizeint;
  2477. stbi:=tbi;
  2478. tokenreadsettings(new_settings, copy_size);
  2479. tbi:=stbi+copy_size;
  2480. if CompareByte(new_settings,prev_settings,sizeof(new_settings))<>0 then
  2481. begin
  2482. dump_new_settings;
  2483. writeln;
  2484. end
  2485. else
  2486. begin
  2487. writeln('Unchanged');
  2488. end;
  2489. prev_settings:=new_settings;
  2490. end;
  2491. ST_LOADMESSAGES:
  2492. begin
  2493. inc(tbi);
  2494. mesgnb:=tokenbuf[tbi];
  2495. writeln([space,mesgnb,' messages: ']);
  2496. inc(tbi);
  2497. for nb:=1 to mesgnb do
  2498. begin
  2499. msgvalue:=gettokenbufsizeint;
  2500. //inc(tbi,sizeof(sizeint));
  2501. state:=tmsgstate(gettokenbufsizeint);
  2502. writeln(['#',msgvalue,' ',state]);
  2503. end;
  2504. end;
  2505. ST_LINE:
  2506. begin
  2507. inc(tbi);
  2508. new_line:=gettokenbufdword;
  2509. if (new_line<>last_line) then
  2510. begin
  2511. StrAppend(genstr,linestr+LineEnding);
  2512. linestr:='';
  2513. end;
  2514. writeln(['Line: ',new_line]);
  2515. last_line:=new_line;
  2516. end;
  2517. ST_COLUMN:
  2518. begin
  2519. inc(tbi);
  2520. new_col:=gettokenbufword;
  2521. write(['Col: ',new_col]);
  2522. if length(linestr)<new_col - 1 then
  2523. StrAppend(linestr,StringOfChar(' ',new_col - 1 - length(linestr)));
  2524. last_col:=new_col;
  2525. end;
  2526. ST_FILEINDEX:
  2527. begin
  2528. inc(tbi);
  2529. StrAppend(genstr,linestr+LineEnding);
  2530. linestr:='';
  2531. write(['File: ',gettokenbufword]);
  2532. end;
  2533. else
  2534. begin
  2535. HasMoreInfos;
  2536. write('Error in Token List');
  2537. break;
  2538. end;
  2539. end;
  2540. end;
  2541. else ; { empty else to avoid warning }
  2542. end;
  2543. if tbi<tokenbufsize then
  2544. write(',');
  2545. end;
  2546. writeln;
  2547. StrAppend(genstr,linestr);
  2548. writeln(['##',genstr,'##']);
  2549. end;
  2550. procedure readcommondef(const s:string; out defoptions: tdefoptions; Def: TPpuDef = nil);
  2551. type
  2552. tdefopt=record
  2553. mask : tdefoption;
  2554. str : string[30];
  2555. end;
  2556. tdefstateinfo=record
  2557. mask : tdefstate;
  2558. str : string[30];
  2559. end;
  2560. tgenconstrflag=record
  2561. mask : tgenericconstraintflag;
  2562. str : string[30];
  2563. end;
  2564. const
  2565. defopt : array[1..ord(high(tdefoption))] of tdefopt=(
  2566. (mask:df_unique; str:'Unique Type'),
  2567. (mask:df_generic; str:'Generic'),
  2568. (mask:df_specialization; str:'Specialization'),
  2569. (mask:df_copied_def; str:'Copied Typedef'),
  2570. (mask:df_genconstraint; str:'Generic Constraint'),
  2571. { this should never happen for defs stored to a ppu file }
  2572. (mask:df_not_registered_no_free; str:'Unregistered/No free (invalid)'),
  2573. (mask:df_llvm_no_struct_packing; str:'LLVM unpacked struct'),
  2574. (mask:df_internal; str:'Internal'),
  2575. (mask:df_has_global_ref; str:'Has Global Ref'),
  2576. (mask:df_has_generic_fields; str:'Has generic fields')
  2577. );
  2578. defstate : array[1..ord(high(tdefstate))] of tdefstateinfo=(
  2579. (mask:ds_vmt_written; str:'VMT Written'),
  2580. (mask:ds_rtti_table_used; str:'RTTITable Used'),
  2581. (mask:ds_init_table_used; str:'InitTable Used'),
  2582. (mask:ds_rtti_table_written; str:'RTTITable Written'),
  2583. (mask:ds_init_table_written; str:'InitTable Written'),
  2584. (mask:ds_dwarf_dbg_info_used; str:'Dwarf DbgInfo Used'),
  2585. (mask:ds_dwarf_dbg_info_written;str:'Dwarf DbgInfo Written')
  2586. );
  2587. genconstrflag : array[1..ord(high(tgenericconstraintflag))] of tgenconstrflag=(
  2588. (mask:gcf_constructor; str:'Constructor'),
  2589. (mask:gcf_class; str:'Class'),
  2590. (mask:gcf_record; str:'Record')
  2591. );
  2592. var
  2593. defstates : tdefstates;
  2594. i, nb, len : longint;
  2595. first : boolean;
  2596. min_size, tokenbufsize : longint;
  2597. tokenbuf : pbyte;
  2598. genconstr : tgenericconstraintflags;
  2599. begin
  2600. i:=ppufile.getlongint;
  2601. if Def <> nil then
  2602. Def.Id:=i;
  2603. writeln([space,'** Definition Id ',i,' **']);
  2604. writeln([space,s]);
  2605. write ([space,' Type symbol : ']);
  2606. if Def <> nil then
  2607. readderef('', Def.Ref)
  2608. else
  2609. readderef('');
  2610. write ([space,' DefOptions : ']);
  2611. ppufile.getset(tppuset2(defoptions));
  2612. if defoptions<>[] then
  2613. begin
  2614. first:=true;
  2615. for i:=1to high(defopt) do
  2616. if (defopt[i].mask in defoptions) then
  2617. begin
  2618. if first then
  2619. first:=false
  2620. else
  2621. write(', ');
  2622. write(defopt[i].str);
  2623. end;
  2624. end;
  2625. writeln;
  2626. write ([space,' DefStates : ']);
  2627. ppufile.getset(tppuset1(defstates));
  2628. if defstates<>[] then
  2629. begin
  2630. first:=true;
  2631. for i:=1 to high(defstate) do
  2632. if (defstate[i].mask in defstates) then
  2633. begin
  2634. if first then
  2635. first:=false
  2636. else
  2637. write(', ');
  2638. write(defstate[i].str);
  2639. end;
  2640. end;
  2641. writeln;
  2642. if df_genconstraint in defoptions then
  2643. begin
  2644. ppufile.getset(tppuset1(genconstr));
  2645. write ([space,' GenConstraints : ']);
  2646. if genconstr<>[] then
  2647. begin
  2648. first:=true;
  2649. for i:=1 to high(genconstrflag) do
  2650. if (genconstrflag[i].mask in genconstr) then
  2651. begin
  2652. if first then
  2653. first:=false
  2654. else
  2655. write(', ');
  2656. write(genconstrflag[i].str);
  2657. end;
  2658. end;
  2659. writeln;
  2660. len:=ppufile.getlongint;
  2661. if len>0 then
  2662. begin
  2663. space:=' '+space;
  2664. writeln([space,'------ constraint defs begin ------']);
  2665. for i:=0 to len-1 do
  2666. begin
  2667. writeln([space,'------ constraint def ',i,' ------']);
  2668. readderef(space);
  2669. end;
  2670. writeln([space,'------ constraint defs end ------']);
  2671. delete(space,1,4);
  2672. end;
  2673. end;
  2674. if [df_generic,df_specialization]*defoptions<>[] then
  2675. begin
  2676. nb:=ppufile.getlongint;
  2677. writeln([space,'has ',nb,' parameters']);
  2678. if nb>0 then
  2679. begin
  2680. for i:=0 to nb-1 do
  2681. begin
  2682. writeln([space,'parameter ',i,': ',ppufile.getstring]);
  2683. readderef(space);
  2684. end;
  2685. end;
  2686. end;
  2687. if df_generic in defoptions then
  2688. begin
  2689. tokenbufsize:=ppufile.getlongint;
  2690. writeln([space,' Tokenbuffer size : ',tokenbufsize]);
  2691. tokenbuf:=allocmem(tokenbufsize);
  2692. ppufile.getdata(tokenbuf^,tokenbufsize);
  2693. displaytokenbuffer(tokenbuf,tokenbufsize);
  2694. freemem(tokenbuf);
  2695. end;
  2696. if df_specialization in defoptions then
  2697. begin
  2698. write ([space,' Orig. GenericDef : ']);
  2699. readderef('');
  2700. end;
  2701. space:=space+' ';
  2702. readattrs(def);
  2703. delete(space,1,4);
  2704. current_defoptions:=defoptions;
  2705. end;
  2706. { Read abstract procdef and return if inline procdef }
  2707. { type tproccalloption is in globtype unit }
  2708. { type tproctypeoption is in globtype unit }
  2709. { type tprocoption is in globtype unit }
  2710. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions; ProcDef: TPpuProcDef);
  2711. type
  2712. tproccallopt=record
  2713. mask : tproccalloption;
  2714. str : string[30];
  2715. end;
  2716. tproctypeopt=record
  2717. mask : tproctypeoption;
  2718. str : string[30];
  2719. end;
  2720. tprocopt=record
  2721. mask : tprocoption;
  2722. str : string[34];
  2723. end;
  2724. const
  2725. {proccalloptionStr is also in globtype unit }
  2726. proctypeopt : array[1..ord(high(tproctypeoption))] of tproctypeopt=(
  2727. (mask:potype_proginit; str:'ProgInit'),
  2728. (mask:potype_unitinit; str:'UnitInit'),
  2729. (mask:potype_unitfinalize; str:'UnitFinalize'),
  2730. (mask:potype_constructor; str:'Constructor'),
  2731. (mask:potype_destructor; str:'Destructor'),
  2732. (mask:potype_operator; str:'Operator'),
  2733. (mask:potype_procedure; str:'Procedure'),
  2734. (mask:potype_function; str:'Function'),
  2735. (mask:potype_class_constructor; str:'Class Constructor'),
  2736. (mask:potype_class_destructor; str:'Class Destructor'),
  2737. { Dispinterface property accessors }
  2738. (mask:potype_propgetter; str:'Property Getter'),
  2739. (mask:potype_propsetter; str:'Property Setter'),
  2740. (mask:potype_exceptfilter; str:'SEH filter'),
  2741. (mask:potype_mainstub; str:'main stub'),
  2742. (mask:potype_pkgstub; str:'package stub'),
  2743. (mask:potype_libmainstub; str:'library main stub')
  2744. );
  2745. procopt : array[1..ord(high(tprocoption))] of tprocopt=(
  2746. (mask:po_classmethod; str:'ClassMethod'),
  2747. (mask:po_virtualmethod; str:'VirtualMethod'),
  2748. (mask:po_abstractmethod; str:'AbstractMethod'),
  2749. (mask:po_finalmethod; str:'FinalMethod'),
  2750. (mask:po_staticmethod; str:'StaticMethod'),
  2751. (mask:po_overridingmethod;str:'OverridingMethod'),
  2752. (mask:po_methodpointer; str:'MethodPointer'),
  2753. (mask:po_interrupt; str:'Interrupt'),
  2754. (mask:po_iocheck; str:'IOCheck'),
  2755. (mask:po_assembler; str:'Assembler'),
  2756. (mask:po_msgstr; str:'MsgStr'),
  2757. (mask:po_msgint; str:'MsgInt'),
  2758. (mask:po_exports; str:'Exports'),
  2759. (mask:po_external; str:'External'),
  2760. (mask:po_overload; str:'Overload'),
  2761. (mask:po_varargs; str:'VarArgs'),
  2762. (mask:po_internconst; str:'InternConst'),
  2763. (mask:po_addressonly; str:'AddressOnly'),
  2764. (mask:po_public; str:'Public'),
  2765. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  2766. (mask:po_reintroduce; str:'ReIntroduce'),
  2767. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  2768. (mask:po_nostackframe; str:'NoStackFrame'),
  2769. (mask:po_has_mangledname; str:'HasMangledName'),
  2770. (mask:po_has_public_name; str:'HasPublicName'),
  2771. (mask:po_forward; str:'Forward'),
  2772. (mask:po_global; str:'Global'),
  2773. (mask:po_syscall; str:'Syscall'),
  2774. (mask:po_syscall_legacy; str:'SyscallLegacy'),
  2775. (mask:po_syscall_basenone;str:'SyscallBaseNone'),
  2776. (mask:po_syscall_basefirst;str:'SyscallBaseFirst'),
  2777. (mask:po_syscall_baselast;str:'SyscallBaseLast'),
  2778. (mask:po_syscall_basereg; str:'SyscallBaseReg'),
  2779. (mask:po_syscall_has_libsym; str:'Has LibSym'),
  2780. (mask:po_syscall_has_importnr; str:'Uses ImportNr'),
  2781. (mask:po_inline; str:'Inline'),
  2782. (mask:po_compilerproc; str:'CompilerProc'),
  2783. (mask:po_has_importdll; str:'HasImportDLL'),
  2784. (mask:po_has_importname; str:'HasImportName'),
  2785. (mask:po_kylixlocal; str:'KylixLocal'),
  2786. (mask:po_dispid; str:'DispId'),
  2787. (mask:po_weakexternal; str:'WeakExternal'),
  2788. (mask:po_objc; str:'ObjC'),
  2789. (mask:po_enumerator_movenext; str:'EnumeratorMoveNext'),
  2790. (mask:po_optional; str: 'Optional'),
  2791. (mask:po_delphi_nested_cc;str: 'Delphi-style nested frameptr'),
  2792. (mask:po_java_nonvirtual; str: 'Java non-virtual method'),
  2793. (mask:po_ignore_for_overload_resolution;str: 'Ignored for overload resolution'),
  2794. (mask:po_rtlproc; str: 'RTL procedure'),
  2795. (mask:po_auto_raised_visibility; str: 'Visibility raised by compiler'),
  2796. (mask:po_far; str: 'Far'),
  2797. (mask:po_hasnearfarcallmodel; str: 'Near/Far explicit'),
  2798. (mask:po_noreturn; str: 'No return'),
  2799. (mask:po_is_function_ref; str: 'Function reference'),
  2800. (mask:po_is_block; str: 'C "Block"'),
  2801. (mask:po_is_auto_getter; str: 'Automatically generated getter'),
  2802. (mask:po_is_auto_setter; str: 'Automatically generated setter'),
  2803. (mask:po_noinline; str: 'Never inline'),
  2804. (mask:po_variadic; str: 'C VarArgs with array-of-const para'),
  2805. (mask:po_objc_related_result_type; str: 'Objective-C related result type')
  2806. );
  2807. var
  2808. proctypeoption : tproctypeoption;
  2809. i : longint;
  2810. first : boolean;
  2811. begin
  2812. write([space,' Return type : ']);
  2813. readderef('', ProcDef.ReturnType);
  2814. proctypeoption:=tproctypeoption(ppufile.getbyte);
  2815. case proctypeoption of
  2816. potype_function: Include(ProcDef.Options, poFunction);
  2817. potype_procedure: Include(ProcDef.Options, poProcedure);
  2818. potype_constructor: Include(ProcDef.Options, poConstructor);
  2819. potype_destructor: Include(ProcDef.Options, poDestructor);
  2820. potype_operator: Include(ProcDef.Options, poOperator);
  2821. end;
  2822. write([space,' TypeOption : ']);
  2823. first:=true;
  2824. for i:=1 to high(proctypeopt) do
  2825. if (proctypeopt[i].mask=proctypeoption) then
  2826. begin
  2827. if first then
  2828. first:=false
  2829. else
  2830. write(', ');
  2831. write(proctypeopt[i].str);
  2832. end;
  2833. writeln;
  2834. proccalloption:=tproccalloption(ppufile.getbyte);
  2835. writeln([space,' CallOption : ',proccalloptionStr[proccalloption]]);
  2836. ppufile.getset(tppuset8(procoptions));
  2837. if procoptions<>[] then
  2838. begin
  2839. if po_classmethod in procoptions then Include(ProcDef.Options, poClassMethod);
  2840. if po_virtualmethod in procoptions then Include(ProcDef.Options, poVirtual);
  2841. if po_abstractmethod in procoptions then Include(ProcDef.Options, poAbstract);
  2842. if po_overridingmethod in procoptions then Include(ProcDef.Options, poOverriding);
  2843. if po_overload in procoptions then Include(ProcDef.Options, poOverload);
  2844. if po_inline in procoptions then Include(ProcDef.Options, poInline);
  2845. if (po_methodpointer in procoptions) and (ProcDef.DefType = dtProcType) then
  2846. TPpuProcTypeDef(ProcDef).MethodPtr:=True;
  2847. write([space,' Options : ']);
  2848. first:=true;
  2849. for i:=1 to high(procopt) do
  2850. if (procopt[i].mask in procoptions) then
  2851. begin
  2852. if first then
  2853. first:=false
  2854. else
  2855. write(', ');
  2856. write(procopt[i].str);
  2857. end;
  2858. writeln;
  2859. end;
  2860. if (po_explicitparaloc in procoptions) then
  2861. begin
  2862. readcgpara(space);
  2863. end;
  2864. end;
  2865. { type tvaroption is in unit symconst }
  2866. { register variable }
  2867. { type tvarregable is in unit symconst }
  2868. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions; VarDef: TPpuVarDef = nil);
  2869. type
  2870. tvaropt=record
  2871. mask : tvaroption;
  2872. str : string[30];
  2873. end;
  2874. const
  2875. varopt : array[1..ord(high(tvaroption))] of tvaropt=(
  2876. (mask:vo_is_external; str:'External'),
  2877. (mask:vo_is_dll_var; str:'DLLVar'),
  2878. (mask:vo_is_thread_var; str:'ThreadVar'),
  2879. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  2880. (mask:vo_is_const; str:'Constant'),
  2881. (mask:vo_is_public; str:'Public'),
  2882. (mask:vo_is_high_para; str:'HighValue'),
  2883. (mask:vo_is_funcret; str:'Funcret'),
  2884. (mask:vo_is_self; str:'Self'),
  2885. (mask:vo_is_vmt; str:'VMT'),
  2886. (mask:vo_is_result; str:'Result'),
  2887. (mask:vo_is_parentfp; str:'ParentFP'),
  2888. (mask:vo_is_loop_counter; str:'LoopCounter'),
  2889. (mask:vo_is_hidden_para; str:'Hidden'),
  2890. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  2891. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  2892. (mask:vo_has_mangledname; str:'HasMangledName'),
  2893. (mask:vo_is_typed_const; str:'TypedConst'),
  2894. (mask:vo_is_range_check; str:'RangeCheckSwitch'),
  2895. (mask:vo_is_overflow_check; str:'OverflowCheckSwitch'),
  2896. (mask:vo_is_typinfo_para; str:'TypeInfo'),
  2897. (mask:vo_is_msgsel;str:'MsgSel'),
  2898. (mask:vo_is_weak_external;str:'WeakExternal'),
  2899. (mask:vo_is_first_field;str:'IsFirstField'),
  2900. (mask:vo_volatile; str:'Volatile'),
  2901. (mask:vo_has_section; str:'HasSection'),
  2902. (mask:vo_force_finalize; str:'ForceFinalize'),
  2903. (mask:vo_is_default_var; str:'DefaultIntrinsicVar'),
  2904. (mask:vo_is_far; str:'IsFar'),
  2905. (mask:vo_has_global_ref; str:'HasGlobalRef')
  2906. );
  2907. type
  2908. tvaraccessdesc=record
  2909. mask: tvarsymaccessflag;
  2910. str: string[30];
  2911. end;
  2912. const
  2913. varaccessstr : array[ord(low(tvarsymaccessflag))..ord(high(tvarsymaccessflag))] of tvaraccessdesc=(
  2914. (mask: vsa_addr_taken; str:'Address taken'),
  2915. (mask: vsa_different_scope; str:'Accessed from different scope')
  2916. );
  2917. var
  2918. i : longint;
  2919. accessflag: tvarsymaccessflag;
  2920. varsymaccessflags: tvarsymaccessflags;
  2921. first : boolean;
  2922. begin
  2923. readcommonsym(s, VarDef);
  2924. i:=ppufile.getbyte;
  2925. if (VarDef <> nil) and (VarDef.DefType = dtParam) then
  2926. with TPpuParamDef(VarDef) do
  2927. case tvarspez(i) of
  2928. vs_value: Spez:=psValue;
  2929. vs_var: Spez:=psVar;
  2930. vs_out: Spez:=psOut;
  2931. vs_const: Spez:=psConst;
  2932. vs_constref: Spez:=psConstRef;
  2933. end;
  2934. writeln([space,' Spez : ',Varspez2Str(i)]);
  2935. writeln([space,' Regable : ',Varregable2Str(ppufile.getbyte)]);
  2936. ppufile.getset(tppuset1(varsymaccessflags));
  2937. write([space, ' Access Flags : ']);
  2938. first:=true;
  2939. for i:=low(varaccessstr) to high(varaccessstr) do
  2940. begin
  2941. if varaccessstr[i].mask in varsymaccessflags then
  2942. begin
  2943. if first then
  2944. first:=false
  2945. else
  2946. write([', ']);
  2947. write([varaccessstr[i].str]);
  2948. end
  2949. end;
  2950. writeln;
  2951. write ([space,' Var Type : ']);
  2952. if VarDef <> nil then
  2953. readderef('',VarDef.VarType)
  2954. else
  2955. readderef('');
  2956. ppufile.getset(tppuset4(varoptions));
  2957. if varoptions<>[] then
  2958. begin
  2959. if (VarDef <> nil) and (VarDef.DefType = dtParam) and (vo_is_hidden_para in varoptions) then
  2960. TPpuParamDef(VarDef).Spez:=psHidden;
  2961. write([space,' Options : ']);
  2962. first:=true;
  2963. for i:=1 to high(varopt) do
  2964. if (varopt[i].mask in varoptions) then
  2965. begin
  2966. if first then
  2967. first:=false
  2968. else
  2969. write(', ');
  2970. write(varopt[i].str);
  2971. end;
  2972. writeln;
  2973. end;
  2974. end;
  2975. procedure readobjectdefoptions(ObjDef: TPpuObjectDef = nil);
  2976. type
  2977. tsymopt=record
  2978. mask : tobjectoption;
  2979. str : string[30];
  2980. end;
  2981. const
  2982. symopt : array[1..ord(high(tobjectoption))] of tsymopt=(
  2983. (mask:oo_is_forward; str:'IsForward'),
  2984. (mask:oo_is_abstract; str:'IsAbstract'),
  2985. (mask:oo_is_sealed; str:'IsSealed'),
  2986. (mask:oo_has_virtual; str:'HasVirtual'),
  2987. (mask:oo_has_private; str:'HasPrivate'),
  2988. (mask:oo_has_protected; str:'HasProtected'),
  2989. (mask:oo_has_strictprivate; str:'HasStrictPrivate'),
  2990. (mask:oo_has_strictprotected;str:'HasStrictProtected'),
  2991. (mask:oo_has_constructor; str:'HasConstructor'),
  2992. (mask:oo_has_destructor; str:'HasDestructor'),
  2993. (mask:oo_has_vmt; str:'HasVMT'),
  2994. (mask:oo_has_msgstr; str:'HasMsgStr'),
  2995. (mask:oo_has_msgint; str:'HasMsgInt'),
  2996. (mask:oo_can_have_published; str:'CanHavePublished'),
  2997. (mask:oo_has_default_property;str:'HasDefaultProperty'),
  2998. (mask:oo_has_valid_guid; str:'HasValidGUID'),
  2999. (mask:oo_has_enumerator_movenext; str:'HasEnumeratorMoveNext'),
  3000. (mask:oo_has_enumerator_current; str:'HasEnumeratorCurrent'),
  3001. (mask:oo_is_external; str:'External'),
  3002. (mask:oo_is_formal; str:'Formal'),
  3003. (mask:oo_is_classhelper; str:'Class Helper/Category'),
  3004. (mask:oo_has_class_constructor; str:'HasClassConstructor'),
  3005. (mask:oo_has_class_destructor; str:'HasClassDestructor'),
  3006. (mask:oo_is_enum_class; str:'JvmEnumClass'),
  3007. (mask:oo_has_new_destructor; str:'HasNewDestructor')
  3008. );
  3009. var
  3010. i : longint;
  3011. first : boolean;
  3012. begin
  3013. ppufile.getset(tppuset4(current_objectoptions));
  3014. if current_objectoptions<>[] then
  3015. begin
  3016. if ObjDef <> nil then
  3017. begin
  3018. if oo_is_abstract in current_objectoptions then
  3019. Include(ObjDef.Options, ooIsAbstract);
  3020. end;
  3021. first:=true;
  3022. for i:=1 to high(symopt) do
  3023. if (symopt[i].mask in current_objectoptions) then
  3024. begin
  3025. if first then
  3026. first:=false
  3027. else
  3028. write(', ');
  3029. write(symopt[i].str);
  3030. end;
  3031. end;
  3032. writeln;
  3033. end;
  3034. procedure readprocimploptions(const space: string; out implprocoptions: timplprocoptions);
  3035. type
  3036. tpiopt=record
  3037. mask : timplprocoption;
  3038. str : string[30];
  3039. end;
  3040. const
  3041. piopt : array[low(timplprocoption)..high(timplprocoption)] of tpiopt=(
  3042. (mask:pio_empty; str:'IsEmpty'),
  3043. (mask:pio_has_inlininginfo; str:'HasInliningInfo'),
  3044. (mask:pio_inline_not_possible; str:'InlineNotPossible'),
  3045. (mask:pio_nested_access; str:'NestedAccess'),
  3046. (mask:pio_thunk; str:'Thunk'),
  3047. (mask:pio_fastmath; str:'FastMath'),
  3048. (mask:pio_inline_forbidden; str:'InlineForbidden')
  3049. );
  3050. var
  3051. i: timplprocoption;
  3052. first: boolean;
  3053. begin
  3054. ppufile.getset(tppuset1(implprocoptions));
  3055. if implprocoptions<>[] then
  3056. begin
  3057. first:=true;
  3058. write([space,' Options : ']);
  3059. for i:=low(piopt) to high(piopt) do
  3060. begin
  3061. if i in implprocoptions then
  3062. begin
  3063. if first then
  3064. first:=false
  3065. else
  3066. write(', ');
  3067. write(piopt[i].str);
  3068. end;
  3069. end;
  3070. writeln;
  3071. end;
  3072. end;
  3073. procedure readarraydefoptions(ArrayDef: TPpuArrayDef);
  3074. { type tarraydefoption is in unit symconst }
  3075. const
  3076. symopt : array[tarraydefoption] of string = (
  3077. { ado_IsConvertedPointer } 'ConvertedPointer',
  3078. { ado_IsDynamicArray } 'IsDynamicArray',
  3079. { ado_IsVariant } 'IsVariant',
  3080. { ado_IsConstructor } 'IsConstructor',
  3081. { ado_IsArrayOfConst } 'ArrayOfConst',
  3082. { ado_IsConstString } 'ConstString',
  3083. { ado_IsBitPacked } 'BitPacked',
  3084. { ado_IsVector } 'Vector',
  3085. { ado_IsGeneric } 'Generic'
  3086. );
  3087. var
  3088. symoptions: tarraydefoptions;
  3089. i: tarraydefoption;
  3090. first: boolean;
  3091. begin
  3092. ppufile.getset(tppuset2(symoptions));
  3093. if symoptions<>[] then
  3094. begin
  3095. if ado_IsDynamicArray in symoptions then Include(ArrayDef.Options, aoDynamic);
  3096. first:=true;
  3097. for i:=Low(symopt) to high(symopt) do
  3098. if (i in symoptions) then
  3099. begin
  3100. if first then
  3101. first:=false
  3102. else
  3103. write(', ');
  3104. write(symopt[i]);
  3105. end;
  3106. end;
  3107. writeln;
  3108. end;
  3109. (* options for properties
  3110. tpropertyoption=(ppo_none,
  3111. ppo_indexed,
  3112. ppo_defaultproperty,
  3113. ppo_stored,
  3114. ppo_hasparameters,
  3115. ppo_implements,
  3116. ppo_enumerator_current,
  3117. ppo_overrides,
  3118. ppo_dispid_write { no longer used }
  3119. );
  3120. tpropertyoptions=set of tpropertyoption;
  3121. *)
  3122. function readpropertyoptions:tpropertyoptions;
  3123. { type tarraydefoption is in unit symconst }
  3124. type
  3125. tpropopt=record
  3126. mask : tpropertyoption;
  3127. str : string[30];
  3128. end;
  3129. const
  3130. symopt : array[1..ord(high(tpropertyoption))] of tpropopt=(
  3131. (mask:ppo_indexed;str:'indexed'),
  3132. (mask:ppo_defaultproperty;str:'default'),
  3133. (mask:ppo_stored;str:'stored'),
  3134. (mask:ppo_hasparameters;str:'has parameters'),
  3135. (mask:ppo_implements;str:'implements'),
  3136. (mask:ppo_enumerator_current;str:'enumerator current'),
  3137. (mask:ppo_overrides;str:'overrides'),
  3138. (mask:ppo_dispid_write;str:'dispid write') { no longer used }
  3139. );
  3140. var
  3141. i : longint;
  3142. first : boolean;
  3143. begin
  3144. ppufile.getset(tppuset2(result));
  3145. if result<>[] then
  3146. begin
  3147. first:=true;
  3148. for i:=1 to high(symopt) do
  3149. if (symopt[i].mask in result) then
  3150. begin
  3151. if first then
  3152. first:=false
  3153. else
  3154. write(', ');
  3155. write(symopt[i].str);
  3156. end;
  3157. end;
  3158. writeln;
  3159. end;
  3160. function readmanagementoperatoroptions(const space : string;const name : string):tmanagementoperators;
  3161. { type is in unit symconst }
  3162. { Management operator options
  3163. tmanagementoperator=(
  3164. mop_none,
  3165. mop_initialize,
  3166. mop_finalize,
  3167. mop_addref,
  3168. mop_copy);
  3169. }
  3170. type
  3171. tmopopt=record
  3172. mask : tmanagementoperator;
  3173. str : string[10];
  3174. end;
  3175. const
  3176. managementoperatoropt : array[1..ord(high(tmanagementoperator))] of tmopopt=(
  3177. (mask:mop_initialize;str:'initialize'),
  3178. (mask:mop_finalize;str:'finalize'),
  3179. (mask:mop_addref;str:'addref'),
  3180. (mask:mop_copy;str:'copy')
  3181. );
  3182. var
  3183. i : longint;
  3184. first : boolean;
  3185. begin
  3186. ppufile.getset(tppuset1(result));
  3187. if result<>[] then
  3188. begin
  3189. first:=true;
  3190. for i:=1 to high(managementoperatoropt) do
  3191. if (managementoperatoropt[i].mask in result) then
  3192. begin
  3193. if first then
  3194. begin
  3195. write(space);
  3196. write(name);
  3197. write(': ');
  3198. first:=false;
  3199. end
  3200. else
  3201. write(', ');
  3202. write(managementoperatoropt[i].str);
  3203. end;
  3204. if not first then
  3205. writeln;
  3206. end;
  3207. end;
  3208. procedure readnodetree;
  3209. var
  3210. l : longint;
  3211. p : pointer;
  3212. begin
  3213. with ppufile do
  3214. begin
  3215. if space<>'' then
  3216. Writeln([space,'------ nodetree ------']);
  3217. if readentry=ibnodetree then
  3218. begin
  3219. l:=entrysize;
  3220. Writeln([space,'Tree size : ',l]);
  3221. { Read data to prevent error that entry is not completly read }
  3222. getmem(p,l);
  3223. getdata(p^,l);
  3224. freemem(p);
  3225. end
  3226. else
  3227. begin
  3228. WriteError('!! ibnodetree not found');
  3229. end;
  3230. end;
  3231. end;
  3232. procedure ReadCreatedObjTypes;
  3233. var
  3234. i,j,
  3235. len,
  3236. bssize: longint;
  3237. bs: pbyte;
  3238. begin
  3239. if ppufile.readentry<>ibcreatedobjtypes then
  3240. begin
  3241. WriteError('!! ibcreatedobjtypes entry not found');
  3242. ppufile.skipdata(ppufile.entrysize);
  3243. exit
  3244. end;
  3245. writeln;
  3246. writeln([space,'WPO info']);
  3247. writeln([space,'--------']);
  3248. len:=ppufile.getlongint;
  3249. writeln([space,'** Instantiated Object/Class types: ',len,' **']);
  3250. space:=space+' ';
  3251. for i:=0 to len-1 do
  3252. readderef(space);
  3253. setlength(space,length(space)-2);
  3254. len:=ppufile.getlongint;
  3255. writeln([space,'** Instantiated ClassRef types: ',len,' **']);
  3256. space:=space+' ';
  3257. for i:=0 to len-1 do
  3258. readderef(space);
  3259. setlength(space,length(space)-2);
  3260. len:=ppufile.getlongint;
  3261. writeln([space,'** Possibly instantiated ClassRef types : ',len,' **']);
  3262. space:=space+' ';
  3263. for i:=0 to len-1 do
  3264. readderef(space);
  3265. setlength(space,length(space)-2);
  3266. len:=ppufile.getlongint;
  3267. writeln([space,'** Class types with called virtual methods info : ',len,' **']);
  3268. space:=space+' ';
  3269. for i:=0 to len-1 do
  3270. begin
  3271. write([space,'Class def : ']);
  3272. readderef('');
  3273. write([space+' ','Called vmtentries : ']);
  3274. bssize:=ppufile.getlongint;
  3275. getmem(bs,bssize);
  3276. ppufile.readdata(bs^,bssize);
  3277. for j:=0 to bssize*8-1 do
  3278. if (((bs+j shr 3)^ shr (j and 7)) and 1) <> 0 then
  3279. write([j,', ']);
  3280. writeln;
  3281. freemem(bs);
  3282. end;
  3283. setlength(space,length(space)-2);
  3284. end;
  3285. {****************************************************************************
  3286. Read Symbols Part
  3287. ****************************************************************************}
  3288. procedure readsymbols(const s:string; ParentDef: TPpuContainerDef = nil);
  3289. function _finddef(symdef: TPpuDef): TPpuDef;
  3290. begin
  3291. Result:=nil;
  3292. if symdef.Ref.IsCurUnit then
  3293. begin;
  3294. Result:=CurUnit.FindById(symdef.Ref.Id);
  3295. if (Result <> nil) and (Result.Ref.Id = symdef.Id) then
  3296. begin
  3297. Result.Name:=symdef.Name;
  3298. Result.FilePos:=symdef.FilePos;
  3299. end
  3300. else
  3301. Result:=nil;
  3302. end;
  3303. end;
  3304. type
  3305. pguid = ^tguid;
  3306. tguid = packed record
  3307. D1: LongWord;
  3308. D2: Word;
  3309. D3: Word;
  3310. D4: array[0..7] of Byte;
  3311. end;
  3312. var
  3313. b : byte;
  3314. pc : pchar;
  3315. ch : dword;
  3316. startnewline : boolean;
  3317. i,j,len : longint;
  3318. prettyname, ss : ansistring;
  3319. ws: widestring;
  3320. guid : tguid;
  3321. realvalue : ppureal;
  3322. doublevalue : double;
  3323. singlevalue : single;
  3324. realstr : shortstring;
  3325. extended : TSplit80bitReal;
  3326. pw : pcompilerwidestring;
  3327. varoptions : tvaroptions;
  3328. propoptions : tpropertyoptions;
  3329. iexp: Tconstexprint;
  3330. def: TPpuDef;
  3331. constdef: TPpuConstDef absolute def;
  3332. begin
  3333. with ppufile do
  3334. begin
  3335. if space<>'' then
  3336. Writeln([space,'------ ',s,' ------']);
  3337. if readentry=ibstartsyms then
  3338. begin
  3339. Writeln([space,'Symtable count: ',getlongint]);
  3340. end
  3341. else
  3342. Writeln('!! ibstartsym not found');
  3343. repeat
  3344. def:=nil;
  3345. b:=readentry;
  3346. case b of
  3347. ibunitsym :
  3348. readcommonsym('Unit symbol ');
  3349. ibnamespacesym :
  3350. begin
  3351. readcommonsym('NameSpace symbol ');
  3352. write([space,' Hidden Unit : ']);
  3353. readderef('');
  3354. end;
  3355. iblabelsym :
  3356. readcommonsym('Label symbol ');
  3357. ibtypesym :
  3358. begin
  3359. def:=TPpuTypeRef.Create(nil);
  3360. readcommonsym('Type symbol ',def);
  3361. write([space,' Result Type : ']);
  3362. readderef('', def.Ref);
  3363. if _finddef(def) = nil then
  3364. def.Parent:=ParentDef;
  3365. prettyname:=getansistring;
  3366. if prettyname<>'' then
  3367. begin
  3368. write([space,' Pretty Name : ']);
  3369. Writeln(prettyname);
  3370. end;
  3371. end;
  3372. ibprocsym :
  3373. begin
  3374. def:=TPpuDef.Create(nil);
  3375. readcommonsym('Procedure symbol ', def);
  3376. len:=ppufile.getword;
  3377. for i:=1 to len do
  3378. begin
  3379. write([space,' Definition : ']);
  3380. readderef('', def.Ref);
  3381. _finddef(def);
  3382. end;
  3383. end;
  3384. ibconstsym :
  3385. begin
  3386. constdef:=TPpuConstDef.Create(ParentDef);
  3387. readcommonsym('Constant symbol ',constdef);
  3388. b:=getbyte;
  3389. case tconsttyp(b) of
  3390. constord :
  3391. begin
  3392. write ([space,' OrdinalType : ']);
  3393. readderef('',constdef.TypeRef);
  3394. iexp:=getexprint;
  3395. constdef.ConstType:=ctInt;
  3396. constdef.VInt:=iexp.svalue;
  3397. writeln([space,' Value : ',constexp.tostr(iexp)]);
  3398. end;
  3399. constpointer :
  3400. begin
  3401. write ([space,' PointerType : ']);
  3402. readderef('',constdef.TypeRef);
  3403. constdef.ConstType:=ctInt;
  3404. constdef.VInt:=int64(getptruint);
  3405. writeln([space,' Value : ',constdef.VInt])
  3406. end;
  3407. conststring,
  3408. constresourcestring :
  3409. begin
  3410. write ([space,' StringType : ']);
  3411. readderef('',constdef.TypeRef);
  3412. len:=getlongint;
  3413. getmem(pc,len+1);
  3414. getdata(pc^,len);
  3415. (pc+len)^:= #0;
  3416. writeln([space,' Length : ',len]);
  3417. writeln([space,' Value : "',pc,'"']);
  3418. constdef.ConstType:=ctStr;
  3419. SetString(constdef.VStr, pc, len);
  3420. constdef.VStr:=UTF8Encode(constdef.VStr);
  3421. freemem(pc,len+1);
  3422. end;
  3423. constreal :
  3424. begin
  3425. constdef.ConstType:=ctFloat;
  3426. write ([space,' RealType : ']);
  3427. readderef('',constdef.TypeRef);
  3428. write([space,' Value : ']);
  3429. if entryleft=sizeof(ppureal) then
  3430. begin
  3431. realvalue:=getrealsize(sizeof(ppureal));
  3432. constdef.VFloat:=realvalue;
  3433. system.str(realvalue,realstr);
  3434. writeln([realstr]);
  3435. end
  3436. else if entryleft=sizeof(double) then
  3437. begin
  3438. doublevalue:=getrealsize(sizeof(double));
  3439. constdef.VFloat:=doublevalue;
  3440. system.str(doublevalue,realstr);
  3441. writeln([realstr]);
  3442. end
  3443. else if entryleft=sizeof(single) then
  3444. begin
  3445. singlevalue:=getrealsize(sizeof(single));
  3446. constdef.VFloat:=singlevalue;
  3447. system.str(singlevalue,realstr);
  3448. writeln([realstr]);
  3449. end
  3450. else if entryleft=10 then
  3451. begin
  3452. getdata(extended,entryleft);
  3453. ss:=Real80bitToStr(extended,constdef.VFloat);
  3454. writeln(ss);
  3455. end
  3456. else
  3457. begin
  3458. realvalue:=0.0;
  3459. WriteError('Error reading real value');
  3460. end;
  3461. end;
  3462. constset :
  3463. begin
  3464. constdef.ConstType:=ctSet;
  3465. write ([space,' Set Type : ']);
  3466. readderef('',constdef.TypeRef);
  3467. for i:=1to 4 do
  3468. begin
  3469. write ([space,' Value : ']);
  3470. for j:=1to 8 do
  3471. begin
  3472. if j>1 then
  3473. write(',');
  3474. b:=getbyte;
  3475. write(hexstr(b,2));
  3476. constdef.VSet[i*j-1]:=b;
  3477. end;
  3478. writeln;
  3479. end;
  3480. end;
  3481. constnil:
  3482. begin
  3483. write([space,' NIL pointer :']);
  3484. readderef('',constdef.TypeRef);
  3485. constdef.ConstType:=ctPtr;
  3486. constdef.VInt:=0;
  3487. end;
  3488. constwstring :
  3489. begin
  3490. initwidestring(pw);
  3491. setlengthwidestring(pw,getlongint);
  3492. if widecharsize=2 then
  3493. { don't use getdata, because the compilerwidechars may have to
  3494. be byteswapped
  3495. }
  3496. begin
  3497. for i:=0 to pw^.len-1 do
  3498. pw^.data[i]:=ppufile.getword;
  3499. SetString(ws, PWideChar(pw^.data), pw^.len);
  3500. constdef.VStr:=UTF8Encode(ws);
  3501. constdef.ConstType:=ctStr;
  3502. end
  3503. else if widecharsize=4 then
  3504. begin
  3505. for i:=0 to pw^.len-1 do
  3506. pw^.data[i]:=cardinal(ppufile.getlongint);
  3507. end
  3508. else
  3509. begin
  3510. WriteError('Unsupported tcompilerwidechar size');
  3511. end;
  3512. Write([space,'Wide string type']);
  3513. startnewline:=true;
  3514. for i:=0 to pw^.len-1 do
  3515. begin
  3516. if startnewline then
  3517. begin
  3518. writeln;
  3519. write(space);
  3520. startnewline:=false;
  3521. end;
  3522. ch:=pw^.data[i];
  3523. if widecharsize=2 then
  3524. write(hexstr(ch,4))
  3525. else
  3526. write(hexstr(ch,8));
  3527. if ((i + 1) mod 8)= 0 then
  3528. startnewline:=true
  3529. else
  3530. if i <> pw^.len-1 then
  3531. write(', ');
  3532. end;
  3533. donewidestring(pw);
  3534. Writeln;
  3535. end;
  3536. constguid:
  3537. begin
  3538. write ([space,' IntfType : ']);
  3539. readderef('',constdef.TypeRef);
  3540. getdata(guid,sizeof(guid));
  3541. write ([space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-']);
  3542. for i:=0 to 7 do
  3543. begin
  3544. write(hexstr(guid.d4[i],2));
  3545. if i=1 then write('-');
  3546. end;
  3547. writeln('}');
  3548. end
  3549. else
  3550. Writeln (['!! Invalid unit format : Invalid const type encountered: ',b]);
  3551. end;
  3552. end;
  3553. ibabsolutevarsym :
  3554. begin
  3555. def:=TPpuVarDef.Create(ParentDef);
  3556. readabstractvarsym('Absolute variable symbol ',varoptions,TPpuVarDef(def));
  3557. Write ([space,' Relocated to ']);
  3558. b:=getbyte;
  3559. case absolutetyp(b) of
  3560. tovar :
  3561. readpropaccesslist(space+' Sym : ');
  3562. toasm :
  3563. Writeln(['Assembler name : ',getstring]);
  3564. toaddr :
  3565. begin
  3566. Write(['Address : ',getpuint]);
  3567. if tsystemcpu(ppufile.header.common.cpu)=cpu_i386 then
  3568. Write([' (Far: ',getbyte<>0,')']);
  3569. if tsystemcpu(ppufile.header.common.cpu)=cpu_i8086 then
  3570. if getbyte<>0 then
  3571. Write([' (Far: TRUE, Segment=',getaword,')'])
  3572. else
  3573. Write([' (Far: FALSE)']);
  3574. Writeln;
  3575. end;
  3576. else
  3577. Writeln (['!! Invalid unit format : Invalid absolute type encountered: ',b]);
  3578. end;
  3579. end;
  3580. ibfieldvarsym :
  3581. begin
  3582. def:=TPpuFieldDef.Create(ParentDef);
  3583. readabstractvarsym('Field Variable symbol ',varoptions,TPpuVarDef(def));
  3584. writeln([space,' Address : ',getasizeint]);
  3585. if vo_has_mangledname in varoptions then
  3586. writeln([space,' Mangled name : ',getstring]);
  3587. end;
  3588. ibstaticvarsym :
  3589. begin
  3590. def:=TPpuVarDef.Create(ParentDef);
  3591. readabstractvarsym('Global Variable symbol ',varoptions,TPpuVarDef(def));
  3592. write ([space,' DefaultConst : ']);
  3593. readderef('');
  3594. if (vo_has_mangledname in varoptions) then
  3595. writeln([space,'Mangledname : ',readsymstr(ppufile)]);
  3596. if vo_has_section in varoptions then
  3597. writeln(['Section name:',ppufile.getansistring]);
  3598. write ([space,' FieldVarSymDeref: ']);
  3599. readderef('');
  3600. end;
  3601. iblocalvarsym :
  3602. begin
  3603. readabstractvarsym('Local Variable symbol ',varoptions);
  3604. write ([space,' DefaultConst : ']);
  3605. readderef('');
  3606. end;
  3607. ibparavarsym :
  3608. begin
  3609. def:=TPpuParamDef.Create(ParentDef);
  3610. readabstractvarsym('Parameter Variable symbol ',varoptions,TPpuVarDef(def));
  3611. write ([space,' DefaultConst : ']);
  3612. readderef('',TPpuParamDef(def).DefaultValue);
  3613. writeln([space,' ParaNr : ',getword]);
  3614. writeln([space,' Univ : ',getboolean]);
  3615. writeln([space,' VarState : ',getbyte]);
  3616. writeln([space,' Refs : ',getbyte]);
  3617. if (vo_has_explicit_paraloc in varoptions) then
  3618. begin
  3619. readcgpara(space+' ');
  3620. end;
  3621. end;
  3622. ibenumsym :
  3623. begin
  3624. def:=TPpuConstDef.Create(nil);
  3625. readcommonsym('Enumeration symbol ',def);
  3626. write ([space,' Definition : ']);
  3627. readderef('');
  3628. TPpuConstDef(def).ConstType:=ctInt;
  3629. TPpuConstDef(def).VInt:=getlongint;
  3630. writeln([space,' Value : ',TPpuConstDef(def).VInt]);
  3631. if (ParentDef <> nil) and (ParentDef.DefType = dtEnum) then
  3632. def.Parent:=ParentDef;
  3633. end;
  3634. ibsyssym :
  3635. begin
  3636. readcommonsym('Internal system symbol ');
  3637. writeln([space,' Internal Nr : ',getlongint]);
  3638. end;
  3639. ibmacrosym :
  3640. begin
  3641. readcommonsym('Macro symbol ');
  3642. writeln([space,' Defined: ',getboolean]);
  3643. writeln([space,' Compiler var: ',getboolean]);
  3644. len:=getlongint;
  3645. writeln([space,' Value length: ',len]);
  3646. if len > 0 then
  3647. begin
  3648. getmem(pc,len+1);
  3649. getdata(pc^,len);
  3650. (pc+len)^:= #0;
  3651. writeln([space,' Value: "',pc,'"']);
  3652. freemem(pc,len+1);
  3653. end;
  3654. end;
  3655. ibpropertysym :
  3656. begin
  3657. def:=TPpuPropDef.Create(ParentDef);
  3658. readcommonsym('Property ',def);
  3659. write ([space,' Prop Options : ']);
  3660. propoptions:=readpropertyoptions;
  3661. if ppo_overrides in propoptions then
  3662. begin
  3663. write ([space,' OverrideProp : ']);
  3664. readderef('');
  3665. end;
  3666. if ppo_defaultproperty in propoptions then
  3667. Include(TPpuPropDef(def).Options, poDefault);
  3668. write ([space,' Prop Type : ']);
  3669. readderef('',TPpuPropDef(def).PropType);
  3670. writeln([space,' Index : ',getlongint]);
  3671. writeln([space,' Default : ',getlongint]);
  3672. write ([space,' Index Type : ']);
  3673. readderef('');
  3674. { palt_none }
  3675. write ([space,' Noneaccess : ']);
  3676. readpropaccesslist('');
  3677. write ([space,' Readaccess : ']);
  3678. readpropaccesslist(space+' Sym: ',TPpuPropDef(def).Getter);
  3679. write ([space,' Writeaccess : ']);
  3680. readpropaccesslist(space+' Sym: ',TPpuPropDef(def).Setter);
  3681. write ([space,' Storedaccess : ']);
  3682. readpropaccesslist(space+' Sym: ');
  3683. if [ppo_hasparameters,ppo_overrides]*propoptions=[ppo_hasparameters] then
  3684. begin
  3685. space:=' '+space;
  3686. readsymtable('parast',TPpuPropDef(def));
  3687. delete(space,1,4);
  3688. end;
  3689. end;
  3690. iberror :
  3691. begin
  3692. WriteError('!! Error in PPU');
  3693. exit;
  3694. end;
  3695. ibendsyms :
  3696. break;
  3697. else
  3698. begin
  3699. WriteError('!! Skipping unsupported PPU Entry in Symbols: '+IntToStr(b));
  3700. end;
  3701. end;
  3702. if assigned(def) then
  3703. readsymsubentries(def);
  3704. if (def <> nil) and (def.Parent = nil) then
  3705. def.Free;
  3706. if not EndOfEntry then
  3707. HasMoreInfos;
  3708. until false;
  3709. end;
  3710. end;
  3711. {****************************************************************************
  3712. Read defintions Part
  3713. ****************************************************************************}
  3714. procedure readdefinitions(const s:string; ParentDef: TPpuContainerDef);
  3715. { type tordtype is in symconst unit }
  3716. {
  3717. uvoid,
  3718. u8bit,u16bit,u32bit,u64bit,u128bit,
  3719. s8bit,s16bit,s32bit,s64bit,s128bit,
  3720. bool8bit,bool16bit,bool32bit,bool64bit,
  3721. uchar,uwidechar,scurrency,customint
  3722. ); }
  3723. { type tobjecttyp is in symconst unit }
  3724. { type tvarianttype is in symconst unit }
  3725. { type thelpertype is in symconst unit }
  3726. var
  3727. b : byte;
  3728. otb : byte; { Object Type byte, needed later again }
  3729. l,j,tokenbufsize : longint;
  3730. tokenbuf : pbyte;
  3731. calloption : tproccalloption;
  3732. procoptions : tprocoptions;
  3733. implprocoptions: timplprocoptions;
  3734. defoptions: tdefoptions;
  3735. iexpr: Tconstexprint;
  3736. def: TPpuDef;
  3737. objdef: TPpuObjectDef absolute def;
  3738. arrdef: TPpuArrayDef absolute def;
  3739. enumdef: TPpuEnumDef absolute def;
  3740. setdef: TPpuSetDef absolute def;
  3741. orddef: TPpuOrdDef absolute def;
  3742. floatdef: TPpuFloatDef absolute def;
  3743. strdef: TPpuStringDef absolute def;
  3744. filedef: TPpuFileDef absolute def;
  3745. begin
  3746. with ppufile do
  3747. begin
  3748. if space<>'' then
  3749. Writeln([space,'------ ',s,' ------']);
  3750. if readentry<>ibstartdefs then
  3751. Writeln('!! ibstartdefs not found');
  3752. repeat
  3753. def:=nil;
  3754. b:=readentry;
  3755. case b of
  3756. ibpointerdef :
  3757. begin
  3758. def:=TPpuPointerDef.Create(ParentDef);
  3759. readcommondef('Pointer definition',defoptions,def);
  3760. write ([space,' Pointed Type : ']);
  3761. readderef('',TPpuPointerDef(def).Ptr);
  3762. writeln([space,' Has Pointer Math : ',(getbyte<>0)]);
  3763. if tsystemcpu(ppufile.header.common.cpu) in [cpu_i8086,cpu_i386,cpu_x86_64] then
  3764. begin
  3765. write([space,' X86 Pointer Type : ']);
  3766. b:=getbyte;
  3767. case tx86pointertyp(b) of
  3768. x86pt_near: writeln('Near');
  3769. x86pt_near_cs: writeln('Near ''CS''');
  3770. x86pt_near_ds: writeln('Near ''DS''');
  3771. x86pt_near_ss: writeln('Near ''SS''');
  3772. x86pt_near_es: writeln('Near ''ES''');
  3773. x86pt_near_fs: writeln('Near ''FS''');
  3774. x86pt_near_gs: writeln('Near ''GS''');
  3775. x86pt_far: writeln('Far');
  3776. x86pt_huge: writeln('Huge');
  3777. else
  3778. WriteWarning('Invalid x86 pointer type: ' + IntToStr(b));
  3779. end;
  3780. end;
  3781. end;
  3782. iborddef :
  3783. begin
  3784. orddef:=TPpuOrdDef.Create(ParentDef);
  3785. readcommondef('Ordinal definition',defoptions,orddef);
  3786. write ([space,' Base type : ']);
  3787. b:=getbyte;
  3788. case tordtype(b) of
  3789. uvoid:
  3790. begin
  3791. writeln('uvoid');
  3792. orddef.OrdType:=otVoid;
  3793. end;
  3794. u8bit:
  3795. begin
  3796. writeln('u8bit');
  3797. orddef.OrdType:=otUInt;
  3798. orddef.Size:=1;
  3799. end;
  3800. u16bit:
  3801. begin
  3802. writeln('u16bit');
  3803. orddef.OrdType:=otUInt;
  3804. orddef.Size:=2;
  3805. end;
  3806. u32bit:
  3807. begin
  3808. writeln('u32bit');
  3809. orddef.OrdType:=otUInt;
  3810. orddef.Size:=4;
  3811. end;
  3812. u64bit:
  3813. begin
  3814. writeln('u64bit');
  3815. orddef.OrdType:=otUInt;
  3816. orddef.Size:=8;
  3817. end;
  3818. u128bit:
  3819. begin
  3820. writeln('u128bit');
  3821. orddef.OrdType:=otUInt;
  3822. orddef.Size:=16;
  3823. end;
  3824. s8bit:
  3825. begin
  3826. writeln('s8bit');
  3827. orddef.OrdType:=otSInt;
  3828. orddef.Size:=1;
  3829. end;
  3830. s16bit:
  3831. begin
  3832. writeln('s16bit');
  3833. orddef.OrdType:=otSInt;
  3834. orddef.Size:=2;
  3835. end;
  3836. s32bit:
  3837. begin
  3838. writeln('s32bit');
  3839. orddef.OrdType:=otSInt;
  3840. orddef.Size:=4;
  3841. end;
  3842. s64bit:
  3843. begin
  3844. writeln('s64bit');
  3845. orddef.OrdType:=otSInt;
  3846. orddef.Size:=8;
  3847. end;
  3848. s128bit:
  3849. begin
  3850. writeln('s128bit');
  3851. orddef.OrdType:=otSInt;
  3852. orddef.Size:=16;
  3853. end;
  3854. pasbool1:
  3855. begin
  3856. writeln('pasbool1');
  3857. orddef.OrdType:=otPasBool;
  3858. orddef.Size:=1;
  3859. end;
  3860. pasbool8:
  3861. begin
  3862. writeln('pasbool8');
  3863. orddef.OrdType:=otPasBool;
  3864. orddef.Size:=1;
  3865. end;
  3866. pasbool16:
  3867. begin
  3868. writeln('pasbool16');
  3869. orddef.OrdType:=otPasBool;
  3870. orddef.Size:=2;
  3871. end;
  3872. pasbool32:
  3873. begin
  3874. writeln('pasbool32');
  3875. orddef.OrdType:=otPasBool;
  3876. orddef.Size:=4;
  3877. end;
  3878. pasbool64:
  3879. begin
  3880. writeln('pasbool64');
  3881. orddef.OrdType:=otPasBool;
  3882. orddef.Size:=8;
  3883. end;
  3884. bool8bit:
  3885. begin
  3886. writeln('bool8bit');
  3887. orddef.OrdType:=otBool;
  3888. orddef.Size:=1;
  3889. end;
  3890. bool16bit:
  3891. begin
  3892. writeln('bool16bit');
  3893. orddef.OrdType:=otBool;
  3894. orddef.Size:=2;
  3895. end;
  3896. bool32bit:
  3897. begin
  3898. writeln('bool32bit');
  3899. orddef.OrdType:=otBool;
  3900. orddef.Size:=4;
  3901. end;
  3902. bool64bit:
  3903. begin
  3904. writeln('bool64bit');
  3905. orddef.OrdType:=otBool;
  3906. orddef.Size:=8;
  3907. end;
  3908. uchar:
  3909. begin
  3910. writeln('uchar');
  3911. orddef.OrdType:=otChar;
  3912. orddef.Size:=1;
  3913. end;
  3914. uwidechar:
  3915. begin
  3916. writeln('uwidechar');
  3917. orddef.OrdType:=otChar;
  3918. orddef.Size:=2;
  3919. end;
  3920. scurrency:
  3921. begin
  3922. writeln('scurrency');
  3923. orddef.OrdType:=otCurrency;
  3924. orddef.Size:=8;
  3925. end;
  3926. customint:
  3927. begin
  3928. writeln('customint');
  3929. orddef.OrdType:=otSint;
  3930. orddef.Size:=sizeof(ASizeInt);
  3931. end
  3932. else
  3933. WriteWarning('Invalid base type: ' + IntToStr(b));
  3934. end;
  3935. iexpr:=getexprint;
  3936. orddef.RangeLow:=iexpr.svalue;
  3937. write([space,' Range : ',constexp.tostr(iexpr)]);
  3938. iexpr:=getexprint;
  3939. orddef.RangeHigh:=iexpr.svalue;
  3940. writeln([' to ',constexp.tostr(iexpr)]);
  3941. end;
  3942. ibfloatdef :
  3943. begin
  3944. floatdef:=TPpuFloatDef.Create(ParentDef);
  3945. readcommondef('Float definition',defoptions,floatdef);
  3946. write ([space,' Float type : ']);
  3947. b:=getbyte;
  3948. case b of
  3949. ftSingle:
  3950. begin
  3951. writeln('Single');
  3952. floatdef.FloatType:=pftSingle;
  3953. end;
  3954. ftDouble:
  3955. begin
  3956. writeln('Double');
  3957. floatdef.FloatType:=pftDouble;
  3958. end;
  3959. ftExtended:
  3960. begin
  3961. writeln('Extended');
  3962. floatdef.FloatType:=pftExtended;
  3963. end;
  3964. ftComp:
  3965. begin
  3966. writeln('Comp');
  3967. floatdef.FloatType:=pftComp;
  3968. end;
  3969. ftCurr:
  3970. begin
  3971. writeln('Currency');
  3972. floatdef.FloatType:=pftCurrency;
  3973. end;
  3974. ftFloat128:
  3975. begin
  3976. writeln('Float128');
  3977. floatdef.FloatType:=pftFloat128;
  3978. end;
  3979. else
  3980. WriteWarning('Invalid float type: ' + IntToStr(b));
  3981. end;
  3982. end;
  3983. ibarraydef :
  3984. begin
  3985. arrdef:=TPpuArrayDef.Create(ParentDef);
  3986. readcommondef('Array definition',defoptions,arrdef);
  3987. write ([space,' Element type : ']);
  3988. readderef('',arrdef.ElType);
  3989. write ([space,' Range Type : ']);
  3990. readderef('',arrdef.RangeType);
  3991. arrdef.RangeLow:=getasizeint;
  3992. arrdef.RangeHigh:=getasizeint;
  3993. writeln([space,' Range : ',arrdef.RangeLow,' to ',arrdef.RangeHigh]);
  3994. write ([space,' Options : ']);
  3995. readarraydefoptions(arrdef);
  3996. if tsystemcpu(ppufile.header.common.cpu)=cpu_i8086 then
  3997. writeln([space,' Huge : ',(getbyte<>0)]);
  3998. readsymtable('symbols', arrdef);
  3999. end;
  4000. ibprocdef :
  4001. begin
  4002. def:=TPpuProcDef.Create(ParentDef);
  4003. readcommondef('Procedure definition',defoptions,def);
  4004. read_abstract_proc_def(calloption,procoptions,TPpuProcDef(def));
  4005. if (po_has_mangledname in procoptions) then
  4006. writeln([space,' Mangled name : ',readsymstr(ppufile)]);
  4007. writeln([space,' Number : ',getword]);
  4008. writeln([space,' Level : ',getbyte]);
  4009. write ([space,' Class : ']);
  4010. readderef('');
  4011. write ([space,' Procsym : ']);
  4012. readderef('', def.Ref);
  4013. write ([space,' File Pos : ']);
  4014. readposinfo(def);
  4015. write ([space,' Visibility : ']);
  4016. readvisibility(def);
  4017. write ([space,' SymOptions : ']);
  4018. readsymoptions(space+' ');
  4019. if (po_has_importdll in procoptions) then
  4020. writeln([space,' Import DLL : ',getstring]);
  4021. if (po_has_importname in procoptions) then
  4022. writeln([space,' Import Name : ',getstring]);
  4023. writeln([space,' Import Nr : ',getword]);
  4024. if (po_msgint in procoptions) then
  4025. writeln([space,' MsgInt : ',getlongint]);
  4026. if (po_msgstr in procoptions) then
  4027. writeln([space,' MsgStr : ',getstring]);
  4028. if (po_dispid in procoptions) then
  4029. writeln([space,' DispID: ',ppufile.getlongint]);
  4030. readprocimploptions(space,implprocoptions);
  4031. if (pio_has_inlininginfo in implprocoptions) then
  4032. begin
  4033. write ([space,' FuncretSym : ']);
  4034. readderef('');
  4035. readprocinfooptions(space);
  4036. end;
  4037. b:=ppufile.getbyte;
  4038. if b<>0 then
  4039. begin
  4040. write ([space,' Alias names : ']);
  4041. for j:=1 to b do
  4042. begin
  4043. write(ppufile.getstring);
  4044. if j<b then
  4045. write(', ');
  4046. end;
  4047. writeln;
  4048. end;
  4049. tokenbufsize:=ppufile.getlongint;
  4050. if tokenbufsize<>0 then
  4051. begin
  4052. space:=space + ' ';
  4053. write ([space,'Declaration token buffer : size = ',tokenbufsize]);
  4054. tokenbuf:=allocmem(tokenbufsize);
  4055. ppufile.getdata(tokenbuf^,tokenbufsize);
  4056. displaytokenbuffer(tokenbuf,tokenbufsize);
  4057. freemem(tokenbuf);
  4058. delete(space,1,4);
  4059. end;
  4060. if po_syscall_has_libsym in procoptions then
  4061. begin
  4062. { library symbol for AmigaOS/MorphOS/AROS }
  4063. write ([space,' Library symbol : ']);
  4064. readderef('');
  4065. end;
  4066. if not EndOfEntry then
  4067. HasMoreInfos;
  4068. space:=' '+space;
  4069. { parast }
  4070. readsymtable('parast', TPpuProcDef(def));
  4071. { localst }
  4072. if (pio_has_inlininginfo in implprocoptions) then
  4073. readsymtable('inline localst')
  4074. else if (df_generic in defoptions) then
  4075. readsymtable('generic localst');
  4076. if (pio_has_inlininginfo in implprocoptions) then
  4077. readnodetree;
  4078. delete(space,1,4);
  4079. end;
  4080. ibprocvardef :
  4081. begin
  4082. def:=TPpuProcTypeDef.Create(ParentDef);
  4083. readcommondef('Procedural type (ProcVar) definition',defoptions,def);
  4084. read_abstract_proc_def(calloption,procoptions, TPpuProcDef(def));
  4085. writeln([space,' Symtable level :',ppufile.getbyte]);
  4086. if tsystemcpu(ppufile.header.common.cpu)=cpu_jvm then
  4087. readderef('');
  4088. if not EndOfEntry then
  4089. HasMoreInfos;
  4090. space:=' '+space;
  4091. { parast }
  4092. readsymtable('parast',TPpuProcDef(def));
  4093. delete(space,1,4);
  4094. end;
  4095. ibshortstringdef :
  4096. begin
  4097. strdef:=TPpuStringDef.Create(ParentDef);
  4098. strdef.StrType:=stShort;
  4099. readcommondef('ShortString definition',defoptions,strdef);
  4100. strdef.Len:=getbyte;
  4101. writeln([space,' Length : ',strdef.Len]);
  4102. end;
  4103. ibwidestringdef :
  4104. begin
  4105. strdef:=TPpuStringDef.Create(ParentDef);
  4106. strdef.StrType:=stWide;
  4107. readcommondef('WideString definition',defoptions,strdef);
  4108. strdef.Len:=getasizeint;
  4109. writeln([space,' Length : ',strdef.Len]);
  4110. end;
  4111. ibunicodestringdef :
  4112. begin
  4113. strdef:=TPpuStringDef.Create(ParentDef);
  4114. strdef.StrType:=stUnicode;
  4115. readcommondef('UnicodeString definition',defoptions,strdef);
  4116. strdef.Len:=getasizeint;
  4117. writeln([space,' Length : ',strdef.Len]);
  4118. writeln([space,' Encoding : ',getword]);
  4119. end;
  4120. ibansistringdef :
  4121. begin
  4122. strdef:=TPpuStringDef.Create(ParentDef);
  4123. strdef.StrType:=stAnsi;
  4124. readcommondef('AnsiString definition',defoptions,strdef);
  4125. strdef.Len:=getasizeint;
  4126. writeln([space,' Length : ',strdef.Len]);
  4127. writeln([space,' Encoding : ',getword]);
  4128. end;
  4129. iblongstringdef :
  4130. begin
  4131. strdef:=TPpuStringDef.Create(ParentDef);
  4132. strdef.StrType:=stLong;
  4133. readcommondef('Longstring definition',defoptions,strdef);
  4134. strdef.Len:=getasizeint;
  4135. writeln([space,' Length : ',strdef.Len]);
  4136. end;
  4137. ibrecorddef :
  4138. begin
  4139. objdef:=TPpuRecordDef.Create(ParentDef);
  4140. readcommondef('Record definition',defoptions, objdef);
  4141. def.Name:=getstring;
  4142. writeln([space,' Name of Record : ',objdef.Name]);
  4143. writeln([space,' Import lib/pkg : ',getstring]);
  4144. write ([space,' Options : ']);
  4145. readobjectdefoptions(objdef);
  4146. if (df_copied_def in defoptions) then
  4147. begin
  4148. Include(TPpuRecordDef(def).Options, ooCopied);
  4149. write([space,' Copied from : ']);
  4150. readderef('',objdef.Ancestor);
  4151. end
  4152. else
  4153. begin
  4154. writeln([space,' FieldAlign : ',shortint(getbyte)]);
  4155. writeln([space,' RecordAlign : ',shortint(getbyte)]);
  4156. writeln([space,' PadAlign : ',shortint(getbyte)]);
  4157. writeln([space,'UseFieldAlignment : ',shortint(getbyte)]);
  4158. writeln([space,' RecordAlignMin : ',shortint(getbyte)]);
  4159. objdef.Size:=getasizeint;
  4160. writeln([space,' DataSize : ',objdef.Size]);
  4161. writeln([space,' PaddingSize : ',getword]);
  4162. readmanagementoperatoroptions(space,'Management operators');
  4163. end;
  4164. {read the record definitions and symbols}
  4165. if not(df_copied_def in current_defoptions) then
  4166. begin
  4167. space:=' '+space;
  4168. readrecordsymtable('fields',TPpuRecordDef(def));
  4169. Delete(space,1,4);
  4170. end;
  4171. if not EndOfEntry then
  4172. HasMoreInfos;
  4173. end;
  4174. ibobjectdef :
  4175. begin
  4176. objdef:=TPpuObjectDef.Create(ParentDef);
  4177. readcommondef('Object/Class definition',defoptions,objdef);
  4178. objdef.Name:=getstring;
  4179. writeln([space,' Name of Class : ',objdef.Name]);
  4180. writeln([space,' Import lib/pkg : ',getstring]);
  4181. write ([space,' Options : ']);
  4182. readobjectdefoptions(objdef);
  4183. otb:=getbyte;
  4184. write ([space,' Type : ']);
  4185. case tobjecttyp(otb) of
  4186. odt_class : writeln('class');
  4187. odt_object : writeln('object');
  4188. odt_interfacecom : writeln('interfacecom');
  4189. odt_interfacecorba : writeln('interfacecorba');
  4190. odt_cppclass : writeln('cppclass');
  4191. odt_dispinterface : writeln('dispinterface');
  4192. odt_objcclass : writeln('objcclass');
  4193. odt_objcprotocol : writeln('objcprotocol');
  4194. odt_helper : writeln('helper');
  4195. odt_objccategory : writeln('objccategory');
  4196. odt_javaclass : writeln('Java class');
  4197. odt_interfacejava : writeln('Java interface');
  4198. else WriteWarning('Invalid object type: ' + IntToStr(b));
  4199. end;
  4200. case tobjecttyp(otb) of
  4201. odt_class, odt_cppclass, odt_objcclass, odt_javaclass:
  4202. objdef.ObjType:=otClass;
  4203. odt_object:
  4204. objdef.ObjType:=otObject;
  4205. odt_interfacecom, odt_interfacecorba, odt_interfacejava, odt_dispinterface:
  4206. objdef.ObjType:=otInterface;
  4207. odt_helper:
  4208. objdef.ObjType:=otHelper;
  4209. end;
  4210. b:=getbyte;
  4211. write ([space,' Helper Type : ']);
  4212. case thelpertype(b) of
  4213. ht_none : writeln('none');
  4214. ht_class : writeln('class helper');
  4215. ht_record : writeln('record helper');
  4216. ht_type : writeln('type helper');
  4217. else WriteWarning('Invalid helper type: ' + IntToStr(b));
  4218. end;
  4219. writeln([space,' External name : ',getstring]);
  4220. objdef.Size:=getasizeint;
  4221. writeln([space,' DataSize : ',objdef.Size]);
  4222. writeln([space,' PaddingSize : ',getword]);
  4223. writeln([space,' FieldAlign : ',shortint(getbyte)]);
  4224. writeln([space,' RecordAlign : ',shortint(getbyte)]);
  4225. writeln([space,' RecordAlignMin : ',shortint(getbyte)]);
  4226. write ([space, ' VmtField : ']);
  4227. readderef('',nil);
  4228. write ([space, ' Ancestor Class : ']);
  4229. readderef('',objdef.Ancestor);
  4230. if tobjecttyp(otb) in [odt_interfacecom,odt_interfacecorba,odt_dispinterface] then
  4231. begin
  4232. { IIDGUID }
  4233. for j:=1to 16 do
  4234. getbyte;
  4235. objdef.IID:=getstring;
  4236. writeln([space,' IID String : ',objdef.IID]);
  4237. end;
  4238. l:=getlongint;
  4239. if l > 0 then
  4240. objdef.Options:=objdef.Options + [ooAbstractMethods];
  4241. writeln([space,' Abstract methods : ',l]);
  4242. if tobjecttyp(otb)=odt_helper then
  4243. begin
  4244. write([space,' Helper parent : ']);
  4245. readderef('',objdef.HelperParent);
  4246. end;
  4247. l:=getlongint;
  4248. writeln([space,' VMT entries: ',l]);
  4249. for j:=1 to l do
  4250. begin
  4251. write([space,' ']);
  4252. readderef('');
  4253. write([space,' Visibility: ']);
  4254. readvisibility;
  4255. end;
  4256. if tobjecttyp(otb) in [odt_class,odt_objcclass,odt_objcprotocol,odt_javaclass,odt_interfacejava] then
  4257. begin
  4258. l:=getlongint;
  4259. writeln([space,' Impl Intf Count : ',l]);
  4260. for j:=1 to l do
  4261. begin
  4262. write ([space,' - Definition : ']);
  4263. readderef('');
  4264. write ([space,' - Getter Def : ']);
  4265. readderef('');
  4266. writeln([space,' IOffset : ',getlongint]);
  4267. writeln([space,' Entry type : ',IntfEntryType2Str(getbyte)]);
  4268. end;
  4269. end;
  4270. if df_copied_def in current_defoptions then
  4271. begin
  4272. Include(objdef.Options, ooCopied);
  4273. writeln(' Copy of def: ');
  4274. readderef('',objdef.Ancestor);
  4275. end
  4276. else
  4277. begin
  4278. {read the record definitions and symbols}
  4279. space:=' '+space;
  4280. readrecordsymtable('fields',objdef);
  4281. Delete(space,1,4);
  4282. end;
  4283. if not EndOfEntry then
  4284. HasMoreInfos;
  4285. end;
  4286. ibfiledef :
  4287. begin
  4288. filedef:=TPpuFileDef.Create(ParentDef);
  4289. ReadCommonDef('File definition',defoptions,filedef);
  4290. write ([space,' Type : ']);
  4291. case getbyte of
  4292. 0 : begin
  4293. writeln('Text');
  4294. filedef.FileType:=ftText;
  4295. end;
  4296. 1 : begin
  4297. writeln('Typed');
  4298. filedef.FileType:=ftTyped;
  4299. write ([space,' File of Type : ']);
  4300. readderef('',filedef.TypeRef);
  4301. end;
  4302. 2 : begin
  4303. writeln('Untyped');
  4304. filedef.FileType:=ftUntyped;
  4305. end;
  4306. end;
  4307. end;
  4308. ibformaldef :
  4309. begin
  4310. def:=TPpuFormalDef.Create(ParentDef);
  4311. readcommondef('Generic definition (void-typ)',defoptions,def);
  4312. TPpuFormalDef(def).IsTyped:=(getbyte<>0);
  4313. writeln([space,' Is Typed : ',TPpuFormalDef(def).IsTyped]);
  4314. end;
  4315. ibundefineddef :
  4316. begin
  4317. def:=TPpuUndefinedDef.Create(ParentDef);
  4318. readcommondef('Undefined definition (generic parameter)',defoptions,def);
  4319. end;
  4320. ibenumdef :
  4321. begin
  4322. enumdef:=TPpuEnumDef.Create(ParentDef);
  4323. readcommondef('Enumeration type definition',defoptions,enumdef);
  4324. enumdef.ElLow:=getaint;
  4325. writeln([space,' Smallest element : ',enumdef.ElLow]);
  4326. enumdef.ElHigh:=getaint;
  4327. writeln([space,' Largest element : ',enumdef.ElHigh]);
  4328. enumdef.Size:=byte(getaint);
  4329. writeln([space,' Size : ',enumdef.Size]);
  4330. if df_copied_def in defoptions then
  4331. begin
  4332. write([space,'Base enumeration type : ']);
  4333. readderef('',enumdef.CopyFrom);
  4334. end
  4335. else
  4336. begin
  4337. space:=' '+space;
  4338. readsymtable('elements',enumdef);
  4339. delete(space,1,4);
  4340. end;
  4341. if tsystemcpu(ppufile.header.common.cpu)=cpu_jvm then
  4342. begin
  4343. write([space,' Class def : ']);
  4344. readderef('');
  4345. end;
  4346. end;
  4347. ibclassrefdef :
  4348. begin
  4349. def:=TPpuClassRefDef.Create(ParentDef);
  4350. readcommondef('Class reference definition',defoptions,def);
  4351. write ([space,' Pointed Type : ']);
  4352. readderef('',TPpuClassRefDef(def).ClassRef);
  4353. end;
  4354. ibsetdef :
  4355. begin
  4356. setdef:=TPpuSetDef.Create(ParentDef);
  4357. readcommondef('Set definition',defoptions,setdef);
  4358. write ([space,' Element type : ']);
  4359. readderef('',setdef.ElType);
  4360. setdef.Size:=getasizeint;
  4361. writeln([space,' Size : ',setdef.Size]);
  4362. setdef.SetBase:=getasizeint;
  4363. writeln([space,' Set Base : ',setdef.SetBase]);
  4364. setdef.SetMax:=getasizeint;
  4365. writeln([space,' Set Max : ',setdef.SetMax]);
  4366. end;
  4367. ibvariantdef :
  4368. begin
  4369. def:=TPpuVariantDef.Create(ParentDef);
  4370. readcommondef('Variant definition',defoptions,def);
  4371. write ([space,' Varianttype : ']);
  4372. b:=getbyte;
  4373. case tvarianttype(b) of
  4374. vt_normalvariant :
  4375. writeln('Normal');
  4376. vt_olevariant :
  4377. begin
  4378. TPpuVariantDef(def).IsOLE:=True;
  4379. writeln('OLE');
  4380. end
  4381. else
  4382. WriteWarning('Invalid varianttype: ' + IntToStr(b));
  4383. end;
  4384. end;
  4385. iberror :
  4386. begin
  4387. WriteError('!! Error in PPU');
  4388. exit;
  4389. end;
  4390. ibenddefs :
  4391. break;
  4392. else
  4393. begin
  4394. WriteError('!! Skipping unsupported PPU Entry in definitions: '+IntToStr(b));
  4395. end;
  4396. end;
  4397. if assigned(def) then
  4398. readdefsubentries(def);
  4399. if (def <> nil) and (def.Parent = nil) then
  4400. def.Free;
  4401. if not EndOfEntry then
  4402. HasMoreInfos;
  4403. until false;
  4404. end;
  4405. end;
  4406. procedure readmoduleoptions(space : string);
  4407. type
  4408. { tmoduleoption type is in unit fmodule }
  4409. tmoduleoption = (mo_none,
  4410. mo_hint_deprecated,
  4411. mo_hint_platform,
  4412. mo_hint_library,
  4413. mo_hint_unimplemented,
  4414. mo_hint_experimental,
  4415. mo_has_deprecated_msg
  4416. );
  4417. tmoduleoptions = set of tmoduleoption;
  4418. tmoduleopt=record
  4419. mask : tmoduleoption;
  4420. str : string[30];
  4421. end;
  4422. const
  4423. moduleopts=ord(high(tmoduleoption));
  4424. moduleopt : array[1..moduleopts] of tmoduleopt=(
  4425. (mask:mo_hint_deprecated; str:'Hint Deprecated'),
  4426. (mask:mo_hint_platform; str:'Hint Platform'),
  4427. (mask:mo_hint_library; str:'Hint Library'),
  4428. (mask:mo_hint_unimplemented; str:'Hint Unimplemented'),
  4429. (mask:mo_hint_experimental; str:'Hint Experimental'),
  4430. (mask:mo_has_deprecated_msg; str:'Has Deprecated Message')
  4431. );
  4432. var
  4433. moduleoptions : tmoduleoptions;
  4434. i : longint;
  4435. first : boolean;
  4436. begin
  4437. ppufile.getset(tppuset1(moduleoptions));
  4438. if moduleoptions<>[] then
  4439. begin
  4440. first:=true;
  4441. for i:=1to moduleopts do
  4442. if (moduleopt[i].mask in moduleoptions) then
  4443. begin
  4444. if first then
  4445. first:=false
  4446. else
  4447. write(', ');
  4448. write(moduleopt[i].str);
  4449. end;
  4450. end;
  4451. writeln;
  4452. if mo_has_deprecated_msg in moduleoptions then
  4453. writeln([space,'Deprecated : ', ppufile.getstring]);
  4454. end;
  4455. {****************************************************************************
  4456. Read General Part
  4457. ****************************************************************************}
  4458. procedure readinterface(silent : boolean);
  4459. var
  4460. b : byte;
  4461. sourcenumber, i : longint;
  4462. feature : tfeature;
  4463. features : tfeatures;
  4464. s : string;
  4465. begin
  4466. with ppufile do
  4467. begin
  4468. repeat
  4469. b:=readentry;
  4470. case b of
  4471. ibmodulename :
  4472. begin
  4473. CurUnit.Name:=getstring;
  4474. if not silent then
  4475. Writeln(['Module Name: ',CurUnit.Name]);
  4476. end;
  4477. ibfeatures :
  4478. begin
  4479. getset(tppuset4(features));
  4480. Writeln('Features: ');
  4481. for feature:=low(tfeatures) to high(tfeature) do
  4482. if feature in features then
  4483. begin
  4484. str(feature,s);
  4485. s:=copy(s,3,255);
  4486. writeln([s]);
  4487. end;
  4488. end;
  4489. ibmoduleoptions:
  4490. if not silent then
  4491. readmoduleoptions(' ');
  4492. ibsourcefiles :
  4493. begin
  4494. sourcenumber:=1;
  4495. if not silent then
  4496. while not EndOfEntry do
  4497. begin
  4498. with TPpuSrcFile.Create(CurUnit.SourceFiles) do begin
  4499. Name:=getstring;
  4500. i:=getlongint;
  4501. if i >= 0 then
  4502. FileTime:=FileDateToDateTime(i);
  4503. Writeln(['Source file ',sourcenumber,' : ',Name,' ',filetimestring(i)]);
  4504. end;
  4505. inc(sourcenumber);
  4506. end;
  4507. end;
  4508. {$IFDEF MACRO_DIFF_HINT}
  4509. ibusedmacros :
  4510. begin
  4511. if not silent then
  4512. while not EndOfEntry do
  4513. begin
  4514. Write('Conditional ',getstring);
  4515. if getboolean then
  4516. write(' defined at startup')
  4517. else
  4518. write(' not defined at startup');
  4519. if getboolean then
  4520. writeln(' was used')
  4521. else
  4522. writeln;
  4523. end;
  4524. end;
  4525. {$ENDIF}
  4526. ibloadunit :
  4527. if not silent then
  4528. ReadLoadUnit;
  4529. iblinkunitofiles :
  4530. if not silent then
  4531. ReadLinkContainer('Link unit object file: ');
  4532. iblinkunitstaticlibs :
  4533. if not silent then
  4534. ReadLinkContainer('Link unit static lib: ');
  4535. iblinkunitsharedlibs :
  4536. if not silent then
  4537. ReadLinkContainer('Link unit shared lib: ');
  4538. iblinkotherofiles :
  4539. if not silent then
  4540. ReadLinkContainer('Link other object file: ');
  4541. iblinkotherstaticlibs :
  4542. if not silent then
  4543. ReadLinkContainer('Link other static lib: ');
  4544. iblinkothersharedlibs :
  4545. if not silent then
  4546. ReadLinkContainer('Link other shared lib: ');
  4547. iblinkotherframeworks:
  4548. if not silent then
  4549. ReadLinkContainer('Link framework: ');
  4550. ibjvmnamespace:
  4551. Writeln('JVM name space: '+getString);
  4552. ibmainname:
  4553. if not silent then
  4554. Writeln(['Specified main program symbol name: ',getstring]);
  4555. ibImportSymbols :
  4556. if not silent then
  4557. ReadImportSymbols;
  4558. ibderefdata :
  4559. ReadDerefData;
  4560. ibderefmap :
  4561. ReadDerefMap;
  4562. ibwpofile :
  4563. if not silent then
  4564. ReadWpoFileInfo;
  4565. ibresources :
  4566. if not silent then
  4567. ReadContainer('Resource file: ');
  4568. iborderedsymbols:
  4569. if not silent then
  4570. ReadContainer('Ordered symbol: ');
  4571. iberror :
  4572. begin
  4573. WriteError('Error in PPU');
  4574. exit;
  4575. end;
  4576. ibendinterface :
  4577. break;
  4578. else
  4579. begin
  4580. WriteError('!! Skipping unsupported PPU Entry in General Part: '+IntToStr(b));
  4581. end;
  4582. end;
  4583. until false;
  4584. end;
  4585. end;
  4586. {****************************************************************************
  4587. Read Implementation Part
  4588. ****************************************************************************}
  4589. procedure readimplementation;
  4590. var
  4591. b : byte;
  4592. begin
  4593. with ppufile do
  4594. begin
  4595. repeat
  4596. b:=readentry;
  4597. case b of
  4598. ibasmsymbols :
  4599. ReadAsmSymbols;
  4600. ibloadunit :
  4601. ReadLoadUnit;
  4602. ibunitimportsyms :
  4603. ReadUnitImportSyms;
  4604. iberror :
  4605. begin
  4606. WriteError('Error in PPU');
  4607. exit;
  4608. end;
  4609. ibendimplementation :
  4610. break;
  4611. else
  4612. begin
  4613. WriteError('!! Skipping unsupported PPU Entry in Implementation: '+IntToStr(b));
  4614. end;
  4615. end;
  4616. until false;
  4617. end;
  4618. end;
  4619. function parseextraheader(module: TPpuModuleDef; ppufile: tppufile): boolean;
  4620. var
  4621. b: byte;
  4622. begin
  4623. result:=false;
  4624. b:=ppufile.readentry;
  4625. if b<>ibextraheader then
  4626. exit;
  4627. CurUnit.LongVersion:=cardinal(ppufile.getlongint);
  4628. Writeln(['LongVersion: ',CurUnit.LongVersion]);
  4629. ppufile.getset(tppuset4(CurUnit.ModuleFlags));
  4630. result:=ppufile.EndOfEntry and (CurUnit.LongVersion=CurrentPPULongVersion);
  4631. if mf_symansistr in CurUnit.ModuleFlags then
  4632. SymAnsiStr:=true;
  4633. end;
  4634. procedure dofile (filename : string);
  4635. begin
  4636. { reset }
  4637. space:='';
  4638. { fix filename }
  4639. if pos('.',filename)=0 then
  4640. filename:=filename+'.ppu';
  4641. ppufile:=tppudumpfile.create(filename);
  4642. if not ppufile.openfile then
  4643. begin
  4644. WriteError('IO-Error when opening : '+filename+', Skipping');
  4645. exit;
  4646. end;
  4647. { PPU File is open, check for PPU Id }
  4648. if not ppufile.CheckPPUID then
  4649. begin
  4650. WriteError(Filename+' : Not a valid PPU file, Skipping');
  4651. exit;
  4652. end;
  4653. { Check PPU Version }
  4654. ppuversion:=ppufile.getversion;
  4655. Writeln(['Analyzing ',filename,' (v',PPUVersion,')']);
  4656. if not SkipVersionCheck and (PPUVersion <> CurrentPPUVersion) then
  4657. begin
  4658. WriteError(Format('Unsupported PPU version %d. Expecting PPU version %d.', [PPUVersion, CurrentPPUVersion]));
  4659. exit;
  4660. end;
  4661. CurUnit:=TPpuModuleDef.Create(UnitList);
  4662. CurUnit.Version:=ppuversion;
  4663. if not parseextraheader(CurUnit, ppufile) then
  4664. begin
  4665. WriteError(Format('Unsupported PPU sub-version %d. Expecting PPU sub-version %d.', [CurUnit.LongVersion, CurrentPPULongVersion]));
  4666. end;
  4667. { Write PPU Header Information }
  4668. if (verbose and v_header)<>0 then
  4669. begin
  4670. Writeln;
  4671. Writeln('Header');
  4672. Writeln('-------');
  4673. with ppufile.header do
  4674. begin
  4675. Writeln(['Compiler version : ',ppufile.header.common.compiler shr 14,'.',
  4676. (ppufile.header.common.compiler shr 7) and $7f,'.',
  4677. ppufile.header.common.compiler and $7f]);
  4678. WriteLn(['Target processor : ',Cpu2Str(common.cpu)]);
  4679. WriteLn(['Target operating system : ',Target2Str(common.target)]);
  4680. Writeln(['Unit flags : ',PPUFlags2Str(common.flags)]);
  4681. Writeln(['FileSize (w/o header) : ',common.size]);
  4682. Writeln(['Checksum : ',hexstr(checksum,8)]);
  4683. Writeln(['Interface Checksum : ',hexstr(interface_checksum,8)]);
  4684. Writeln(['Indirect Checksum : ',hexstr(indirect_checksum,8)]);
  4685. Writeln(['Definitions stored : ',tostr(deflistsize)]);
  4686. Writeln(['Symbols stored : ',tostr(symlistsize)]);
  4687. end;
  4688. end;
  4689. with ppufile.header do
  4690. begin
  4691. CurUnit.Crc:=checksum;
  4692. CurUnit.IntfCrc:=interface_checksum;
  4693. CurUnit.TargetCPU:=Cpu2Str(common.cpu);
  4694. CurUnit.TargetOS:=Target2Str(common.target);
  4695. end;
  4696. {read the general stuff}
  4697. if (verbose and v_interface)<>0 then
  4698. begin
  4699. Writeln;
  4700. Writeln('Interface section');
  4701. Writeln('------------------');
  4702. readinterface(false);
  4703. end
  4704. { We need derefdata from Interface }
  4705. else if verbose and (v_defs or v_syms or v_implementation)<>0 then
  4706. readinterface(true)
  4707. else
  4708. ppufile.skipuntilentry(ibendinterface);
  4709. Writeln;
  4710. Writeln('Interface symtable');
  4711. Writeln('----------------------');
  4712. readsymtableoptions('interface');
  4713. {read the definitions}
  4714. if (verbose and v_defs)<>0 then
  4715. begin
  4716. Writeln;
  4717. Writeln('Interface definitions');
  4718. Writeln('----------------------');
  4719. readdefinitions('interface', CurUnit);
  4720. end
  4721. else
  4722. ppufile.skipuntilentry(ibenddefs);
  4723. {read the symbols}
  4724. if (verbose and v_syms)<>0 then
  4725. begin
  4726. Writeln;
  4727. Writeln('Interface Symbols');
  4728. Writeln('------------------');
  4729. readsymbols('interface',CurUnit);
  4730. end
  4731. else
  4732. ppufile.skipuntilentry(ibendsyms);
  4733. {read the macro symbols}
  4734. if (verbose and v_syms)<>0 then
  4735. begin
  4736. Writeln;
  4737. Writeln('Interface Macro Symbols');
  4738. Writeln('-----------------------');
  4739. end;
  4740. if ppufile.readentry<>ibexportedmacros then
  4741. begin
  4742. WriteError('!! Error in PPU');
  4743. exit;
  4744. end;
  4745. if ppufile.getboolean then
  4746. begin
  4747. readsymtableoptions('interface macro');
  4748. {skip the definition section for macros (since they are never used) }
  4749. ppufile.skipuntilentry(ibenddefs);
  4750. {read the macro symbols}
  4751. if (verbose and v_syms)<>0 then
  4752. readsymbols('interface macro')
  4753. else
  4754. ppufile.skipuntilentry(ibendsyms);
  4755. end
  4756. else
  4757. Writeln('(no exported macros)');
  4758. {read the implementation stuff}
  4759. if (verbose and v_implementation)<>0 then
  4760. begin
  4761. Writeln;
  4762. Writeln('Implementation section');
  4763. Writeln('-----------------------');
  4764. readimplementation;
  4765. end
  4766. else
  4767. ppufile.skipuntilentry(ibendimplementation);
  4768. {read the static symtable}
  4769. Writeln;
  4770. Writeln('Implementation symtable');
  4771. Writeln('----------------------');
  4772. readsymtableoptions('implementation');
  4773. if (mf_local_symtable in CurUnit.ModuleFlags) then
  4774. begin
  4775. if (verbose and v_defs)<>0 then
  4776. begin
  4777. Writeln;
  4778. Writeln('Static definitions');
  4779. Writeln('----------------------');
  4780. readdefinitions('implementation', nil);
  4781. end
  4782. else
  4783. ppufile.skipuntilentry(ibenddefs);
  4784. {read the symbols}
  4785. if (verbose and v_syms)<>0 then
  4786. begin
  4787. Writeln;
  4788. Writeln('Static Symbols');
  4789. Writeln('------------------');
  4790. readsymbols('implementation');
  4791. end
  4792. else
  4793. ppufile.skipuntilentry(ibendsyms);
  4794. end;
  4795. ReadCreatedObjTypes;
  4796. FreeDerefdata;
  4797. {shutdown ppufile}
  4798. ppufile.closefile;
  4799. ppufile.free;
  4800. Writeln;
  4801. end;
  4802. procedure WriteLogo;
  4803. begin
  4804. writeln(Title+' Version '+version_string);
  4805. writeln(Copyright);
  4806. writeln;
  4807. end;
  4808. procedure help;
  4809. begin
  4810. WriteLogo;
  4811. writeln('usage: ppudump [options] <filename1> <filename2>...');
  4812. writeln;
  4813. writeln('[options] can be:');
  4814. writeln(' -F<format> Set output format to <format>');
  4815. writeln(' t - text format (default)');
  4816. writeln(' j - JSON format');
  4817. writeln(' x - XML format');
  4818. writeln(' -M Exit with ExitCode=2 if more information is available');
  4819. writeln(' -S Skip PPU version check. May lead to reading errors');
  4820. writeln(' -V<verbose> Set verbosity to <verbose>');
  4821. writeln(' H - Show header info');
  4822. writeln(' I - Show interface');
  4823. writeln(' M - Show implementation');
  4824. writeln(' S - Show interface symbols');
  4825. writeln(' D - Show interface definitions');
  4826. writeln(' A - Show all');
  4827. writeln(' -h, -? This helpscreen');
  4828. halt;
  4829. end;
  4830. var
  4831. startpara,
  4832. nrfile,i : longint;
  4833. para : string;
  4834. const
  4835. error_on_more : boolean = false;
  4836. begin
  4837. if paramcount<1 then
  4838. help;
  4839. { turn verbose on by default }
  4840. verbose:=v_all;
  4841. { read options }
  4842. startpara:=1;
  4843. while copy(paramstr(startpara),1,1)='-' do
  4844. begin
  4845. para:=paramstr(startpara);
  4846. case upcase(para[2]) of
  4847. 'F' : begin
  4848. FreeAndNil(pout);
  4849. if Length(para) > 2 then
  4850. case upcase(para[3]) of
  4851. 'T':
  4852. nostdout:=False;
  4853. 'J':
  4854. begin
  4855. nostdout:=True;
  4856. pout:=TPpuJsonOutput.Create(StdOutputHandle);
  4857. end;
  4858. 'X':
  4859. begin
  4860. nostdout:=True;
  4861. pout:=TPpuXmlOutput.Create(StdOutputHandle);
  4862. end;
  4863. else
  4864. begin
  4865. WriteError('Invalid output format: ' + para[3]);
  4866. Halt(1);
  4867. end;
  4868. end;
  4869. end;
  4870. 'M' : error_on_more:=true;
  4871. 'S' : SkipVersionCheck:=True;
  4872. 'V' : begin
  4873. verbose:=0;
  4874. for i:=3 to length(para) do
  4875. case upcase(para[i]) of
  4876. 'H' : verbose:=verbose or v_header;
  4877. 'I' : verbose:=verbose or v_interface;
  4878. 'M' : verbose:=verbose or v_implementation;
  4879. 'D' : verbose:=verbose or v_defs;
  4880. 'S' : verbose:=verbose or v_syms;
  4881. 'A' : verbose:=verbose or v_all;
  4882. end;
  4883. end;
  4884. 'H' : help;
  4885. '?' : help;
  4886. else
  4887. begin
  4888. WriteError('Invalid option: ' + para);
  4889. Halt(1);
  4890. end;
  4891. end;
  4892. inc(startpara);
  4893. end;
  4894. if not nostdout then
  4895. WriteLogo;
  4896. UnitList:=TPpuContainerDef.Create(nil);
  4897. try
  4898. UnitList.ItemsName:='';
  4899. { process files }
  4900. for nrfile:=startpara to paramcount do
  4901. dofile (paramstr(nrfile));
  4902. if not has_errors and (pout <> nil) then
  4903. begin
  4904. pout.Init;
  4905. UnitList.Write(pout);
  4906. pout.Done;
  4907. end;
  4908. finally
  4909. UnitList.Free;
  4910. pout.Free;
  4911. end;
  4912. if has_errors then
  4913. Halt(1);
  4914. if error_on_more and
  4915. (has_more_infos or has_warnings) then
  4916. Halt(2);
  4917. end.