ppudump.pp 68 KB

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