ppudump.pp 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301
  1. {
  2. Copyright (c) 1998-2002 by the FPC Development Team
  3. Dumps the contents of a FPC unit file (PPU File)
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************}
  16. {$ifdef TP}
  17. {$N+,E+}
  18. {$endif}
  19. program pppdump;
  20. uses
  21. dos,
  22. ppu,
  23. globals,
  24. tokens;
  25. const
  26. Version = 'Version 2.1.1';
  27. Title = 'PPU-Analyser';
  28. Copyright = 'Copyright (c) 1998-2006 by the Free Pascal Development Team';
  29. { verbosity }
  30. v_none = $0;
  31. v_header = $1;
  32. v_defs = $2;
  33. v_syms = $4;
  34. v_interface = $8;
  35. v_implementation = $10;
  36. // v_browser = $20;
  37. v_all = $ff;
  38. type
  39. tprocinfoflag=(
  40. {# procedure uses asm }
  41. pi_uses_asm,
  42. {# procedure does a call }
  43. pi_do_call,
  44. {# procedure has a try statement = no register optimization }
  45. pi_uses_exceptions,
  46. {# procedure is declared as @var(assembler), don't optimize}
  47. pi_is_assembler,
  48. {# procedure contains data which needs to be finalized }
  49. pi_needs_implicit_finally
  50. );
  51. tprocinfoflags=set of tprocinfoflag;
  52. { copied from scanner.pas }
  53. tspecialgenerictoken = (ST_LOADSETTINGS,ST_LINE,ST_COLUMN,ST_FILEINDEX);
  54. { Copied from systems.pas }
  55. tsystemcpu=
  56. (
  57. cpu_no, { 0 }
  58. cpu_i386, { 1 }
  59. cpu_m68k, { 2 }
  60. cpu_alpha, { 3 }
  61. cpu_powerpc, { 4 }
  62. cpu_sparc, { 5 }
  63. cpu_vm, { 6 }
  64. cpu_iA64, { 7 }
  65. cpu_x86_64, { 8 }
  66. cpu_mips, { 9 }
  67. cpu_arm { 10 }
  68. );
  69. var
  70. ppufile : tppufile;
  71. space : string;
  72. verbose : longint;
  73. derefdata : pbyte;
  74. derefdatalen : longint;
  75. {****************************************************************************
  76. Helper Routines
  77. ****************************************************************************}
  78. const has_errors : boolean = false;
  79. Procedure Error(const S : string);
  80. Begin
  81. Writeln(S);
  82. has_errors:=true;
  83. End;
  84. function ToStr(w:longint):String;
  85. begin
  86. Str(w,ToStr);
  87. end;
  88. Function Target2Str(w:longint):string;
  89. type
  90. { taken from systems.pas }
  91. ttarget =
  92. (
  93. target_none, { 0 }
  94. target_i386_GO32V1, { 1 }
  95. target_i386_GO32V2, { 2 }
  96. target_i386_linux, { 3 }
  97. target_i386_OS2, { 4 }
  98. target_i386_Win32, { 5 }
  99. target_i386_freebsd, { 6 }
  100. target_m68k_Amiga, { 7 }
  101. target_m68k_Atari, { 8 }
  102. target_m68k_Mac, { 9 }
  103. target_m68k_linux, { 10 }
  104. target_m68k_PalmOS, { 11 }
  105. target_alpha_linux, { 12 }
  106. target_powerpc_linux, { 13 }
  107. target_powerpc_macos, { 14 }
  108. target_i386_sunos, { 15 }
  109. target_i386_beos, { 16 }
  110. target_i386_netbsd, { 17 }
  111. target_m68k_netbsd, { 18 }
  112. target_i386_Netware, { 19 }
  113. target_i386_qnx, { 20 }
  114. target_i386_wdosx, { 21 }
  115. target_sparc_sunos, { 22 }
  116. target_sparc_linux, { 23 }
  117. target_i386_openbsd, { 24 }
  118. target_m68k_openbsd, { 25 }
  119. system_x86_64_linux, { 26 }
  120. system_powerpc_macosx, { 27 }
  121. target_i386_emx, { 28 }
  122. target_powerpc_netbsd, { 29 }
  123. target_powerpc_openbsd, { 30 }
  124. target_arm_linux, { 31 }
  125. target_i386_watcom, { 32 }
  126. target_powerpc_MorphOS, { 33 }
  127. target_x86_64_freebsd, { 34 }
  128. target_i386_netwlibc, { 35 }
  129. system_powerpc_Amiga, { 36 }
  130. system_x86_64_win64, { 37 }
  131. system_arm_wince, { 38 }
  132. system_ia64_win64, { 39 }
  133. system_i386_wince, { 40 }
  134. system_x86_6432_linux, { 41 }
  135. system_arm_gba { 42 }
  136. );
  137. const
  138. Targets : array[ttarget] of string[17]=(
  139. { 0 } 'none',
  140. { 1 } 'GO32V1',
  141. { 2 } 'GO32V2',
  142. { 3 } 'Linux-i386',
  143. { 4 } 'OS/2',
  144. { 5 } 'Win32',
  145. { 6 } 'FreeBSD-i386',
  146. { 7 } 'Amiga',
  147. { 8 } 'Atari',
  148. { 9 } 'MacOS-m68k',
  149. { 10 } 'Linux-m68k',
  150. { 11 } 'PalmOS-m68k',
  151. { 12 } 'Linux-alpha',
  152. { 13 } 'Linux-ppc',
  153. { 14 } 'MacOS-ppc',
  154. { 15 } 'Solaris-i386',
  155. { 16 } 'BeOS-i386',
  156. { 17 } 'NetBSD-i386',
  157. { 18 } 'NetBSD-m68k',
  158. { 19 } 'Netware-i386-clib',
  159. { 20 } 'Qnx-i386',
  160. { 21 } 'WDOSX-i386',
  161. { 22 } 'Solaris-sparc',
  162. { 23 } 'Linux-sparc',
  163. { 24 } 'OpenBSD-i386',
  164. { 25 } 'OpenBSD-m68k',
  165. { 26 } 'Linux-x86-64',
  166. { 27 } 'MacOSX-ppc',
  167. { 28 } 'OS/2 via EMX',
  168. { 29 } 'NetBSD-powerpc',
  169. { 30 } 'OpenBSD-powerpc',
  170. { 31 } 'Linux-arm',
  171. { 32 } 'Watcom-i386',
  172. { 33 } 'MorphOS-powerpc',
  173. { 34 } 'FreeBSD-x86-64',
  174. { 35 } 'Netware-i386-libc',
  175. { 36 } 'Amiga-PowerPC',
  176. { 37 } 'Win64-x64',
  177. { 38 } 'WinCE-ARM',
  178. { 39 } 'Win64-iA64',
  179. { 40 } 'WinCE-i386',
  180. { 41 } 'Linux-x64',
  181. { 42 } 'GBA-ARM'
  182. );
  183. begin
  184. if w<=ord(high(ttarget)) then
  185. Target2Str:=Targets[ttarget(w)]
  186. else
  187. Target2Str:='<!! Unknown target value '+tostr(w)+'>';
  188. end;
  189. Function Cpu2Str(w:longint):string;
  190. const
  191. CpuTxt : array[tsystemcpu] of string[8]=
  192. ('none','i386','m68k','alpha','powerpc','sparc','vis','ia64','x86_64','mips','arm');
  193. begin
  194. if w<=ord(high(tsystemcpu)) then
  195. Cpu2Str:=CpuTxt[tsystemcpu(w)]
  196. else
  197. Cpu2Str:='<!! Unknown cpu value '+tostr(w)+'>';
  198. end;
  199. Function Varspez2Str(w:longint):string;
  200. const
  201. varspezstr : array[0..4] of string[6]=('Value','Const','Var','Out','Hidden');
  202. begin
  203. if w<=ord(high(varspezstr)) then
  204. Varspez2Str:=varspezstr[w]
  205. else
  206. Varspez2Str:='<!! Unknown varspez value '+tostr(w)+'>';
  207. end;
  208. Function VarRegable2Str(w:longint):string;
  209. const
  210. varregableStr : array[0..4] of string[6]=('None','IntReg','FPUReg','MMReg','Addr');
  211. begin
  212. if w<=ord(high(varregablestr)) then
  213. Varregable2Str:=varregablestr[w]
  214. else
  215. Varregable2Str:='<!! Unknown regable value '+tostr(w)+'>';
  216. end;
  217. function PPUFlags2Str(flags:longint):string;
  218. type
  219. tflagopt=record
  220. mask : longint;
  221. str : string[30];
  222. end;
  223. const
  224. flagopts=17;
  225. flagopt : array[1..flagopts] of tflagopt=(
  226. (mask: $1 ;str:'init'),
  227. (mask: $2 ;str:'final'),
  228. (mask: $4 ;str:'big_endian'),
  229. (mask: $8 ;str:'dbx'),
  230. // (mask: $10 ;str:'browser'),
  231. (mask: $20 ;str:'in_library'),
  232. (mask: $40 ;str:'smart_linked'),
  233. (mask: $80 ;str:'static_linked'),
  234. (mask: $100 ;str:'shared_linked'),
  235. // (mask: $200 ;str:'local_browser'),
  236. (mask: $400 ;str:'no_link'),
  237. (mask: $800 ;str:'has_resources'),
  238. (mask: $1000 ;str:'little_endian'),
  239. (mask: $2000 ;str:'release'),
  240. (mask: $4000 ;str:'local_threadvars'),
  241. (mask: $8000 ;str:'fpu_emulation_on'),
  242. (mask: $10000 ;str:'has_debug_info'),
  243. (mask: $20000 ;str:'local_symtable'),
  244. (mask: $40000 ;str:'uses_variants')
  245. );
  246. var
  247. i : longint;
  248. first : boolean;
  249. s : string;
  250. begin
  251. s:='';
  252. if flags<>0 then
  253. begin
  254. first:=true;
  255. for i:=1to flagopts do
  256. if (flags and flagopt[i].mask)<>0 then
  257. begin
  258. if first then
  259. first:=false
  260. else
  261. s:=s+', ';
  262. s:=s+flagopt[i].str;
  263. end;
  264. end
  265. else
  266. s:='none';
  267. PPUFlags2Str:=s;
  268. end;
  269. const
  270. HexTbl : array[0..15] of char='0123456789ABCDEF';
  271. function HexB(b:byte):string;
  272. begin
  273. HexB[0]:=#2;
  274. HexB[1]:=HexTbl[b shr 4];
  275. HexB[2]:=HexTbl[b and $f];
  276. end;
  277. function hexstr(val : cardinal;cnt : byte) : string;
  278. const
  279. HexTbl : array[0..15] of char='0123456789ABCDEF';
  280. var
  281. i : longint;
  282. begin
  283. hexstr[0]:=char(cnt);
  284. for i:=cnt downto 1 do
  285. begin
  286. hexstr[i]:=hextbl[val and $f];
  287. val:=val shr 4;
  288. end;
  289. end;
  290. Function L0(l:longint):string;
  291. {
  292. return the string of value l, if l<10 then insert a zero, so
  293. the string is always at least 2 chars '01','02',etc
  294. }
  295. var
  296. s : string;
  297. begin
  298. Str(l,s);
  299. if l<10 then
  300. s:='0'+s;
  301. L0:=s;
  302. end;
  303. function filetimestring( t : longint) : string;
  304. {
  305. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  306. }
  307. var
  308. DT : DateTime;
  309. begin
  310. if t=-1 then
  311. begin
  312. FileTimeString:='Not Found';
  313. exit;
  314. end;
  315. unpacktime(t,DT);
  316. filetimestring:=L0(dt.Year)+'/'+L0(dt.Month)+'/'+L0(dt.Day)+' '+L0(dt.Hour)+':'+L0(dt.min)+':'+L0(dt.sec);
  317. end;
  318. {****************************************************************************
  319. Read Routines
  320. ****************************************************************************}
  321. Procedure ReadLinkContainer(const prefix:string);
  322. {
  323. Read a serie of strings and write to the screen starting every line
  324. with prefix
  325. }
  326. function maskstr(m:longint):string;
  327. const
  328. { link options }
  329. link_none = $0;
  330. link_always = $1;
  331. link_static = $2;
  332. link_smart = $4;
  333. link_shared = $8;
  334. var
  335. s : string;
  336. begin
  337. s:='';
  338. if (m and link_always)<>0 then
  339. s:=s+'always ';
  340. if (m and link_static)<>0 then
  341. s:=s+'static ';
  342. if (m and link_smart)<>0 then
  343. s:=s+'smart ';
  344. if (m and link_shared)<>0 then
  345. s:=s+'shared ';
  346. maskstr:=s;
  347. end;
  348. var
  349. s : string;
  350. m : longint;
  351. begin
  352. while not ppufile.endofentry do
  353. begin
  354. s:=ppufile.getstring;
  355. m:=ppufile.getlongint;
  356. WriteLn(prefix,s,' (',maskstr(m),')');
  357. end;
  358. end;
  359. Procedure ReadContainer(const prefix:string);
  360. {
  361. Read a serie of strings and write to the screen starting every line
  362. with prefix
  363. }
  364. begin
  365. while not ppufile.endofentry do
  366. WriteLn(prefix,ppufile.getstring);
  367. end;
  368. procedure ReadLoadUnit;
  369. var
  370. ucrc,uintfcrc : cardinal;
  371. begin
  372. while not ppufile.EndOfEntry do
  373. begin
  374. write('Uses unit: ',ppufile.getstring);
  375. ucrc:=cardinal(ppufile.getlongint);
  376. uintfcrc:=cardinal(ppufile.getlongint);
  377. writeln(' (Crc: ',hexstr(ucrc,8),', IntfcCrc: ',hexstr(uintfcrc,8),')');
  378. end;
  379. end;
  380. Procedure ReadDerefmap;
  381. var
  382. i,mapsize : longint;
  383. begin
  384. mapsize:=ppufile.getlongint;
  385. writeln('DerefMapsize: ',mapsize);
  386. for i:=0 to mapsize-1 do
  387. writeln('DerefMap[',i,'] = ',ppufile.getstring);
  388. end;
  389. Procedure ReadImportSymbols;
  390. var
  391. extlibname : string;
  392. j,
  393. extsymcnt : longint;
  394. extsymname : string;
  395. extsymordnr : longint;
  396. extsymisvar : boolean;
  397. begin
  398. while not ppufile.endofentry do
  399. begin
  400. extlibname:=ppufile.getstring;
  401. extsymcnt:=ppufile.getlongint;
  402. writeln('External Library: ',extlibname,' (',extsymcnt,' imports)');
  403. for j:=0 to extsymcnt-1 do
  404. begin
  405. extsymname:=ppufile.getstring;
  406. extsymordnr:=ppufile.getlongint;
  407. extsymisvar:=ppufile.getbyte<>0;
  408. writeln(' ',extsymname,' (OrdNr: ',extsymordnr,' IsVar: ',extsymisvar,')');
  409. end;
  410. end;
  411. end;
  412. Procedure ReadDerefdata;
  413. begin
  414. derefdatalen:=ppufile.entrysize;
  415. if derefdatalen=0 then
  416. begin
  417. writeln('!! Error: derefdatalen=0');
  418. exit;
  419. end;
  420. Writeln('Derefdata length: ',derefdatalen);
  421. derefdata:=allocmem(derefdatalen);
  422. ppufile.getdata(derefdata^,derefdatalen);
  423. end;
  424. Procedure ReadAsmSymbols;
  425. type
  426. { Copied from aasmbase.pas }
  427. TAsmsymbind=(AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL);
  428. TAsmsymtype=(AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL);
  429. var
  430. s,
  431. bindstr,
  432. typestr : string;
  433. i : longint;
  434. begin
  435. writeln(space,'Number of AsmSymbols: ',ppufile.getlongint);
  436. i:=0;
  437. while (not ppufile.endofentry) and (not ppufile.error) do
  438. begin
  439. s:=ppufile.getstring;
  440. case tasmsymbind(ppufile.getbyte) of
  441. AB_EXTERNAL :
  442. bindstr:='External';
  443. AB_COMMON :
  444. bindstr:='Common';
  445. AB_LOCAL :
  446. bindstr:='Local';
  447. AB_GLOBAL :
  448. bindstr:='Global';
  449. else
  450. bindstr:='<Error !!>'
  451. end;
  452. case tasmsymtype(ppufile.getbyte) of
  453. AT_FUNCTION :
  454. typestr:='Function';
  455. AT_DATA :
  456. typestr:='Data';
  457. AT_SECTION :
  458. typestr:='Section';
  459. AT_LABEL :
  460. typestr:='Label';
  461. else
  462. typestr:='<Error !!>'
  463. end;
  464. Writeln(space,' ',i,' : ',s,' [',bindstr,',',typestr,']');
  465. inc(i);
  466. end;
  467. end;
  468. Procedure ReadPosInfo;
  469. var
  470. info : byte;
  471. fileindex,line,column : longint;
  472. begin
  473. with ppufile do
  474. begin
  475. {
  476. info byte layout in bits:
  477. 0-1 - amount of bytes for fileindex
  478. 2-3 - amount of bytes for line
  479. 4-5 - amount of bytes for column
  480. }
  481. info:=getbyte;
  482. case (info and $03) of
  483. 0 : fileindex:=getbyte;
  484. 1 : fileindex:=getword;
  485. 2 : fileindex:=(getbyte shl 16) or getword;
  486. 3 : fileindex:=getlongint;
  487. end;
  488. case ((info shr 2) and $03) of
  489. 0 : line:=getbyte;
  490. 1 : line:=getword;
  491. 2 : line:=(getbyte shl 16) or getword;
  492. 3 : line:=getlongint;
  493. end;
  494. case ((info shr 4) and $03) of
  495. 0 : column:=getbyte;
  496. 1 : column:=getword;
  497. 2 : column:=(getbyte shl 16) or getword;
  498. 3 : column:=getlongint;
  499. end;
  500. Writeln(fileindex,' (',line,',',column,')');
  501. end;
  502. end;
  503. procedure readderef;
  504. type
  505. tdereftype = (deref_nil,
  506. deref_unit,
  507. deref_symid,
  508. deref_defid
  509. );
  510. var
  511. b : tdereftype;
  512. first : boolean;
  513. idx : longint;
  514. i,n : byte;
  515. pdata : pbyte;
  516. begin
  517. if not assigned(derefdata) then
  518. exit;
  519. first:=true;
  520. idx:=ppufile.getlongint;
  521. if (idx>derefdatalen) then
  522. begin
  523. writeln('!! Error: Deref idx ',idx,' > ',derefdatalen);
  524. exit;
  525. end;
  526. write('(',idx,') ');
  527. pdata:=@derefdata[idx];
  528. i:=0;
  529. n:=pdata[i];
  530. inc(i);
  531. if n<1 then
  532. begin
  533. writeln('!! Error: Deref len < 1');
  534. exit;
  535. end;
  536. while (i<=n) do
  537. begin
  538. if not first then
  539. write(', ')
  540. else
  541. first:=false;
  542. b:=tdereftype(pdata[i]);
  543. inc(i);
  544. case b of
  545. deref_nil :
  546. write('Nil');
  547. deref_symid :
  548. begin
  549. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  550. inc(i,4);
  551. write('SymId ',idx);
  552. end;
  553. deref_defid :
  554. begin
  555. idx:=pdata[i] shl 24 or pdata[i+1] shl 16 or pdata[i+2] shl 8 or pdata[i+3];
  556. inc(i,4);
  557. write('DefId ',idx);
  558. end;
  559. deref_unit :
  560. begin
  561. idx:=pdata[i] shl 8 or pdata[i+1];
  562. inc(i,2);
  563. write('Unit ',idx);
  564. end;
  565. else
  566. begin
  567. writeln('!! unsupported dereftyp: ',ord(b));
  568. break;
  569. end;
  570. end;
  571. end;
  572. writeln;
  573. end;
  574. procedure readpropaccesslist(const s:string);
  575. type
  576. tsltype = (sl_none,
  577. sl_load,
  578. sl_call,
  579. sl_subscript,
  580. sl_vec,
  581. sl_typeconv,
  582. sl_absolutetype
  583. );
  584. const
  585. slstr : array[tsltype] of string[12] = ('',
  586. 'load',
  587. 'call',
  588. 'subscript',
  589. 'vec',
  590. 'typeconv',
  591. 'absolutetype'
  592. );
  593. var
  594. sl : tsltype;
  595. begin
  596. readderef;
  597. repeat
  598. sl:=tsltype(ppufile.getbyte);
  599. if sl=sl_none then
  600. break;
  601. write(s,'(',slstr[sl],') ');
  602. case sl of
  603. sl_call,
  604. sl_load,
  605. sl_subscript :
  606. readderef;
  607. sl_absolutetype,
  608. sl_typeconv :
  609. readderef;
  610. sl_vec :
  611. begin
  612. writeln(ppufile.getlongint);
  613. readderef;
  614. end;
  615. end;
  616. until false;
  617. end;
  618. procedure readsymoptions;
  619. type
  620. tsymoption=(sp_none,
  621. sp_public,
  622. sp_private,
  623. sp_published,
  624. sp_protected,
  625. sp_static,
  626. sp_hint_deprecated,
  627. sp_hint_platform,
  628. sp_hint_library,
  629. sp_hint_unimplemented,
  630. sp_has_overloaded,
  631. sp_internal { internal symbol, not reported as unused }
  632. );
  633. tsymoptions=set of tsymoption;
  634. tsymopt=record
  635. mask : tsymoption;
  636. str : string[30];
  637. end;
  638. const
  639. symopts=11;
  640. symopt : array[1..symopts] of tsymopt=(
  641. (mask:sp_public; str:'Public'),
  642. (mask:sp_private; str:'Private'),
  643. (mask:sp_published; str:'Published'),
  644. (mask:sp_protected; str:'Protected'),
  645. (mask:sp_static; str:'Static'),
  646. (mask:sp_hint_deprecated;str:'Hint Deprecated'),
  647. (mask:sp_hint_deprecated;str:'Hint Platform'),
  648. (mask:sp_hint_deprecated;str:'Hint Library'),
  649. (mask:sp_hint_deprecated;str:'Hint Unimplemented'),
  650. (mask:sp_has_overloaded; str:'Has overloaded'),
  651. (mask:sp_internal; str:'Internal')
  652. );
  653. var
  654. symoptions : tsymoptions;
  655. i : longint;
  656. first : boolean;
  657. begin
  658. ppufile.getsmallset(symoptions);
  659. if symoptions<>[] then
  660. begin
  661. first:=true;
  662. for i:=1to symopts do
  663. if (symopt[i].mask in symoptions) then
  664. begin
  665. if first then
  666. first:=false
  667. else
  668. write(', ');
  669. write(symopt[i].str);
  670. end;
  671. end;
  672. writeln;
  673. end;
  674. procedure readcommonsym(const s:string);
  675. begin
  676. writeln(space,'** Symbol Id ',ppufile.getlongint,' **');
  677. writeln(space,s,ppufile.getstring);
  678. write(space,' File Pos : ');
  679. readposinfo;
  680. write(space,' SymOptions : ');
  681. readsymoptions;
  682. end;
  683. procedure readcommondef(const s:string);
  684. type
  685. tdefoption=(df_none,
  686. { init data has been generated }
  687. df_has_inittable,
  688. { rtti data has been generated }
  689. df_has_rttitable,
  690. { dwarf debug info has been generated }
  691. df_has_dwarf_dbg_info,
  692. { type is unique, i.e. declared with type = type <tdef>; }
  693. df_unique,
  694. { type is a generic }
  695. df_generic,
  696. { type is a specialization of a generic type }
  697. df_specialization
  698. );
  699. tdefoptions=set of tdefoption;
  700. tdefopt=record
  701. mask : tdefoption;
  702. str : string[30];
  703. end;
  704. const
  705. defopts=6;
  706. defopt : array[1..defopts] of tdefopt=(
  707. (mask:df_has_inittable; str:'InitTable'),
  708. (mask:df_has_rttitable; str:'RTTITable'),
  709. (mask:df_has_dwarf_dbg_info; str:'Dwarf DbgInfo'),
  710. (mask:df_unique; str:'Unique Type'),
  711. (mask:df_generic; str:'Generic'),
  712. (mask:df_specialization; str:'Specialization')
  713. );
  714. var
  715. defoptions : tdefoptions;
  716. i : longint;
  717. first : boolean;
  718. tokenbufsize : longint;
  719. tokenbuf : pbyte;
  720. begin
  721. writeln(space,'** Definition Id ',ppufile.getlongint,' **');
  722. writeln(space,s);
  723. write (space,' Type symbol : ');
  724. readderef;
  725. write (space,' DefOptions : ');
  726. ppufile.getsmallset(defoptions);
  727. if defoptions<>[] then
  728. begin
  729. first:=true;
  730. for i:=1to defopts do
  731. if (defopt[i].mask in defoptions) then
  732. begin
  733. if first then
  734. first:=false
  735. else
  736. write(', ');
  737. write(defopt[i].str);
  738. end;
  739. end;
  740. writeln;
  741. if df_unique in defoptions then
  742. writeln (space,' Unique type symbol');
  743. if df_generic in defoptions then
  744. begin
  745. tokenbufsize:=ppufile.getlongint;
  746. writeln(space,' Tokenbuffer size : ',tokenbufsize);
  747. tokenbuf:=allocmem(tokenbufsize);
  748. ppufile.getdata(tokenbuf^,tokenbufsize);
  749. i:=0;
  750. write(space,' Tokens: ');
  751. while i<tokenbufsize do
  752. begin
  753. if ttoken(tokenbuf[i])<>_GENERICSPECIALTOKEN then
  754. write(arraytokeninfo[ttoken(tokenbuf[i])].str);
  755. case ttoken(tokenbuf[i]) of
  756. _CWCHAR,
  757. _CWSTRING :
  758. begin
  759. inc(i);
  760. {
  761. replaytokenbuf.read(wlen,sizeof(SizeInt));
  762. setlengthwidestring(patternw,wlen);
  763. replaytokenbuf.read(patternw^.data^,patternw^.len*sizeof(tcompilerwidechar));
  764. pattern:='';
  765. }
  766. end;
  767. _CCHAR,
  768. _CSTRING,
  769. _INTCONST,
  770. _REALNUMBER :
  771. begin
  772. inc(i);
  773. {
  774. replaytokenbuf.read(pattern[0],1);
  775. replaytokenbuf.read(pattern[1],length(pattern));
  776. orgpattern:='';
  777. }
  778. end;
  779. _ID :
  780. begin
  781. inc(i);
  782. inc(i);
  783. write(' ',pshortstring(@tokenbuf[i])^);
  784. inc(i,tokenbuf[i]+1);
  785. {
  786. replaytokenbuf.read(orgpattern[0],1);
  787. replaytokenbuf.read(orgpattern[1],length(orgpattern));
  788. pattern:=upper(orgpattern);
  789. }
  790. end;
  791. _GENERICSPECIALTOKEN:
  792. begin
  793. inc(i);
  794. case tspecialgenerictoken(tokenbuf[i]) of
  795. ST_LOADSETTINGS:
  796. begin
  797. inc(i);
  798. write('Settings');
  799. inc(i,sizeof(tsettings));
  800. end;
  801. ST_LINE:
  802. begin
  803. inc(i);
  804. write('Line: ',pdword(@tokenbuf[i])^);
  805. inc(i,4);
  806. end;
  807. ST_COLUMN:
  808. begin
  809. inc(i);
  810. write('Col: ',pword(@tokenbuf[i])^);
  811. inc(i,2);
  812. end;
  813. ST_FILEINDEX:
  814. begin
  815. inc(i);
  816. write('File: ',pword(@tokenbuf[i])^);
  817. inc(i,2);
  818. end;
  819. end;
  820. {
  821. replaytokenbuf.read(specialtoken,1);
  822. case specialtoken of
  823. ST_LOADSETTINGS:
  824. begin
  825. replaytokenbuf.read(current_settings,sizeof(current_settings));
  826. end
  827. else
  828. internalerror(2006103010);
  829. end;
  830. continue;
  831. }
  832. end;
  833. else
  834. inc(i);
  835. end;
  836. if i<tokenbufsize then
  837. write(',');
  838. end;
  839. writeln;
  840. freemem(tokenbuf);
  841. end;
  842. if df_specialization in defoptions then
  843. begin
  844. write (space,' Orig. GenericDef : ');
  845. readderef;
  846. end;
  847. end;
  848. { Read abstract procdef and return if inline procdef }
  849. type
  850. tproccalloption=(pocall_none,
  851. { procedure uses C styled calling }
  852. pocall_cdecl,
  853. { C++ calling conventions }
  854. pocall_cppdecl,
  855. { Far16 for OS/2 }
  856. pocall_far16,
  857. { Old style FPC default calling }
  858. pocall_oldfpccall,
  859. { Procedure has compiler magic}
  860. pocall_internproc,
  861. { procedure is a system call, applies e.g. to MorphOS and PalmOS }
  862. pocall_syscall,
  863. { pascal standard left to right }
  864. pocall_pascal,
  865. { procedure uses register (fastcall) calling }
  866. pocall_register,
  867. { safe call calling conventions }
  868. pocall_safecall,
  869. { procedure uses stdcall call }
  870. pocall_stdcall,
  871. { Special calling convention for cpus without a floating point
  872. unit. Floating point numbers are passed in integer registers
  873. instead of floating point registers. Depending on the other
  874. available calling conventions available for the cpu
  875. this replaces either pocall_fastcall or pocall_stdcall.
  876. }
  877. pocall_softfloat,
  878. { Metrowerks Pascal. Special case on Mac OS (X): passes all }
  879. { constant records by reference. }
  880. pocall_mwpascal
  881. );
  882. tproccalloptions=set of tproccalloption;
  883. tproctypeoption=(potype_none,
  884. potype_proginit, { Program initialization }
  885. potype_unitinit, { unit initialization }
  886. potype_unitfinalize, { unit finalization }
  887. potype_constructor, { Procedure is a constructor }
  888. potype_destructor, { Procedure is a destructor }
  889. potype_operator, { Procedure defines an operator }
  890. potype_procedure,
  891. potype_function
  892. );
  893. tproctypeoptions=set of tproctypeoption;
  894. tprocoption=(po_none,
  895. po_classmethod, { class method }
  896. po_virtualmethod, { Procedure is a virtual method }
  897. po_abstractmethod, { Procedure is an abstract method }
  898. po_staticmethod, { static method }
  899. po_overridingmethod, { method with override directive }
  900. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  901. po_interrupt, { Procedure is an interrupt handler }
  902. po_iocheck, { IO checking should be done after a call to the procedure }
  903. po_assembler, { Procedure is written in assembler }
  904. po_msgstr, { method for string message handling }
  905. po_msgint, { method for int message handling }
  906. po_exports, { Procedure has export directive (needed for OS/2) }
  907. po_external, { Procedure is external (in other object or lib)}
  908. po_overload, { procedure is declared with overload directive }
  909. po_varargs, { printf like arguments }
  910. po_internconst, { procedure has constant evaluator intern }
  911. { flag that only the address of a method is returned and not a full methodpointer }
  912. po_addressonly,
  913. { procedure is exported }
  914. po_public,
  915. { calling convention is specified explicitly }
  916. po_hascallingconvention,
  917. { reintroduce flag }
  918. po_reintroduce,
  919. { location of parameters is given explicitly as it is necessary for some syscall
  920. conventions like that one of MorphOS }
  921. po_explicitparaloc,
  922. { no stackframe will be generated, used by lowlevel assembler like get_frame }
  923. po_nostackframe,
  924. po_has_mangledname,
  925. po_has_public_name,
  926. po_forward,
  927. po_global,
  928. po_has_inlininginfo,
  929. { The different kind of syscalls on MorphOS }
  930. po_syscall_legacy,
  931. po_syscall_sysv,
  932. po_syscall_basesysv,
  933. po_syscall_sysvbase,
  934. po_syscall_r12base,
  935. po_local,
  936. { Procedure can be inlined }
  937. po_inline,
  938. { Procedure is used for internal compiler calls }
  939. po_compilerproc,
  940. { importing }
  941. po_has_importdll,
  942. po_has_importname,
  943. po_kylixlocal
  944. );
  945. tprocoptions=set of tprocoption;
  946. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions);
  947. type
  948. tproccallopt=record
  949. mask : tproccalloption;
  950. str : string[30];
  951. end;
  952. tproctypeopt=record
  953. mask : tproctypeoption;
  954. str : string[30];
  955. end;
  956. tprocopt=record
  957. mask : tprocoption;
  958. str : string[30];
  959. end;
  960. const
  961. proccalloptionStr : array[tproccalloption] of string[14]=('',
  962. 'CDecl',
  963. 'CPPDecl',
  964. 'Far16',
  965. 'OldFPCCall',
  966. 'InternProc',
  967. 'SysCall',
  968. 'Pascal',
  969. 'Register',
  970. 'SafeCall',
  971. 'StdCall',
  972. 'SoftFloat',
  973. 'MWPascal'
  974. );
  975. proctypeopts=8;
  976. proctypeopt : array[1..proctypeopts] of tproctypeopt=(
  977. (mask:potype_proginit; str:'ProgInit'),
  978. (mask:potype_unitinit; str:'UnitInit'),
  979. (mask:potype_unitfinalize;str:'UnitFinalize'),
  980. (mask:potype_constructor; str:'Constructor'),
  981. (mask:potype_destructor; str:'Destructor'),
  982. (mask:potype_operator; str:'Operator'),
  983. (mask:potype_function; str:'Function'),
  984. (mask:potype_procedure; str:'Procedure')
  985. );
  986. procopts=38;
  987. procopt : array[1..procopts] of tprocopt=(
  988. (mask:po_classmethod; str:'ClassMethod'),
  989. (mask:po_virtualmethod; str:'VirtualMethod'),
  990. (mask:po_abstractmethod; str:'AbstractMethod'),
  991. (mask:po_staticmethod; str:'StaticMethod'),
  992. (mask:po_overridingmethod;str:'OverridingMethod'),
  993. (mask:po_methodpointer; str:'MethodPointer'),
  994. (mask:po_interrupt; str:'Interrupt'),
  995. (mask:po_iocheck; str:'IOCheck'),
  996. (mask:po_assembler; str:'Assembler'),
  997. (mask:po_msgstr; str:'MsgStr'),
  998. (mask:po_msgint; str:'MsgInt'),
  999. (mask:po_exports; str:'Exports'),
  1000. (mask:po_external; str:'External'),
  1001. (mask:po_overload; str:'Overload'),
  1002. (mask:po_varargs; str:'VarArgs'),
  1003. (mask:po_internconst; str:'InternConst'),
  1004. (mask:po_addressonly; str:'AddressOnly'),
  1005. (mask:po_public; str:'Public'),
  1006. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  1007. (mask:po_reintroduce; str:'ReIntroduce'),
  1008. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  1009. (mask:po_nostackframe; str:'NoStackFrame'),
  1010. (mask:po_has_mangledname; str:'HasMangledName'),
  1011. (mask:po_has_public_name; str:'HasPublicName'),
  1012. (mask:po_forward; str:'Forward'),
  1013. (mask:po_global; str:'Global'),
  1014. (mask:po_has_inlininginfo;str:'HasInliningInfo'),
  1015. (mask:po_syscall_legacy; str:'SyscallLegacy'),
  1016. (mask:po_syscall_sysv; str:'SyscallSysV'),
  1017. (mask:po_syscall_basesysv;str:'SyscallBaseSysV'),
  1018. (mask:po_syscall_sysvbase;str:'SyscallSysVBase'),
  1019. (mask:po_syscall_r12base; str:'SyscallR12Base'),
  1020. (mask:po_local; str:'Local'),
  1021. (mask:po_inline; str:'Inline'),
  1022. (mask:po_compilerproc; str:'CompilerProc'),
  1023. (mask:po_has_importdll; str:'HasImportDLL'),
  1024. (mask:po_has_importname; str:'HasImportName'),
  1025. (mask:po_kylixlocal; str:'KylixLocal')
  1026. );
  1027. var
  1028. proctypeoption : tproctypeoption;
  1029. i : longint;
  1030. first : boolean;
  1031. tempbuf : array[0..255] of byte;
  1032. begin
  1033. write(space,' Return type : ');
  1034. readderef;
  1035. writeln(space,' Fpu used : ',ppufile.getbyte);
  1036. proctypeoption:=tproctypeoption(ppufile.getbyte);
  1037. write(space,' TypeOption : ');
  1038. first:=true;
  1039. for i:=1 to proctypeopts do
  1040. if (proctypeopt[i].mask=proctypeoption) then
  1041. begin
  1042. if first then
  1043. first:=false
  1044. else
  1045. write(', ');
  1046. write(proctypeopt[i].str);
  1047. end;
  1048. writeln;
  1049. proccalloption:=tproccalloption(ppufile.getbyte);
  1050. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  1051. ppufile.getnormalset(procoptions);
  1052. if procoptions<>[] then
  1053. begin
  1054. write(space,' Options : ');
  1055. first:=true;
  1056. for i:=1to procopts do
  1057. if (procopt[i].mask in procoptions) then
  1058. begin
  1059. if first then
  1060. first:=false
  1061. else
  1062. write(', ');
  1063. write(procopt[i].str);
  1064. end;
  1065. writeln;
  1066. end;
  1067. if (po_explicitparaloc in procoptions) then
  1068. begin
  1069. i:=ppufile.getbyte;
  1070. ppufile.getdata(tempbuf,i);
  1071. end;
  1072. end;
  1073. type
  1074. { options for variables }
  1075. tvaroption=(vo_none,
  1076. vo_is_external,
  1077. vo_is_dll_var,
  1078. vo_is_thread_var,
  1079. vo_has_local_copy,
  1080. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  1081. vo_is_public,
  1082. vo_is_high_para,
  1083. vo_is_funcret,
  1084. vo_is_self,
  1085. vo_is_vmt,
  1086. vo_is_result, { special result variable }
  1087. vo_is_parentfp,
  1088. vo_is_loop_counter, { used to detect assignments to loop counter }
  1089. vo_is_hidden_para,
  1090. vo_has_explicit_paraloc,
  1091. vo_is_syscall_lib,
  1092. vo_has_mangledname,
  1093. vo_is_typed_const
  1094. );
  1095. tvaroptions=set of tvaroption;
  1096. { register variable }
  1097. tvarregable=(vr_none,
  1098. vr_intreg,
  1099. vr_fpureg,
  1100. vr_mmreg,
  1101. vr_addr
  1102. );
  1103. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions);
  1104. type
  1105. tvaropt=record
  1106. mask : tvaroption;
  1107. str : string[30];
  1108. end;
  1109. const
  1110. varopts=18;
  1111. varopt : array[1..varopts] of tvaropt=(
  1112. (mask:vo_is_external; str:'External'),
  1113. (mask:vo_is_dll_var; str:'DLLVar'),
  1114. (mask:vo_is_thread_var; str:'ThreadVar'),
  1115. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  1116. (mask:vo_is_const; str:'Constant'),
  1117. (mask:vo_is_public; str:'Public'),
  1118. (mask:vo_is_high_para; str:'HighValue'),
  1119. (mask:vo_is_funcret; str:'Funcret'),
  1120. (mask:vo_is_self; str:'Self'),
  1121. (mask:vo_is_vmt; str:'VMT'),
  1122. (mask:vo_is_result; str:'Result'),
  1123. (mask:vo_is_parentfp; str:'ParentFP'),
  1124. (mask:vo_is_loop_counter; str:'LoopCounter'),
  1125. (mask:vo_is_hidden_para; str:'Hidden'),
  1126. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  1127. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  1128. (mask:vo_has_mangledname; str:'HasMangledName'),
  1129. (mask:vo_is_typed_const; str:'TypedConst')
  1130. );
  1131. var
  1132. i : longint;
  1133. first : boolean;
  1134. begin
  1135. readcommonsym(s);
  1136. writeln(space,' Spez : ',Varspez2Str(ppufile.getbyte));
  1137. writeln(space,' Regable : ',Varregable2Str(ppufile.getbyte));
  1138. write (space,' Var Type : ');
  1139. readderef;
  1140. ppufile.getsmallset(varoptions);
  1141. if varoptions<>[] then
  1142. begin
  1143. write(space,' Options : ');
  1144. first:=true;
  1145. for i:=1to varopts do
  1146. if (varopt[i].mask in varoptions) then
  1147. begin
  1148. if first then
  1149. first:=false
  1150. else
  1151. write(', ');
  1152. write(varopt[i].str);
  1153. end;
  1154. writeln;
  1155. end;
  1156. end;
  1157. procedure readobjectdefoptions;
  1158. type
  1159. tobjectoption=(oo_none,
  1160. oo_is_forward, { the class is only a forward declared yet }
  1161. oo_has_virtual, { the object/class has virtual methods }
  1162. oo_has_private,
  1163. oo_has_protected,
  1164. oo_has_strictprivate,
  1165. oo_has_strictprotected,
  1166. oo_has_constructor, { the object/class has a constructor }
  1167. oo_has_destructor, { the object/class has a destructor }
  1168. oo_has_vmt, { the object/class has a vmt }
  1169. oo_has_msgstr,
  1170. oo_has_msgint,
  1171. oo_can_have_published,{ the class has rtti, i.e. you can publish properties }
  1172. oo_has_default_property,
  1173. oo_vmt_written
  1174. );
  1175. tobjectoptions=set of tobjectoption;
  1176. tsymopt=record
  1177. mask : tobjectoption;
  1178. str : string[30];
  1179. end;
  1180. const
  1181. symopts=14;
  1182. symopt : array[1..symopts] of tsymopt=(
  1183. (mask:oo_has_virtual; str:'IsForward'),
  1184. (mask:oo_has_virtual; str:'HasVirtual'),
  1185. (mask:oo_has_private; str:'HasPrivate'),
  1186. (mask:oo_has_protected; str:'HasProtected'),
  1187. (mask:oo_has_strictprivate; str:'HasStrictPrivate'),
  1188. (mask:oo_has_strictprotected;str:'HasStrictProtected'),
  1189. (mask:oo_has_constructor; str:'HasConstructor'),
  1190. (mask:oo_has_destructor; str:'HasDestructor'),
  1191. (mask:oo_has_vmt; str:'HasVMT'),
  1192. (mask:oo_has_msgstr; str:'HasMsgStr'),
  1193. (mask:oo_has_msgint; str:'HasMsgInt'),
  1194. (mask:oo_can_have_published; str:'CanHavePublished'),
  1195. (mask:oo_has_default_property;str:'HasDefaultProperty'),
  1196. (mask:oo_vmt_written; str:'VMTWritten')
  1197. );
  1198. var
  1199. symoptions : tobjectoptions;
  1200. i : longint;
  1201. first : boolean;
  1202. begin
  1203. ppufile.getsmallset(symoptions);
  1204. if symoptions<>[] then
  1205. begin
  1206. first:=true;
  1207. for i:=1to symopts do
  1208. if (symopt[i].mask in symoptions) then
  1209. begin
  1210. if first then
  1211. first:=false
  1212. else
  1213. write(', ');
  1214. write(symopt[i].str);
  1215. end;
  1216. end;
  1217. writeln;
  1218. end;
  1219. procedure readarraydefoptions;
  1220. type
  1221. tarraydefoption=(ado_none,
  1222. ado_IsConvertedPointer,
  1223. ado_IsDynamicArray,
  1224. ado_IsVariant,
  1225. ado_IsConstructor,
  1226. ado_IsArrayOfConst,
  1227. ado_IsConstString
  1228. );
  1229. tarraydefoptions=set of tarraydefoption;
  1230. tsymopt=record
  1231. mask : tarraydefoption;
  1232. str : string[30];
  1233. end;
  1234. const
  1235. symopts=6;
  1236. symopt : array[1..symopts] of tsymopt=(
  1237. (mask:ado_IsConvertedPointer;str:'ConvertedPointer'),
  1238. (mask:ado_IsDynamicArray; str:'IsDynamicArray'),
  1239. (mask:ado_IsVariant; str:'IsVariant'),
  1240. (mask:ado_IsConstructor; str:'IsConstructor'),
  1241. (mask:ado_IsArrayOfConst; str:'ArrayOfConst'),
  1242. (mask:ado_IsConstString; str:'ConstString')
  1243. );
  1244. var
  1245. symoptions : tarraydefoptions;
  1246. i : longint;
  1247. first : boolean;
  1248. begin
  1249. ppufile.getsmallset(symoptions);
  1250. if symoptions<>[] then
  1251. begin
  1252. first:=true;
  1253. for i:=1to symopts do
  1254. if (symopt[i].mask in symoptions) then
  1255. begin
  1256. if first then
  1257. first:=false
  1258. else
  1259. write(', ');
  1260. write(symopt[i].str);
  1261. end;
  1262. end;
  1263. writeln;
  1264. end;
  1265. procedure readnodetree;
  1266. var
  1267. l : longint;
  1268. p : pointer;
  1269. begin
  1270. with ppufile do
  1271. begin
  1272. if space<>'' then
  1273. Writeln(space,'------ nodetree ------');
  1274. if readentry=ibnodetree then
  1275. begin
  1276. l:=entrysize;
  1277. Writeln(space,'Tree size : ',l);
  1278. { Read data to prevent error that entry is not completly read }
  1279. getmem(p,l);
  1280. getdata(p^,l);
  1281. freemem(p);
  1282. end
  1283. else
  1284. begin
  1285. Writeln('!! ibnodetree not found');
  1286. end;
  1287. end;
  1288. end;
  1289. {****************************************************************************
  1290. Read Symbols Part
  1291. ****************************************************************************}
  1292. procedure readsymbols(const s:string);
  1293. type
  1294. pguid = ^tguid;
  1295. tguid = packed record
  1296. D1: LongWord;
  1297. D2: Word;
  1298. D3: Word;
  1299. D4: array[0..7] of Byte;
  1300. end;
  1301. absolutetyp = (tovar,toasm,toaddr);
  1302. tconsttyp = (constnone,
  1303. constord,conststring,constreal,
  1304. constset,constpointer,constnil,
  1305. constresourcestring,constwstring,constguid
  1306. );
  1307. var
  1308. b : byte;
  1309. pc : pchar;
  1310. i,j,len : longint;
  1311. guid : tguid;
  1312. tempbuf : array[0..127] of char;
  1313. varoptions : tvaroptions;
  1314. begin
  1315. with ppufile do
  1316. begin
  1317. if space<>'' then
  1318. Writeln(space,'------ ',s,' ------');
  1319. if readentry=ibstartsyms then
  1320. begin
  1321. Writeln(space,'Symtable datasize : ',getlongint);
  1322. Writeln(space,'Symtable alignment: ',getlongint);
  1323. end
  1324. else
  1325. Writeln('!! ibstartsym not found');
  1326. repeat
  1327. b:=readentry;
  1328. case b of
  1329. ibunitsym :
  1330. readcommonsym('Unit symbol ');
  1331. iblabelsym :
  1332. readcommonsym('Label symbol ');
  1333. ibtypesym :
  1334. begin
  1335. readcommonsym('Type symbol ');
  1336. write(space,' Result Type : ');
  1337. readderef;
  1338. end;
  1339. ibprocsym :
  1340. begin
  1341. readcommonsym('Procedure symbol ');
  1342. len:=ppufile.getword;
  1343. for i:=1 to len do
  1344. begin
  1345. write(space,' Definition : ');
  1346. readderef;
  1347. end;
  1348. end;
  1349. ibconstsym :
  1350. begin
  1351. readcommonsym('Constant symbol ');
  1352. b:=getbyte;
  1353. case tconsttyp(b) of
  1354. constord :
  1355. begin
  1356. write (space,' OrdinalType : ');
  1357. readderef;
  1358. writeln(space,' Value : ',getint64);
  1359. end;
  1360. constpointer :
  1361. begin
  1362. write (space,' PointerType : ');
  1363. readderef;
  1364. writeln(space,' Value : ',getlongint)
  1365. end;
  1366. conststring,
  1367. constresourcestring :
  1368. begin
  1369. len:=getlongint;
  1370. getmem(pc,len+1);
  1371. getdata(pc^,len);
  1372. (pc+len)^:= #0;
  1373. writeln(space,' Length : ',len);
  1374. writeln(space,' Value : "',pc,'"');
  1375. freemem(pc,len+1);
  1376. if tconsttyp(b)=constresourcestring then
  1377. writeln(space,' Index : ',getlongint);
  1378. end;
  1379. constreal :
  1380. writeln(space,' Value : ',getreal);
  1381. constset :
  1382. begin
  1383. write (space,' Set Type : ');
  1384. readderef;
  1385. for i:=1to 4 do
  1386. begin
  1387. write (space,' Value : ');
  1388. for j:=1to 8 do
  1389. begin
  1390. if j>1 then
  1391. write(',');
  1392. write(hexb(getbyte));
  1393. end;
  1394. writeln;
  1395. end;
  1396. end;
  1397. constwstring:
  1398. begin
  1399. end;
  1400. constguid:
  1401. begin
  1402. getdata(guid,sizeof(guid));
  1403. write (space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-');
  1404. for i:=0 to 7 do
  1405. begin
  1406. write(hexstr(guid.d4[i],2));
  1407. if i=1 then write('-');
  1408. end;
  1409. writeln('}');
  1410. end
  1411. else
  1412. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  1413. end;
  1414. end;
  1415. ibabsolutevarsym :
  1416. begin
  1417. readabstractvarsym('Absolute variable symbol ',varoptions);
  1418. Write (space,' Relocated to ');
  1419. b:=getbyte;
  1420. case absolutetyp(b) of
  1421. tovar :
  1422. readpropaccesslist(space+' Sym : ');
  1423. toasm :
  1424. Writeln('Assembler name : ',getstring);
  1425. toaddr :
  1426. begin
  1427. Write('Address : ',getlongint);
  1428. if tsystemcpu(ppufile.header.cpu)=cpu_i386 then
  1429. WriteLn(' (Far: ',getbyte<>0,')');
  1430. end;
  1431. else
  1432. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  1433. end;
  1434. end;
  1435. ibfieldvarsym :
  1436. begin
  1437. readabstractvarsym('Field Variable symbol ',varoptions);
  1438. writeln(space,' Address : ',getaint);
  1439. end;
  1440. ibstaticvarsym :
  1441. begin
  1442. readabstractvarsym('Global Variable symbol ',varoptions);
  1443. write (space,' DefaultConst : ');
  1444. readderef;
  1445. if (vo_has_mangledname in varoptions) then
  1446. writeln(space,' Mangledname : ',getstring);
  1447. end;
  1448. iblocalvarsym :
  1449. begin
  1450. readabstractvarsym('Local Variable symbol ',varoptions);
  1451. write (space,' DefaultConst : ');
  1452. readderef;
  1453. end;
  1454. ibparavarsym :
  1455. begin
  1456. readabstractvarsym('Parameter Variable symbol ',varoptions);
  1457. write (space,' DefaultConst : ');
  1458. readderef;
  1459. writeln(space,' ParaNr : ',getword);
  1460. writeln(space,' VarState : ',getbyte);
  1461. if (vo_has_explicit_paraloc in varoptions) then
  1462. begin
  1463. i:=getbyte;
  1464. getdata(tempbuf,i);
  1465. end;
  1466. end;
  1467. ibenumsym :
  1468. begin
  1469. readcommonsym('Enumeration symbol ');
  1470. write (space,' Definition : ');
  1471. readderef;
  1472. writeln(space,' Value : ',getlongint);
  1473. end;
  1474. ibsyssym :
  1475. begin
  1476. readcommonsym('Internal system symbol ');
  1477. writeln(space,' Internal Nr : ',getlongint);
  1478. end;
  1479. ibmacrosym :
  1480. begin
  1481. readcommonsym('Macro symbol ');
  1482. writeln(space,' Name: ',getstring);
  1483. writeln(space,' Defined: ',getbyte);
  1484. writeln(space,' Compiler var: ',getbyte);
  1485. len:=getlongint;
  1486. writeln(space,' Value length: ',len);
  1487. if len > 0 then
  1488. begin
  1489. getmem(pc,len+1);
  1490. getdata(pc^,len);
  1491. (pc+len)^:= #0;
  1492. writeln(space,' Value: "',pc,'"');
  1493. freemem(pc,len+1);
  1494. end;
  1495. end;
  1496. ibpropertysym :
  1497. begin
  1498. readcommonsym('Property ');
  1499. i:=getlongint;
  1500. writeln(space,' PropOptions : ',i);
  1501. write (space,' OverrideProp : ');
  1502. readderef;
  1503. write (space,' Prop Type : ');
  1504. readderef;
  1505. writeln(space,' Index : ',getlongint);
  1506. writeln(space,' Default : ',getlongint);
  1507. write (space,' Index Type : ');
  1508. readderef;
  1509. write (space,' Readaccess : ');
  1510. readpropaccesslist(space+' Sym: ');
  1511. write (space,' Writeaccess : ');
  1512. readpropaccesslist(space+' Sym: ');
  1513. write (space,' Storedaccess : ');
  1514. readpropaccesslist(space+' Sym: ');
  1515. end;
  1516. iberror :
  1517. begin
  1518. Writeln('!! Error in PPU');
  1519. exit;
  1520. end;
  1521. ibendsyms :
  1522. break;
  1523. else
  1524. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  1525. end;
  1526. if not EndOfEntry then
  1527. Writeln('!! Entry has more information stored');
  1528. until false;
  1529. end;
  1530. end;
  1531. {****************************************************************************
  1532. Read defintions Part
  1533. ****************************************************************************}
  1534. procedure readdefinitions(const s:string);
  1535. type
  1536. tsettype = (normset,smallset,varset);
  1537. tordtype = (
  1538. uvoid,
  1539. u8bit,u16bit,u32bit,u64bit,
  1540. s8bit,s16bit,s32bit,s64bit,
  1541. bool8bit,bool16bit,bool32bit,
  1542. uchar,uwidechar,scurrency
  1543. );
  1544. tobjecttyp = (odt_none,
  1545. odt_class,
  1546. odt_object,
  1547. odt_interfacecom,
  1548. odt_interfacecorba,
  1549. odt_cppclass,
  1550. odt_dispinterface
  1551. );
  1552. tvarianttype = (
  1553. vt_normalvariant,vt_olevariant
  1554. );
  1555. var
  1556. b : byte;
  1557. l,j : longint;
  1558. calloption : tproccalloption;
  1559. procoptions : tprocoptions;
  1560. procinfooptions : tprocinfoflag;
  1561. begin
  1562. with ppufile do
  1563. begin
  1564. if space<>'' then
  1565. Writeln(space,'------ ',s,' ------');
  1566. if readentry<>ibstartdefs then
  1567. Writeln('!! ibstartdefs not found');
  1568. repeat
  1569. b:=readentry;
  1570. case b of
  1571. ibpointerdef :
  1572. begin
  1573. readcommondef('Pointer definition');
  1574. write (space,' Pointed Type : ');
  1575. readderef;
  1576. writeln(space,' Is Far : ',(getbyte<>0));
  1577. end;
  1578. iborddef :
  1579. begin
  1580. readcommondef('Ordinal definition');
  1581. write (space,' Base type : ');
  1582. b:=getbyte;
  1583. case tordtype(b) of
  1584. uvoid : writeln('uvoid');
  1585. u8bit : writeln('u8bit');
  1586. u16bit : writeln('u16bit');
  1587. u32bit : writeln('s32bit');
  1588. u64bit : writeln('u64bit');
  1589. s8bit : writeln('s8bit');
  1590. s16bit : writeln('s16bit');
  1591. s32bit : writeln('s32bit');
  1592. s64bit : writeln('s64bit');
  1593. bool8bit : writeln('bool8bit');
  1594. bool16bit : writeln('bool16bit');
  1595. bool32bit : writeln('bool32bit');
  1596. uchar : writeln('uchar');
  1597. uwidechar : writeln('uwidechar');
  1598. scurrency : writeln('ucurrency');
  1599. else writeln('!! Warning: Invalid base type ',b);
  1600. end;
  1601. writeln(space,' Range : ',getint64,' to ',getint64);
  1602. end;
  1603. ibfloatdef :
  1604. begin
  1605. readcommondef('Float definition');
  1606. writeln(space,' Float type : ',getbyte);
  1607. end;
  1608. ibarraydef :
  1609. begin
  1610. readcommondef('Array definition');
  1611. write (space,' Element type : ');
  1612. readderef;
  1613. write (space,' Range Type : ');
  1614. readderef;
  1615. writeln(space,' Range : ',getaint,' to ',getaint);
  1616. write (space,' Options : ');
  1617. readarraydefoptions;
  1618. end;
  1619. ibprocdef :
  1620. begin
  1621. readcommondef('Procedure definition');
  1622. read_abstract_proc_def(calloption,procoptions);
  1623. if (po_has_mangledname in procoptions) then
  1624. writeln(space,' Mangled name : ',getstring);
  1625. writeln(space,' Number : ',getword);
  1626. writeln(space,' Level : ',getbyte);
  1627. write (space,' Class : ');
  1628. readderef;
  1629. write (space,' Procsym : ');
  1630. readderef;
  1631. write (space,' File Pos : ');
  1632. readposinfo;
  1633. write (space,' SymOptions : ');
  1634. readsymoptions;
  1635. if tsystemcpu(ppufile.header.cpu)=cpu_powerpc then
  1636. begin
  1637. { library symbol for AmigaOS/MorphOS }
  1638. write (space,' Library symbol : ');
  1639. readderef;
  1640. end;
  1641. if (po_has_importdll in procoptions) then
  1642. writeln(space,' Import DLL : ',getstring);
  1643. if (po_has_importname in procoptions) then
  1644. writeln(space,' Import Name : ',getstring);
  1645. writeln(space,' Import Nr : ',getword);
  1646. if (po_msgint in procoptions) then
  1647. writeln(space,' MsgInt : ',getlongint);
  1648. if (po_msgstr in procoptions) then
  1649. writeln(space,' MsgStr : ',getstring);
  1650. if (po_has_inlininginfo in procoptions) then
  1651. begin
  1652. write (space,' FuncretSym : ');
  1653. readderef;
  1654. ppufile.getsmallset(procinfooptions);
  1655. writeln(space,' ProcInfoOptions : ',dword(procinfooptions));
  1656. end;
  1657. if not EndOfEntry then
  1658. Writeln('!! Entry has more information stored');
  1659. space:=' '+space;
  1660. { parast }
  1661. readdefinitions('parast');
  1662. readsymbols('parast');
  1663. { localst }
  1664. if (po_has_inlininginfo in procoptions) then
  1665. begin
  1666. readdefinitions('localst');
  1667. readsymbols('localst');
  1668. end;
  1669. if (po_has_inlininginfo in procoptions) then
  1670. readnodetree;
  1671. delete(space,1,4);
  1672. end;
  1673. ibprocvardef :
  1674. begin
  1675. readcommondef('Procedural type (ProcVar) definition');
  1676. read_abstract_proc_def(calloption,procoptions);
  1677. if not EndOfEntry then
  1678. Writeln('!! Entry has more information stored');
  1679. space:=' '+space;
  1680. { parast }
  1681. readdefinitions('parast');
  1682. readsymbols('parast');
  1683. delete(space,1,4);
  1684. end;
  1685. ibshortstringdef :
  1686. begin
  1687. readcommondef('ShortString definition');
  1688. writeln(space,' Length : ',getbyte);
  1689. end;
  1690. ibwidestringdef :
  1691. begin
  1692. readcommondef('WideString definition');
  1693. writeln(space,' Length : ',getlongint);
  1694. end;
  1695. ibansistringdef :
  1696. begin
  1697. readcommondef('AnsiString definition');
  1698. writeln(space,' Length : ',getlongint);
  1699. end;
  1700. iblongstringdef :
  1701. begin
  1702. readcommondef('Longstring definition');
  1703. writeln(space,' Length : ',getlongint);
  1704. end;
  1705. ibrecorddef :
  1706. begin
  1707. readcommondef('Record definition');
  1708. writeln(space,' DataSize : ',getaint);
  1709. writeln(space,' FieldAlign : ',getbyte);
  1710. writeln(space,' RecordAlign : ',getbyte);
  1711. writeln(space,' PadAlign : ',getbyte);
  1712. writeln(space,'UseFieldAlignment : ',getbyte);
  1713. if not EndOfEntry then
  1714. Writeln('!! Entry has more information stored');
  1715. {read the record definitions and symbols}
  1716. space:=' '+space;
  1717. readdefinitions('fields');
  1718. readsymbols('fields');
  1719. Delete(space,1,4);
  1720. end;
  1721. ibobjectdef :
  1722. begin
  1723. readcommondef('Object/Class definition');
  1724. b:=getbyte;
  1725. write (space,' Type : ');
  1726. case tobjecttyp(b) of
  1727. odt_class : writeln('class');
  1728. odt_object : writeln('object');
  1729. odt_interfacecom : writeln('interfacecom');
  1730. odt_interfacecorba : writeln('interfacecorba');
  1731. odt_cppclass : writeln('cppclass');
  1732. else writeln('!! Warning: Invalid object type ',b);
  1733. end;
  1734. writeln(space,' Name of Class : ',getstring);
  1735. writeln(space,' DataSize : ',getaint);
  1736. writeln(space,' FieldAlign : ',getbyte);
  1737. writeln(space,' RecordAlign : ',getbyte);
  1738. writeln(space,' Vmt offset : ',getlongint);
  1739. write (space, ' Ancestor Class : ');
  1740. readderef;
  1741. write (space,' Options : ');
  1742. readobjectdefoptions;
  1743. if tobjecttyp(b) in [odt_interfacecom,odt_interfacecorba,odt_dispinterface] then
  1744. begin
  1745. { IIDGUID }
  1746. for j:=1to 16 do
  1747. getbyte;
  1748. writeln(space,' IID String : ',getstring);
  1749. writeln(space,' Last VTable idx : ',getlongint);
  1750. end;
  1751. if tobjecttyp(b) in [odt_class,odt_interfacecorba] then
  1752. begin
  1753. l:=getlongint;
  1754. writeln(space,' Impl Intf Count : ',l);
  1755. for j:=1 to l do
  1756. begin
  1757. write (space,' - Definition : ');
  1758. readderef;
  1759. writeln(space,' IOffset : ',getlongint);
  1760. end;
  1761. end;
  1762. if not EndOfEntry then
  1763. Writeln('!! Entry has more information stored');
  1764. {read the record definitions and symbols}
  1765. space:=' '+space;
  1766. readdefinitions('fields');
  1767. readsymbols('fields');
  1768. Delete(space,1,4);
  1769. end;
  1770. ibfiledef :
  1771. begin
  1772. ReadCommonDef('File definition');
  1773. write (space,' Type : ');
  1774. case getbyte of
  1775. 0 : writeln('Text');
  1776. 1 : begin
  1777. writeln('Typed');
  1778. write (space,' File of Type : ');
  1779. readderef;
  1780. end;
  1781. 2 : writeln('Untyped');
  1782. end;
  1783. end;
  1784. ibformaldef :
  1785. readcommondef('Generic definition (void-typ)');
  1786. ibundefineddef :
  1787. readcommondef('Undefined definition (generic parameter)');
  1788. ibenumdef :
  1789. begin
  1790. readcommondef('Enumeration type definition');
  1791. write(space,'Base enumeration type : ');
  1792. readderef;
  1793. writeln(space,' Smallest element : ',getaint);
  1794. writeln(space,' Largest element : ',getaint);
  1795. writeln(space,' Size : ',getaint);
  1796. end;
  1797. ibclassrefdef :
  1798. begin
  1799. readcommondef('Class reference definition');
  1800. write (space,' Pointed Type : ');
  1801. readderef;
  1802. end;
  1803. ibsetdef :
  1804. begin
  1805. readcommondef('Set definition');
  1806. write (space,' Element type : ');
  1807. readderef;
  1808. b:=getbyte;
  1809. case tsettype(b) of
  1810. smallset : writeln(space,' Set with 32 Elements');
  1811. normset : writeln(space,' Set with 256 Elements');
  1812. varset : writeln(space,' Set with ',getlongint,' Elements');
  1813. else writeln('!! Warning: Invalid set type ',b);
  1814. end;
  1815. end;
  1816. ibvariantdef :
  1817. begin
  1818. readcommondef('Variant definition');
  1819. write (space,' Varianttype : ');
  1820. b:=getbyte;
  1821. case tvarianttype(b) of
  1822. vt_normalvariant :
  1823. writeln('Normal');
  1824. vt_olevariant :
  1825. writeln('OLE');
  1826. else
  1827. writeln('!! Warning: Invalid varianttype ',b);
  1828. end;
  1829. end;
  1830. iberror :
  1831. begin
  1832. Writeln('!! Error in PPU');
  1833. exit;
  1834. end;
  1835. ibenddefs :
  1836. break;
  1837. else
  1838. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  1839. end;
  1840. if not EndOfEntry then
  1841. Writeln('!! Entry has more information stored');
  1842. until false;
  1843. end;
  1844. end;
  1845. {****************************************************************************
  1846. Read General Part
  1847. ****************************************************************************}
  1848. procedure readinterface;
  1849. var
  1850. b : byte;
  1851. sourcenumber : longint;
  1852. begin
  1853. with ppufile do
  1854. begin
  1855. repeat
  1856. b:=readentry;
  1857. case b of
  1858. ibmodulename :
  1859. Writeln('Module Name: ',getstring);
  1860. ibsourcefiles :
  1861. begin
  1862. sourcenumber:=1;
  1863. while not EndOfEntry do
  1864. begin
  1865. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  1866. inc(sourcenumber);
  1867. end;
  1868. end;
  1869. {$IFDEF MACRO_DIFF_HINT}
  1870. ibusedmacros :
  1871. begin
  1872. while not EndOfEntry do
  1873. begin
  1874. Write('Conditional ',getstring);
  1875. b:=getbyte;
  1876. if boolean(b)=true then
  1877. write(' defined at startup')
  1878. else
  1879. write(' not defined at startup');
  1880. b:=getbyte;
  1881. if boolean(b)=true then
  1882. writeln(' was used')
  1883. else
  1884. writeln;
  1885. end;
  1886. end;
  1887. {$ENDIF}
  1888. ibloadunit :
  1889. ReadLoadUnit;
  1890. iblinkunitofiles :
  1891. ReadLinkContainer('Link unit object file: ');
  1892. iblinkunitstaticlibs :
  1893. ReadLinkContainer('Link unit static lib: ');
  1894. iblinkunitsharedlibs :
  1895. ReadLinkContainer('Link unit shared lib: ');
  1896. iblinkotherofiles :
  1897. ReadLinkContainer('Link other object file: ');
  1898. iblinkotherstaticlibs :
  1899. ReadLinkContainer('Link other static lib: ');
  1900. iblinkothersharedlibs :
  1901. ReadLinkContainer('Link other shared lib: ');
  1902. ibImportSymbols :
  1903. ReadImportSymbols;
  1904. ibderefdata :
  1905. ReadDerefData;
  1906. ibderefmap :
  1907. ReadDerefMap;
  1908. iberror :
  1909. begin
  1910. Writeln('Error in PPU');
  1911. exit;
  1912. end;
  1913. ibendinterface :
  1914. break;
  1915. else
  1916. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  1917. end;
  1918. until false;
  1919. end;
  1920. end;
  1921. {****************************************************************************
  1922. Read Implementation Part
  1923. ****************************************************************************}
  1924. procedure readimplementation;
  1925. var
  1926. b : byte;
  1927. begin
  1928. with ppufile do
  1929. begin
  1930. repeat
  1931. b:=readentry;
  1932. case b of
  1933. ibasmsymbols :
  1934. ReadAsmSymbols;
  1935. ibloadunit :
  1936. ReadLoadUnit;
  1937. iberror :
  1938. begin
  1939. Writeln('Error in PPU');
  1940. exit;
  1941. end;
  1942. ibendimplementation :
  1943. break;
  1944. else
  1945. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  1946. end;
  1947. until false;
  1948. end;
  1949. end;
  1950. procedure dofile (filename : string);
  1951. begin
  1952. { reset }
  1953. space:='';
  1954. { fix filename }
  1955. if pos('.',filename)=0 then
  1956. filename:=filename+'.ppu';
  1957. ppufile:=tppufile.create(filename);
  1958. if not ppufile.openfile then
  1959. begin
  1960. writeln ('IO-Error when opening : ',filename,', Skipping');
  1961. exit;
  1962. end;
  1963. { PPU File is open, check for PPU Id }
  1964. if not ppufile.CheckPPUID then
  1965. begin
  1966. writeln(Filename,' : Not a valid PPU file, Skipping');
  1967. exit;
  1968. end;
  1969. { Check PPU Version }
  1970. Writeln('Analyzing ',filename,' (v',ppufile.GetPPUVersion,')');
  1971. if ppufile.GetPPUVersion<16 then
  1972. begin
  1973. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  1974. exit;
  1975. end;
  1976. { Write PPU Header Information }
  1977. if (verbose and v_header)<>0 then
  1978. begin
  1979. Writeln;
  1980. Writeln('Header');
  1981. Writeln('-------');
  1982. with ppufile.header do
  1983. begin
  1984. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  1985. (ppufile.header.compiler shr 7) and $7f,'.',
  1986. ppufile.header.compiler and $7f);
  1987. WriteLn('Target processor : ',Cpu2Str(cpu));
  1988. WriteLn('Target operating system : ',Target2Str(target));
  1989. Writeln('Unit flags : ',PPUFlags2Str(flags));
  1990. Writeln('FileSize (w/o header) : ',size);
  1991. Writeln('Checksum : ',hexstr(checksum,8));
  1992. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  1993. Writeln('Definitions stored : ',tostr(deflistsize));
  1994. Writeln('Symbols stored : ',tostr(symlistsize));
  1995. end;
  1996. end;
  1997. {read the general stuff}
  1998. if (verbose and v_interface)<>0 then
  1999. begin
  2000. Writeln;
  2001. Writeln('Interface section');
  2002. Writeln('------------------');
  2003. readinterface;
  2004. end
  2005. else
  2006. ppufile.skipuntilentry(ibendinterface);
  2007. {read the definitions}
  2008. if (verbose and v_defs)<>0 then
  2009. begin
  2010. Writeln;
  2011. Writeln('Interface definitions');
  2012. Writeln('----------------------');
  2013. readdefinitions('interface');
  2014. end
  2015. else
  2016. ppufile.skipuntilentry(ibenddefs);
  2017. {read the symbols}
  2018. if (verbose and v_syms)<>0 then
  2019. begin
  2020. Writeln;
  2021. Writeln('Interface Symbols');
  2022. Writeln('------------------');
  2023. readsymbols('interface');
  2024. end
  2025. else
  2026. ppufile.skipuntilentry(ibendsyms);
  2027. {read the macro symbols}
  2028. if (verbose and v_syms)<>0 then
  2029. begin
  2030. Writeln;
  2031. Writeln('Interface Macro Symbols');
  2032. Writeln('-----------------------');
  2033. end;
  2034. if ppufile.readentry<>ibexportedmacros then
  2035. begin
  2036. Writeln('!! Error in PPU');
  2037. exit;
  2038. end;
  2039. if boolean(ppufile.getbyte) then
  2040. begin
  2041. {skip the definition section for macros (since they are never used) }
  2042. ppufile.skipuntilentry(ibenddefs);
  2043. {read the macro symbols}
  2044. if (verbose and v_syms)<>0 then
  2045. readsymbols('interface macro')
  2046. else
  2047. ppufile.skipuntilentry(ibendsyms);
  2048. end
  2049. else
  2050. Writeln('(no exported macros)');
  2051. {read the implementation stuff}
  2052. if (verbose and v_implementation)<>0 then
  2053. begin
  2054. Writeln;
  2055. Writeln('Implementation section');
  2056. Writeln('-----------------------');
  2057. readimplementation;
  2058. end
  2059. else
  2060. ppufile.skipuntilentry(ibendimplementation);
  2061. {read the static symtable}
  2062. if (ppufile.header.flags and uf_local_symtable)<>0 then
  2063. begin
  2064. if (verbose and v_defs)<>0 then
  2065. begin
  2066. Writeln;
  2067. Writeln('Static definitions');
  2068. Writeln('----------------------');
  2069. readdefinitions('implementation');
  2070. end
  2071. else
  2072. ppufile.skipuntilentry(ibenddefs);
  2073. {read the symbols}
  2074. if (verbose and v_syms)<>0 then
  2075. begin
  2076. Writeln;
  2077. Writeln('Static Symbols');
  2078. Writeln('------------------');
  2079. readsymbols('implementation');
  2080. end
  2081. else
  2082. ppufile.skipuntilentry(ibendsyms);
  2083. end;
  2084. {shutdown ppufile}
  2085. ppufile.closefile;
  2086. ppufile.free;
  2087. Writeln;
  2088. end;
  2089. procedure help;
  2090. begin
  2091. writeln('usage: ppudump [options] <filename1> <filename2>...');
  2092. writeln;
  2093. writeln('[options] can be:');
  2094. writeln(' -V<verbose> Set verbosity to <verbose>');
  2095. writeln(' H - Show header info');
  2096. writeln(' I - Show interface');
  2097. writeln(' M - Show implementation');
  2098. writeln(' S - Show interface symbols');
  2099. writeln(' D - Show interface definitions');
  2100. // writeln(' B - Show browser info');
  2101. writeln(' A - Show all');
  2102. writeln(' -h, -? This helpscreen');
  2103. halt;
  2104. end;
  2105. var
  2106. startpara,
  2107. nrfile,i : longint;
  2108. para : string;
  2109. begin
  2110. writeln(Title+' '+Version);
  2111. writeln(Copyright);
  2112. writeln;
  2113. if paramcount<1 then
  2114. begin
  2115. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  2116. halt(1);
  2117. end;
  2118. { turn verbose on by default }
  2119. verbose:=v_all;
  2120. { read options }
  2121. startpara:=1;
  2122. while copy(paramstr(startpara),1,1)='-' do
  2123. begin
  2124. para:=paramstr(startpara);
  2125. case upcase(para[2]) of
  2126. 'V' : begin
  2127. verbose:=0;
  2128. for i:=3 to length(para) do
  2129. case upcase(para[i]) of
  2130. 'H' : verbose:=verbose or v_header;
  2131. 'I' : verbose:=verbose or v_interface;
  2132. 'M' : verbose:=verbose or v_implementation;
  2133. 'D' : verbose:=verbose or v_defs;
  2134. 'S' : verbose:=verbose or v_syms;
  2135. 'A' : verbose:=verbose or v_all;
  2136. end;
  2137. end;
  2138. 'H' : help;
  2139. '?' : help;
  2140. end;
  2141. inc(startpara);
  2142. end;
  2143. { process files }
  2144. for nrfile:=startpara to paramcount do
  2145. dofile (paramstr(nrfile));
  2146. if has_errors then
  2147. Halt(1);
  2148. end.