dbgstabs.pas 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688
  1. {
  2. Copyright (c) 2003-2004 by Peter Vreman and Florian Klaempfl
  3. This units contains support for STABS debug info generation
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit dbgstabs;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cclasses,
  22. dbgbase,
  23. symtype,symdef,symsym,symtable,symbase,
  24. aasmtai,aasmdata;
  25. const
  26. { stab types }
  27. N_GSYM = $20;
  28. N_STSYM = 38; { initialized const }
  29. N_LCSYM = 40; { non initialized variable}
  30. N_Function = $24; { function or const }
  31. N_TextLine = $44;
  32. N_DataLine = $46;
  33. N_BssLine = $48;
  34. N_RSYM = $40; { register variable }
  35. N_LSYM = $80;
  36. N_tsym = 160;
  37. N_SourceFile = $64;
  38. { APPLE LOCAL N_OSO: This is the stab that associated the .o file with the
  39. N_SO stab, in the case where debug info is mostly stored in the .o file. }
  40. N_OSO = $66;
  41. N_IncludeFile = $84;
  42. N_BINCL = $82;
  43. N_EINCL = $A2;
  44. N_LBRAC = $C0;
  45. N_EXCL = $C2;
  46. N_RBRAC = $E0;
  47. type
  48. TDebugInfoStabs=class(TDebugInfo)
  49. private
  50. writing_def_stabs : boolean;
  51. global_stab_number : word;
  52. defnumberlist : TFPObjectList;
  53. { tsym writing }
  54. function sym_var_value(const s:string;arg:pointer):string;
  55. function sym_stabstr_evaluate(sym:tsym;const s:string;const vars:array of string):Pchar;
  56. procedure write_symtable_syms(list:TAsmList;st:TSymtable);
  57. { tdef writing }
  58. function def_stab_number(def:tdef):string;
  59. function def_stab_classnumber(def:tobjectdef):string;
  60. function def_var_value(const s:string;arg:pointer):string;
  61. function def_stabstr_evaluate(def:tdef;const s:string;const vars:array of string):Pchar;
  62. procedure field_add_stabstr(p:TObject;arg:pointer);
  63. procedure method_add_stabstr(p:TObject;arg:pointer);
  64. function def_stabstr(def:tdef):pchar;
  65. procedure write_def_stabstr(list:TAsmList;def:tdef);
  66. procedure write_procdef(list:TAsmList;pd:tprocdef);
  67. procedure insertsym(list:TAsmList;sym:tsym);
  68. public
  69. procedure inserttypeinfo;override;
  70. procedure insertmoduleinfo;override;
  71. procedure insertlineinfo(list:TAsmList);override;
  72. procedure referencesections(list:TAsmList);override;
  73. procedure insertdef(list:TAsmList;def:tdef);override;
  74. procedure write_symtable_defs(list:TAsmList;st:TSymtable);override;
  75. end;
  76. implementation
  77. uses
  78. SysUtils,cutils,cfileutl,
  79. systems,globals,globtype,verbose,constexp,
  80. symconst,defutil,
  81. cpuinfo,cpubase,cgbase,paramgr,
  82. aasmbase,procinfo,
  83. finput,fmodule,ppu;
  84. function GetSymName(Sym : TSymEntry) : string;
  85. begin
  86. if Not (cs_stabs_preservecase in current_settings.globalswitches) then
  87. result := Sym.Name
  88. else
  89. result := Sym.RealName;
  90. end;
  91. function GetSymTableName(SymTable : TSymTable) : string;
  92. begin
  93. if Not (cs_stabs_preservecase in current_settings.globalswitches) then
  94. result := SymTable.Name^
  95. else
  96. result := SymTable.RealName^;
  97. end;
  98. const
  99. memsizeinc = 512;
  100. tagtypes = [
  101. recorddef,
  102. enumdef,
  103. stringdef,
  104. filedef,
  105. objectdef
  106. ];
  107. type
  108. get_var_value_proc=function(const s:string;arg:pointer):string of object;
  109. Trecord_stabgen_state=record
  110. stabstring:Pchar;
  111. stabsize,staballoc,recoffset:integer;
  112. end;
  113. Precord_stabgen_state=^Trecord_stabgen_state;
  114. function string_evaluate(s:string;get_var_value:get_var_value_proc;
  115. get_var_value_arg:pointer;
  116. const vars:array of string):Pchar;
  117. (*
  118. S contains a prototype of a result. Stabstr_evaluate will expand
  119. variables and parameters.
  120. Output is s in ASCIIZ format, with the following expanded:
  121. ${varname} - The variable name is expanded.
  122. $n - The parameter n is expanded.
  123. $$ - Is expanded to $
  124. *)
  125. const maxvalue=9;
  126. maxdata=1023;
  127. var i,j:byte;
  128. varname:string[63];
  129. varno,varcounter:byte;
  130. varvalues:array[0..9] of pshortstring;
  131. {1 kb of parameters is the limit. 256 extra bytes are allocated to
  132. ensure buffer integrity.}
  133. varvaluedata:array[0..maxdata+256] of char;
  134. varptr:Pchar;
  135. varidx : byte;
  136. len:longint;
  137. r:Pchar;
  138. begin
  139. {Two pass approach, first, calculate the length and receive variables.}
  140. i:=1;
  141. len:=0;
  142. varcounter:=0;
  143. varptr:=@varvaluedata[0];
  144. while i<=length(s) do
  145. begin
  146. if (s[i]='$') and (i<length(s)) then
  147. begin
  148. if s[i+1]='$' then
  149. begin
  150. inc(len);
  151. inc(i);
  152. end
  153. else if (s[i+1]='{') and (length(s)>2) and (i<length(s)-2) then
  154. begin
  155. varname:='';
  156. inc(i,2);
  157. repeat
  158. inc(varname[0]);
  159. varname[length(varname)]:=s[i];
  160. s[i]:=char(varcounter);
  161. inc(i);
  162. until s[i]='}';
  163. varvalues[varcounter]:=pshortstring(varptr);
  164. if varptr>@varvaluedata[maxdata] then
  165. internalerrorproc(200411152);
  166. pshortstring(varptr)^:=get_var_value(varname,get_var_value_arg);
  167. inc(len,length(pshortstring(varptr)^));
  168. inc(varptr,length(pshortstring(varptr)^)+1);
  169. inc(varcounter);
  170. end
  171. else if s[i+1] in ['1'..'9'] then
  172. begin
  173. varidx:=byte(s[i+1])-byte('1');
  174. if varidx>high(vars) then
  175. internalerror(200509263);
  176. inc(len,length(vars[varidx]));
  177. inc(i);
  178. end;
  179. end
  180. else
  181. inc(len);
  182. inc(i);
  183. end;
  184. {Second pass, writeout result.}
  185. getmem(r,len+1);
  186. string_evaluate:=r;
  187. i:=1;
  188. while i<=length(s) do
  189. begin
  190. if (s[i]='$') and (i<length(s)) then
  191. begin
  192. if s[i+1]='$' then
  193. begin
  194. r^:='$';
  195. inc(r);
  196. inc(i);
  197. end
  198. else if (s[i+1]='{') and (length(s)>2) and (i<length(s)-2) then
  199. begin
  200. varname:='';
  201. inc(i,2);
  202. varno:=byte(s[i]);
  203. repeat
  204. inc(i);
  205. until s[i]='}';
  206. for j:=1 to length(varvalues[varno]^) do
  207. begin
  208. r^:=varvalues[varno]^[j];
  209. inc(r);
  210. end;
  211. end
  212. else if s[i+1] in ['0'..'9'] then
  213. begin
  214. for j:=1 to length(vars[byte(s[i+1])-byte('1')]) do
  215. begin
  216. r^:=vars[byte(s[i+1])-byte('1')][j];
  217. inc(r);
  218. end;
  219. inc(i);
  220. end
  221. end
  222. else
  223. begin
  224. r^:=s[i];
  225. inc(r);
  226. end;
  227. inc(i);
  228. end;
  229. r^:=#0;
  230. end;
  231. {****************************************************************************
  232. TDef support
  233. ****************************************************************************}
  234. function TDebugInfoStabs.def_stab_number(def:tdef):string;
  235. begin
  236. { procdefs only need a number, mark them as already written
  237. so they won't be written implicitly }
  238. if (def.typ=procdef) then
  239. def.dbg_state:=dbg_state_written;
  240. { Stab must already be written, or we must be busy writing it }
  241. if writing_def_stabs and
  242. not(def.dbg_state in [dbg_state_writing,dbg_state_written,dbg_state_queued]) then
  243. internalerror(200403091);
  244. { Keep track of used stabs, this info is only usefull for stabs
  245. referenced by the symbols. Definitions will always include all
  246. required stabs }
  247. if def.dbg_state=dbg_state_unused then
  248. def.dbg_state:=dbg_state_used;
  249. { Need a new number? }
  250. if def.stab_number=0 then
  251. begin
  252. inc(global_stab_number);
  253. { classes require 2 numbers }
  254. if is_class(def) then
  255. inc(global_stab_number);
  256. def.stab_number:=global_stab_number;
  257. if global_stab_number>=defnumberlist.count then
  258. defnumberlist.count:=global_stab_number+250;
  259. defnumberlist[global_stab_number]:=def;
  260. end;
  261. result:=tostr(def.stab_number);
  262. end;
  263. function TDebugInfoStabs.def_stab_classnumber(def:tobjectdef):string;
  264. begin
  265. if def.stab_number=0 then
  266. def_stab_number(def);
  267. if (def.objecttype=odt_class) then
  268. result:=tostr(def.stab_number-1)
  269. else
  270. result:=tostr(def.stab_number);
  271. end;
  272. function TDebugInfoStabs.def_var_value(const s:string;arg:pointer):string;
  273. var
  274. def : tdef;
  275. begin
  276. def:=tdef(arg);
  277. result:='';
  278. if s='numberstring' then
  279. result:=def_stab_number(def)
  280. else if s='sym_name' then
  281. begin
  282. if assigned(def.typesym) then
  283. result:=GetSymName(Ttypesym(def.typesym));
  284. end
  285. else if s='N_LSYM' then
  286. result:=tostr(N_LSYM)
  287. else if s='savesize' then
  288. result:=tostr(def.size);
  289. end;
  290. function TDebugInfoStabs.def_stabstr_evaluate(def:tdef;const s:string;const vars:array of string):Pchar;
  291. begin
  292. result:=string_evaluate(s,@def_var_value,def,vars);
  293. end;
  294. procedure TDebugInfoStabs.field_add_stabstr(p:TObject;arg:pointer);
  295. var
  296. newrec : Pchar;
  297. spec : string[3];
  298. varsize : aint;
  299. state : Precord_stabgen_state;
  300. begin
  301. state:=arg;
  302. { static variables from objects are like global objects }
  303. if (Tsym(p).typ=fieldvarsym) and
  304. not(sp_static in Tsym(p).symoptions) then
  305. begin
  306. if ([sp_protected,sp_strictprotected]*tsym(p).symoptions)<>[] then
  307. spec:='/1'
  308. else if ([sp_private,sp_strictprivate]*tsym(p).symoptions)<>[] then
  309. spec:='/0'
  310. else
  311. spec:='';
  312. if (tabstractrecordsymtable(tsym(p).owner).usefieldalignment<>bit_alignment) then
  313. begin
  314. varsize:=tfieldvarsym(p).vardef.size;
  315. { open arrays made overflows !! }
  316. { how can a record/object/class contain an open array? (JM) }
  317. if varsize>$fffffff then
  318. varsize:=$fffffff;
  319. newrec:=def_stabstr_evaluate(nil,'$1:$2,$3,$4;',[GetSymName(tfieldvarsym(p)),
  320. spec+def_stab_number(tfieldvarsym(p).vardef),
  321. tostr(TConstExprInt(tfieldvarsym(p).fieldoffset)*8),tostr(varsize*8)])
  322. end
  323. else
  324. newrec:=def_stabstr_evaluate(nil,'$1:$2,$3,$4;',[GetSymName(tfieldvarsym(p)),
  325. spec+def_stab_number(tfieldvarsym(p).vardef),
  326. tostr(TConstExprInt(tfieldvarsym(p).fieldoffset)),tostr(tfieldvarsym(p).vardef.packedbitsize)]);
  327. if state^.stabsize+strlen(newrec)>=state^.staballoc-256 then
  328. begin
  329. inc(state^.staballoc,strlen(newrec)+64);
  330. reallocmem(state^.stabstring,state^.staballoc);
  331. end;
  332. strcopy(state^.stabstring+state^.stabsize,newrec);
  333. inc(state^.stabsize,strlen(newrec));
  334. freemem(newrec);
  335. {This should be used for case !!}
  336. if int64(state^.recoffset)+Tfieldvarsym(p).vardef.size>high(longint) then
  337. state^.recoffset:=high(longint)
  338. else
  339. inc(state^.recoffset,Tfieldvarsym(p).vardef.size);
  340. end;
  341. end;
  342. procedure TDebugInfoStabs.method_add_stabstr(p:TObject;arg:pointer);
  343. var virtualind,argnames : string;
  344. newrec : pchar;
  345. pd : tprocdef;
  346. lindex : longint;
  347. arglength : byte;
  348. sp : char;
  349. state:^Trecord_stabgen_state;
  350. olds:integer;
  351. i : integer;
  352. parasym : tparavarsym;
  353. begin
  354. state:=arg;
  355. if tsym(p).typ = procsym then
  356. begin
  357. pd :=tprocdef(tprocsym(p).ProcdefList[0]);
  358. if (po_virtualmethod in pd.procoptions) then
  359. begin
  360. lindex := pd.extnumber;
  361. {doesnt seem to be necessary
  362. lindex := lindex or $80000000;}
  363. virtualind := '*'+tostr(lindex)+';'+def_stab_classnumber(pd._class)+';'
  364. end
  365. else
  366. virtualind := '.';
  367. { used by gdbpas to recognize constructor and destructors }
  368. if (pd.proctypeoption=potype_constructor) then
  369. argnames:='__ct__'
  370. else if (pd.proctypeoption=potype_destructor) then
  371. argnames:='__dt__'
  372. else
  373. argnames := '';
  374. { arguments are not listed here }
  375. {we don't need another definition}
  376. for i:=0 to pd.paras.count-1 do
  377. begin
  378. parasym:=tparavarsym(pd.paras[i]);
  379. if Parasym.vardef.typ = formaldef then
  380. begin
  381. case Parasym.varspez of
  382. vs_var :
  383. argnames := argnames+'3var';
  384. vs_const :
  385. argnames:=argnames+'5const';
  386. vs_out :
  387. argnames:=argnames+'3out';
  388. end;
  389. end
  390. else
  391. begin
  392. { if the arg definition is like (v: ^byte;..
  393. there is no sym attached to data !!! }
  394. if assigned(Parasym.vardef.typesym) then
  395. begin
  396. arglength := length(GetSymName(Parasym.vardef.typesym));
  397. argnames := argnames + tostr(arglength)+GetSymName(Parasym.vardef.typesym);
  398. end
  399. else
  400. argnames:=argnames+'11unnamedtype';
  401. end;
  402. end;
  403. { here 2A must be changed for private and protected }
  404. { 0 is private 1 protected and 2 public }
  405. if ([sp_private,sp_strictprivate]*tsym(p).symoptions)<>[] then
  406. sp:='0'
  407. else if ([sp_protected,sp_strictprotected]*tsym(p).symoptions)<>[] then
  408. sp:='1'
  409. else
  410. sp:='2';
  411. newrec:=def_stabstr_evaluate(nil,'$1::$2=##$3;:$4;$5A$6;',[GetSymName(tsym(p)),def_stab_number(pd),
  412. def_stab_number(pd.returndef),argnames,sp,
  413. virtualind]);
  414. { get spare place for a string at the end }
  415. olds:=state^.stabsize;
  416. inc(state^.stabsize,strlen(newrec));
  417. if state^.stabsize>=state^.staballoc-256 then
  418. begin
  419. inc(state^.staballoc,strlen(newrec)+64);
  420. reallocmem(state^.stabstring,state^.staballoc);
  421. end;
  422. strcopy(state^.stabstring+olds,newrec);
  423. freemem(newrec);
  424. {This should be used for case !!
  425. RecOffset := RecOffset + pd.size;}
  426. end;
  427. end;
  428. function TDebugInfoStabs.def_stabstr(def:tdef):pchar;
  429. function stringdef_stabstr(def:tstringdef):pchar;
  430. var
  431. slen : aint;
  432. bytest,charst,longst : string;
  433. begin
  434. case def.stringtype of
  435. st_shortstring:
  436. begin
  437. { fix length of openshortstring }
  438. slen:=def.len;
  439. if slen=0 then
  440. slen:=255;
  441. charst:=def_stab_number(cchartype);
  442. bytest:=def_stab_number(u8inttype);
  443. result:=def_stabstr_evaluate(def,'s$1length:$2,0,8;st:ar$2;1;$3;$4,8,$5;;',
  444. [tostr(slen+1),bytest,tostr(slen),charst,tostr(slen*8)]);
  445. end;
  446. st_longstring:
  447. begin
  448. charst:=def_stab_number(cchartype);
  449. bytest:=def_stab_number(u8inttype);
  450. longst:=def_stab_number(u32inttype);
  451. result:=def_stabstr_evaluate(def,'s$1length:$2,0,32;dummy:$6,32,8;st:ar$2;1;$3;$4,40,$5;;',
  452. [tostr(def.len+5),longst,tostr(def.len),charst,tostr(def.len*8),bytest]);
  453. end;
  454. st_ansistring:
  455. begin
  456. { looks like a pchar }
  457. charst:=def_stab_number(cchartype);
  458. result:=strpnew('*'+charst);
  459. end;
  460. st_widestring:
  461. begin
  462. { looks like a pwidechar }
  463. charst:=def_stab_number(cwidechartype);
  464. result:=strpnew('*'+charst);
  465. end;
  466. end;
  467. end;
  468. function enumdef_stabstr(def:tenumdef):pchar;
  469. var
  470. st : Pchar;
  471. p : Tenumsym;
  472. s : string;
  473. memsize,
  474. stl : aint;
  475. begin
  476. memsize:=memsizeinc;
  477. getmem(st,memsize);
  478. { we can specify the size with @s<size>; prefix PM }
  479. if def.size <> std_param_align then
  480. strpcopy(st,'@s'+tostr(def.size*8)+';e')
  481. else
  482. strpcopy(st,'e');
  483. p := tenumsym(def.firstenum);
  484. stl:=strlen(st);
  485. while assigned(p) do
  486. begin
  487. s :=GetSymName(p)+':'+tostr(p.value)+',';
  488. { place for the ending ';' also }
  489. if (stl+length(s)+1>=memsize) then
  490. begin
  491. inc(memsize,memsizeinc);
  492. reallocmem(st,memsize);
  493. end;
  494. strpcopy(st+stl,s);
  495. inc(stl,length(s));
  496. p:=p.nextenum;
  497. end;
  498. st[stl]:=';';
  499. st[stl+1]:=#0;
  500. reallocmem(st,stl+2);
  501. result:=st;
  502. end;
  503. function orddef_stabstr(def:torddef):pchar;
  504. begin
  505. if cs_gdb_valgrind in current_settings.globalswitches then
  506. begin
  507. case def.ordtype of
  508. uvoid :
  509. result:=strpnew(def_stab_number(def));
  510. bool8bit,
  511. bool16bit,
  512. bool32bit,
  513. bool64bit :
  514. result:=def_stabstr_evaluate(def,'r${numberstring};0;255;',[]);
  515. u32bit,
  516. s64bit,
  517. u64bit :
  518. result:=def_stabstr_evaluate(def,'r${numberstring};0;-1;',[]);
  519. else
  520. result:=def_stabstr_evaluate(def,'r${numberstring};$1;$2;',[tostr(longint(def.low.svalue)),tostr(longint(def.high.svalue))]);
  521. end;
  522. end
  523. else
  524. begin
  525. case def.ordtype of
  526. uvoid :
  527. result:=strpnew(def_stab_number(def));
  528. uchar :
  529. result:=strpnew('-20;');
  530. uwidechar :
  531. result:=strpnew('-30;');
  532. bool8bit :
  533. result:=strpnew('-21;');
  534. bool16bit :
  535. result:=strpnew('-22;');
  536. bool32bit :
  537. result:=strpnew('-23;');
  538. bool64bit :
  539. { no clue if this is correct (FK) }
  540. result:=strpnew('-23;');
  541. u64bit :
  542. result:=strpnew('-32;');
  543. s64bit :
  544. result:=strpnew('-31;');
  545. {u32bit : result:=def_stab_number(s32inttype)+';0;-1;'); }
  546. else
  547. result:=def_stabstr_evaluate(def,'r${numberstring};$1;$2;',[tostr(longint(def.low.svalue)),tostr(longint(def.high.svalue))]);
  548. end;
  549. end;
  550. end;
  551. function floatdef_stabstr(def:tfloatdef):Pchar;
  552. begin
  553. case def.floattype of
  554. s32real,
  555. s64real,
  556. s80real:
  557. result:=def_stabstr_evaluate(def,'r$1;${savesize};0;',[def_stab_number(s32inttype)]);
  558. s64currency,
  559. s64comp:
  560. result:=def_stabstr_evaluate(def,'r$1;-${savesize};0;',[def_stab_number(s32inttype)]);
  561. else
  562. internalerror(200509261);
  563. end;
  564. end;
  565. function filedef_stabstr(def:tfiledef):pchar;
  566. begin
  567. {$ifdef cpu64bit}
  568. result:=def_stabstr_evaluate(def,'s${savesize}HANDLE:$1,0,32;MODE:$1,32,32;RECSIZE:$2,64,64;'+
  569. '_PRIVATE:ar$1;1;64;$3,128,256;USERDATA:ar$1;1;16;$3,384,128;'+
  570. 'NAME:ar$1;0;255;$4,512,2048;;',[def_stab_number(s32inttype),
  571. def_stab_number(s64inttype),
  572. def_stab_number(u8inttype),
  573. def_stab_number(cchartype)]);
  574. {$else cpu64bit}
  575. result:=def_stabstr_evaluate(def,'s${savesize}HANDLE:$1,0,32;MODE:$1,32,32;RECSIZE:$1,64,32;'+
  576. '_PRIVATE:ar$1;1;32;$3,96,256;USERDATA:ar$1;1;16;$2,352,128;'+
  577. 'NAME:ar$1;0;255;$3,480,2048;;',[def_stab_number(s32inttype),
  578. def_stab_number(u8inttype),
  579. def_stab_number(cchartype)]);
  580. {$endif cpu64bit}
  581. end;
  582. function procdef_stabstr(def:tprocdef):pchar;
  583. Var
  584. RType : Char;
  585. Obj,Info : String;
  586. stabsstr : string;
  587. p : pchar;
  588. begin
  589. obj := GetSymName(def.procsym);
  590. info := '';
  591. if (po_global in def.procoptions) then
  592. RType := 'F'
  593. else
  594. RType := 'f';
  595. if assigned(def.owner) then
  596. begin
  597. if (def.owner.symtabletype = objecTSymtable) then
  598. obj := GetSymTableName(def.owner)+'__'+GetSymName(def.procsym);
  599. if not(cs_gdb_valgrind in current_settings.globalswitches) and
  600. (def.owner.symtabletype=localsymtable) and
  601. assigned(def.owner.defowner) and
  602. assigned(tprocdef(def.owner.defowner).procsym) then
  603. info := ','+GetSymName(def.procsym)+','+GetSymName(tprocdef(def.owner.defowner).procsym);
  604. end;
  605. stabsstr:=def.mangledname;
  606. getmem(p,length(stabsstr)+255);
  607. strpcopy(p,'"'+obj+':'+RType
  608. +def_stab_number(def.returndef)+info+'",'+tostr(n_function)
  609. +',0,'+
  610. tostr(def.fileinfo.line)
  611. +',');
  612. strpcopy(strend(p),stabsstr);
  613. getmem(result,strlen(p)+1);
  614. move(p^,result^,strlen(p)+1);
  615. freemem(p);
  616. end;
  617. function recorddef_stabstr(def:trecorddef):pchar;
  618. var
  619. state : Trecord_stabgen_state;
  620. begin
  621. getmem(state.stabstring,memsizeinc);
  622. state.staballoc:=memsizeinc;
  623. strpcopy(state.stabstring,'s'+tostr(def.size));
  624. state.recoffset:=0;
  625. state.stabsize:=strlen(state.stabstring);
  626. def.symtable.SymList.ForEachCall(@field_add_stabstr,@state);
  627. state.stabstring[state.stabsize]:=';';
  628. state.stabstring[state.stabsize+1]:=#0;
  629. reallocmem(state.stabstring,state.stabsize+2);
  630. result:=state.stabstring;
  631. end;
  632. function objectdef_stabstr(def:tobjectdef):pchar;
  633. var
  634. anc : tobjectdef;
  635. state :Trecord_stabgen_state;
  636. ts : string;
  637. begin
  638. { Write the invisible pointer for the class? }
  639. if (def.objecttype=odt_class) and
  640. (not def.writing_class_record_dbginfo) then
  641. begin
  642. result:=strpnew('*'+def_stab_classnumber(def));
  643. exit;
  644. end;
  645. state.staballoc:=memsizeinc;
  646. getmem(state.stabstring,state.staballoc);
  647. strpcopy(state.stabstring,'s'+tostr(tobjecTSymtable(def.symtable).datasize));
  648. if assigned(def.childof) then
  649. begin
  650. {only one ancestor not virtual, public, at base offset 0 }
  651. { !1 , 0 2 0 , }
  652. strpcopy(strend(state.stabstring),'!1,020,'+def_stab_classnumber(def.childof)+';');
  653. end;
  654. {virtual table to implement yet}
  655. state.recoffset:=0;
  656. state.stabsize:=strlen(state.stabstring);
  657. def.symtable.symList.ForEachCall(@field_add_stabstr,@state);
  658. if (oo_has_vmt in def.objectoptions) then
  659. if not assigned(def.childof) or not(oo_has_vmt in def.childof.objectoptions) then
  660. begin
  661. ts:='$vf'+def_stab_classnumber(def)+':'+def_stab_number(vmtarraytype)+','+tostr(def.vmt_offset*8)+';';
  662. strpcopy(state.stabstring+state.stabsize,ts);
  663. inc(state.stabsize,length(ts));
  664. end;
  665. def.symtable.symList.ForEachCall(@method_add_stabstr,@state);
  666. if (oo_has_vmt in def.objectoptions) then
  667. begin
  668. anc := def;
  669. while assigned(anc.childof) and (oo_has_vmt in anc.childof.objectoptions) do
  670. anc := anc.childof;
  671. { just in case anc = self }
  672. ts:=';~%'+def_stab_classnumber(anc)+';';
  673. end
  674. else
  675. ts:=';';
  676. strpcopy(state.stabstring+state.stabsize,ts);
  677. inc(state.stabsize,length(ts));
  678. reallocmem(state.stabstring,state.stabsize+1);
  679. result:=state.stabstring;
  680. end;
  681. var
  682. tempstr: pchar;
  683. begin
  684. result:=nil;
  685. case def.typ of
  686. stringdef :
  687. result:=stringdef_stabstr(tstringdef(def));
  688. enumdef :
  689. result:=enumdef_stabstr(tenumdef(def));
  690. orddef :
  691. result:=orddef_stabstr(torddef(def));
  692. floatdef :
  693. result:=floatdef_stabstr(tfloatdef(def));
  694. filedef :
  695. result:=filedef_stabstr(tfiledef(def));
  696. recorddef :
  697. result:=recorddef_stabstr(trecorddef(def));
  698. variantdef :
  699. result:=def_stabstr_evaluate(def,'${numberstring};',[]);
  700. pointerdef :
  701. result:=strpnew('*'+def_stab_number(tpointerdef(def).pointeddef));
  702. classrefdef :
  703. result:=strpnew(def_stab_number(pvmttype));
  704. setdef :
  705. result:=def_stabstr_evaluate(def,'@s$1;S$2',[tostr(def.size*8),def_stab_number(tsetdef(def).elementdef)]);
  706. formaldef :
  707. result:=def_stabstr_evaluate(def,'${numberstring};',[]);
  708. arraydef :
  709. if not is_packed_array(def) then
  710. result:=def_stabstr_evaluate(def,'ar$1;$2;$3;$4',[def_stab_number(tarraydef(def).rangedef),
  711. tostr(tarraydef(def).lowrange),tostr(tarraydef(def).highrange),def_stab_number(tarraydef(def).elementdef)])
  712. else
  713. begin
  714. // the @P seems to be ignored by gdb
  715. // result:=def_stabstr_evaluate(def,'ar$1;$2;$3;$4;@P;',[def_stab_number(tarraydef(def).rangedef),tostr(tarraydef(def).lowrange),tostr(tarraydef(def).highrange),def_stab_number(tarraydef(def).elementdef)]);
  716. tempstr:=def_stabstr_evaluate(tarraydef(def).rangedef,'r${numberstring};$1;$2;',
  717. [tostr(tarraydef(def).lowrange),tostr(tarraydef(def).highrange)]);
  718. // will only show highrange-lowrange+1 bits in gdb
  719. result:=def_stabstr_evaluate(def,'@s$1;@S;S$2',
  720. [tostr(TConstExprInt(tarraydef(def).elepackedbitsize) * tarraydef(def).elecount),tempstr]);
  721. freemem(tempstr);
  722. end;
  723. procdef :
  724. result:=procdef_stabstr(tprocdef(def));
  725. procvardef :
  726. result:=strpnew('*f'+def_stab_number(tprocvardef(def).returndef));
  727. objectdef :
  728. result:=objectdef_stabstr(tobjectdef(def));
  729. undefineddef :
  730. result:=def_stabstr_evaluate(def,'${numberstring};',[]);
  731. end;
  732. if result=nil then
  733. internalerror(200512203);
  734. end;
  735. procedure TDebugInfoStabs.write_def_stabstr(list:TAsmList;def:tdef);
  736. var
  737. stabchar : string[2];
  738. ss,st,su : pchar;
  739. begin
  740. { procdefs require a different stabs style without type prefix }
  741. if def.typ=procdef then
  742. begin
  743. st:=def_stabstr(def);
  744. { add to list }
  745. list.concat(Tai_stab.create(stab_stabs,st));
  746. end
  747. else
  748. begin
  749. { type prefix }
  750. if def.typ in tagtypes then
  751. stabchar := 'Tt'
  752. else
  753. stabchar := 't';
  754. { Here we maybe generate a type, so we have to use numberstring }
  755. if is_class(def) and
  756. tobjectdef(def).writing_class_record_dbginfo then
  757. st:=def_stabstr_evaluate(def,'"${sym_name}:$1$2=',[stabchar,def_stab_classnumber(tobjectdef(def))])
  758. else
  759. st:=def_stabstr_evaluate(def,'"${sym_name}:$1$2=',[stabchar,def_stab_number(def)]);
  760. ss:=def_stabstr(def);
  761. reallocmem(st,strlen(ss)+512);
  762. { line info is set to 0 for all defs, because the def can be in an other
  763. unit and then the linenumber is invalid in the current sourcefile }
  764. su:=def_stabstr_evaluate(def,'",${N_LSYM},0,0,0',[]);
  765. strcopy(strecopy(strend(st),ss),su);
  766. reallocmem(st,strlen(st)+1);
  767. freemem(ss);
  768. freemem(su);
  769. { add to list }
  770. list.concat(Tai_stab.create(stab_stabs,st));
  771. end;
  772. end;
  773. procedure TDebugInfoStabs.insertdef(list:TAsmList;def:tdef);
  774. var
  775. anc : tobjectdef;
  776. oldtypesym : tsym;
  777. i : longint;
  778. begin
  779. if (def.dbg_state in [dbg_state_writing,dbg_state_written]) then
  780. exit;
  781. { never write generic template defs }
  782. if df_generic in def.defoptions then
  783. begin
  784. def.dbg_state:=dbg_state_written;
  785. exit;
  786. end;
  787. { to avoid infinite loops }
  788. def.dbg_state := dbg_state_writing;
  789. { write dependencies first }
  790. case def.typ of
  791. stringdef :
  792. begin
  793. if tstringdef(def).stringtype=st_widestring then
  794. insertdef(list,cwidechartype)
  795. else
  796. begin
  797. insertdef(list,cchartype);
  798. insertdef(list,u8inttype);
  799. end;
  800. end;
  801. floatdef :
  802. insertdef(list,s32inttype);
  803. filedef :
  804. begin
  805. insertdef(list,s32inttype);
  806. {$ifdef cpu64bit}
  807. insertdef(list,s64inttype);
  808. {$endif cpu64bit}
  809. insertdef(list,u8inttype);
  810. insertdef(list,cchartype);
  811. end;
  812. classrefdef :
  813. insertdef(list,pvmttype);
  814. pointerdef :
  815. insertdef(list,tpointerdef(def).pointeddef);
  816. setdef :
  817. insertdef(list,tsetdef(def).elementdef);
  818. procvardef :
  819. begin
  820. insertdef(list,tprocvardef(def).returndef);
  821. if assigned(tprocvardef(def).parast) then
  822. write_symtable_defs(list,tprocvardef(def).parast);
  823. end;
  824. procdef :
  825. begin
  826. insertdef(list,tprocdef(def).returndef);
  827. if assigned(tprocdef(def).parast) then
  828. write_symtable_defs(list,tprocdef(def).parast);
  829. if assigned(tprocdef(def).localst) and
  830. (tprocdef(def).localst.symtabletype=localsymtable) then
  831. write_symtable_defs(list,tprocdef(def).localst);
  832. end;
  833. arraydef :
  834. begin
  835. insertdef(list,tarraydef(def).rangedef);
  836. insertdef(list,tarraydef(def).elementdef);
  837. end;
  838. recorddef :
  839. trecorddef(def).symtable.symList.ForEachCall(@field_write_defs,list);
  840. enumdef :
  841. if assigned(tenumdef(def).basedef) then
  842. insertdef(list,tenumdef(def).basedef);
  843. objectdef :
  844. begin
  845. { make sure we don't write child classdefs before their parent }
  846. { classdefs, because this crashes gdb }
  847. anc:=tobjectdef(def);
  848. while assigned(anc.childof) do
  849. begin
  850. anc:=anc.childof;
  851. if (anc.dbg_state=dbg_state_writing) then
  852. { happens in case a field of a parent is of the (forward }
  853. { defined) child type }
  854. begin
  855. { We don't explicitly requeue it, but the fact that }
  856. { a child type was used in a parent before the child }
  857. { type was fully defined means that it was forward }
  858. { declared, and will still be encountered later (it }
  859. { cannot have been declared in another unit, because }
  860. { then this and that other unit would depend on }
  861. { eachother's interface) }
  862. { Setting the state to queued however allows us to }
  863. { get the def number already without an IE }
  864. def.dbg_state:=dbg_state_queued;
  865. exit;
  866. end;
  867. end;
  868. insertdef(list,vmtarraytype);
  869. if assigned(tobjectdef(def).ImplementedInterfaces) then
  870. for i:=0 to tobjectdef(def).ImplementedInterfaces.Count-1 do
  871. insertdef(list,TImplementedInterface(tobjectdef(def).ImplementedInterfaces[i]).IntfDef);
  872. { first the parents }
  873. anc:=tobjectdef(def);
  874. while assigned(anc.childof) do
  875. begin
  876. anc:=anc.childof;
  877. insertdef(list,anc);
  878. if assigned(anc.ImplementedInterfaces) then
  879. for i:=0 to anc.ImplementedInterfaces.Count-1 do
  880. insertdef(list,TImplementedInterface(anc.ImplementedInterfaces[i]).IntfDef);
  881. end;
  882. tobjectdef(def).symtable.symList.ForEachCall(@field_write_defs,list);
  883. tobjectdef(def).symtable.symList.ForEachCall(@method_write_defs,list);
  884. end;
  885. end;
  886. case def.typ of
  887. objectdef :
  888. begin
  889. { classes require special code to write the record and the invisible pointer }
  890. if is_class(def) then
  891. begin
  892. { Write the record class itself }
  893. tobjectdef(def).writing_class_record_dbginfo:=true;
  894. write_def_stabstr(list,def);
  895. tobjectdef(def).writing_class_record_dbginfo:=false;
  896. { Write the invisible pointer class }
  897. oldtypesym:=def.typesym;
  898. def.typesym:=nil;
  899. write_def_stabstr(list,def);
  900. def.typesym:=oldtypesym;
  901. end
  902. else
  903. write_def_stabstr(list,def);
  904. { VMT symbol }
  905. if (oo_has_vmt in tobjectdef(def).objectoptions) and
  906. assigned(def.owner) and
  907. assigned(def.owner.name) then
  908. list.concat(Tai_stab.create(stab_stabs,strpnew('"vmt_'+GetSymTableName(def.owner)+tobjectdef(def).objname^+':S'+
  909. def_stab_number(vmttype)+'",'+tostr(N_STSYM)+',0,0,'+tobjectdef(def).vmt_mangledname)));
  910. end;
  911. procdef :
  912. begin
  913. { procdefs are handled separatly }
  914. end;
  915. else
  916. write_def_stabstr(list,def);
  917. end;
  918. def.dbg_state := dbg_state_written;
  919. end;
  920. procedure TDebugInfoStabs.write_symtable_defs(list:TAsmList;st:TSymtable);
  921. procedure dowritestabs(list:TAsmList;st:TSymtable);
  922. var
  923. def : tdef;
  924. i : longint;
  925. begin
  926. for i:=0 to st.DefList.Count-1 do
  927. begin
  928. def:=tdef(st.DefList[i]);
  929. if (def.dbg_state in [dbg_state_used,dbg_state_queued]) then
  930. insertdef(list,def);
  931. end;
  932. end;
  933. var
  934. old_writing_def_stabs : boolean;
  935. begin
  936. case st.symtabletype of
  937. staticsymtable :
  938. list.concat(tai_comment.Create(strpnew('Defs - Begin Staticsymtable')));
  939. globalsymtable :
  940. list.concat(tai_comment.Create(strpnew('Defs - Begin unit '+GetSymTableName(st)+' has index '+tostr(st.moduleid))));
  941. end;
  942. old_writing_def_stabs:=writing_def_stabs;
  943. writing_def_stabs:=true;
  944. dowritestabs(list,st);
  945. writing_def_stabs:=old_writing_def_stabs;
  946. case st.symtabletype of
  947. staticsymtable :
  948. list.concat(tai_comment.Create(strpnew('Defs - End Staticsymtable')));
  949. globalsymtable :
  950. list.concat(tai_comment.Create(strpnew('Defs - End unit '+GetSymTableName(st)+' has index '+tostr(st.moduleid))));
  951. end;
  952. end;
  953. procedure TDebugInfoStabs.write_procdef(list:TAsmList;pd:tprocdef);
  954. var
  955. templist : TAsmList;
  956. stabsendlabel : tasmlabel;
  957. mangled_length : longint;
  958. p,p1 : pchar;
  959. hs : string;
  960. begin
  961. if assigned(pd.procstarttai) then
  962. begin
  963. { mark as used, so also the local and para defs will be written }
  964. pd.dbg_state:=dbg_state_used;
  965. templist:=TAsmList.create;
  966. { end of procedure }
  967. current_asmdata.getlabel(stabsendlabel,alt_dbgtype);
  968. if assigned(pd.funcretsym) and
  969. (tabstractnormalvarsym(pd.funcretsym).refs>0) then
  970. begin
  971. if tabstractnormalvarsym(pd.funcretsym).localloc.loc=LOC_REFERENCE then
  972. begin
  973. {$warning Need to add gdb support for ret in param register calling}
  974. if paramanager.ret_in_param(pd.returndef,pd.proccalloption) then
  975. hs:='X*'
  976. else
  977. hs:='X';
  978. templist.concat(Tai_stab.create(stab_stabs,strpnew(
  979. '"'+GetSymName(pd.procsym)+':'+hs+def_stab_number(pd.returndef)+'",'+
  980. tostr(N_tsym)+',0,0,'+tostr(tabstractnormalvarsym(pd.funcretsym).localloc.reference.offset))));
  981. if (m_result in current_settings.modeswitches) then
  982. templist.concat(Tai_stab.create(stab_stabs,strpnew(
  983. '"RESULT:'+hs+def_stab_number(pd.returndef)+'",'+
  984. tostr(N_tsym)+',0,0,'+tostr(tabstractnormalvarsym(pd.funcretsym).localloc.reference.offset))));
  985. end;
  986. end;
  987. mangled_length:=length(pd.mangledname);
  988. getmem(p,2*mangled_length+50);
  989. strpcopy(p,tostr(N_LBRAC)+',0,0,');
  990. {$IFDEF POWERPC64}strpcopy(strend(p), '.');{$ENDIF POWERPC64}
  991. strpcopy(strend(p),pd.mangledname);
  992. if (tf_use_function_relative_addresses in target_info.flags) then
  993. begin
  994. strpcopy(strend(p),'-');
  995. {$IFDEF POWERPC64}strpcopy(strend(p), '.');{$ENDIF POWERPC64}
  996. strpcopy(strend(p),pd.mangledname);
  997. end;
  998. getmem(p1,strlen(p)+1);
  999. move(p^,p1^,strlen(p)+1);
  1000. templist.concat(Tai_stab.Create(stab_stabn,p1));
  1001. strpcopy(p,tostr(N_RBRAC)+',0,0,'+stabsendlabel.name);
  1002. if (tf_use_function_relative_addresses in target_info.flags) then
  1003. begin
  1004. strpcopy(strend(p),'-');
  1005. {$IFDEF POWERPC64}strpcopy(strend(p), '.');{$ENDIF POWERPC64}
  1006. strpcopy(strend(p),pd.mangledname);
  1007. end;
  1008. getmem(p1,strlen(p)+1);
  1009. move(p^,p1^,strlen(p)+1);
  1010. templist.concat(Tai_stab.Create(stab_stabn,p1));
  1011. freemem(p,2*mangled_length+50);
  1012. { the stabsendlabel must come after all other stabs for this }
  1013. { function }
  1014. templist.concat(tai_label.create(stabsendlabel));
  1015. { Add a "size" stab as described in the last paragraph of 2.5 at }
  1016. { http://sourceware.org/gdb/current/onlinedocs/stabs_2.html#SEC12 }
  1017. { This works at least on Darwin (and is needed on Darwin to get }
  1018. { correct smartlinking of stabs), but I don't know which binutils }
  1019. { version is required on other platforms }
  1020. { This stab must come after all other stabs for the procedure, }
  1021. { including the LBRAC/RBRAC ones }
  1022. if (target_info.system in systems_darwin) then
  1023. templist.concat(Tai_stab.create(stab_stabs,
  1024. strpnew('"",'+tostr(N_FUNCTION)+',0,0,'+stabsendlabel.name+'-'+pd.mangledname)));
  1025. current_asmdata.asmlists[al_procedures].insertlistafter(pd.procendtai,templist);
  1026. { "The stab representing a procedure is located immediately
  1027. following the code of the procedure. This stab is in turn
  1028. directly followed by a group of other stabs describing
  1029. elements of the procedure. These other stabs describe the
  1030. procedure's parameters, its block local variables, and its
  1031. block structure." (stab docs) }
  1032. { this is however incorrect in case "include source" statements }
  1033. { appear in the block, in that case the procedure stab must }
  1034. { appear before this include stabs (and we generate such an }
  1035. { stabs for all functions) (JM) }
  1036. { procdef }
  1037. write_def_stabstr(templist,pd);
  1038. current_asmdata.asmlists[al_procedures].insertlistbefore(pd.procstarttai,templist);
  1039. { para types }
  1040. if assigned(pd.parast) then
  1041. write_symtable_syms(templist,pd.parast);
  1042. { local type defs and vars should not be written
  1043. inside the main proc stab }
  1044. if assigned(pd.localst) and
  1045. (pd.localst.symtabletype=localsymtable) then
  1046. write_symtable_syms(templist,pd.localst);
  1047. current_asmdata.asmlists[al_procedures].insertlistbefore(pd.procstarttai,templist);
  1048. templist.free;
  1049. end;
  1050. end;
  1051. {****************************************************************************
  1052. TSym support
  1053. ****************************************************************************}
  1054. function TDebugInfoStabs.sym_var_value(const s:string;arg:pointer):string;
  1055. var
  1056. sym : tsym;
  1057. begin
  1058. sym:=tsym(arg);
  1059. result:='';
  1060. if s='name' then
  1061. result:=GetSymName(sym)
  1062. else if s='mangledname' then
  1063. result:=sym.mangledname
  1064. else if s='ownername' then
  1065. result:=GetSymTableName(sym.owner)
  1066. else if s='line' then
  1067. result:=tostr(sym.fileinfo.line)
  1068. else if s='N_LSYM' then
  1069. result:=tostr(N_LSYM)
  1070. else if s='N_LCSYM' then
  1071. result:=tostr(N_LCSYM)
  1072. else if s='N_RSYM' then
  1073. result:=tostr(N_RSYM)
  1074. else if s='N_TSYM' then
  1075. result:=tostr(N_TSYM)
  1076. else if s='N_STSYM' then
  1077. result:=tostr(N_STSYM)
  1078. else if s='N_FUNCTION' then
  1079. result:=tostr(N_FUNCTION)
  1080. else
  1081. internalerror(200401152);
  1082. end;
  1083. function TDebugInfoStabs.sym_stabstr_evaluate(sym:tsym;const s:string;const vars:array of string):Pchar;
  1084. begin
  1085. result:=string_evaluate(s,@sym_var_value,sym,vars);
  1086. end;
  1087. procedure TDebugInfoStabs.insertsym(list:TAsmList;sym:tsym);
  1088. function fieldvarsym_stabstr(sym:tfieldvarsym):Pchar;
  1089. begin
  1090. result:=nil;
  1091. if (sym.owner.symtabletype=objecTSymtable) and
  1092. (sp_static in sym.symoptions) then
  1093. result:=sym_stabstr_evaluate(sym,'"${ownername}__${name}:S$1",${N_LCSYM},0,${line},${mangledname}',
  1094. [def_stab_number(sym.vardef)]);
  1095. end;
  1096. function staticvarsym_stabstr(sym:tstaticvarsym):Pchar;
  1097. var
  1098. st : string;
  1099. threadvaroffset : string;
  1100. regidx : Tregisterindex;
  1101. nsym : string[7];
  1102. begin
  1103. result:=nil;
  1104. { external symbols can't be resolved at link time, so we
  1105. can't generate stabs for them }
  1106. if vo_is_external in sym.varoptions then
  1107. exit;
  1108. st:=def_stab_number(sym.vardef);
  1109. case sym.localloc.loc of
  1110. LOC_REGISTER,
  1111. LOC_CREGISTER,
  1112. LOC_MMREGISTER,
  1113. LOC_CMMREGISTER,
  1114. LOC_FPUREGISTER,
  1115. LOC_CFPUREGISTER :
  1116. begin
  1117. regidx:=findreg_by_number(sym.localloc.register);
  1118. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1119. { this is the register order for GDB}
  1120. if regidx<>0 then
  1121. result:=sym_stabstr_evaluate(sym,'"${name}:r$1",${N_RSYM},0,${line},$2',[st,tostr(regstabs_table[regidx])]);
  1122. end;
  1123. else
  1124. begin
  1125. if (vo_is_thread_var in sym.varoptions) then
  1126. threadvaroffset:='+'+tostr(sizeof(aint))
  1127. else
  1128. threadvaroffset:='';
  1129. if (vo_is_typed_const in sym.varoptions) then
  1130. nsym:='N_STSYM'
  1131. else
  1132. nsym:='N_LCSYM';
  1133. { Here we used S instead of
  1134. because with G GDB doesn't look at the address field
  1135. but searches the same name or with a leading underscore
  1136. but these names don't exist in pascal !}
  1137. st:='S'+st;
  1138. result:=sym_stabstr_evaluate(sym,'"${name}:$1",${'+nsym+'},0,${line},${mangledname}$2',[st,threadvaroffset]);
  1139. end;
  1140. end;
  1141. end;
  1142. function localvarsym_stabstr(sym:tlocalvarsym):Pchar;
  1143. var
  1144. st : string;
  1145. regidx : Tregisterindex;
  1146. begin
  1147. result:=nil;
  1148. { There is no space allocated for not referenced locals }
  1149. if (sym.owner.symtabletype=localsymtable) and (sym.refs=0) then
  1150. exit;
  1151. st:=def_stab_number(sym.vardef);
  1152. case sym.localloc.loc of
  1153. LOC_REGISTER,
  1154. LOC_CREGISTER,
  1155. LOC_MMREGISTER,
  1156. LOC_CMMREGISTER,
  1157. LOC_FPUREGISTER,
  1158. LOC_CFPUREGISTER :
  1159. begin
  1160. regidx:=findreg_by_number(sym.localloc.register);
  1161. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1162. { this is the register order for GDB}
  1163. if regidx<>0 then
  1164. result:=sym_stabstr_evaluate(sym,'"${name}:r$1",${N_RSYM},0,${line},$2',[st,tostr(regstabs_table[regidx])]);
  1165. end;
  1166. LOC_REFERENCE :
  1167. { offset to ebp => will not work if the framepointer is esp
  1168. so some optimizing will make things harder to debug }
  1169. result:=sym_stabstr_evaluate(sym,'"${name}:$1",${N_TSYM},0,${line},$2',[st,tostr(sym.localloc.reference.offset)])
  1170. else
  1171. internalerror(2003091814);
  1172. end;
  1173. end;
  1174. function paravarsym_stabstr(sym:tparavarsym):Pchar;
  1175. var
  1176. st : string;
  1177. regidx : Tregisterindex;
  1178. c : char;
  1179. begin
  1180. result:=nil;
  1181. { set loc to LOC_REFERENCE to get somewhat usable debugging info for -Or }
  1182. { while stabs aren't adapted for regvars yet }
  1183. if (vo_is_self in sym.varoptions) then
  1184. begin
  1185. case sym.localloc.loc of
  1186. LOC_REGISTER,
  1187. LOC_CREGISTER:
  1188. regidx:=findreg_by_number(sym.localloc.register);
  1189. LOC_REFERENCE: ;
  1190. else
  1191. internalerror(2003091815);
  1192. end;
  1193. if (po_classmethod in tabstractprocdef(sym.owner.defowner).procoptions) or
  1194. (po_staticmethod in tabstractprocdef(sym.owner.defowner).procoptions) then
  1195. begin
  1196. if (sym.localloc.loc=LOC_REFERENCE) then
  1197. result:=sym_stabstr_evaluate(sym,'"pvmt:p$1",${N_TSYM},0,0,$2',
  1198. [def_stab_number(pvmttype),tostr(sym.localloc.reference.offset)])
  1199. else
  1200. begin
  1201. regidx:=findreg_by_number(sym.localloc.register);
  1202. result:=sym_stabstr_evaluate(sym,'"pvmt:r$1",${N_RSYM},0,0,$2',
  1203. [def_stab_number(pvmttype),tostr(regstabs_table[regidx])]);
  1204. end
  1205. end
  1206. else
  1207. begin
  1208. if not(is_class(tprocdef(sym.owner.defowner)._class)) then
  1209. c:='v'
  1210. else
  1211. c:='p';
  1212. if (sym.localloc.loc=LOC_REFERENCE) then
  1213. result:=sym_stabstr_evaluate(sym,'"$$t:$1",${N_TSYM},0,0,$2',
  1214. [c+def_stab_number(tprocdef(sym.owner.defowner)._class),tostr(sym.localloc.reference.offset)])
  1215. else
  1216. begin
  1217. regidx:=findreg_by_number(sym.localloc.register);
  1218. result:=sym_stabstr_evaluate(sym,'"$$t:r$1",${N_RSYM},0,0,$2',
  1219. [c+def_stab_number(tprocdef(sym.owner.defowner)._class),tostr(regstabs_table[regidx])]);
  1220. end
  1221. end;
  1222. end
  1223. else
  1224. begin
  1225. st:=def_stab_number(sym.vardef);
  1226. if paramanager.push_addr_param(sym.varspez,sym.vardef,tprocdef(sym.owner.defowner).proccalloption) and
  1227. not(vo_has_local_copy in sym.varoptions) and
  1228. not is_open_string(sym.vardef) then
  1229. c:='v' { should be 'i' but 'i' doesn't work }
  1230. else
  1231. c:='p';
  1232. case sym.localloc.loc of
  1233. LOC_REGISTER,
  1234. LOC_CREGISTER,
  1235. LOC_MMREGISTER,
  1236. LOC_CMMREGISTER,
  1237. LOC_FPUREGISTER,
  1238. LOC_CFPUREGISTER :
  1239. begin
  1240. if c='p' then
  1241. c:='R'
  1242. else
  1243. c:='a';
  1244. st:=c+st;
  1245. regidx:=findreg_by_number(sym.localloc.register);
  1246. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1247. { this is the register order for GDB}
  1248. if regidx<>0 then
  1249. result:=sym_stabstr_evaluate(sym,'"${name}:$1",${N_RSYM},0,${line},$2',[st,tostr(longint(regstabs_table[regidx]))]);
  1250. end;
  1251. LOC_REFERENCE :
  1252. begin
  1253. st:=c+st;
  1254. { offset to ebp => will not work if the framepointer is esp
  1255. so some optimizing will make things harder to debug }
  1256. result:=sym_stabstr_evaluate(sym,'"${name}:$1",${N_TSYM},0,${line},$2',[st,tostr(sym.localloc.reference.offset)])
  1257. end;
  1258. else
  1259. internalerror(2003091814);
  1260. end;
  1261. end;
  1262. end;
  1263. function constsym_stabstr(sym:tconstsym):Pchar;
  1264. var
  1265. st : string;
  1266. begin
  1267. result:=nil;
  1268. { Don't write info for default parameter values, the N_Func breaks
  1269. the N_Func for the function itself.
  1270. Valgrind does not support constants }
  1271. if (sym.owner.symtabletype=parasymtable) or
  1272. (cs_gdb_valgrind in current_settings.globalswitches) then
  1273. exit;
  1274. case sym.consttyp of
  1275. conststring:
  1276. begin
  1277. if sym.value.len<200 then
  1278. st:='s'''+backspace_quote(octal_quote(strpas(pchar(sym.value.valueptr)),[#0..#9,#11,#12,#14..#31,'''']),['"','\',#10,#13])+''''
  1279. else
  1280. st:='<constant string too long>';
  1281. end;
  1282. constord:
  1283. st:='i'+tostr(sym.value.valueord);
  1284. constpointer:
  1285. st:='i'+tostr(sym.value.valueordptr);
  1286. constreal:
  1287. begin
  1288. system.str(pbestreal(sym.value.valueptr)^,st);
  1289. st := 'r'+st;
  1290. end;
  1291. else
  1292. begin
  1293. { if we don't know just put zero !! }
  1294. st:='i0';
  1295. end;
  1296. end;
  1297. result:=sym_stabstr_evaluate(sym,'"${name}:c=$1;",${N_FUNCTION},0,${line},0',[st]);
  1298. end;
  1299. function typesym_stabstr(sym:ttypesym) : pchar;
  1300. var
  1301. stabchar : string[2];
  1302. begin
  1303. result:=nil;
  1304. if not assigned(sym.typedef) then
  1305. internalerror(200509262);
  1306. if sym.typedef.typ in tagtypes then
  1307. stabchar:='Tt'
  1308. else
  1309. stabchar:='t';
  1310. result:=sym_stabstr_evaluate(sym,'"${name}:$1$2",${N_LSYM},0,${line},0',[stabchar,def_stab_number(sym.typedef)]);
  1311. end;
  1312. function procsym_stabstr(sym:tprocsym) : pchar;
  1313. var
  1314. i : longint;
  1315. begin
  1316. result:=nil;
  1317. for i:=0 to sym.ProcdefList.Count-1 do
  1318. write_procdef(list,tprocdef(sym.ProcdefList[i]));
  1319. end;
  1320. var
  1321. stabstr : Pchar;
  1322. begin
  1323. stabstr:=nil;
  1324. case sym.typ of
  1325. labelsym :
  1326. stabstr:=sym_stabstr_evaluate(sym,'"${name}",${N_LSYM},0,${line},0',[]);
  1327. fieldvarsym :
  1328. stabstr:=fieldvarsym_stabstr(tfieldvarsym(sym));
  1329. staticvarsym :
  1330. stabstr:=staticvarsym_stabstr(tstaticvarsym(sym));
  1331. localvarsym :
  1332. stabstr:=localvarsym_stabstr(tlocalvarsym(sym));
  1333. paravarsym :
  1334. stabstr:=paravarsym_stabstr(tparavarsym(sym));
  1335. constsym :
  1336. stabstr:=constsym_stabstr(tconstsym(sym));
  1337. typesym :
  1338. stabstr:=typesym_stabstr(ttypesym(sym));
  1339. procsym :
  1340. stabstr:=procsym_stabstr(tprocsym(sym));
  1341. end;
  1342. if stabstr<>nil then
  1343. list.concat(Tai_stab.create(stab_stabs,stabstr));
  1344. { For object types write also the symtable entries }
  1345. if (sym.typ=typesym) and (ttypesym(sym).typedef.typ=objectdef) then
  1346. write_symtable_syms(list,tobjectdef(ttypesym(sym).typedef).symtable);
  1347. sym.isdbgwritten:=true;
  1348. end;
  1349. procedure TDebugInfoStabs.write_symtable_syms(list:TAsmList;st:TSymtable);
  1350. var
  1351. sym : tsym;
  1352. i : longint;
  1353. begin
  1354. case st.symtabletype of
  1355. staticsymtable :
  1356. list.concat(tai_comment.Create(strpnew('Syms - Begin Staticsymtable')));
  1357. globalsymtable :
  1358. list.concat(tai_comment.Create(strpnew('Syms - Begin unit '+GetSymTableName(st)+' has index '+tostr(st.moduleid))));
  1359. end;
  1360. for i:=0 to st.SymList.Count-1 do
  1361. begin
  1362. sym:=tsym(st.SymList[i]);
  1363. if not(sp_hidden in sym.symoptions) and
  1364. (not sym.isdbgwritten) then
  1365. insertsym(list,sym);
  1366. end;
  1367. case st.symtabletype of
  1368. staticsymtable :
  1369. list.concat(tai_comment.Create(strpnew('Syms - End Staticsymtable')));
  1370. globalsymtable :
  1371. list.concat(tai_comment.Create(strpnew('Syms - End unit '+GetSymTableName(st)+' has index '+tostr(st.moduleid))));
  1372. end;
  1373. end;
  1374. {****************************************************************************
  1375. Proc/Module support
  1376. ****************************************************************************}
  1377. procedure tdebuginfostabs.inserttypeinfo;
  1378. var
  1379. stabsvarlist,
  1380. stabstypelist : TAsmList;
  1381. storefilepos : tfileposinfo;
  1382. i : longint;
  1383. begin
  1384. storefilepos:=current_filepos;
  1385. current_filepos:=current_module.mainfilepos;
  1386. global_stab_number:=0;
  1387. defnumberlist:=TFPObjectlist.create(false);
  1388. stabsvarlist:=TAsmList.create;
  1389. stabstypelist:=TAsmList.create;
  1390. { include symbol that will be referenced from the main to be sure to
  1391. include this debuginfo .o file }
  1392. current_module.flags:=current_module.flags or uf_has_debuginfo;
  1393. if not(target_info.system in systems_darwin) then
  1394. begin
  1395. new_section(current_asmdata.asmlists[al_stabs],sec_data,GetSymTableName(current_module.localsymtable),0);
  1396. current_asmdata.asmlists[al_stabs].concat(tai_symbol.Createname_global(make_mangledname('DEBUGINFO',current_module.localsymtable,''),AT_DATA,0));
  1397. end
  1398. else
  1399. new_section(current_asmdata.asmlists[al_stabs],sec_code,GetSymTableName(current_module.localsymtable),0);
  1400. { first write all global/local symbols. This will flag all required tdefs }
  1401. if assigned(current_module.globalsymtable) then
  1402. write_symtable_syms(stabsvarlist,current_module.globalsymtable);
  1403. if assigned(current_module.localsymtable) then
  1404. write_symtable_syms(stabsvarlist,current_module.localsymtable);
  1405. { reset unit type info flag }
  1406. reset_unit_type_info;
  1407. { write used types from the used units }
  1408. write_used_unit_type_info(stabstypelist,current_module);
  1409. { last write the types from this unit }
  1410. if assigned(current_module.globalsymtable) then
  1411. write_symtable_defs(stabstypelist,current_module.globalsymtable);
  1412. if assigned(current_module.localsymtable) then
  1413. write_symtable_defs(stabstypelist,current_module.localsymtable);
  1414. current_asmdata.asmlists[al_stabs].concatlist(stabstypelist);
  1415. current_asmdata.asmlists[al_stabs].concatlist(stabsvarlist);
  1416. { reset stab numbers }
  1417. for i:=0 to defnumberlist.count-1 do
  1418. begin
  1419. if assigned(defnumberlist[i]) then
  1420. begin
  1421. tdef(defnumberlist[i]).stab_number:=0;
  1422. tdef(defnumberlist[i]).dbg_state:=dbg_state_unused;
  1423. end;
  1424. end;
  1425. defnumberlist.free;
  1426. defnumberlist:=nil;
  1427. stabsvarlist.free;
  1428. stabstypelist.free;
  1429. current_filepos:=storefilepos;
  1430. end;
  1431. procedure tdebuginfostabs.insertlineinfo(list:TAsmList);
  1432. var
  1433. currfileinfo,
  1434. lastfileinfo : tfileposinfo;
  1435. currfuncname : pshortstring;
  1436. currsectype : TAsmSectiontype;
  1437. hlabel : tasmlabel;
  1438. hp : tai;
  1439. infile : tinputfile;
  1440. begin
  1441. FillChar(lastfileinfo,sizeof(lastfileinfo),0);
  1442. currfuncname:=nil;
  1443. currsectype:=sec_code;
  1444. hp:=Tai(list.first);
  1445. while assigned(hp) do
  1446. begin
  1447. case hp.typ of
  1448. ait_section :
  1449. currsectype:=tai_section(hp).sectype;
  1450. ait_function_name :
  1451. currfuncname:=tai_function_name(hp).funcname;
  1452. ait_force_line :
  1453. lastfileinfo.line:=-1;
  1454. end;
  1455. if (currsectype=sec_code) and
  1456. (hp.typ=ait_instruction) then
  1457. begin
  1458. currfileinfo:=tailineinfo(hp).fileinfo;
  1459. { file changed ? (must be before line info) }
  1460. if (currfileinfo.fileindex<>0) and
  1461. (lastfileinfo.fileindex<>currfileinfo.fileindex) then
  1462. begin
  1463. infile:=current_module.sourcefiles.get_file(currfileinfo.fileindex);
  1464. if assigned(infile) then
  1465. begin
  1466. current_asmdata.getlabel(hlabel,alt_dbgfile);
  1467. { emit stabs }
  1468. if (infile.path^<>'') then
  1469. list.insertbefore(Tai_stab.Create_str(stab_stabs,'"'+BsToSlash(FixPath(infile.path^,false))+'",'+tostr(n_includefile)+
  1470. ',0,0,'+hlabel.name),hp);
  1471. list.insertbefore(Tai_stab.Create_str(stab_stabs,'"'+FixFileName(infile.name^)+'",'+tostr(n_includefile)+
  1472. ',0,0,'+hlabel.name),hp);
  1473. list.insertbefore(tai_label.create(hlabel),hp);
  1474. { force new line info }
  1475. lastfileinfo.line:=-1;
  1476. end;
  1477. end;
  1478. { line changed ? }
  1479. if (currfileinfo.line>lastfileinfo.line) and (currfileinfo.line<>0) then
  1480. begin
  1481. if assigned(currfuncname) and
  1482. (tf_use_function_relative_addresses in target_info.flags) then
  1483. begin
  1484. current_asmdata.getlabel(hlabel,alt_dbgline);
  1485. list.insertbefore(Tai_stab.Create_str(stab_stabn,tostr(n_textline)+',0,'+tostr(currfileinfo.line)+','+
  1486. hlabel.name+' - '+{$IFDEF POWERPC64}'.'+{$ENDIF POWERPC64}currfuncname^),hp);
  1487. list.insertbefore(tai_label.create(hlabel),hp);
  1488. end
  1489. else
  1490. list.insertbefore(Tai_stab.Create_str(stab_stabd,tostr(n_textline)+',0,'+tostr(currfileinfo.line)),hp);
  1491. end;
  1492. lastfileinfo:=currfileinfo;
  1493. end;
  1494. hp:=tai(hp.next);
  1495. end;
  1496. end;
  1497. procedure tdebuginfostabs.insertmoduleinfo;
  1498. var
  1499. hlabel : tasmlabel;
  1500. infile : tinputfile;
  1501. begin
  1502. { emit main source n_sourcefile for start of module }
  1503. current_asmdata.getlabel(hlabel,alt_dbgfile);
  1504. infile:=current_module.sourcefiles.get_file(1);
  1505. new_section(current_asmdata.asmlists[al_start],sec_code,make_mangledname('DEBUGSTART',current_module.localsymtable,''),0,secorder_begin);
  1506. if not(target_info.system in systems_darwin) then
  1507. current_asmdata.asmlists[al_start].concat(tai_symbol.Createname_global(make_mangledname('DEBUGSTART',current_module.localsymtable,''),AT_DATA,0));
  1508. if (infile.path^<>'') then
  1509. current_asmdata.asmlists[al_start].concat(Tai_stab.Create_str(stab_stabs,'"'+BsToSlash(FixPath(infile.path^,false))+'",'+tostr(n_sourcefile)+
  1510. ',0,0,'+hlabel.name));
  1511. current_asmdata.asmlists[al_start].concat(Tai_stab.Create_str(stab_stabs,'"'+FixFileName(infile.name^)+'",'+tostr(n_sourcefile)+
  1512. ',0,0,'+hlabel.name));
  1513. current_asmdata.asmlists[al_start].concat(tai_label.create(hlabel));
  1514. { for darwin, you need a "module marker" too to work around }
  1515. { either some assembler or gdb bug (radar 4386531 according to a }
  1516. { comment in dbxout.c of Apple's gcc) }
  1517. if (target_info.system in systems_darwin) then
  1518. current_asmdata.asmlists[al_end].concat(Tai_stab.Create_str(stab_stabs,'"",'+tostr(N_OSO)+',0,0,0'));
  1519. { emit empty n_sourcefile for end of module }
  1520. current_asmdata.getlabel(hlabel,alt_dbgfile);
  1521. new_section(current_asmdata.asmlists[al_end],sec_code,make_mangledname('DEBUGEND',current_module.localsymtable,''),0,secorder_end);
  1522. if not(target_info.system in systems_darwin) then
  1523. current_asmdata.asmlists[al_end].concat(tai_symbol.Createname_global(make_mangledname('DEBUGEND',current_module.localsymtable,''),AT_DATA,0));
  1524. current_asmdata.asmlists[al_end].concat(Tai_stab.Create_str(stab_stabs,'"",'+tostr(n_sourcefile)+',0,0,'+hlabel.name));
  1525. current_asmdata.asmlists[al_end].concat(tai_label.create(hlabel));
  1526. end;
  1527. procedure tdebuginfostabs.referencesections(list:TAsmList);
  1528. var
  1529. hp : tmodule;
  1530. dbgtable : tai_symbol;
  1531. begin
  1532. { Reference all DEBUGINFO sections from the main .fpc section }
  1533. if (target_info.system in ([system_powerpc_macos]+systems_darwin)) then
  1534. exit;
  1535. list.concat(Tai_section.create(sec_fpc,'links',0));
  1536. { make sure the debuginfo doesn't get stripped out }
  1537. if (target_info.system in systems_darwin) then
  1538. begin
  1539. dbgtable:=tai_symbol.createname('DEBUGINFOTABLE',AT_DATA,0);
  1540. list.concat(tai_directive.create(asd_no_dead_strip,dbgtable.sym.name));
  1541. list.concat(dbgtable);
  1542. end;
  1543. { include reference to all debuginfo sections of used units }
  1544. hp:=tmodule(loaded_units.first);
  1545. while assigned(hp) do
  1546. begin
  1547. If (hp.flags and uf_has_debuginfo)=uf_has_debuginfo then
  1548. begin
  1549. list.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',hp.localsymtable,''),0));
  1550. list.concat(Tai_const.Createname(make_mangledname('DEBUGSTART',hp.localsymtable,''),0));
  1551. list.concat(Tai_const.Createname(make_mangledname('DEBUGEND',hp.localsymtable,''),0));
  1552. end;
  1553. hp:=tmodule(hp.next);
  1554. end;
  1555. end;
  1556. const
  1557. dbg_stabs_info : tdbginfo =
  1558. (
  1559. id : dbg_stabs;
  1560. idtxt : 'STABS';
  1561. );
  1562. initialization
  1563. RegisterDebugInfo(dbg_stabs_info,TDebugInfoStabs);
  1564. end.