ppudump.pp 61 KB

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