ppudump.pp 65 KB

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