ppudump.pp 68 KB

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