ppudump.pp 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318
  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. ibtypedconstsym :
  1196. begin
  1197. readcommonsym('Typed constant ');
  1198. write (space,' Constant Type : ');
  1199. readtype;
  1200. writeln(space,' ReallyConst : ',(getbyte<>0));
  1201. end;
  1202. ibpropertysym :
  1203. begin
  1204. readcommonsym('Property ');
  1205. i:=getlongint;
  1206. writeln(space,' PropOptions : ',i);
  1207. if (i and 32)>0 then
  1208. begin
  1209. write (space,' OverrideProp : ');
  1210. readderef;
  1211. end
  1212. else
  1213. begin
  1214. write (space,' Prop Type : ');
  1215. readtype;
  1216. writeln(space,' Index : ',getlongint);
  1217. writeln(space,' Default : ',getlongint);
  1218. write (space,' Index Type : ');
  1219. readtype;
  1220. write (space,' Readaccess : ');
  1221. readsymlist(space+' Sym: ');
  1222. write (space,' Writeaccess : ');
  1223. readsymlist(space+' Sym: ');
  1224. write (space,' Storedaccess : ');
  1225. readsymlist(space+' Sym: ');
  1226. end;
  1227. end;
  1228. iberror :
  1229. begin
  1230. Writeln('!! Error in PPU');
  1231. exit;
  1232. end;
  1233. ibendsyms :
  1234. break;
  1235. else
  1236. WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
  1237. end;
  1238. if not EndOfEntry then
  1239. Writeln('!! Entry has more information stored');
  1240. until false;
  1241. if (totalsyms<>-1) and (symcnt-1<>totalsyms) then
  1242. Writeln('!! Only read ',symcnt-1,' of ',totalsyms,' symbols');
  1243. end;
  1244. end;
  1245. {****************************************************************************
  1246. Read defintions Part
  1247. ****************************************************************************}
  1248. procedure readdefinitions(const s:string;start_read : boolean);
  1249. type
  1250. tsettype = (normset,smallset,varset);
  1251. tbasetype = (
  1252. uvoid,
  1253. u8bit,u16bit,u32bit,u64bit,
  1254. s8bit,s16bit,s32bit,s64bit,
  1255. bool8bit,bool16bit,bool32bit,
  1256. uchar,uwidechar
  1257. );
  1258. tobjectdeftype = (odt_none,
  1259. odt_class,
  1260. odt_object,
  1261. odt_interfacecom,
  1262. odt_interfacecorba,
  1263. odt_cppclass
  1264. );
  1265. tvarianttype = (
  1266. vt_normalvariant,vt_olevariant
  1267. );
  1268. var
  1269. b : byte;
  1270. totaldefs,l,j,
  1271. defcnt : longint;
  1272. calloption : tproccalloption;
  1273. procoptions : tprocoptions;
  1274. procinfooptions : tprocinfoflag;
  1275. begin
  1276. defcnt:=0;
  1277. with ppufile do
  1278. begin
  1279. if space<>'' then
  1280. Writeln(space,'------ ',s,' ------');
  1281. if not start_read then
  1282. if readentry=ibstartdefs then
  1283. begin
  1284. totaldefs:=getlongint;
  1285. Writeln(space,'Number of definitions: ',totaldefs);
  1286. end
  1287. else
  1288. begin
  1289. totaldefs:=-1;
  1290. Writeln('!! ibstartdef not found');
  1291. end;
  1292. repeat
  1293. b:=readentry;
  1294. if not (b in [iberror,ibenddefs]) then
  1295. inc(defcnt);
  1296. case b of
  1297. ibpointerdef :
  1298. begin
  1299. readcommondef('Pointer definition');
  1300. write (space,' Pointed Type : ');
  1301. readtype;
  1302. writeln(space,' Is Far : ',(getbyte<>0));
  1303. end;
  1304. iborddef :
  1305. begin
  1306. readcommondef('Ordinal definition');
  1307. write (space,' Base type : ');
  1308. b:=getbyte;
  1309. case tbasetype(b) of
  1310. uvoid : writeln('uvoid');
  1311. u8bit : writeln('u8bit');
  1312. u16bit : writeln('u16bit');
  1313. u32bit : writeln('s32bit');
  1314. u64bit : writeln('u64bit');
  1315. s8bit : writeln('s8bit');
  1316. s16bit : writeln('s16bit');
  1317. s32bit : writeln('s32bit');
  1318. s64bit : writeln('s64bit');
  1319. bool8bit : writeln('bool8bit');
  1320. bool16bit : writeln('bool16bit');
  1321. bool32bit : writeln('bool32bit');
  1322. uchar : writeln('uchar');
  1323. uwidechar : writeln('uwidechar');
  1324. else writeln('!! Warning: Invalid base type ',b);
  1325. end;
  1326. writeln(space,' Range : ',getint64,' to ',getint64);
  1327. end;
  1328. ibfloatdef :
  1329. begin
  1330. readcommondef('Float definition');
  1331. writeln(space,' Float type : ',getbyte);
  1332. end;
  1333. ibarraydef :
  1334. begin
  1335. readcommondef('Array definition');
  1336. write (space,' Element type : ');
  1337. readtype;
  1338. write (space,' Range Type : ');
  1339. readtype;
  1340. writeln(space,' Range : ',getlongint,' to ',getlongint);
  1341. writeln(space,' Is Constructor : ',(getbyte<>0));
  1342. writeln(space,' Is Dynamic : ',(getbyte<>0));
  1343. end;
  1344. ibprocdef :
  1345. begin
  1346. readcommondef('Procedure definition');
  1347. read_abstract_proc_def(calloption,procoptions);
  1348. if (po_has_mangledname in procoptions) then
  1349. writeln(space,' Mangled name : ',getstring);
  1350. writeln(space,' Number : ',getword);
  1351. writeln(space,' Level : ',getbyte);
  1352. write (space,' Class : ');
  1353. readderef;
  1354. write (space,' Procsym : ');
  1355. readderef;
  1356. write (space,' File Pos : ');
  1357. readposinfo;
  1358. write (space,' SymOptions : ');
  1359. readsymoptions;
  1360. {$ifdef powerpc}
  1361. { library symbol for AmigaOS/MorphOS }
  1362. write (space,' Library symbol : ');
  1363. readderef;
  1364. {$endif powerpc}
  1365. if (calloption=pocall_inline) then
  1366. begin
  1367. write (space,' FuncretSym : ');
  1368. readderef;
  1369. ppufile.getsmallset(procinfooptions);
  1370. writeln(space,' ProcInfoOptions : ',dword(procinfooptions));
  1371. b := ppufile.getbyte;
  1372. writeln(space,' Inline node tree : ',b);
  1373. end;
  1374. if not EndOfEntry then
  1375. Writeln('!! Entry has more information stored');
  1376. space:=' '+space;
  1377. { parast }
  1378. readdefinitions('parast',false);
  1379. readsymbols('parast');
  1380. { localst }
  1381. if (calloption = pocall_inline) then
  1382. begin
  1383. readdefinitions('localst',false);
  1384. readsymbols('localst');
  1385. end;
  1386. if (calloption=pocall_inline) then
  1387. readnodetree;
  1388. delete(space,1,4);
  1389. end;
  1390. ibprocvardef :
  1391. begin
  1392. readcommondef('Procedural type (ProcVar) definition');
  1393. read_abstract_proc_def(calloption,procoptions);
  1394. if not EndOfEntry then
  1395. Writeln('!! Entry has more information stored');
  1396. space:=' '+space;
  1397. { parast }
  1398. readdefinitions('parast',false);
  1399. readsymbols('parast');
  1400. delete(space,1,4);
  1401. end;
  1402. ibshortstringdef :
  1403. begin
  1404. readcommondef('ShortString definition');
  1405. writeln(space,' Length : ',getbyte);
  1406. end;
  1407. ibwidestringdef :
  1408. begin
  1409. readcommondef('WideString definition');
  1410. writeln(space,' Length : ',getlongint);
  1411. end;
  1412. ibansistringdef :
  1413. begin
  1414. readcommondef('AnsiString definition');
  1415. writeln(space,' Length : ',getlongint);
  1416. end;
  1417. iblongstringdef :
  1418. begin
  1419. readcommondef('Longstring definition');
  1420. writeln(space,' Length : ',getlongint);
  1421. end;
  1422. ibrecorddef :
  1423. begin
  1424. readcommondef('Record definition');
  1425. writeln(space,' DataSize : ',getlongint);
  1426. writeln(space,' FieldAlign : ',getbyte);
  1427. writeln(space,' RecordAlign : ',getbyte);
  1428. writeln(space,' PadAlign : ',getbyte);
  1429. if not EndOfEntry then
  1430. Writeln('!! Entry has more information stored');
  1431. {read the record definitions and symbols}
  1432. space:=' '+space;
  1433. readdefinitions('fields',false);
  1434. readsymbols('fields');
  1435. Delete(space,1,4);
  1436. end;
  1437. ibobjectdef :
  1438. begin
  1439. readcommondef('Object/Class definition');
  1440. b:=getbyte;
  1441. write (space,' Type : ');
  1442. case tobjectdeftype(b) of
  1443. odt_class : writeln('class');
  1444. odt_object : writeln('object');
  1445. odt_interfacecom : writeln('interfacecom');
  1446. odt_interfacecorba : writeln('interfacecorba');
  1447. odt_cppclass : writeln('cppclass');
  1448. else writeln('!! Warning: Invalid object type ',b);
  1449. end;
  1450. writeln(space,' Name of Class : ',getstring);
  1451. writeln(space,' DataSize : ',getlongint);
  1452. writeln(space,' FieldAlign : ',getbyte);
  1453. writeln(space,' RecordAlign : ',getbyte);
  1454. writeln(space,' Vmt offset : ',getlongint);
  1455. write(space, ' Ancestor Class : ');
  1456. readderef;
  1457. writeln(space,' Options : ',getlongint);
  1458. if tobjectdeftype(b) in [odt_interfacecom,odt_interfacecorba] then
  1459. begin
  1460. { IIDGUID }
  1461. for j:=1to 16 do
  1462. getbyte;
  1463. writeln(space,' IID String : ',getstring);
  1464. writeln(space,' Last VTable idx : ',getlongint);
  1465. end;
  1466. if tobjectdeftype(b) in [odt_class,odt_interfacecorba] then
  1467. begin
  1468. l:=getlongint;
  1469. writeln(space,' Impl Intf Count : ',l);
  1470. for j:=1 to l do
  1471. begin
  1472. write (space,' - Definition : ');
  1473. readderef;
  1474. writeln(space,' IOffset : ',getlongint);
  1475. end;
  1476. end;
  1477. if not EndOfEntry then
  1478. Writeln('!! Entry has more information stored');
  1479. {read the record definitions and symbols}
  1480. space:=' '+space;
  1481. readdefinitions('fields',false);
  1482. readsymbols('fields');
  1483. Delete(space,1,4);
  1484. end;
  1485. ibfiledef :
  1486. begin
  1487. ReadCommonDef('File definition');
  1488. write (space,' Type : ');
  1489. case getbyte of
  1490. 0 : writeln('Text');
  1491. 1 : begin
  1492. writeln('Typed');
  1493. write (space,' File of Type : ');
  1494. Readtype;
  1495. end;
  1496. 2 : writeln('Untyped');
  1497. end;
  1498. end;
  1499. ibformaldef :
  1500. readcommondef('Generic Definition (void-typ)');
  1501. ibenumdef :
  1502. begin
  1503. readcommondef('Enumeration type definition');
  1504. write(space,'Base enumeration type : ');
  1505. readderef;
  1506. writeln(space,' Smallest element : ',getlongint);
  1507. writeln(space,' Largest element : ',getlongint);
  1508. writeln(space,' Size : ',getlongint);
  1509. end;
  1510. ibclassrefdef :
  1511. begin
  1512. readcommondef('Class reference definition');
  1513. write (space,' Pointed Type : ');
  1514. readtype;
  1515. end;
  1516. ibsetdef :
  1517. begin
  1518. readcommondef('Set definition');
  1519. write (space,' Element type : ');
  1520. readtype;
  1521. b:=getbyte;
  1522. case tsettype(b) of
  1523. smallset : writeln(space,' Set with 32 Elements');
  1524. normset : writeln(space,' Set with 256 Elements');
  1525. varset : writeln(space,' Set with ',getlongint,' Elements');
  1526. else writeln('!! Warning: Invalid set type ',b);
  1527. end;
  1528. end;
  1529. ibvariantdef :
  1530. begin
  1531. readcommondef('Variant definition');
  1532. write (space,' Varianttype : ');
  1533. b:=getbyte;
  1534. case tvarianttype(b) of
  1535. vt_normalvariant :
  1536. writeln('Normal');
  1537. vt_olevariant :
  1538. writeln('OLE');
  1539. else
  1540. writeln('!! Warning: Invalid varianttype ',b);
  1541. end;
  1542. end;
  1543. iberror :
  1544. begin
  1545. Writeln('!! Error in PPU');
  1546. exit;
  1547. end;
  1548. ibenddefs :
  1549. break;
  1550. else
  1551. WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
  1552. end;
  1553. if not EndOfEntry then
  1554. Writeln('!! Entry has more information stored');
  1555. until false;
  1556. if (totaldefs<>-1) and (defcnt<>totaldefs) then
  1557. Writeln('!! Only read ',defcnt,' of ',totaldefs,' definitions');
  1558. end;
  1559. end;
  1560. {****************************************************************************
  1561. Read General Part
  1562. ****************************************************************************}
  1563. procedure readinterface;
  1564. var
  1565. b : byte;
  1566. sourcenumber : longint;
  1567. begin
  1568. with ppufile do
  1569. begin
  1570. repeat
  1571. b:=readentry;
  1572. case b of
  1573. ibmodulename :
  1574. Writeln('Module Name: ',getstring);
  1575. ibsourcefiles :
  1576. begin
  1577. sourcenumber:=1;
  1578. while not EndOfEntry do
  1579. begin
  1580. Writeln('Source file ',sourcenumber,' : ',getstring,' ',filetimestring(getlongint));
  1581. inc(sourcenumber);
  1582. end;
  1583. end;
  1584. ibusedmacros :
  1585. begin
  1586. while not EndOfEntry do
  1587. begin
  1588. Write('Conditional ',getstring);
  1589. b:=getbyte;
  1590. if boolean(b)=true then
  1591. write(' defined at startup')
  1592. else
  1593. write(' not defined at startup');
  1594. b:=getbyte;
  1595. if boolean(b)=true then
  1596. writeln(' was used')
  1597. else
  1598. writeln;
  1599. end;
  1600. end;
  1601. ibloadunit :
  1602. ReadLoadUnit;
  1603. iblinkunitofiles :
  1604. ReadLinkContainer('Link unit object file: ');
  1605. iblinkunitstaticlibs :
  1606. ReadLinkContainer('Link unit static lib: ');
  1607. iblinkunitsharedlibs :
  1608. ReadLinkContainer('Link unit shared lib: ');
  1609. iblinkotherofiles :
  1610. ReadLinkContainer('Link other object file: ');
  1611. iblinkotherstaticlibs :
  1612. ReadLinkContainer('Link other static lib: ');
  1613. iblinkothersharedlibs :
  1614. ReadLinkContainer('Link other shared lib: ');
  1615. ibderefdata :
  1616. ReadDerefData;
  1617. iberror :
  1618. begin
  1619. Writeln('Error in PPU');
  1620. exit;
  1621. end;
  1622. ibendinterface :
  1623. break;
  1624. else
  1625. WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
  1626. end;
  1627. until false;
  1628. end;
  1629. end;
  1630. {****************************************************************************
  1631. Read Implementation Part
  1632. ****************************************************************************}
  1633. procedure readimplementation;
  1634. var
  1635. b : byte;
  1636. begin
  1637. with ppufile do
  1638. begin
  1639. repeat
  1640. b:=readentry;
  1641. case b of
  1642. ibasmsymbols :
  1643. ReadAsmSymbols;
  1644. ibloadunit :
  1645. ReadLoadUnit;
  1646. iberror :
  1647. begin
  1648. Writeln('Error in PPU');
  1649. exit;
  1650. end;
  1651. ibendimplementation :
  1652. break;
  1653. else
  1654. WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
  1655. end;
  1656. until false;
  1657. end;
  1658. end;
  1659. {****************************************************************************
  1660. Read Browser Part
  1661. ****************************************************************************}
  1662. procedure readbrowser;
  1663. var
  1664. b : byte;
  1665. const indent : string = '';
  1666. begin
  1667. Writeln(indent,'Start of symtable browser');
  1668. indent:=indent+'**';
  1669. with ppufile do
  1670. begin
  1671. repeat
  1672. b:=readentry;
  1673. case b of
  1674. ibbeginsymtablebrowser :
  1675. begin
  1676. { here we must read object and record symtables !! }
  1677. indent:=indent+' ';
  1678. Writeln(indent,'Record/Object symtable');
  1679. readbrowser;
  1680. Indent:=Copy(Indent,1,Length(Indent)-2);
  1681. end;
  1682. ibsymref :
  1683. begin
  1684. readderef;
  1685. readref;
  1686. end;
  1687. ibdefref :
  1688. begin
  1689. readderef;
  1690. readref;
  1691. if ((ppufile.header.flags and uf_local_browser)<>0) and
  1692. (UnitIndex=0) then
  1693. begin
  1694. { parast and localst }
  1695. indent:=indent+' ';
  1696. b:=ppufile.readentry;
  1697. if b=ibbeginsymtablebrowser then
  1698. readbrowser;
  1699. b:=ppufile.readentry;
  1700. if b=ibbeginsymtablebrowser then
  1701. readbrowser;
  1702. Indent:=Copy(Indent,1,Length(Indent)-2);
  1703. end;
  1704. end;
  1705. iberror :
  1706. begin
  1707. Writeln('Error in PPU');
  1708. exit;
  1709. end;
  1710. ibendsymtablebrowser :
  1711. break;
  1712. else
  1713. begin
  1714. WriteLn('!! Skipping unsupported PPU Entry in Browser: ',b);
  1715. Halt;
  1716. end;
  1717. end;
  1718. until false;
  1719. end;
  1720. Indent:=Copy(Indent,1,Length(Indent)-2);
  1721. Writeln(Indent,'End of symtable browser');
  1722. end;
  1723. procedure dofile (filename : string);
  1724. var
  1725. b : byte;
  1726. begin
  1727. { reset }
  1728. space:='';
  1729. { fix filename }
  1730. if pos('.',filename)=0 then
  1731. filename:=filename+'.ppu';
  1732. ppufile:=tppufile.create(filename);
  1733. if not ppufile.openfile then
  1734. begin
  1735. writeln ('IO-Error when opening : ',filename,', Skipping');
  1736. exit;
  1737. end;
  1738. { PPU File is open, check for PPU Id }
  1739. if not ppufile.CheckPPUID then
  1740. begin
  1741. writeln(Filename,' : Not a valid PPU file, Skipping');
  1742. exit;
  1743. end;
  1744. { Check PPU Version }
  1745. Writeln('Analyzing ',filename,' (v',ppufile.GetPPUVersion,')');
  1746. if ppufile.GetPPUVersion<16 then
  1747. begin
  1748. writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
  1749. exit;
  1750. end;
  1751. { Write PPU Header Information }
  1752. if (verbose and v_header)<>0 then
  1753. begin
  1754. Writeln;
  1755. Writeln('Header');
  1756. Writeln('-------');
  1757. with ppufile.header do
  1758. begin
  1759. Writeln('Compiler version : ',ppufile.header.compiler shr 14,'.',
  1760. (ppufile.header.compiler shr 7) and $7f,'.',
  1761. ppufile.header.compiler and $7f);
  1762. WriteLn('Target processor : ',Cpu2Str(cpu));
  1763. WriteLn('Target operating system : ',Target2Str(target));
  1764. Writeln('Unit flags : ',PPUFlags2Str(flags));
  1765. Writeln('FileSize (w/o header) : ',size);
  1766. Writeln('Checksum : ',hexstr(checksum,8));
  1767. Writeln('Interface Checksum : ',hexstr(interface_checksum,8));
  1768. end;
  1769. end;
  1770. {read the general stuff}
  1771. if (verbose and v_interface)<>0 then
  1772. begin
  1773. Writeln;
  1774. Writeln('Interface section');
  1775. Writeln('------------------');
  1776. readinterface;
  1777. end
  1778. else
  1779. ppufile.skipuntilentry(ibendinterface);
  1780. {read the definitions}
  1781. if (verbose and v_defs)<>0 then
  1782. begin
  1783. Writeln;
  1784. Writeln('Interface definitions');
  1785. Writeln('----------------------');
  1786. readdefinitions('interface',false);
  1787. end
  1788. else
  1789. ppufile.skipuntilentry(ibenddefs);
  1790. {read the symbols}
  1791. if (verbose and v_syms)<>0 then
  1792. begin
  1793. Writeln;
  1794. Writeln('Interface Symbols');
  1795. Writeln('------------------');
  1796. readsymbols('interface');
  1797. end
  1798. else
  1799. ppufile.skipuntilentry(ibendsyms);
  1800. {read the implementation stuff}
  1801. if (verbose and v_implementation)<>0 then
  1802. begin
  1803. Writeln;
  1804. Writeln('Implementation section');
  1805. Writeln('-----------------------');
  1806. readimplementation;
  1807. end
  1808. else
  1809. ppufile.skipuntilentry(ibendimplementation);
  1810. {read the static browser units stuff}
  1811. if (ppufile.header.flags and uf_local_symtable)<>0 then
  1812. begin
  1813. if (verbose and v_defs)<>0 then
  1814. begin
  1815. Writeln;
  1816. Writeln('Static definitions');
  1817. Writeln('----------------------');
  1818. readdefinitions('implementation',false);
  1819. end
  1820. else
  1821. ppufile.skipuntilentry(ibenddefs);
  1822. {read the symbols}
  1823. if (verbose and v_syms)<>0 then
  1824. begin
  1825. Writeln;
  1826. Writeln('Static Symbols');
  1827. Writeln('------------------');
  1828. readsymbols('implementation');
  1829. end
  1830. else
  1831. ppufile.skipuntilentry(ibendsyms);
  1832. end;
  1833. {read the browser units stuff}
  1834. if (ppufile.header.flags and uf_has_browser)<>0 then
  1835. begin
  1836. if (verbose and v_browser)<>0 then
  1837. begin
  1838. Writeln;
  1839. Writeln('Browser section');
  1840. Writeln('---------------');
  1841. UnitIndex:=0;
  1842. repeat
  1843. b:=ppufile.readentry;
  1844. if b = ibendbrowser then break;
  1845. if b=ibbeginsymtablebrowser then
  1846. begin
  1847. Writeln('Unit ',UnitIndex);
  1848. readbrowser;
  1849. Inc(UnitIndex);
  1850. end
  1851. else
  1852. Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
  1853. until false;
  1854. end;
  1855. end;
  1856. {read the static browser units stuff}
  1857. if (ppufile.header.flags and uf_local_browser)<>0 then
  1858. begin
  1859. if (verbose and v_browser)<>0 then
  1860. begin
  1861. Writeln;
  1862. Writeln('Static browser section');
  1863. Writeln('---------------');
  1864. UnitIndex:=0;
  1865. b:=ppufile.readentry;
  1866. if b=ibbeginsymtablebrowser then
  1867. readbrowser
  1868. else
  1869. Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
  1870. end;
  1871. end;
  1872. {shutdown ppufile}
  1873. ppufile.closefile;
  1874. ppufile.free;
  1875. Writeln;
  1876. end;
  1877. procedure help;
  1878. begin
  1879. writeln('usage: ppudump [options] <filename1> <filename2>...');
  1880. writeln;
  1881. writeln('[options] can be:');
  1882. writeln(' -V<verbose> Set verbosity to <verbose>');
  1883. writeln(' H - Show header info');
  1884. writeln(' I - Show interface');
  1885. writeln(' M - Show implementation');
  1886. writeln(' S - Show interface symbols');
  1887. writeln(' D - Show interface definitions');
  1888. writeln(' B - Show browser info');
  1889. writeln(' A - Show all');
  1890. writeln(' -h, -? This helpscreen');
  1891. halt;
  1892. end;
  1893. var
  1894. startpara,
  1895. nrfile,i : longint;
  1896. para : string;
  1897. begin
  1898. writeln(Title+' '+Version);
  1899. writeln(Copyright);
  1900. writeln;
  1901. if paramcount<1 then
  1902. begin
  1903. writeln('usage: dumpppu [options] <filename1> <filename2>...');
  1904. halt(1);
  1905. end;
  1906. { turn verbose on by default }
  1907. verbose:=v_all;
  1908. { read options }
  1909. startpara:=1;
  1910. while copy(paramstr(startpara),1,1)='-' do
  1911. begin
  1912. para:=paramstr(startpara);
  1913. case upcase(para[2]) of
  1914. 'V' : begin
  1915. verbose:=0;
  1916. for i:=3to length(para) do
  1917. case upcase(para[i]) of
  1918. 'H' : verbose:=verbose or v_header;
  1919. 'I' : verbose:=verbose or v_interface;
  1920. 'M' : verbose:=verbose or v_implementation;
  1921. 'D' : verbose:=verbose or v_defs;
  1922. 'S' : verbose:=verbose or v_syms;
  1923. 'B' : verbose:=verbose or v_browser;
  1924. 'A' : verbose:=verbose or v_all;
  1925. end;
  1926. end;
  1927. 'H' : help;
  1928. '?' : help;
  1929. end;
  1930. inc(startpara);
  1931. end;
  1932. { process files }
  1933. for nrfile:=startpara to paramcount do
  1934. dofile (paramstr(nrfile));
  1935. if has_errors then
  1936. Halt(1);
  1937. end.
  1938. {
  1939. $Log$
  1940. Revision 1.63 2004-11-19 08:33:02 marco
  1941. * fix for " Split po_public into po_public and po_global"
  1942. Revision 1.62 2004/11/19 08:17:02 michael
  1943. * Split po_public into po_public and po_global (Peter)
  1944. Revision 1.61 2004/11/17 22:22:12 peter
  1945. mangledname setting moved to place after the complete proc declaration is read
  1946. import generation moved to place where body is also parsed (still gives problems with win32)
  1947. Revision 1.60 2004/11/16 20:49:08 peter
  1948. * fixed rangecheck error with derefdata
  1949. Revision 1.59 2004/11/15 23:35:31 peter
  1950. * tparaitem removed, use tparavarsym instead
  1951. * parameter order is now calculated from paranr value in tparavarsym
  1952. Revision 1.58 2004/11/08 22:09:59 peter
  1953. * tvarsym splitted
  1954. Revision 1.57 2004/11/02 22:17:25 olle
  1955. * fixed possible problem with null termination
  1956. Revision 1.56 2004/09/27 18:04:11 olle
  1957. + added -h option to show help
  1958. Revision 1.55 2004/09/04 21:11:49 armin
  1959. * missing targets added
  1960. Revision 1.54 2004/08/27 21:59:27 peter
  1961. browser disabled
  1962. uf_local_symtable ppu flag when a localsymtable is stored
  1963. Revision 1.53 2004/07/12 09:14:04 jonas
  1964. * inline procedures at the node tree level, but only under some very
  1965. limited circumstances for now (only procedures, and only if they have
  1966. no or only vs_out/vs_var parameters).
  1967. * fixed ppudump for inline procedures
  1968. * fixed ppudump for ppc
  1969. Revision 1.52 2004/07/09 22:17:32 peter
  1970. * revert has_localst patch
  1971. * replace aktstaticsymtable/aktglobalsymtable with current_module
  1972. Revision 1.51 2004/07/06 19:52:04 peter
  1973. * fix storing of localst in ppu
  1974. Revision 1.50 2003/12/16 21:29:25 florian
  1975. + inlined procedures inherit procinfo flags
  1976. Revision 1.49 2003/12/08 21:04:08 peter
  1977. * line break in uses unit
  1978. Revision 1.48 2003/11/10 22:02:52 peter
  1979. * cross unit inlining fixed
  1980. Revision 1.47 2003/10/22 20:40:00 peter
  1981. * write derefdata in a separate ppu entry
  1982. Revision 1.46 2003/07/02 22:18:04 peter
  1983. * paraloc splitted in callerparaloc,calleeparaloc
  1984. * sparc calling convention updates
  1985. Revision 1.45 2003/06/25 18:31:23 peter
  1986. * sym,def resolving partly rewritten to support also parent objects
  1987. not directly available through the uses clause
  1988. Revision 1.44 2003/06/09 12:59:00 peter
  1989. * updated for new deref info
  1990. Revision 1.43 2003/06/05 20:06:11 peter
  1991. * new procoptions
  1992. Revision 1.42 2003/05/09 17:47:03 peter
  1993. * self moved to hidden parameter
  1994. * removed hdisposen,hnewn,selfn
  1995. Revision 1.41 2003/04/27 07:29:52 peter
  1996. * aktprocdef cleanup, aktprocdef is now always nil when parsing
  1997. a new procdef declaration
  1998. * aktprocsym removed
  1999. * lexlevel removed, use symtable.symtablelevel instead
  2000. * implicit init/final code uses the normal genentry/genexit
  2001. * funcret state checking updated for new funcret handling
  2002. Revision 1.39 2003/04/25 20:59:35 peter
  2003. * removed funcretn,funcretsym, function result is now in varsym
  2004. and aliases for result and function name are added using absolutesym
  2005. * vs_hidden parameter for funcret passed in parameter
  2006. * vs_hidden fixes
  2007. * writenode changed to printnode and released from extdebug
  2008. * -vp option added to generate a tree.log with the nodetree
  2009. * nicer printnode for statements, callnode
  2010. Revision 1.38 2003/04/10 17:57:53 peter
  2011. * vs_hidden released
  2012. Revision 1.37 2003/03/24 19:57:54 hajny
  2013. + emx target added
  2014. Revision 1.36 2003/03/17 15:54:22 peter
  2015. * store symoptions also for procdef
  2016. * check symoptions (private,public) when calculating possible
  2017. overload candidates
  2018. Revision 1.35 2003/01/03 22:16:29 peter
  2019. * updated for absolutesym and varsym
  2020. Revision 1.34 2002/11/17 16:32:04 carl
  2021. * memory optimization (3-4%) : cleanup of tai fields,
  2022. cleanup of tdef and tsym fields.
  2023. * make it work for m68k
  2024. Revision 1.33 2002/10/20 14:49:31 peter
  2025. * store original source time in ppu so it can be compared instead of
  2026. comparing with the ppu time
  2027. Revision 1.32 2002/10/06 12:25:53 florian
  2028. + dump of tdefoptions.df_unique
  2029. Revision 1.31 2002/09/27 21:22:04 carl
  2030. * update system information
  2031. Revision 1.30 2002/09/26 12:03:54 florian
  2032. + support of constguid and constwchar const symbols added
  2033. Revision 1.29 2002/08/20 16:54:40 peter
  2034. * write address of varsym always
  2035. Revision 1.28 2002/08/19 19:36:44 peter
  2036. * More fixes for cross unit inlining, all tnodes are now implemented
  2037. * Moved pocall_internconst to po_internconst because it is not a
  2038. calling type at all and it conflicted when inlining of these small
  2039. functions was requested
  2040. Revision 1.27 2002/08/15 15:15:56 carl
  2041. * jmpbuf size allocation for exceptions is now cpu specific (as it should)
  2042. * more generic nodes for maths
  2043. * several fixes for better m68k support
  2044. Revision 1.26 2002/08/11 13:24:20 peter
  2045. * saving of asmsymbols in ppu supported
  2046. * asmsymbollist global is removed and moved into a new class
  2047. tasmlibrarydata that will hold the info of a .a file which
  2048. corresponds with a single module. Added librarydata to tmodule
  2049. to keep the library info stored for the module. In the future the
  2050. objectfiles will also be stored to the tasmlibrarydata class
  2051. * all getlabel/newasmsymbol and friends are moved to the new class
  2052. Revision 1.25 2002/05/18 13:34:27 peter
  2053. * readded missing revisions
  2054. Revision 1.24 2002/05/16 19:46:54 carl
  2055. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  2056. + try to fix temp allocation (still in ifdef)
  2057. + generic constructor calls
  2058. + start of tassembler / tmodulebase class cleanup
  2059. Revision 1.22 2002/05/12 16:53:18 peter
  2060. * moved entry and exitcode to ncgutil and cgobj
  2061. * foreach gets extra argument for passing local data to the
  2062. iterator function
  2063. * -CR checks also class typecasts at runtime by changing them
  2064. into as
  2065. * fixed compiler to cycle with the -CR option
  2066. * fixed stabs with elf writer, finally the global variables can
  2067. be watched
  2068. * removed a lot of routines from cga unit and replaced them by
  2069. calls to cgobj
  2070. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  2071. u32bit then the other is typecasted also to u32bit without giving
  2072. a rangecheck warning/error.
  2073. * fixed pascal calling method with reversing also the high tree in
  2074. the parast, detected by tcalcst3 test
  2075. Revision 1.21 2002/04/23 13:12:58 peter
  2076. * updated for posinfo change
  2077. * updated for mangledname change
  2078. * include i386 registers, removed reference to cpubase unit that would
  2079. make ppudump dependent on the source processor
  2080. Revision 1.20 2002/04/15 19:15:09 carl
  2081. + write std_reg2str instead of gas registers
  2082. Revision 1.19 2002/04/14 17:02:19 carl
  2083. + att_reg2str -> gas_reg2str
  2084. Revision 1.18 2002/04/07 10:23:36 carl
  2085. + added vm / sparc targets
  2086. Revision 1.17 2002/04/04 19:06:14 peter
  2087. * removed unused units
  2088. * use tlocation.size in cg.a_*loc*() routines
  2089. Revision 1.16 2002/04/04 18:50:27 carl
  2090. + added wdosx support (patch from Pavel)
  2091. Revision 1.15 2002/03/31 20:26:42 jonas
  2092. + a_loadfpu_* and a_loadmm_* methods in tcg
  2093. * register allocation is now handled by a class and is mostly processor
  2094. independent (+rgobj.pas and i386/rgcpu.pas)
  2095. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  2096. * some small improvements and fixes to the optimizer
  2097. * some register allocation fixes
  2098. * some fpuvaroffset fixes in the unary minus node
  2099. * push/popusedregisters is now called rg.save/restoreusedregisters and
  2100. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  2101. also better optimizable)
  2102. * fixed and optimized register saving/restoring for new/dispose nodes
  2103. * LOC_FPU locations now also require their "register" field to be set to
  2104. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  2105. - list field removed of the tnode class because it's not used currently
  2106. and can cause hard-to-find bugs
  2107. Revision 1.14 2002/03/28 20:48:52 carl
  2108. - remove go32v1 support
  2109. Revision 1.13 2002/03/28 16:44:59 armin
  2110. + new flag if unit has local threadvars
  2111. Revision 1.12 2002/03/01 14:08:47 peter
  2112. * parasym added
  2113. Revision 1.11 2002/01/06 12:08:16 peter
  2114. * removed uauto from orddef, use new range_to_basetype generating
  2115. the correct ordinal type for a range
  2116. }