ppudump.pp 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182
  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. { Metrowerks Pascal. Special case on Mac OS (X): passes all }
  734. { constant records by reference. }
  735. pocall_mwpascal
  736. );
  737. tproccalloptions=set of tproccalloption;
  738. tproctypeoption=(potype_none,
  739. potype_proginit, { Program initialization }
  740. potype_unitinit, { unit initialization }
  741. potype_unitfinalize, { unit finalization }
  742. potype_constructor, { Procedure is a constructor }
  743. potype_destructor, { Procedure is a destructor }
  744. potype_operator { Procedure defines an operator }
  745. );
  746. tproctypeoptions=set of tproctypeoption;
  747. tprocoption=(po_none,
  748. po_classmethod, { class method }
  749. po_virtualmethod, { Procedure is a virtual method }
  750. po_abstractmethod, { Procedure is an abstract method }
  751. po_staticmethod, { static method }
  752. po_overridingmethod, { method with override directive }
  753. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do' }
  754. po_interrupt, { Procedure is an interrupt handler }
  755. po_iocheck, { IO checking should be done after a call to the procedure }
  756. po_assembler, { Procedure is written in assembler }
  757. po_msgstr, { method for string message handling }
  758. po_msgint, { method for int message handling }
  759. po_exports, { Procedure has export directive (needed for OS/2) }
  760. po_external, { Procedure is external (in other object or lib)}
  761. po_overload, { procedure is declared with overload directive }
  762. po_varargs, { printf like arguments }
  763. po_internconst, { procedure has constant evaluator intern }
  764. { flag that only the address of a method is returned and not a full methodpointer }
  765. po_addressonly,
  766. { procedure is exported }
  767. po_public,
  768. { calling convention is specified explicitly }
  769. po_hascallingconvention,
  770. { reintroduce flag }
  771. po_reintroduce,
  772. { location of parameters is given explicitly as it is necessary for some syscall
  773. conventions like that one of MorphOS }
  774. po_explicitparaloc,
  775. { no stackframe will be generated, used by lowlevel assembler like get_frame }
  776. po_nostackframe,
  777. po_has_mangledname,
  778. po_has_public_name,
  779. po_forward,
  780. po_global
  781. );
  782. tprocoptions=set of tprocoption;
  783. procedure read_abstract_proc_def(var proccalloption:tproccalloption;var procoptions:tprocoptions);
  784. type
  785. tproccallopt=record
  786. mask : tproccalloption;
  787. str : string[30];
  788. end;
  789. tproctypeopt=record
  790. mask : tproctypeoption;
  791. str : string[30];
  792. end;
  793. tprocopt=record
  794. mask : tprocoption;
  795. str : string[30];
  796. end;
  797. const
  798. proccalloptionStr : array[tproccalloption] of string[14]=('',
  799. 'CDecl',
  800. 'CPPDecl',
  801. 'CompilerProc',
  802. 'Far16',
  803. 'OldFPCCall',
  804. 'Inline',
  805. 'InternProc',
  806. 'SysCall',
  807. 'Pascal',
  808. 'Register',
  809. 'SafeCall',
  810. 'StdCall',
  811. 'SoftFloat',
  812. 'MWPascal'
  813. );
  814. proctypeopts=6;
  815. proctypeopt : array[1..proctypeopts] of tproctypeopt=(
  816. (mask:potype_proginit; str:'ProgInit'),
  817. (mask:potype_unitinit; str:'UnitInit'),
  818. (mask:potype_unitfinalize;str:'UnitFinalize'),
  819. (mask:potype_constructor; str:'Constructor'),
  820. (mask:potype_destructor; str:'Destructor'),
  821. (mask:potype_operator; str:'Operator')
  822. );
  823. procopts=26;
  824. procopt : array[1..procopts] of tprocopt=(
  825. (mask:po_classmethod; str:'ClassMethod'),
  826. (mask:po_virtualmethod; str:'VirtualMethod'),
  827. (mask:po_abstractmethod; str:'AbstractMethod'),
  828. (mask:po_staticmethod; str:'StaticMethod'),
  829. (mask:po_overridingmethod;str:'OverridingMethod'),
  830. (mask:po_methodpointer; str:'MethodPointer'),
  831. (mask:po_interrupt; str:'Interrupt'),
  832. (mask:po_iocheck; str:'IOCheck'),
  833. (mask:po_assembler; str:'Assembler'),
  834. (mask:po_msgstr; str:'MsgStr'),
  835. (mask:po_msgint; str:'MsgInt'),
  836. (mask:po_exports; str:'Exports'),
  837. (mask:po_external; str:'External'),
  838. (mask:po_overload; str:'Overload'),
  839. (mask:po_varargs; str:'VarArgs'),
  840. (mask:po_internconst; str:'InternConst'),
  841. (mask:po_addressonly; str:'AddressOnly'),
  842. (mask:po_public; str:'Public'),
  843. (mask:po_hascallingconvention;str:'HasCallingConvention'),
  844. (mask:po_reintroduce; str:'ReIntroduce'),
  845. (mask:po_explicitparaloc; str:'ExplicitParaloc'),
  846. (mask:po_nostackframe; str:'NoStackFrame'),
  847. (mask:po_has_mangledname; str:'HasMangledName'),
  848. (mask:po_has_public_name; str:'HasPublicName'),
  849. (mask:po_forward; str:'Forward'),
  850. (mask:po_global; str:'Global')
  851. );
  852. var
  853. proctypeoption : tproctypeoption;
  854. i : longint;
  855. first : boolean;
  856. tempbuf : array[0..255] of byte;
  857. begin
  858. write(space,' Return type : ');
  859. readtype;
  860. writeln(space,' Fpu used : ',ppufile.getbyte);
  861. proctypeoption:=tproctypeoption(ppufile.getbyte);
  862. if proctypeoption<>potype_none then
  863. begin
  864. write(space,' TypeOption : ');
  865. first:=true;
  866. for i:=1 to proctypeopts do
  867. if (proctypeopt[i].mask=proctypeoption) then
  868. begin
  869. if first then
  870. first:=false
  871. else
  872. write(', ');
  873. write(proctypeopt[i].str);
  874. end;
  875. writeln;
  876. end;
  877. proccalloption:=tproccalloption(ppufile.getbyte);
  878. writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
  879. ppufile.getsmallset(procoptions);
  880. if procoptions<>[] then
  881. begin
  882. write(space,' Options : ');
  883. first:=true;
  884. for i:=1to procopts do
  885. if (procopt[i].mask in procoptions) then
  886. begin
  887. if first then
  888. first:=false
  889. else
  890. write(', ');
  891. write(procopt[i].str);
  892. end;
  893. writeln;
  894. end;
  895. if (po_explicitparaloc in procoptions) then
  896. begin
  897. i:=ppufile.getbyte;
  898. ppufile.getdata(tempbuf,i);
  899. end;
  900. end;
  901. type
  902. { options for variables }
  903. tvaroption=(vo_none,
  904. vo_is_C_var,
  905. vo_is_external,
  906. vo_is_dll_var,
  907. vo_is_thread_var,
  908. vo_has_local_copy,
  909. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  910. vo_is_exported,
  911. vo_is_high_para,
  912. vo_is_funcret,
  913. vo_is_self,
  914. vo_is_vmt,
  915. vo_is_result, { special result variable }
  916. vo_is_parentfp,
  917. vo_is_loop_counter, { used to detect assignments to loop counter }
  918. vo_is_hidden_para,
  919. vo_has_explicit_paraloc,
  920. vo_is_syscall_lib,
  921. vo_has_mangledname
  922. );
  923. tvaroptions=set of tvaroption;
  924. { register variable }
  925. tvarregable=(vr_none,
  926. vr_intreg,
  927. vr_fpureg,
  928. vr_mmreg
  929. );
  930. procedure readabstractvarsym(const s:string;var varoptions:tvaroptions);
  931. type
  932. tvaropt=record
  933. mask : tvaroption;
  934. str : string[30];
  935. end;
  936. const
  937. varopts=18;
  938. varopt : array[1..varopts] of tvaropt=(
  939. (mask:vo_is_C_var; str:'CVar'),
  940. (mask:vo_is_external; str:'External'),
  941. (mask:vo_is_dll_var; str:'DLLVar'),
  942. (mask:vo_is_thread_var; str:'ThreadVar'),
  943. (mask:vo_has_local_copy; str:'HasLocalCopy'),
  944. (mask:vo_is_const; str:'Constant'),
  945. (mask:vo_is_exported; str:'Exported'),
  946. (mask:vo_is_high_para; str:'HighValue'),
  947. (mask:vo_is_funcret; str:'Funcret'),
  948. (mask:vo_is_self; str:'Self'),
  949. (mask:vo_is_vmt; str:'VMT'),
  950. (mask:vo_is_result; str:'Result'),
  951. (mask:vo_is_parentfp; str:'ParentFP'),
  952. (mask:vo_is_loop_counter; str:'LoopCounter'),
  953. (mask:vo_is_hidden_para; str:'Hidden'),
  954. (mask:vo_has_explicit_paraloc;str:'ExplicitParaloc'),
  955. (mask:vo_is_syscall_lib; str:'SysCallLib'),
  956. (mask:vo_has_mangledname; str:'HasMangledName')
  957. );
  958. var
  959. i : longint;
  960. first : boolean;
  961. begin
  962. readcommonsym(s);
  963. writeln(space,' Spez : ',Varspez2Str(ppufile.getbyte));
  964. writeln(space,' Regable : ',Varregable2Str(ppufile.getbyte));
  965. write (space,' Var Type : ');
  966. readtype;
  967. ppufile.getsmallset(varoptions);
  968. if varoptions<>[] then
  969. begin
  970. write(space,' Options : ');
  971. first:=true;
  972. for i:=1to varopts do
  973. if (varopt[i].mask in varoptions) then
  974. begin
  975. if first then
  976. first:=false
  977. else
  978. write(', ');
  979. write(varopt[i].str);
  980. end;
  981. writeln;
  982. end;
  983. end;
  984. procedure readnodetree;
  985. var
  986. l : longint;
  987. p : pointer;
  988. begin
  989. with ppufile do
  990. begin
  991. if space<>'' then
  992. Writeln(space,'------ nodetree ------');
  993. if readentry=ibnodetree then
  994. begin
  995. l:=entrysize;
  996. Writeln(space,'Tree size : ',l);
  997. { Read data to prevent error that entry is not completly read }
  998. getmem(p,l);
  999. getdata(p^,l);
  1000. freemem(p);
  1001. end
  1002. else
  1003. begin
  1004. Writeln('!! ibnodetree not found');
  1005. end;
  1006. end;
  1007. end;
  1008. {****************************************************************************
  1009. Read Symbols Part
  1010. ****************************************************************************}
  1011. procedure readsymbols(const s:string);
  1012. type
  1013. pguid = ^tguid;
  1014. tguid = packed record
  1015. D1: LongWord;
  1016. D2: Word;
  1017. D3: Word;
  1018. D4: array[0..7] of Byte;
  1019. end;
  1020. absolutetyp = (tovar,toasm,toaddr);
  1021. tconsttyp = (constnone,
  1022. constord,conststring,constreal,
  1023. constset,constpointer,constnil,
  1024. constresourcestring,constwstring,constguid
  1025. );
  1026. var
  1027. b : byte;
  1028. pc : pchar;
  1029. totalsyms,
  1030. symcnt,
  1031. i,j,len : longint;
  1032. guid : tguid;
  1033. tempbuf : array[0..127] of char;
  1034. varoptions : tvaroptions;
  1035. begin
  1036. symcnt:=1;
  1037. with ppufile do
  1038. begin
  1039. if space<>'' then
  1040. Writeln(space,'------ ',s,' ------');
  1041. if readentry=ibstartsyms then
  1042. begin
  1043. totalsyms:=getlongint;
  1044. Writeln(space,'Number of symbols : ',totalsyms);
  1045. Writeln(space,'Symtable datasize : ',getlongint);
  1046. Writeln(space,'Symtable alignment: ',getlongint);
  1047. end
  1048. else
  1049. begin
  1050. totalsyms:=-1;
  1051. Writeln('!! ibstartsym not found');
  1052. end;
  1053. repeat
  1054. b:=readentry;
  1055. if not (b in [iberror,ibendsyms]) then
  1056. inc(symcnt);
  1057. case b of
  1058. ibunitsym :
  1059. readcommonsym('Unit symbol ');
  1060. iblabelsym :
  1061. readcommonsym('Label symbol ');
  1062. ibtypesym :
  1063. begin
  1064. readcommonsym('Type symbol ');
  1065. write(space,' Result Type : ');
  1066. readtype;
  1067. end;
  1068. ibprocsym :
  1069. begin
  1070. readcommonsym('Procedure symbol ');
  1071. len:=ppufile.getword;
  1072. for i:=1 to len do
  1073. begin
  1074. write(space,' Definition : ');
  1075. readderef;
  1076. end;
  1077. end;
  1078. ibconstsym :
  1079. begin
  1080. readcommonsym('Constant symbol ');
  1081. b:=getbyte;
  1082. case tconsttyp(b) of
  1083. constord :
  1084. begin
  1085. write (space,' OrdinalType : ');
  1086. readtype;
  1087. writeln(space,' Value : ',getint64);
  1088. end;
  1089. constpointer :
  1090. begin
  1091. write (space,' PointerType : ');
  1092. readtype;
  1093. writeln(space,' Value : ',getlongint)
  1094. end;
  1095. conststring,
  1096. constresourcestring :
  1097. begin
  1098. len:=getlongint;
  1099. getmem(pc,len+1);
  1100. getdata(pc^,len);
  1101. (pc+len)^:= #0;
  1102. writeln(space,' Length : ',len);
  1103. writeln(space,' Value : "',pc,'"');
  1104. freemem(pc,len+1);
  1105. if tconsttyp(b)=constresourcestring then
  1106. writeln(space,' Index : ',getlongint);
  1107. end;
  1108. constreal :
  1109. writeln(space,' Value : ',getreal);
  1110. constset :
  1111. begin
  1112. write (space,' Set Type : ');
  1113. readtype;
  1114. for i:=1to 4 do
  1115. begin
  1116. write (space,' Value : ');
  1117. for j:=1to 8 do
  1118. begin
  1119. if j>1 then
  1120. write(',');
  1121. write(hexb(getbyte));
  1122. end;
  1123. writeln;
  1124. end;
  1125. end;
  1126. constwstring:
  1127. begin
  1128. end;
  1129. constguid:
  1130. begin
  1131. getdata(guid,sizeof(guid));
  1132. write (space,' IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-');
  1133. for i:=0 to 7 do
  1134. begin
  1135. write(hexstr(guid.d4[i],2));
  1136. if i=1 then write('-');
  1137. end;
  1138. writeln('}');
  1139. end
  1140. else
  1141. Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
  1142. end;
  1143. end;
  1144. ibabsolutevarsym :
  1145. begin
  1146. readabstractvarsym('Absolute variable symbol ',varoptions);
  1147. Write (space,' Relocated to ');
  1148. b:=getbyte;
  1149. case absolutetyp(b) of
  1150. tovar :
  1151. readsymlist(space+' Sym : ');
  1152. toasm :
  1153. Writeln('Assembler name : ',getstring);
  1154. toaddr :
  1155. begin
  1156. Write('Address : ',getlongint);
  1157. if tsystemcpu(ppufile.header.cpu)=cpu_i386 then
  1158. WriteLn(' (Far: ',getbyte<>0,')');
  1159. end;
  1160. else
  1161. Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
  1162. end;
  1163. end;
  1164. ibfieldvarsym :
  1165. begin
  1166. readabstractvarsym('Field Variable symbol ',varoptions);
  1167. writeln(space,' Address : ',getlongint);
  1168. end;
  1169. ibglobalvarsym :
  1170. begin
  1171. readabstractvarsym('Global Variable symbol ',varoptions);
  1172. write (space,' DefaultConst : ');
  1173. readderef;
  1174. if (vo_has_mangledname in varoptions) then
  1175. writeln(space,' Mangledname : ',getstring);
  1176. end;
  1177. iblocalvarsym :
  1178. begin
  1179. readabstractvarsym('Local Variable symbol ',varoptions);
  1180. write (space,' DefaultConst : ');
  1181. readderef;
  1182. end;
  1183. ibparavarsym :
  1184. begin
  1185. readabstractvarsym('Parameter Variable symbol ',varoptions);
  1186. write (space,' DefaultConst : ');
  1187. readderef;
  1188. writeln(space,' ParaNr : ',getword);
  1189. if (vo_has_explicit_paraloc in varoptions) then
  1190. begin
  1191. i:=getbyte;
  1192. getdata(tempbuf,i);
  1193. end;
  1194. end;
  1195. ibenumsym :
  1196. begin
  1197. readcommonsym('Enumeration symbol ');
  1198. write (space,' Definition : ');
  1199. readderef;
  1200. writeln(space,' Value : ',getlongint);
  1201. end;
  1202. ibsyssym :
  1203. begin
  1204. readcommonsym('Internal system symbol ');
  1205. writeln(space,' Internal Nr : ',getlongint);
  1206. end;
  1207. ibrttisym :
  1208. begin
  1209. readcommonsym('RTTI symbol ');
  1210. writeln(space,' RTTI Type : ',getbyte);
  1211. end;
  1212. ibmacrosym :
  1213. begin
  1214. readcommonsym('Macro symbol ');
  1215. writeln(space,' Name: ',getstring);
  1216. writeln(space,' Defined: ',getbyte);
  1217. writeln(space,' Compiler var: ',getbyte);
  1218. len:=getlongint;
  1219. writeln(space,' Value length: ',len);
  1220. if len > 0 then
  1221. begin
  1222. getmem(pc,len+1);
  1223. getdata(pc^,len);
  1224. (pc+len)^:= #0;
  1225. writeln(space,' Value: "',pc,'"');
  1226. freemem(pc,len+1);
  1227. end;
  1228. end;
  1229. ibtypedconstsym :
  1230. begin
  1231. readcommonsym('Typed constant ');
  1232. write (space,' Constant Type : ');
  1233. readtype;
  1234. writeln(space,' ReallyConst : ',(getbyte<>0));
  1235. end;
  1236. ibpropertysym :
  1237. begin
  1238. readcommonsym('Property ');
  1239. i:=getlongint;
  1240. writeln(space,' PropOptions : ',i);
  1241. if (i and 32)>0 then
  1242. begin
  1243. write (space,' OverrideProp : ');
  1244. readderef;
  1245. end
  1246. else
  1247. begin
  1248. write (space,' Prop Type : ');
  1249. readtype;
  1250. writeln(space,' Index : ',getlongint);
  1251. writeln(space,' Default : ',getlongint);
  1252. write (space,' Index Type : ');
  1253. readtype;
  1254. write (space,' Readaccess : ');
  1255. readsymlist(space+' Sym: ');
  1256. write (space,' Writeaccess : ');
  1257. readsymlist(space+' Sym: ');
  1258. write (space,' Storedaccess : ');
  1259. readsymlist(space+' Sym: ');
  1260. end;
  1261. end;
  1262. iberror :
  1263. begin
  1264. Writeln('!! Error in PPU');
  1265. exit;
  1266. end;
  1267. ibendsyms :
  1268. break;
  1269. else
  1270. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  1271. end;
  1272. if not EndOfEntry then
  1273. Writeln('!! Entry has more information stored');
  1274. until false;
  1275. if (totalsyms<>-1) and (symcnt-1<>totalsyms) then
  1276. Writeln('!! Only read ',symcnt-1,' of ',totalsyms,' symbols');
  1277. end;
  1278. end;
  1279. {****************************************************************************
  1280. Read defintions Part
  1281. ****************************************************************************}
  1282. procedure readdefinitions(const s:string;start_read : boolean);
  1283. type
  1284. tsettype = (normset,smallset,varset);
  1285. tbasetype = (
  1286. uvoid,
  1287. u8bit,u16bit,u32bit,u64bit,
  1288. s8bit,s16bit,s32bit,s64bit,
  1289. bool8bit,bool16bit,bool32bit,
  1290. uchar,uwidechar
  1291. );
  1292. tobjectdeftype = (odt_none,
  1293. odt_class,
  1294. odt_object,
  1295. odt_interfacecom,
  1296. odt_interfacecorba,
  1297. odt_cppclass
  1298. );
  1299. tvarianttype = (
  1300. vt_normalvariant,vt_olevariant
  1301. );
  1302. var
  1303. b : byte;
  1304. totaldefs,l,j,
  1305. defcnt : longint;
  1306. calloption : tproccalloption;
  1307. procoptions : tprocoptions;
  1308. procinfooptions : tprocinfoflag;
  1309. begin
  1310. defcnt:=0;
  1311. with ppufile do
  1312. begin
  1313. if space<>'' then
  1314. Writeln(space,'------ ',s,' ------');
  1315. if not start_read then
  1316. if readentry=ibstartdefs then
  1317. begin
  1318. totaldefs:=getlongint;
  1319. Writeln(space,'Number of definitions: ',totaldefs);
  1320. end
  1321. else
  1322. begin
  1323. totaldefs:=-1;
  1324. Writeln('!! ibstartdef not found');
  1325. end;
  1326. repeat
  1327. b:=readentry;
  1328. if not (b in [iberror,ibenddefs]) then
  1329. inc(defcnt);
  1330. case b of
  1331. ibpointerdef :
  1332. begin
  1333. readcommondef('Pointer definition');
  1334. write (space,' Pointed Type : ');
  1335. readtype;
  1336. writeln(space,' Is Far : ',(getbyte<>0));
  1337. end;
  1338. iborddef :
  1339. begin
  1340. readcommondef('Ordinal definition');
  1341. write (space,' Base type : ');
  1342. b:=getbyte;
  1343. case tbasetype(b) of
  1344. uvoid : writeln('uvoid');
  1345. u8bit : writeln('u8bit');
  1346. u16bit : writeln('u16bit');
  1347. u32bit : writeln('s32bit');
  1348. u64bit : writeln('u64bit');
  1349. s8bit : writeln('s8bit');
  1350. s16bit : writeln('s16bit');
  1351. s32bit : writeln('s32bit');
  1352. s64bit : writeln('s64bit');
  1353. bool8bit : writeln('bool8bit');
  1354. bool16bit : writeln('bool16bit');
  1355. bool32bit : writeln('bool32bit');
  1356. uchar : writeln('uchar');
  1357. uwidechar : writeln('uwidechar');
  1358. else writeln('!! Warning: Invalid base type ',b);
  1359. end;
  1360. writeln(space,' Range : ',getint64,' to ',getint64);
  1361. end;
  1362. ibfloatdef :
  1363. begin
  1364. readcommondef('Float definition');
  1365. writeln(space,' Float type : ',getbyte);
  1366. end;
  1367. ibarraydef :
  1368. begin
  1369. readcommondef('Array definition');
  1370. write (space,' Element type : ');
  1371. readtype;
  1372. write (space,' Range Type : ');
  1373. readtype;
  1374. writeln(space,' Range : ',getlongint,' to ',getlongint);
  1375. writeln(space,' Is Constructor : ',(getbyte<>0));
  1376. writeln(space,' Is Dynamic : ',(getbyte<>0));
  1377. end;
  1378. ibprocdef :
  1379. begin
  1380. readcommondef('Procedure definition');
  1381. read_abstract_proc_def(calloption,procoptions);
  1382. if (po_has_mangledname in procoptions) then
  1383. writeln(space,' Mangled name : ',getstring);
  1384. writeln(space,' Number : ',getword);
  1385. writeln(space,' Level : ',getbyte);
  1386. write (space,' Class : ');
  1387. readderef;
  1388. write (space,' Procsym : ');
  1389. readderef;
  1390. write (space,' File Pos : ');
  1391. readposinfo;
  1392. write (space,' SymOptions : ');
  1393. readsymoptions;
  1394. if tsystemcpu(ppufile.header.cpu)=cpu_powerpc then
  1395. begin
  1396. { library symbol for AmigaOS/MorphOS }
  1397. write (space,' Library symbol : ');
  1398. readderef;
  1399. end;
  1400. if (calloption=pocall_inline) then
  1401. begin
  1402. write (space,' FuncretSym : ');
  1403. readderef;
  1404. ppufile.getsmallset(procinfooptions);
  1405. writeln(space,' ProcInfoOptions : ',dword(procinfooptions));
  1406. b := ppufile.getbyte;
  1407. writeln(space,' Inline node tree : ',b);
  1408. end;
  1409. if not EndOfEntry then
  1410. Writeln('!! Entry has more information stored');
  1411. space:=' '+space;
  1412. { parast }
  1413. readdefinitions('parast',false);
  1414. readsymbols('parast');
  1415. { localst }
  1416. if (calloption = pocall_inline) then
  1417. begin
  1418. readdefinitions('localst',false);
  1419. readsymbols('localst');
  1420. end;
  1421. if (calloption=pocall_inline) then
  1422. readnodetree;
  1423. delete(space,1,4);
  1424. end;
  1425. ibprocvardef :
  1426. begin
  1427. readcommondef('Procedural type (ProcVar) definition');
  1428. read_abstract_proc_def(calloption,procoptions);
  1429. if not EndOfEntry then
  1430. Writeln('!! Entry has more information stored');
  1431. space:=' '+space;
  1432. { parast }
  1433. readdefinitions('parast',false);
  1434. readsymbols('parast');
  1435. delete(space,1,4);
  1436. end;
  1437. ibshortstringdef :
  1438. begin
  1439. readcommondef('ShortString definition');
  1440. writeln(space,' Length : ',getbyte);
  1441. end;
  1442. ibwidestringdef :
  1443. begin
  1444. readcommondef('WideString definition');
  1445. writeln(space,' Length : ',getlongint);
  1446. end;
  1447. ibansistringdef :
  1448. begin
  1449. readcommondef('AnsiString definition');
  1450. writeln(space,' Length : ',getlongint);
  1451. end;
  1452. iblongstringdef :
  1453. begin
  1454. readcommondef('Longstring definition');
  1455. writeln(space,' Length : ',getlongint);
  1456. end;
  1457. ibrecorddef :
  1458. begin
  1459. readcommondef('Record definition');
  1460. writeln(space,' DataSize : ',getlongint);
  1461. writeln(space,' FieldAlign : ',getbyte);
  1462. writeln(space,' RecordAlign : ',getbyte);
  1463. writeln(space,' PadAlign : ',getbyte);
  1464. if not EndOfEntry then
  1465. Writeln('!! Entry has more information stored');
  1466. {read the record definitions and symbols}
  1467. space:=' '+space;
  1468. readdefinitions('fields',false);
  1469. readsymbols('fields');
  1470. Delete(space,1,4);
  1471. end;
  1472. ibobjectdef :
  1473. begin
  1474. readcommondef('Object/Class definition');
  1475. b:=getbyte;
  1476. write (space,' Type : ');
  1477. case tobjectdeftype(b) of
  1478. odt_class : writeln('class');
  1479. odt_object : writeln('object');
  1480. odt_interfacecom : writeln('interfacecom');
  1481. odt_interfacecorba : writeln('interfacecorba');
  1482. odt_cppclass : writeln('cppclass');
  1483. else writeln('!! Warning: Invalid object type ',b);
  1484. end;
  1485. writeln(space,' Name of Class : ',getstring);
  1486. writeln(space,' DataSize : ',getlongint);
  1487. writeln(space,' FieldAlign : ',getbyte);
  1488. writeln(space,' RecordAlign : ',getbyte);
  1489. writeln(space,' Vmt offset : ',getlongint);
  1490. write(space, ' Ancestor Class : ');
  1491. readderef;
  1492. writeln(space,' Options : ',getlongint);
  1493. if tobjectdeftype(b) in [odt_interfacecom,odt_interfacecorba] then
  1494. begin
  1495. { IIDGUID }
  1496. for j:=1to 16 do
  1497. getbyte;
  1498. writeln(space,' IID String : ',getstring);
  1499. writeln(space,' Last VTable idx : ',getlongint);
  1500. end;
  1501. if tobjectdeftype(b) in [odt_class,odt_interfacecorba] then
  1502. begin
  1503. l:=getlongint;
  1504. writeln(space,' Impl Intf Count : ',l);
  1505. for j:=1 to l do
  1506. begin
  1507. write (space,' - Definition : ');
  1508. readderef;
  1509. writeln(space,' IOffset : ',getlongint);
  1510. end;
  1511. end;
  1512. if not EndOfEntry then
  1513. Writeln('!! Entry has more information stored');
  1514. {read the record definitions and symbols}
  1515. space:=' '+space;
  1516. readdefinitions('fields',false);
  1517. readsymbols('fields');
  1518. Delete(space,1,4);
  1519. end;
  1520. ibfiledef :
  1521. begin
  1522. ReadCommonDef('File definition');
  1523. write (space,' Type : ');
  1524. case getbyte of
  1525. 0 : writeln('Text');
  1526. 1 : begin
  1527. writeln('Typed');
  1528. write (space,' File of Type : ');
  1529. Readtype;
  1530. end;
  1531. 2 : writeln('Untyped');
  1532. end;
  1533. end;
  1534. ibformaldef :
  1535. readcommondef('Generic Definition (void-typ)');
  1536. ibenumdef :
  1537. begin
  1538. readcommondef('Enumeration type definition');
  1539. write(space,'Base enumeration type : ');
  1540. readderef;
  1541. writeln(space,' Smallest element : ',getlongint);
  1542. writeln(space,' Largest element : ',getlongint);
  1543. writeln(space,' Size : ',getlongint);
  1544. end;
  1545. ibclassrefdef :
  1546. begin
  1547. readcommondef('Class reference definition');
  1548. write (space,' Pointed Type : ');
  1549. readtype;
  1550. end;
  1551. ibsetdef :
  1552. begin
  1553. readcommondef('Set definition');
  1554. write (space,' Element type : ');
  1555. readtype;
  1556. b:=getbyte;
  1557. case tsettype(b) of
  1558. smallset : writeln(space,' Set with 32 Elements');
  1559. normset : writeln(space,' Set with 256 Elements');
  1560. varset : writeln(space,' Set with ',getlongint,' Elements');
  1561. else writeln('!! Warning: Invalid set type ',b);
  1562. end;
  1563. end;
  1564. ibvariantdef :
  1565. begin
  1566. readcommondef('Variant definition');
  1567. write (space,' Varianttype : ');
  1568. b:=getbyte;
  1569. case tvarianttype(b) of
  1570. vt_normalvariant :
  1571. writeln('Normal');
  1572. vt_olevariant :
  1573. writeln('OLE');
  1574. else
  1575. writeln('!! Warning: Invalid varianttype ',b);
  1576. end;
  1577. end;
  1578. iberror :
  1579. begin
  1580. Writeln('!! Error in PPU');
  1581. exit;
  1582. end;
  1583. ibenddefs :
  1584. break;
  1585. else
  1586. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  1587. end;
  1588. if not EndOfEntry then
  1589. Writeln('!! Entry has more information stored');
  1590. until false;
  1591. if (totaldefs<>-1) and (defcnt<>totaldefs) then
  1592. Writeln('!! Only read ',defcnt,' of ',totaldefs,' definitions');
  1593. end;
  1594. end;
  1595. {****************************************************************************
  1596. Read General Part
  1597. ****************************************************************************}
  1598. procedure readinterface;
  1599. var
  1600. b : byte;
  1601. sourcenumber : longint;
  1602. begin
  1603. with ppufile do
  1604. begin
  1605. repeat
  1606. b:=readentry;
  1607. case b of
  1608. ibmodulename :
  1609. Writeln('Module Name: ',getstring);
  1610. ibsourcefiles :
  1611. begin
  1612. sourcenumber:=1;
  1613. while not EndOfEntry do
  1614. begin
  1615. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  1616. inc(sourcenumber);
  1617. end;
  1618. end;
  1619. {$IFDEF MACRO_DIFF_HINT}
  1620. ibusedmacros :
  1621. begin
  1622. while not EndOfEntry do
  1623. begin
  1624. Write('Conditional ',getstring);
  1625. b:=getbyte;
  1626. if boolean(b)=true then
  1627. write(' defined at startup')
  1628. else
  1629. write(' not defined at startup');
  1630. b:=getbyte;
  1631. if boolean(b)=true then
  1632. writeln(' was used')
  1633. else
  1634. writeln;
  1635. end;
  1636. end;
  1637. {$ENDIF}
  1638. ibloadunit :
  1639. ReadLoadUnit;
  1640. iblinkunitofiles :
  1641. ReadLinkContainer('Link unit object file: ');
  1642. iblinkunitstaticlibs :
  1643. ReadLinkContainer('Link unit static lib: ');
  1644. iblinkunitsharedlibs :
  1645. ReadLinkContainer('Link unit shared lib: ');
  1646. iblinkotherofiles :
  1647. ReadLinkContainer('Link other object file: ');
  1648. iblinkotherstaticlibs :
  1649. ReadLinkContainer('Link other static lib: ');
  1650. iblinkothersharedlibs :
  1651. ReadLinkContainer('Link other shared lib: ');
  1652. ibderefdata :
  1653. ReadDerefData;
  1654. ibderefmap :
  1655. ReadDerefMap;
  1656. iberror :
  1657. begin
  1658. Writeln('Error in PPU');
  1659. exit;
  1660. end;
  1661. ibendinterface :
  1662. break;
  1663. else
  1664. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  1665. end;
  1666. until false;
  1667. end;
  1668. end;
  1669. {****************************************************************************
  1670. Read Implementation Part
  1671. ****************************************************************************}
  1672. procedure readimplementation;
  1673. var
  1674. b : byte;
  1675. begin
  1676. with ppufile do
  1677. begin
  1678. repeat
  1679. b:=readentry;
  1680. case b of
  1681. ibasmsymbols :
  1682. ReadAsmSymbols;
  1683. ibloadunit :
  1684. ReadLoadUnit;
  1685. iberror :
  1686. begin
  1687. Writeln('Error in PPU');
  1688. exit;
  1689. end;
  1690. ibendimplementation :
  1691. break;
  1692. else
  1693. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  1694. end;
  1695. until false;
  1696. end;
  1697. end;
  1698. {****************************************************************************
  1699. Read Browser Part
  1700. ****************************************************************************}
  1701. procedure readbrowser;
  1702. var
  1703. b : byte;
  1704. const indent : string = '';
  1705. begin
  1706. Writeln(indent,'Start of symtable browser');
  1707. indent:=indent+'**';
  1708. with ppufile do
  1709. begin
  1710. repeat
  1711. b:=readentry;
  1712. case b of
  1713. ibbeginsymtablebrowser :
  1714. begin
  1715. { here we must read object and record symtables !! }
  1716. indent:=indent+' ';
  1717. Writeln(indent,'Record/Object symtable');
  1718. readbrowser;
  1719. Indent:=Copy(Indent,1,Length(Indent)-2);
  1720. end;
  1721. ibsymref :
  1722. begin
  1723. readderef;
  1724. readref;
  1725. end;
  1726. ibdefref :
  1727. begin
  1728. readderef;
  1729. readref;
  1730. if ((ppufile.header.flags and uf_local_browser)<>0) and
  1731. (UnitIndex=0) then
  1732. begin
  1733. { parast and localst }
  1734. indent:=indent+' ';
  1735. b:=ppufile.readentry;
  1736. if b=ibbeginsymtablebrowser then
  1737. readbrowser;
  1738. b:=ppufile.readentry;
  1739. if b=ibbeginsymtablebrowser then
  1740. readbrowser;
  1741. Indent:=Copy(Indent,1,Length(Indent)-2);
  1742. end;
  1743. end;
  1744. iberror :
  1745. begin
  1746. Writeln('Error in PPU');
  1747. exit;
  1748. end;
  1749. ibendsymtablebrowser :
  1750. break;
  1751. else
  1752. begin
  1753. WriteLn('!! Skipping unsupported PPU Entry in Browser: ',b);
  1754. Halt;
  1755. end;
  1756. end;
  1757. until false;
  1758. end;
  1759. Indent:=Copy(Indent,1,Length(Indent)-2);
  1760. Writeln(Indent,'End of symtable browser');
  1761. end;
  1762. procedure dofile (filename : string);
  1763. var
  1764. b : byte;
  1765. begin
  1766. { reset }
  1767. space:='';
  1768. { fix filename }
  1769. if pos('.',filename)=0 then
  1770. filename:=filename+'.ppu';
  1771. ppufile:=tppufile.create(filename);
  1772. if not ppufile.openfile then
  1773. begin
  1774. writeln ('IO-Error when opening : ',filename,', Skipping');
  1775. exit;
  1776. end;
  1777. { PPU File is open, check for PPU Id }
  1778. if not ppufile.CheckPPUID then
  1779. begin
  1780. writeln(Filename,' : Not a valid PPU file, Skipping');
  1781. exit;
  1782. end;
  1783. { Check PPU Version }
  1784. Writeln('Analyzing ',filename,' (v',ppufile.GetPPUVersion,')');
  1785. if ppufile.GetPPUVersion<16 then
  1786. begin
  1787. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  1788. exit;
  1789. end;
  1790. { Write PPU Header Information }
  1791. if (verbose and v_header)<>0 then
  1792. begin
  1793. Writeln;
  1794. Writeln('Header');
  1795. Writeln('-------');
  1796. with ppufile.header do
  1797. begin
  1798. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  1799. (ppufile.header.compiler shr 7) and $7f,'.',
  1800. ppufile.header.compiler and $7f);
  1801. WriteLn('Target processor : ',Cpu2Str(cpu));
  1802. WriteLn('Target operating system : ',Target2Str(target));
  1803. Writeln('Unit flags : ',PPUFlags2Str(flags));
  1804. Writeln('FileSize (w/o header) : ',size);
  1805. Writeln('Checksum : ',hexstr(checksum,8));
  1806. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  1807. end;
  1808. end;
  1809. {read the general stuff}
  1810. if (verbose and v_interface)<>0 then
  1811. begin
  1812. Writeln;
  1813. Writeln('Interface section');
  1814. Writeln('------------------');
  1815. readinterface;
  1816. end
  1817. else
  1818. ppufile.skipuntilentry(ibendinterface);
  1819. {read the definitions}
  1820. if (verbose and v_defs)<>0 then
  1821. begin
  1822. Writeln;
  1823. Writeln('Interface definitions');
  1824. Writeln('----------------------');
  1825. readdefinitions('interface',false);
  1826. end
  1827. else
  1828. ppufile.skipuntilentry(ibenddefs);
  1829. {read the symbols}
  1830. if (verbose and v_syms)<>0 then
  1831. begin
  1832. Writeln;
  1833. Writeln('Interface Symbols');
  1834. Writeln('------------------');
  1835. readsymbols('interface');
  1836. end
  1837. else
  1838. ppufile.skipuntilentry(ibendsyms);
  1839. {read the macro symbols}
  1840. if (verbose and v_syms)<>0 then
  1841. begin
  1842. Writeln;
  1843. Writeln('Interface Macro Symbols');
  1844. Writeln('-----------------------');
  1845. end;
  1846. if ppufile.readentry<>ibexportedmacros then
  1847. begin
  1848. Writeln('!! Error in PPU');
  1849. exit;
  1850. end;
  1851. if boolean(ppufile.getbyte) then
  1852. begin
  1853. {skip the definition section for macros (since they are never used) }
  1854. ppufile.skipuntilentry(ibenddefs);
  1855. {read the macro symbols}
  1856. if (verbose and v_syms)<>0 then
  1857. readsymbols('interface macro')
  1858. else
  1859. ppufile.skipuntilentry(ibendsyms);
  1860. end
  1861. else
  1862. Writeln('(no exported macros)');
  1863. {read the implementation stuff}
  1864. if (verbose and v_implementation)<>0 then
  1865. begin
  1866. Writeln;
  1867. Writeln('Implementation section');
  1868. Writeln('-----------------------');
  1869. readimplementation;
  1870. end
  1871. else
  1872. ppufile.skipuntilentry(ibendimplementation);
  1873. {read the static browser units stuff}
  1874. if (ppufile.header.flags and uf_local_symtable)<>0 then
  1875. begin
  1876. if (verbose and v_defs)<>0 then
  1877. begin
  1878. Writeln;
  1879. Writeln('Static definitions');
  1880. Writeln('----------------------');
  1881. readdefinitions('implementation',false);
  1882. end
  1883. else
  1884. ppufile.skipuntilentry(ibenddefs);
  1885. {read the symbols}
  1886. if (verbose and v_syms)<>0 then
  1887. begin
  1888. Writeln;
  1889. Writeln('Static Symbols');
  1890. Writeln('------------------');
  1891. readsymbols('implementation');
  1892. end
  1893. else
  1894. ppufile.skipuntilentry(ibendsyms);
  1895. end;
  1896. {read the browser units stuff}
  1897. if (ppufile.header.flags and uf_has_browser)<>0 then
  1898. begin
  1899. if (verbose and v_browser)<>0 then
  1900. begin
  1901. Writeln;
  1902. Writeln('Browser section');
  1903. Writeln('---------------');
  1904. UnitIndex:=0;
  1905. repeat
  1906. b:=ppufile.readentry;
  1907. if b = ibendbrowser then break;
  1908. if b=ibbeginsymtablebrowser then
  1909. begin
  1910. Writeln('Unit ',UnitIndex);
  1911. readbrowser;
  1912. Inc(UnitIndex);
  1913. end
  1914. else
  1915. Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
  1916. until false;
  1917. end;
  1918. end;
  1919. {read the static browser units stuff}
  1920. if (ppufile.header.flags and uf_local_browser)<>0 then
  1921. begin
  1922. if (verbose and v_browser)<>0 then
  1923. begin
  1924. Writeln;
  1925. Writeln('Static browser section');
  1926. Writeln('---------------');
  1927. UnitIndex:=0;
  1928. b:=ppufile.readentry;
  1929. if b=ibbeginsymtablebrowser then
  1930. readbrowser
  1931. else
  1932. Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
  1933. end;
  1934. end;
  1935. {shutdown ppufile}
  1936. ppufile.closefile;
  1937. ppufile.free;
  1938. Writeln;
  1939. end;
  1940. procedure help;
  1941. begin
  1942. writeln('usage: ppudump [options] <filename1> <filename2>...');
  1943. writeln;
  1944. writeln('[options] can be:');
  1945. writeln(' -V<verbose> Set verbosity to <verbose>');
  1946. writeln(' H - Show header info');
  1947. writeln(' I - Show interface');
  1948. writeln(' M - Show implementation');
  1949. writeln(' S - Show interface symbols');
  1950. writeln(' D - Show interface definitions');
  1951. writeln(' B - Show browser info');
  1952. writeln(' A - Show all');
  1953. writeln(' -h, -? This helpscreen');
  1954. halt;
  1955. end;
  1956. var
  1957. startpara,
  1958. nrfile,i : longint;
  1959. para : string;
  1960. begin
  1961. writeln(Title+' '+Version);
  1962. writeln(Copyright);
  1963. writeln;
  1964. if paramcount<1 then
  1965. begin
  1966. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  1967. halt(1);
  1968. end;
  1969. { turn verbose on by default }
  1970. verbose:=v_all;
  1971. { read options }
  1972. startpara:=1;
  1973. while copy(paramstr(startpara),1,1)='-' do
  1974. begin
  1975. para:=paramstr(startpara);
  1976. case upcase(para[2]) of
  1977. 'V' : begin
  1978. verbose:=0;
  1979. for i:=3 to length(para) do
  1980. case upcase(para[i]) of
  1981. 'H' : verbose:=verbose or v_header;
  1982. 'I' : verbose:=verbose or v_interface;
  1983. 'M' : verbose:=verbose or v_implementation;
  1984. 'D' : verbose:=verbose or v_defs;
  1985. 'S' : verbose:=verbose or v_syms;
  1986. 'B' : verbose:=verbose or v_browser;
  1987. 'A' : verbose:=verbose or v_all;
  1988. end;
  1989. end;
  1990. 'H' : help;
  1991. '?' : help;
  1992. end;
  1993. inc(startpara);
  1994. end;
  1995. { process files }
  1996. for nrfile:=startpara to paramcount do
  1997. dofile (paramstr(nrfile));
  1998. if has_errors then
  1999. Halt(1);
  2000. end.
  2001. {
  2002. $Log$
  2003. Revision 1.68 2005-03-27 14:10:53 jonas
  2004. * const record parameters > 8 bytes are now passed by reference for non
  2005. cdecl/cppdecl procedures on Mac OS/Mac OS X to fix compatibility with
  2006. GPC (slightly more efficient than Metrowerks behaviour below, but
  2007. less efficient in most cases than our previous scheme)
  2008. + "mwpascal" procedure directive to support the const record parameter
  2009. behaviour of Metrowerks Pascal, which passes all const records by
  2010. reference
  2011. Revision 1.67 2005/03/07 18:38:46 peter
  2012. * explicit paraloc for funcret
  2013. * libsym for powerpc ppu's
  2014. Revision 1.66 2005/02/14 17:13:10 peter
  2015. * truncate log
  2016. Revision 1.65 2005/01/19 22:19:41 peter
  2017. * unit mapping rewrite
  2018. * new derefmap added
  2019. Revision 1.64 2005/01/09 20:24:43 olle
  2020. * rework of macro subsystem
  2021. + exportable macros for mode macpas
  2022. }