ppudump.pp 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311
  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 : cardinal;
  353. begin
  354. while not ppufile.EndOfEntry do
  355. begin
  356. inc(unitnumber);
  357. write('Uses unit: ',ppufile.getstring,' (Number: ',unitnumber,')');
  358. ucrc:=cardinal(ppufile.getlongint);
  359. uintfcrc:=cardinal(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 : longint;
  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_overload, { procedure is declared with overload directive }
  752. po_varargs, { printf like arguments }
  753. po_internconst, { procedure has constant evaluator intern }
  754. { flag that only the address of a method is returned and not a full methodpointer }
  755. po_addressonly,
  756. { procedure is exported }
  757. po_public,
  758. { calling convention is specified explicitly }
  759. po_hascallingconvention,
  760. { reintroduce flag }
  761. po_reintroduce,
  762. { location of parameters is given explicitly as it is necessary for some syscall
  763. conventions like that one of MorphOS }
  764. po_explicitparaloc,
  765. { no stackframe will be generated, used by lowlevel assembler like get_frame }
  766. po_nostackframe,
  767. po_has_mangledname,
  768. po_has_public_name,
  769. po_forward
  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=25;
  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_overload; str:'Overload'),
  827. (mask:po_varargs; str:'VarArgs'),
  828. (mask:po_internconst; str:'InternConst'),
  829. (mask:po_addressonly; str:'AddressOnly'),
  830. (mask:po_public; str:'Public'),
  831. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  832. (mask:po_reintroduce; str:'ReIntroduce'),
  833. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  834. (mask:po_nostackframe; str:'NoStackFrame'),
  835. (mask:po_has_mangledname; str:'HasMangledName'),
  836. (mask:po_has_public_name; str:'HasPublicName'),
  837. (mask:po_forward; str:'Forward')
  838. );
  839. var
  840. proctypeoption : tproctypeoption;
  841. i : longint;
  842. first : boolean;
  843. begin
  844. write(space,' Return type : ');
  845. readtype;
  846. writeln(space,' Fpu used : ',ppufile.getbyte);
  847. proctypeoption:=tproctypeoption(ppufile.getbyte);
  848. if proctypeoption<>potype_none then
  849. begin
  850. write(space,' TypeOption : ');
  851. first:=true;
  852. for i:=1 to proctypeopts do
  853. if (proctypeopt[i].mask=proctypeoption) then
  854. begin
  855. if first then
  856. first:=false
  857. else
  858. write(', ');
  859. write(proctypeopt[i].str);
  860. end;
  861. writeln;
  862. end;
  863. proccalloption:=tproccalloption(ppufile.getbyte);
  864. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  865. ppufile.getsmallset(procoptions);
  866. if procoptions<>[] then
  867. begin
  868. write(space,' Options : ');
  869. first:=true;
  870. for i:=1to procopts do
  871. if (procopt[i].mask in procoptions) then
  872. begin
  873. if first then
  874. first:=false
  875. else
  876. write(', ');
  877. write(procopt[i].str);
  878. end;
  879. writeln;
  880. end;
  881. end;
  882. type
  883. { options for variables }
  884. tvaroption=(vo_none,
  885. vo_is_C_var,
  886. vo_is_external,
  887. vo_is_dll_var,
  888. vo_is_thread_var,
  889. vo_has_local_copy,
  890. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  891. vo_is_exported,
  892. vo_is_high_para,
  893. vo_is_funcret,
  894. vo_is_self,
  895. vo_is_vmt,
  896. vo_is_result, { special result variable }
  897. vo_is_parentfp,
  898. vo_is_loop_counter, { used to detect assignments to loop counter }
  899. vo_is_hidden_para,
  900. vo_has_explicit_paraloc,
  901. vo_is_syscall_lib,
  902. vo_has_mangledname
  903. );
  904. tvaroptions=set of tvaroption;
  905. { register variable }
  906. tvarregable=(vr_none,
  907. vr_intreg,
  908. vr_fpureg,
  909. vr_mmreg
  910. );
  911. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions);
  912. type
  913. tvaropt=record
  914. mask : tvaroption;
  915. str : string[30];
  916. end;
  917. const
  918. varopts=18;
  919. varopt : array[1..varopts] of tvaropt=(
  920. (mask:vo_is_C_var; str:'CVar'),
  921. (mask:vo_is_external; str:'External'),
  922. (mask:vo_is_dll_var; str:'DLLVar'),
  923. (mask:vo_is_thread_var; str:'ThreadVar'),
  924. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  925. (mask:vo_is_const; str:'Constant'),
  926. (mask:vo_is_exported; str:'Exported'),
  927. (mask:vo_is_high_para; str:'HighValue'),
  928. (mask:vo_is_funcret; str:'Funcret'),
  929. (mask:vo_is_self; str:'Self'),
  930. (mask:vo_is_vmt; str:'VMT'),
  931. (mask:vo_is_result; str:'Result'),
  932. (mask:vo_is_parentfp; str:'ParentFP'),
  933. (mask:vo_is_loop_counter; str:'LoopCounter'),
  934. (mask:vo_is_hidden_para; str:'Hidden'),
  935. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  936. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  937. (mask:vo_has_mangledname; str:'HasMangledName')
  938. );
  939. var
  940. i : longint;
  941. first : boolean;
  942. begin
  943. readcommonsym(s);
  944. writeln(space,' Spez : ',Varspez2Str(ppufile.getbyte));
  945. writeln(space,' Regable : ',Varregable2Str(ppufile.getbyte));
  946. write (space,' Var Type : ');
  947. readtype;
  948. ppufile.getsmallset(varoptions);
  949. if varoptions<>[] then
  950. begin
  951. write(space,' Options : ');
  952. first:=true;
  953. for i:=1to varopts do
  954. if (varopt[i].mask in varoptions) then
  955. begin
  956. if first then
  957. first:=false
  958. else
  959. write(', ');
  960. write(varopt[i].str);
  961. end;
  962. writeln;
  963. end;
  964. end;
  965. procedure readnodetree;
  966. var
  967. l : longint;
  968. p : pointer;
  969. begin
  970. with ppufile do
  971. begin
  972. if space<>'' then
  973. Writeln(space,'------ nodetree ------');
  974. if readentry=ibnodetree then
  975. begin
  976. l:=entrysize;
  977. Writeln(space,'Tree size : ',l);
  978. { Read data to prevent error that entry is not completly read }
  979. getmem(p,l);
  980. getdata(p^,l);
  981. freemem(p);
  982. end
  983. else
  984. begin
  985. Writeln('!! ibnodetree not found');
  986. end;
  987. end;
  988. end;
  989. {****************************************************************************
  990. Read Symbols Part
  991. ****************************************************************************}
  992. procedure readsymbols(const s:string);
  993. type
  994. pguid = ^tguid;
  995. tguid = packed record
  996. D1: LongWord;
  997. D2: Word;
  998. D3: Word;
  999. D4: array[0..7] of Byte;
  1000. end;
  1001. absolutetyp = (tovar,toasm,toaddr);
  1002. tconsttyp = (constnone,
  1003. constord,conststring,constreal,
  1004. constset,constpointer,constnil,
  1005. constresourcestring,constwstring,constguid
  1006. );
  1007. var
  1008. b : byte;
  1009. pc : pchar;
  1010. totalsyms,
  1011. symcnt,
  1012. i,j,len : longint;
  1013. guid : tguid;
  1014. tempbuf : array[0..127] of char;
  1015. varoptions : tvaroptions;
  1016. begin
  1017. symcnt:=1;
  1018. with ppufile do
  1019. begin
  1020. if space<>'' then
  1021. Writeln(space,'------ ',s,' ------');
  1022. if readentry=ibstartsyms then
  1023. begin
  1024. totalsyms:=getlongint;
  1025. Writeln(space,'Number of symbols : ',totalsyms);
  1026. Writeln(space,'Symtable datasize : ',getlongint);
  1027. Writeln(space,'Symtable alignment: ',getlongint);
  1028. end
  1029. else
  1030. begin
  1031. totalsyms:=-1;
  1032. Writeln('!! ibstartsym not found');
  1033. end;
  1034. repeat
  1035. b:=readentry;
  1036. if not (b in [iberror,ibendsyms]) then
  1037. inc(symcnt);
  1038. case b of
  1039. ibunitsym :
  1040. readcommonsym('Unit symbol ');
  1041. iblabelsym :
  1042. readcommonsym('Label symbol ');
  1043. ibtypesym :
  1044. begin
  1045. readcommonsym('Type symbol ');
  1046. write(space,' Result Type : ');
  1047. readtype;
  1048. end;
  1049. ibprocsym :
  1050. begin
  1051. readcommonsym('Procedure symbol ');
  1052. len:=ppufile.getword;
  1053. for i:=1 to len do
  1054. begin
  1055. write(space,' Definition : ');
  1056. readderef;
  1057. end;
  1058. end;
  1059. ibconstsym :
  1060. begin
  1061. readcommonsym('Constant symbol ');
  1062. b:=getbyte;
  1063. case tconsttyp(b) of
  1064. constord :
  1065. begin
  1066. write (space,' OrdinalType : ');
  1067. readtype;
  1068. writeln(space,' Value : ',getint64);
  1069. end;
  1070. constpointer :
  1071. begin
  1072. write (space,' PointerType : ');
  1073. readtype;
  1074. writeln(space,' Value : ',getlongint)
  1075. end;
  1076. conststring,
  1077. constresourcestring :
  1078. begin
  1079. len:=getlongint;
  1080. getmem(pc,len+1);
  1081. getdata(pc^,len);
  1082. (pc+len)^:= #0;
  1083. writeln(space,' Length : ',len);
  1084. writeln(space,' Value : "',pc,'"');
  1085. freemem(pc,len+1);
  1086. if tconsttyp(b)=constresourcestring then
  1087. writeln(space,' Index : ',getlongint);
  1088. end;
  1089. constreal :
  1090. writeln(space,' Value : ',getreal);
  1091. constset :
  1092. begin
  1093. write (space,' Set Type : ');
  1094. readtype;
  1095. for i:=1to 4 do
  1096. begin
  1097. write (space,' Value : ');
  1098. for j:=1to 8 do
  1099. begin
  1100. if j>1 then
  1101. write(',');
  1102. write(hexb(getbyte));
  1103. end;
  1104. writeln;
  1105. end;
  1106. end;
  1107. constwstring:
  1108. begin
  1109. end;
  1110. constguid:
  1111. begin
  1112. getdata(guid,sizeof(guid));
  1113. write (space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-');
  1114. for i:=0 to 7 do
  1115. begin
  1116. write(hexstr(guid.d4[i],2));
  1117. if i=1 then write('-');
  1118. end;
  1119. writeln('}');
  1120. end
  1121. else
  1122. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  1123. end;
  1124. end;
  1125. ibabsolutevarsym :
  1126. begin
  1127. readabstractvarsym('Absolute variable symbol ',varoptions);
  1128. Write (space,' Relocated to ');
  1129. b:=getbyte;
  1130. case absolutetyp(b) of
  1131. tovar :
  1132. readsymlist(space+' Sym : ');
  1133. toasm :
  1134. Writeln('Assembler name : ',getstring);
  1135. toaddr :
  1136. begin
  1137. Write('Address : ',getlongint);
  1138. if tsystemcpu(ppufile.header.cpu)=cpu_i386 then
  1139. WriteLn(' (Far: ',getbyte<>0,')');
  1140. end;
  1141. else
  1142. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  1143. end;
  1144. end;
  1145. ibfieldvarsym :
  1146. begin
  1147. readabstractvarsym('Field Variable symbol ',varoptions);
  1148. writeln(space,' Address : ',getlongint);
  1149. end;
  1150. ibglobalvarsym :
  1151. begin
  1152. readabstractvarsym('Global Variable symbol ',varoptions);
  1153. write (space,' DefaultConst : ');
  1154. readderef;
  1155. if (vo_has_mangledname in varoptions) then
  1156. writeln(space,' Mangledname : ',getstring);
  1157. end;
  1158. iblocalvarsym :
  1159. begin
  1160. readabstractvarsym('Local Variable symbol ',varoptions);
  1161. write (space,' DefaultConst : ');
  1162. readderef;
  1163. end;
  1164. ibparavarsym :
  1165. begin
  1166. readabstractvarsym('Parameter Variable symbol ',varoptions);
  1167. write (space,' DefaultConst : ');
  1168. readderef;
  1169. writeln(space,' ParaNr : ',getword);
  1170. if (vo_has_explicit_paraloc in varoptions) then
  1171. begin
  1172. i:=getbyte;
  1173. getdata(tempbuf,i);
  1174. end;
  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 (po_has_mangledname in procoptions) 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 (calloption = pocall_inline) then
  1381. begin
  1382. readdefinitions('localst',false);
  1383. readsymbols('localst');
  1384. end;
  1385. if (calloption=pocall_inline) then
  1386. readnodetree;
  1387. delete(space,1,4);
  1388. end;
  1389. ibprocvardef :
  1390. begin
  1391. readcommondef('Procedural type (ProcVar) definition');
  1392. read_abstract_proc_def(calloption,procoptions);
  1393. if not EndOfEntry then
  1394. Writeln('!! Entry has more information stored');
  1395. space:=' '+space;
  1396. { parast }
  1397. readdefinitions('parast',false);
  1398. readsymbols('parast');
  1399. delete(space,1,4);
  1400. end;
  1401. ibshortstringdef :
  1402. begin
  1403. readcommondef('ShortString definition');
  1404. writeln(space,' Length : ',getbyte);
  1405. end;
  1406. ibwidestringdef :
  1407. begin
  1408. readcommondef('WideString definition');
  1409. writeln(space,' Length : ',getlongint);
  1410. end;
  1411. ibansistringdef :
  1412. begin
  1413. readcommondef('AnsiString definition');
  1414. writeln(space,' Length : ',getlongint);
  1415. end;
  1416. iblongstringdef :
  1417. begin
  1418. readcommondef('Longstring definition');
  1419. writeln(space,' Length : ',getlongint);
  1420. end;
  1421. ibrecorddef :
  1422. begin
  1423. readcommondef('Record definition');
  1424. writeln(space,' DataSize : ',getlongint);
  1425. writeln(space,' FieldAlign : ',getbyte);
  1426. writeln(space,' RecordAlign : ',getbyte);
  1427. writeln(space,' PadAlign : ',getbyte);
  1428. if not EndOfEntry then
  1429. Writeln('!! Entry has more information stored');
  1430. {read the record definitions and symbols}
  1431. space:=' '+space;
  1432. readdefinitions('fields',false);
  1433. readsymbols('fields');
  1434. Delete(space,1,4);
  1435. end;
  1436. ibobjectdef :
  1437. begin
  1438. readcommondef('Object/Class definition');
  1439. b:=getbyte;
  1440. write (space,' Type : ');
  1441. case tobjectdeftype(b) of
  1442. odt_class : writeln('class');
  1443. odt_object : writeln('object');
  1444. odt_interfacecom : writeln('interfacecom');
  1445. odt_interfacecorba : writeln('interfacecorba');
  1446. odt_cppclass : writeln('cppclass');
  1447. else writeln('!! Warning: Invalid object type ',b);
  1448. end;
  1449. writeln(space,' Name of Class : ',getstring);
  1450. writeln(space,' DataSize : ',getlongint);
  1451. writeln(space,' FieldAlign : ',getbyte);
  1452. writeln(space,' RecordAlign : ',getbyte);
  1453. writeln(space,' Vmt offset : ',getlongint);
  1454. write(space, ' Ancestor Class : ');
  1455. readderef;
  1456. writeln(space,' Options : ',getlongint);
  1457. if tobjectdeftype(b) in [odt_interfacecom,odt_interfacecorba] then
  1458. begin
  1459. { IIDGUID }
  1460. for j:=1to 16 do
  1461. getbyte;
  1462. writeln(space,' IID String : ',getstring);
  1463. writeln(space,' Last VTable idx : ',getlongint);
  1464. end;
  1465. if tobjectdeftype(b) in [odt_class,odt_interfacecorba] then
  1466. begin
  1467. l:=getlongint;
  1468. writeln(space,' Impl Intf Count : ',l);
  1469. for j:=1 to l do
  1470. begin
  1471. write (space,' - Definition : ');
  1472. readderef;
  1473. writeln(space,' IOffset : ',getlongint);
  1474. end;
  1475. end;
  1476. if not EndOfEntry then
  1477. Writeln('!! Entry has more information stored');
  1478. {read the record definitions and symbols}
  1479. space:=' '+space;
  1480. readdefinitions('fields',false);
  1481. readsymbols('fields');
  1482. Delete(space,1,4);
  1483. end;
  1484. ibfiledef :
  1485. begin
  1486. ReadCommonDef('File definition');
  1487. write (space,' Type : ');
  1488. case getbyte of
  1489. 0 : writeln('Text');
  1490. 1 : begin
  1491. writeln('Typed');
  1492. write (space,' File of Type : ');
  1493. Readtype;
  1494. end;
  1495. 2 : writeln('Untyped');
  1496. end;
  1497. end;
  1498. ibformaldef :
  1499. readcommondef('Generic Definition (void-typ)');
  1500. ibenumdef :
  1501. begin
  1502. readcommondef('Enumeration type definition');
  1503. write(space,'Base enumeration type : ');
  1504. readderef;
  1505. writeln(space,' Smallest element : ',getlongint);
  1506. writeln(space,' Largest element : ',getlongint);
  1507. writeln(space,' Size : ',getlongint);
  1508. end;
  1509. ibclassrefdef :
  1510. begin
  1511. readcommondef('Class reference definition');
  1512. write (space,' Pointed Type : ');
  1513. readtype;
  1514. end;
  1515. ibsetdef :
  1516. begin
  1517. readcommondef('Set definition');
  1518. write (space,' Element type : ');
  1519. readtype;
  1520. b:=getbyte;
  1521. case tsettype(b) of
  1522. smallset : writeln(space,' Set with 32 Elements');
  1523. normset : writeln(space,' Set with 256 Elements');
  1524. varset : writeln(space,' Set with ',getlongint,' Elements');
  1525. else writeln('!! Warning: Invalid set type ',b);
  1526. end;
  1527. end;
  1528. ibvariantdef :
  1529. begin
  1530. readcommondef('Variant definition');
  1531. write (space,' Varianttype : ');
  1532. b:=getbyte;
  1533. case tvarianttype(b) of
  1534. vt_normalvariant :
  1535. writeln('Normal');
  1536. vt_olevariant :
  1537. writeln('OLE');
  1538. else
  1539. writeln('!! Warning: Invalid varianttype ',b);
  1540. end;
  1541. end;
  1542. iberror :
  1543. begin
  1544. Writeln('!! Error in PPU');
  1545. exit;
  1546. end;
  1547. ibenddefs :
  1548. break;
  1549. else
  1550. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  1551. end;
  1552. if not EndOfEntry then
  1553. Writeln('!! Entry has more information stored');
  1554. until false;
  1555. if (totaldefs<>-1) and (defcnt<>totaldefs) then
  1556. Writeln('!! Only read ',defcnt,' of ',totaldefs,' definitions');
  1557. end;
  1558. end;
  1559. {****************************************************************************
  1560. Read General Part
  1561. ****************************************************************************}
  1562. procedure readinterface;
  1563. var
  1564. b : byte;
  1565. sourcenumber : longint;
  1566. begin
  1567. with ppufile do
  1568. begin
  1569. repeat
  1570. b:=readentry;
  1571. case b of
  1572. ibmodulename :
  1573. Writeln('Module Name: ',getstring);
  1574. ibsourcefiles :
  1575. begin
  1576. sourcenumber:=1;
  1577. while not EndOfEntry do
  1578. begin
  1579. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  1580. inc(sourcenumber);
  1581. end;
  1582. end;
  1583. ibusedmacros :
  1584. begin
  1585. while not EndOfEntry do
  1586. begin
  1587. Write('Conditional ',getstring);
  1588. b:=getbyte;
  1589. if boolean(b)=true then
  1590. write(' defined at startup')
  1591. else
  1592. write(' not defined at startup');
  1593. b:=getbyte;
  1594. if boolean(b)=true then
  1595. writeln(' was used')
  1596. else
  1597. writeln;
  1598. end;
  1599. end;
  1600. ibloadunit :
  1601. ReadLoadUnit;
  1602. iblinkunitofiles :
  1603. ReadLinkContainer('Link unit object file: ');
  1604. iblinkunitstaticlibs :
  1605. ReadLinkContainer('Link unit static lib: ');
  1606. iblinkunitsharedlibs :
  1607. ReadLinkContainer('Link unit shared lib: ');
  1608. iblinkotherofiles :
  1609. ReadLinkContainer('Link other object file: ');
  1610. iblinkotherstaticlibs :
  1611. ReadLinkContainer('Link other static lib: ');
  1612. iblinkothersharedlibs :
  1613. ReadLinkContainer('Link other shared lib: ');
  1614. ibderefdata :
  1615. ReadDerefData;
  1616. iberror :
  1617. begin
  1618. Writeln('Error in PPU');
  1619. exit;
  1620. end;
  1621. ibendinterface :
  1622. break;
  1623. else
  1624. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  1625. end;
  1626. until false;
  1627. end;
  1628. end;
  1629. {****************************************************************************
  1630. Read Implementation Part
  1631. ****************************************************************************}
  1632. procedure readimplementation;
  1633. var
  1634. b : byte;
  1635. begin
  1636. with ppufile do
  1637. begin
  1638. repeat
  1639. b:=readentry;
  1640. case b of
  1641. ibasmsymbols :
  1642. ReadAsmSymbols;
  1643. ibloadunit :
  1644. ReadLoadUnit;
  1645. iberror :
  1646. begin
  1647. Writeln('Error in PPU');
  1648. exit;
  1649. end;
  1650. ibendimplementation :
  1651. break;
  1652. else
  1653. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  1654. end;
  1655. until false;
  1656. end;
  1657. end;
  1658. {****************************************************************************
  1659. Read Browser Part
  1660. ****************************************************************************}
  1661. procedure readbrowser;
  1662. var
  1663. b : byte;
  1664. const indent : string = '';
  1665. begin
  1666. Writeln(indent,'Start of symtable browser');
  1667. indent:=indent+'**';
  1668. with ppufile do
  1669. begin
  1670. repeat
  1671. b:=readentry;
  1672. case b of
  1673. ibbeginsymtablebrowser :
  1674. begin
  1675. { here we must read object and record symtables !! }
  1676. indent:=indent+' ';
  1677. Writeln(indent,'Record/Object symtable');
  1678. readbrowser;
  1679. Indent:=Copy(Indent,1,Length(Indent)-2);
  1680. end;
  1681. ibsymref :
  1682. begin
  1683. readderef;
  1684. readref;
  1685. end;
  1686. ibdefref :
  1687. begin
  1688. readderef;
  1689. readref;
  1690. if ((ppufile.header.flags and uf_local_browser)<>0) and
  1691. (UnitIndex=0) then
  1692. begin
  1693. { parast and localst }
  1694. indent:=indent+' ';
  1695. b:=ppufile.readentry;
  1696. if b=ibbeginsymtablebrowser then
  1697. readbrowser;
  1698. b:=ppufile.readentry;
  1699. if b=ibbeginsymtablebrowser then
  1700. readbrowser;
  1701. Indent:=Copy(Indent,1,Length(Indent)-2);
  1702. end;
  1703. end;
  1704. iberror :
  1705. begin
  1706. Writeln('Error in PPU');
  1707. exit;
  1708. end;
  1709. ibendsymtablebrowser :
  1710. break;
  1711. else
  1712. begin
  1713. WriteLn('!! Skipping unsupported PPU Entry in Browser: ',b);
  1714. Halt;
  1715. end;
  1716. end;
  1717. until false;
  1718. end;
  1719. Indent:=Copy(Indent,1,Length(Indent)-2);
  1720. Writeln(Indent,'End of symtable browser');
  1721. end;
  1722. procedure dofile (filename : string);
  1723. var
  1724. b : byte;
  1725. begin
  1726. { reset }
  1727. space:='';
  1728. { fix filename }
  1729. if pos('.',filename)=0 then
  1730. filename:=filename+'.ppu';
  1731. ppufile:=tppufile.create(filename);
  1732. if not ppufile.openfile then
  1733. begin
  1734. writeln ('IO-Error when opening : ',filename,', Skipping');
  1735. exit;
  1736. end;
  1737. { PPU File is open, check for PPU Id }
  1738. if not ppufile.CheckPPUID then
  1739. begin
  1740. writeln(Filename,' : Not a valid PPU file, Skipping');
  1741. exit;
  1742. end;
  1743. { Check PPU Version }
  1744. Writeln('Analyzing ',filename,' (v',ppufile.GetPPUVersion,')');
  1745. if ppufile.GetPPUVersion<16 then
  1746. begin
  1747. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  1748. exit;
  1749. end;
  1750. { Write PPU Header Information }
  1751. if (verbose and v_header)<>0 then
  1752. begin
  1753. Writeln;
  1754. Writeln('Header');
  1755. Writeln('-------');
  1756. with ppufile.header do
  1757. begin
  1758. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  1759. (ppufile.header.compiler shr 7) and $7f,'.',
  1760. ppufile.header.compiler and $7f);
  1761. WriteLn('Target processor : ',Cpu2Str(cpu));
  1762. WriteLn('Target operating system : ',Target2Str(target));
  1763. Writeln('Unit flags : ',PPUFlags2Str(flags));
  1764. Writeln('FileSize (w/o header) : ',size);
  1765. Writeln('Checksum : ',hexstr(checksum,8));
  1766. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  1767. end;
  1768. end;
  1769. {read the general stuff}
  1770. if (verbose and v_interface)<>0 then
  1771. begin
  1772. Writeln;
  1773. Writeln('Interface section');
  1774. Writeln('------------------');
  1775. readinterface;
  1776. end
  1777. else
  1778. ppufile.skipuntilentry(ibendinterface);
  1779. {read the definitions}
  1780. if (verbose and v_defs)<>0 then
  1781. begin
  1782. Writeln;
  1783. Writeln('Interface definitions');
  1784. Writeln('----------------------');
  1785. readdefinitions('interface',false);
  1786. end
  1787. else
  1788. ppufile.skipuntilentry(ibenddefs);
  1789. {read the symbols}
  1790. if (verbose and v_syms)<>0 then
  1791. begin
  1792. Writeln;
  1793. Writeln('Interface Symbols');
  1794. Writeln('------------------');
  1795. readsymbols('interface');
  1796. end
  1797. else
  1798. ppufile.skipuntilentry(ibendsyms);
  1799. {read the implementation stuff}
  1800. if (verbose and v_implementation)<>0 then
  1801. begin
  1802. Writeln;
  1803. Writeln('Implementation section');
  1804. Writeln('-----------------------');
  1805. readimplementation;
  1806. end
  1807. else
  1808. ppufile.skipuntilentry(ibendimplementation);
  1809. {read the static browser units stuff}
  1810. if (ppufile.header.flags and uf_local_symtable)<>0 then
  1811. begin
  1812. if (verbose and v_defs)<>0 then
  1813. begin
  1814. Writeln;
  1815. Writeln('Static definitions');
  1816. Writeln('----------------------');
  1817. readdefinitions('implementation',false);
  1818. end
  1819. else
  1820. ppufile.skipuntilentry(ibenddefs);
  1821. {read the symbols}
  1822. if (verbose and v_syms)<>0 then
  1823. begin
  1824. Writeln;
  1825. Writeln('Static Symbols');
  1826. Writeln('------------------');
  1827. readsymbols('implementation');
  1828. end
  1829. else
  1830. ppufile.skipuntilentry(ibendsyms);
  1831. end;
  1832. {read the browser units stuff}
  1833. if (ppufile.header.flags and uf_has_browser)<>0 then
  1834. begin
  1835. if (verbose and v_browser)<>0 then
  1836. begin
  1837. Writeln;
  1838. Writeln('Browser section');
  1839. Writeln('---------------');
  1840. UnitIndex:=0;
  1841. repeat
  1842. b:=ppufile.readentry;
  1843. if b = ibendbrowser then break;
  1844. if b=ibbeginsymtablebrowser then
  1845. begin
  1846. Writeln('Unit ',UnitIndex);
  1847. readbrowser;
  1848. Inc(UnitIndex);
  1849. end
  1850. else
  1851. Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
  1852. until false;
  1853. end;
  1854. end;
  1855. {read the static browser units stuff}
  1856. if (ppufile.header.flags and uf_local_browser)<>0 then
  1857. begin
  1858. if (verbose and v_browser)<>0 then
  1859. begin
  1860. Writeln;
  1861. Writeln('Static browser section');
  1862. Writeln('---------------');
  1863. UnitIndex:=0;
  1864. b:=ppufile.readentry;
  1865. if b=ibbeginsymtablebrowser then
  1866. readbrowser
  1867. else
  1868. Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
  1869. end;
  1870. end;
  1871. {shutdown ppufile}
  1872. ppufile.closefile;
  1873. ppufile.free;
  1874. Writeln;
  1875. end;
  1876. procedure help;
  1877. begin
  1878. writeln('usage: ppudump [options] <filename1> <filename2>...');
  1879. writeln;
  1880. writeln('[options] can be:');
  1881. writeln(' -V<verbose> Set verbosity to <verbose>');
  1882. writeln(' H - Show header info');
  1883. writeln(' I - Show interface');
  1884. writeln(' M - Show implementation');
  1885. writeln(' S - Show interface symbols');
  1886. writeln(' D - Show interface definitions');
  1887. writeln(' B - Show browser info');
  1888. writeln(' A - Show all');
  1889. writeln(' -h, -? This helpscreen');
  1890. halt;
  1891. end;
  1892. var
  1893. startpara,
  1894. nrfile,i : longint;
  1895. para : string;
  1896. begin
  1897. writeln(Title+' '+Version);
  1898. writeln(Copyright);
  1899. writeln;
  1900. if paramcount<1 then
  1901. begin
  1902. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  1903. halt(1);
  1904. end;
  1905. { turn verbose on by default }
  1906. verbose:=v_all;
  1907. { read options }
  1908. startpara:=1;
  1909. while copy(paramstr(startpara),1,1)='-' do
  1910. begin
  1911. para:=paramstr(startpara);
  1912. case upcase(para[2]) of
  1913. 'V' : begin
  1914. verbose:=0;
  1915. for i:=3to length(para) do
  1916. case upcase(para[i]) of
  1917. 'H' : verbose:=verbose or v_header;
  1918. 'I' : verbose:=verbose or v_interface;
  1919. 'M' : verbose:=verbose or v_implementation;
  1920. 'D' : verbose:=verbose or v_defs;
  1921. 'S' : verbose:=verbose or v_syms;
  1922. 'B' : verbose:=verbose or v_browser;
  1923. 'A' : verbose:=verbose or v_all;
  1924. end;
  1925. end;
  1926. 'H' : help;
  1927. '?' : help;
  1928. end;
  1929. inc(startpara);
  1930. end;
  1931. { process files }
  1932. for nrfile:=startpara to paramcount do
  1933. dofile (paramstr(nrfile));
  1934. if has_errors then
  1935. Halt(1);
  1936. end.
  1937. {
  1938. $Log$
  1939. Revision 1.61 2004-11-17 22:22:12 peter
  1940. mangledname setting moved to place after the complete proc declaration is read
  1941. import generation moved to place where body is also parsed (still gives problems with win32)
  1942. Revision 1.60 2004/11/16 20:49:08 peter
  1943. * fixed rangecheck error with derefdata
  1944. Revision 1.59 2004/11/15 23:35:31 peter
  1945. * tparaitem removed, use tparavarsym instead
  1946. * parameter order is now calculated from paranr value in tparavarsym
  1947. Revision 1.58 2004/11/08 22:09:59 peter
  1948. * tvarsym splitted
  1949. Revision 1.57 2004/11/02 22:17:25 olle
  1950. * fixed possible problem with null termination
  1951. Revision 1.56 2004/09/27 18:04:11 olle
  1952. + added -h option to show help
  1953. Revision 1.55 2004/09/04 21:11:49 armin
  1954. * missing targets added
  1955. Revision 1.54 2004/08/27 21:59:27 peter
  1956. browser disabled
  1957. uf_local_symtable ppu flag when a localsymtable is stored
  1958. Revision 1.53 2004/07/12 09:14:04 jonas
  1959. * inline procedures at the node tree level, but only under some very
  1960. limited circumstances for now (only procedures, and only if they have
  1961. no or only vs_out/vs_var parameters).
  1962. * fixed ppudump for inline procedures
  1963. * fixed ppudump for ppc
  1964. Revision 1.52 2004/07/09 22:17:32 peter
  1965. * revert has_localst patch
  1966. * replace aktstaticsymtable/aktglobalsymtable with current_module
  1967. Revision 1.51 2004/07/06 19:52:04 peter
  1968. * fix storing of localst in ppu
  1969. Revision 1.50 2003/12/16 21:29:25 florian
  1970. + inlined procedures inherit procinfo flags
  1971. Revision 1.49 2003/12/08 21:04:08 peter
  1972. * line break in uses unit
  1973. Revision 1.48 2003/11/10 22:02:52 peter
  1974. * cross unit inlining fixed
  1975. Revision 1.47 2003/10/22 20:40:00 peter
  1976. * write derefdata in a separate ppu entry
  1977. Revision 1.46 2003/07/02 22:18:04 peter
  1978. * paraloc splitted in callerparaloc,calleeparaloc
  1979. * sparc calling convention updates
  1980. Revision 1.45 2003/06/25 18:31:23 peter
  1981. * sym,def resolving partly rewritten to support also parent objects
  1982. not directly available through the uses clause
  1983. Revision 1.44 2003/06/09 12:59:00 peter
  1984. * updated for new deref info
  1985. Revision 1.43 2003/06/05 20:06:11 peter
  1986. * new procoptions
  1987. Revision 1.42 2003/05/09 17:47:03 peter
  1988. * self moved to hidden parameter
  1989. * removed hdisposen,hnewn,selfn
  1990. Revision 1.41 2003/04/27 07:29:52 peter
  1991. * aktprocdef cleanup, aktprocdef is now always nil when parsing
  1992. a new procdef declaration
  1993. * aktprocsym removed
  1994. * lexlevel removed, use symtable.symtablelevel instead
  1995. * implicit init/final code uses the normal genentry/genexit
  1996. * funcret state checking updated for new funcret handling
  1997. Revision 1.39 2003/04/25 20:59:35 peter
  1998. * removed funcretn,funcretsym, function result is now in varsym
  1999. and aliases for result and function name are added using absolutesym
  2000. * vs_hidden parameter for funcret passed in parameter
  2001. * vs_hidden fixes
  2002. * writenode changed to printnode and released from extdebug
  2003. * -vp option added to generate a tree.log with the nodetree
  2004. * nicer printnode for statements, callnode
  2005. Revision 1.38 2003/04/10 17:57:53 peter
  2006. * vs_hidden released
  2007. Revision 1.37 2003/03/24 19:57:54 hajny
  2008. + emx target added
  2009. Revision 1.36 2003/03/17 15:54:22 peter
  2010. * store symoptions also for procdef
  2011. * check symoptions (private,public) when calculating possible
  2012. overload candidates
  2013. Revision 1.35 2003/01/03 22:16:29 peter
  2014. * updated for absolutesym and varsym
  2015. Revision 1.34 2002/11/17 16:32:04 carl
  2016. * memory optimization (3-4%) : cleanup of tai fields,
  2017. cleanup of tdef and tsym fields.
  2018. * make it work for m68k
  2019. Revision 1.33 2002/10/20 14:49:31 peter
  2020. * store original source time in ppu so it can be compared instead of
  2021. comparing with the ppu time
  2022. Revision 1.32 2002/10/06 12:25:53 florian
  2023. + dump of tdefoptions.df_unique
  2024. Revision 1.31 2002/09/27 21:22:04 carl
  2025. * update system information
  2026. Revision 1.30 2002/09/26 12:03:54 florian
  2027. + support of constguid and constwchar const symbols added
  2028. Revision 1.29 2002/08/20 16:54:40 peter
  2029. * write address of varsym always
  2030. Revision 1.28 2002/08/19 19:36:44 peter
  2031. * More fixes for cross unit inlining, all tnodes are now implemented
  2032. * Moved pocall_internconst to po_internconst because it is not a
  2033. calling type at all and it conflicted when inlining of these small
  2034. functions was requested
  2035. Revision 1.27 2002/08/15 15:15:56 carl
  2036. * jmpbuf size allocation for exceptions is now cpu specific (as it should)
  2037. * more generic nodes for maths
  2038. * several fixes for better m68k support
  2039. Revision 1.26 2002/08/11 13:24:20 peter
  2040. * saving of asmsymbols in ppu supported
  2041. * asmsymbollist global is removed and moved into a new class
  2042. tasmlibrarydata that will hold the info of a .a file which
  2043. corresponds with a single module. Added librarydata to tmodule
  2044. to keep the library info stored for the module. In the future the
  2045. objectfiles will also be stored to the tasmlibrarydata class
  2046. * all getlabel/newasmsymbol and friends are moved to the new class
  2047. Revision 1.25 2002/05/18 13:34:27 peter
  2048. * readded missing revisions
  2049. Revision 1.24 2002/05/16 19:46:54 carl
  2050. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  2051. + try to fix temp allocation (still in ifdef)
  2052. + generic constructor calls
  2053. + start of tassembler / tmodulebase class cleanup
  2054. Revision 1.22 2002/05/12 16:53:18 peter
  2055. * moved entry and exitcode to ncgutil and cgobj
  2056. * foreach gets extra argument for passing local data to the
  2057. iterator function
  2058. * -CR checks also class typecasts at runtime by changing them
  2059. into as
  2060. * fixed compiler to cycle with the -CR option
  2061. * fixed stabs with elf writer, finally the global variables can
  2062. be watched
  2063. * removed a lot of routines from cga unit and replaced them by
  2064. calls to cgobj
  2065. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  2066. u32bit then the other is typecasted also to u32bit without giving
  2067. a rangecheck warning/error.
  2068. * fixed pascal calling method with reversing also the high tree in
  2069. the parast, detected by tcalcst3 test
  2070. Revision 1.21 2002/04/23 13:12:58 peter
  2071. * updated for posinfo change
  2072. * updated for mangledname change
  2073. * include i386 registers, removed reference to cpubase unit that would
  2074. make ppudump dependent on the source processor
  2075. Revision 1.20 2002/04/15 19:15:09 carl
  2076. + write std_reg2str instead of gas registers
  2077. Revision 1.19 2002/04/14 17:02:19 carl
  2078. + att_reg2str -> gas_reg2str
  2079. Revision 1.18 2002/04/07 10:23:36 carl
  2080. + added vm / sparc targets
  2081. Revision 1.17 2002/04/04 19:06:14 peter
  2082. * removed unused units
  2083. * use tlocation.size in cg.a_*loc*() routines
  2084. Revision 1.16 2002/04/04 18:50:27 carl
  2085. + added wdosx support (patch from Pavel)
  2086. Revision 1.15 2002/03/31 20:26:42 jonas
  2087. + a_loadfpu_* and a_loadmm_* methods in tcg
  2088. * register allocation is now handled by a class and is mostly processor
  2089. independent (+rgobj.pas and i386/rgcpu.pas)
  2090. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  2091. * some small improvements and fixes to the optimizer
  2092. * some register allocation fixes
  2093. * some fpuvaroffset fixes in the unary minus node
  2094. * push/popusedregisters is now called rg.save/restoreusedregisters and
  2095. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  2096. also better optimizable)
  2097. * fixed and optimized register saving/restoring for new/dispose nodes
  2098. * LOC_FPU locations now also require their "register" field to be set to
  2099. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  2100. - list field removed of the tnode class because it's not used currently
  2101. and can cause hard-to-find bugs
  2102. Revision 1.14 2002/03/28 20:48:52 carl
  2103. - remove go32v1 support
  2104. Revision 1.13 2002/03/28 16:44:59 armin
  2105. + new flag if unit has local threadvars
  2106. Revision 1.12 2002/03/01 14:08:47 peter
  2107. * parasym added
  2108. Revision 1.11 2002/01/06 12:08:16 peter
  2109. * removed uauto from orddef, use new range_to_basetype generating
  2110. the correct ordinal type for a range
  2111. }