ppudump.pp 60 KB

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