dbgstabs.pas 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684
  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. templist.concat(tai_label.create(stabsendlabel));
  969. current_asmdata.asmlists[al_procedures].insertlistbefore(pd.procendtai,templist);
  970. if assigned(pd.funcretsym) and
  971. (tabstractnormalvarsym(pd.funcretsym).refs>0) then
  972. begin
  973. if tabstractnormalvarsym(pd.funcretsym).localloc.loc=LOC_REFERENCE then
  974. begin
  975. {$warning Need to add gdb support for ret in param register calling}
  976. if paramanager.ret_in_param(pd.returndef,pd.proccalloption) then
  977. hs:='X*'
  978. else
  979. hs:='X';
  980. templist.concat(Tai_stab.create(stab_stabs,strpnew(
  981. '"'+GetSymName(pd.procsym)+':'+hs+def_stab_number(pd.returndef)+'",'+
  982. tostr(N_tsym)+',0,0,'+tostr(tabstractnormalvarsym(pd.funcretsym).localloc.reference.offset))));
  983. if (m_result in current_settings.modeswitches) then
  984. templist.concat(Tai_stab.create(stab_stabs,strpnew(
  985. '"RESULT:'+hs+def_stab_number(pd.returndef)+'",'+
  986. tostr(N_tsym)+',0,0,'+tostr(tabstractnormalvarsym(pd.funcretsym).localloc.reference.offset))));
  987. end;
  988. end;
  989. mangled_length:=length(pd.mangledname);
  990. getmem(p,2*mangled_length+50);
  991. strpcopy(p,tostr(N_LBRAC)+',0,0,');
  992. {$IFDEF POWERPC64}strpcopy(strend(p), '.');{$ENDIF POWERPC64}
  993. strpcopy(strend(p),pd.mangledname);
  994. if (tf_use_function_relative_addresses in target_info.flags) then
  995. begin
  996. strpcopy(strend(p),'-');
  997. {$IFDEF POWERPC64}strpcopy(strend(p), '.');{$ENDIF POWERPC64}
  998. strpcopy(strend(p),pd.mangledname);
  999. end;
  1000. getmem(p1,strlen(p)+1);
  1001. move(p^,p1^,strlen(p)+1);
  1002. templist.concat(Tai_stab.Create(stab_stabn,p1));
  1003. strpcopy(p,tostr(N_RBRAC)+',0,0,'+stabsendlabel.name);
  1004. if (tf_use_function_relative_addresses in target_info.flags) then
  1005. begin
  1006. strpcopy(strend(p),'-');
  1007. {$IFDEF POWERPC64}strpcopy(strend(p), '.');{$ENDIF POWERPC64}
  1008. strpcopy(strend(p),pd.mangledname);
  1009. end;
  1010. getmem(p1,strlen(p)+1);
  1011. move(p^,p1^,strlen(p)+1);
  1012. templist.concat(Tai_stab.Create(stab_stabn,p1));
  1013. freemem(p,2*mangled_length+50);
  1014. current_asmdata.asmlists[al_procedures].insertlistafter(pd.procendtai,templist);
  1015. { "The stab representing a procedure is located immediately
  1016. following the code of the procedure. This stab is in turn
  1017. directly followed by a group of other stabs describing
  1018. elements of the procedure. These other stabs describe the
  1019. procedure's parameters, its block local variables, and its
  1020. block structure." (stab docs) }
  1021. { this is however incorrect in case "include source" statements }
  1022. { appear in the block, in that case the procedure stab must }
  1023. { appear before this include stabs (and we generate such an }
  1024. { stabs for all functions) (JM) }
  1025. { procdef }
  1026. write_def_stabstr(templist,pd);
  1027. current_asmdata.asmlists[al_procedures].insertlistbefore(pd.procstarttai,templist);
  1028. { para types }
  1029. if assigned(pd.parast) then
  1030. write_symtable_syms(templist,pd.parast);
  1031. { local type defs and vars should not be written
  1032. inside the main proc stab }
  1033. if assigned(pd.localst) and
  1034. (pd.localst.symtabletype=localsymtable) then
  1035. write_symtable_syms(templist,pd.localst);
  1036. { Add a "size" stab as described in the last paragraph of 2.5 at }
  1037. { http://sourceware.org/gdb/current/onlinedocs/stabs_2.html#SEC12 }
  1038. { This works at least on Darwin (and is needed on Darwin to get }
  1039. { correct smartlinking of stabs), but I don't know which binutils }
  1040. { version is required on other platforms }
  1041. if (target_info.system in systems_darwin) then
  1042. templist.concat(Tai_stab.create(stab_stabs,
  1043. strpnew('"",'+tostr(N_FUNCTION)+',0,0,'+stabsendlabel.name+'-'+pd.mangledname)));
  1044. { after the endtai, because the ".size" must come before it }
  1045. current_asmdata.asmlists[al_procedures].insertlistafter(pd.procendtai,templist);
  1046. templist.free;
  1047. end;
  1048. end;
  1049. {****************************************************************************
  1050. TSym support
  1051. ****************************************************************************}
  1052. function TDebugInfoStabs.sym_var_value(const s:string;arg:pointer):string;
  1053. var
  1054. sym : tsym;
  1055. begin
  1056. sym:=tsym(arg);
  1057. result:='';
  1058. if s='name' then
  1059. result:=GetSymName(sym)
  1060. else if s='mangledname' then
  1061. result:=sym.mangledname
  1062. else if s='ownername' then
  1063. result:=GetSymTableName(sym.owner)
  1064. else if s='line' then
  1065. result:=tostr(sym.fileinfo.line)
  1066. else if s='N_LSYM' then
  1067. result:=tostr(N_LSYM)
  1068. else if s='N_LCSYM' then
  1069. result:=tostr(N_LCSYM)
  1070. else if s='N_RSYM' then
  1071. result:=tostr(N_RSYM)
  1072. else if s='N_TSYM' then
  1073. result:=tostr(N_TSYM)
  1074. else if s='N_STSYM' then
  1075. result:=tostr(N_STSYM)
  1076. else if s='N_FUNCTION' then
  1077. result:=tostr(N_FUNCTION)
  1078. else
  1079. internalerror(200401152);
  1080. end;
  1081. function TDebugInfoStabs.sym_stabstr_evaluate(sym:tsym;const s:string;const vars:array of string):Pchar;
  1082. begin
  1083. result:=string_evaluate(s,@sym_var_value,sym,vars);
  1084. end;
  1085. procedure TDebugInfoStabs.insertsym(list:TAsmList;sym:tsym);
  1086. function fieldvarsym_stabstr(sym:tfieldvarsym):Pchar;
  1087. begin
  1088. result:=nil;
  1089. if (sym.owner.symtabletype=objecTSymtable) and
  1090. (sp_static in sym.symoptions) then
  1091. result:=sym_stabstr_evaluate(sym,'"${ownername}__${name}:S$1",${N_LCSYM},0,${line},${mangledname}',
  1092. [def_stab_number(sym.vardef)]);
  1093. end;
  1094. function staticvarsym_stabstr(sym:tstaticvarsym):Pchar;
  1095. var
  1096. st : string;
  1097. threadvaroffset : string;
  1098. regidx : Tregisterindex;
  1099. nsym : string[7];
  1100. begin
  1101. result:=nil;
  1102. { external symbols can't be resolved at link time, so we
  1103. can't generate stabs for them }
  1104. if vo_is_external in sym.varoptions then
  1105. exit;
  1106. st:=def_stab_number(sym.vardef);
  1107. case sym.localloc.loc of
  1108. LOC_REGISTER,
  1109. LOC_CREGISTER,
  1110. LOC_MMREGISTER,
  1111. LOC_CMMREGISTER,
  1112. LOC_FPUREGISTER,
  1113. LOC_CFPUREGISTER :
  1114. begin
  1115. regidx:=findreg_by_number(sym.localloc.register);
  1116. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1117. { this is the register order for GDB}
  1118. if regidx<>0 then
  1119. result:=sym_stabstr_evaluate(sym,'"${name}:r$1",${N_RSYM},0,${line},$2',[st,tostr(regstabs_table[regidx])]);
  1120. end;
  1121. else
  1122. begin
  1123. if (vo_is_thread_var in sym.varoptions) then
  1124. threadvaroffset:='+'+tostr(sizeof(aint))
  1125. else
  1126. threadvaroffset:='';
  1127. if (vo_is_typed_const in sym.varoptions) then
  1128. nsym:='N_STSYM'
  1129. else
  1130. nsym:='N_LCSYM';
  1131. { Here we used S instead of
  1132. because with G GDB doesn't look at the address field
  1133. but searches the same name or with a leading underscore
  1134. but these names don't exist in pascal !}
  1135. st:='S'+st;
  1136. result:=sym_stabstr_evaluate(sym,'"${name}:$1",${'+nsym+'},0,${line},${mangledname}$2',[st,threadvaroffset]);
  1137. end;
  1138. end;
  1139. end;
  1140. function localvarsym_stabstr(sym:tlocalvarsym):Pchar;
  1141. var
  1142. st : string;
  1143. regidx : Tregisterindex;
  1144. begin
  1145. result:=nil;
  1146. { There is no space allocated for not referenced locals }
  1147. if (sym.owner.symtabletype=localsymtable) and (sym.refs=0) then
  1148. exit;
  1149. st:=def_stab_number(sym.vardef);
  1150. case sym.localloc.loc of
  1151. LOC_REGISTER,
  1152. LOC_CREGISTER,
  1153. LOC_MMREGISTER,
  1154. LOC_CMMREGISTER,
  1155. LOC_FPUREGISTER,
  1156. LOC_CFPUREGISTER :
  1157. begin
  1158. regidx:=findreg_by_number(sym.localloc.register);
  1159. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1160. { this is the register order for GDB}
  1161. if regidx<>0 then
  1162. result:=sym_stabstr_evaluate(sym,'"${name}:r$1",${N_RSYM},0,${line},$2',[st,tostr(regstabs_table[regidx])]);
  1163. end;
  1164. LOC_REFERENCE :
  1165. { offset to ebp => will not work if the framepointer is esp
  1166. so some optimizing will make things harder to debug }
  1167. result:=sym_stabstr_evaluate(sym,'"${name}:$1",${N_TSYM},0,${line},$2',[st,tostr(sym.localloc.reference.offset)])
  1168. else
  1169. internalerror(2003091814);
  1170. end;
  1171. end;
  1172. function paravarsym_stabstr(sym:tparavarsym):Pchar;
  1173. var
  1174. st : string;
  1175. regidx : Tregisterindex;
  1176. c : char;
  1177. begin
  1178. result:=nil;
  1179. { set loc to LOC_REFERENCE to get somewhat usable debugging info for -Or }
  1180. { while stabs aren't adapted for regvars yet }
  1181. if (vo_is_self in sym.varoptions) then
  1182. begin
  1183. case sym.localloc.loc of
  1184. LOC_REGISTER,
  1185. LOC_CREGISTER:
  1186. regidx:=findreg_by_number(sym.localloc.register);
  1187. LOC_REFERENCE: ;
  1188. else
  1189. internalerror(2003091815);
  1190. end;
  1191. if (po_classmethod in tabstractprocdef(sym.owner.defowner).procoptions) or
  1192. (po_staticmethod in tabstractprocdef(sym.owner.defowner).procoptions) then
  1193. begin
  1194. if (sym.localloc.loc=LOC_REFERENCE) then
  1195. result:=sym_stabstr_evaluate(sym,'"pvmt:p$1",${N_TSYM},0,0,$2',
  1196. [def_stab_number(pvmttype),tostr(sym.localloc.reference.offset)])
  1197. else
  1198. begin
  1199. regidx:=findreg_by_number(sym.localloc.register);
  1200. result:=sym_stabstr_evaluate(sym,'"pvmt:r$1",${N_RSYM},0,0,$2',
  1201. [def_stab_number(pvmttype),tostr(regstabs_table[regidx])]);
  1202. end
  1203. end
  1204. else
  1205. begin
  1206. if not(is_class(tprocdef(sym.owner.defowner)._class)) then
  1207. c:='v'
  1208. else
  1209. c:='p';
  1210. if (sym.localloc.loc=LOC_REFERENCE) then
  1211. result:=sym_stabstr_evaluate(sym,'"$$t:$1",${N_TSYM},0,0,$2',
  1212. [c+def_stab_number(tprocdef(sym.owner.defowner)._class),tostr(sym.localloc.reference.offset)])
  1213. else
  1214. begin
  1215. regidx:=findreg_by_number(sym.localloc.register);
  1216. result:=sym_stabstr_evaluate(sym,'"$$t:r$1",${N_RSYM},0,0,$2',
  1217. [c+def_stab_number(tprocdef(sym.owner.defowner)._class),tostr(regstabs_table[regidx])]);
  1218. end
  1219. end;
  1220. end
  1221. else
  1222. begin
  1223. st:=def_stab_number(sym.vardef);
  1224. if paramanager.push_addr_param(sym.varspez,sym.vardef,tprocdef(sym.owner.defowner).proccalloption) and
  1225. not(vo_has_local_copy in sym.varoptions) and
  1226. not is_open_string(sym.vardef) then
  1227. c:='v' { should be 'i' but 'i' doesn't work }
  1228. else
  1229. c:='p';
  1230. case sym.localloc.loc of
  1231. LOC_REGISTER,
  1232. LOC_CREGISTER,
  1233. LOC_MMREGISTER,
  1234. LOC_CMMREGISTER,
  1235. LOC_FPUREGISTER,
  1236. LOC_CFPUREGISTER :
  1237. begin
  1238. if c='p' then
  1239. c:='R'
  1240. else
  1241. c:='a';
  1242. st:=c+st;
  1243. regidx:=findreg_by_number(sym.localloc.register);
  1244. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1245. { this is the register order for GDB}
  1246. if regidx<>0 then
  1247. result:=sym_stabstr_evaluate(sym,'"${name}:$1",${N_RSYM},0,${line},$2',[st,tostr(longint(regstabs_table[regidx]))]);
  1248. end;
  1249. LOC_REFERENCE :
  1250. begin
  1251. st:=c+st;
  1252. { offset to ebp => will not work if the framepointer is esp
  1253. so some optimizing will make things harder to debug }
  1254. result:=sym_stabstr_evaluate(sym,'"${name}:$1",${N_TSYM},0,${line},$2',[st,tostr(sym.localloc.reference.offset)])
  1255. end;
  1256. else
  1257. internalerror(2003091814);
  1258. end;
  1259. end;
  1260. end;
  1261. function constsym_stabstr(sym:tconstsym):Pchar;
  1262. var
  1263. st : string;
  1264. begin
  1265. result:=nil;
  1266. { Don't write info for default parameter values, the N_Func breaks
  1267. the N_Func for the function itself.
  1268. Valgrind does not support constants }
  1269. if (sym.owner.symtabletype=parasymtable) or
  1270. (cs_gdb_valgrind in current_settings.globalswitches) then
  1271. exit;
  1272. case sym.consttyp of
  1273. conststring:
  1274. begin
  1275. if sym.value.len<200 then
  1276. st:='s'''+backspace_quote(octal_quote(strpas(pchar(sym.value.valueptr)),[#0..#9,#11,#12,#14..#31,'''']),['"','\',#10,#13])+''''
  1277. else
  1278. st:='<constant string too long>';
  1279. end;
  1280. constord:
  1281. st:='i'+tostr(sym.value.valueord);
  1282. constpointer:
  1283. st:='i'+tostr(sym.value.valueordptr);
  1284. constreal:
  1285. begin
  1286. system.str(pbestreal(sym.value.valueptr)^,st);
  1287. st := 'r'+st;
  1288. end;
  1289. else
  1290. begin
  1291. { if we don't know just put zero !! }
  1292. st:='i0';
  1293. end;
  1294. end;
  1295. result:=sym_stabstr_evaluate(sym,'"${name}:c=$1;",${N_FUNCTION},0,${line},0',[st]);
  1296. end;
  1297. function typesym_stabstr(sym:ttypesym) : pchar;
  1298. var
  1299. stabchar : string[2];
  1300. begin
  1301. result:=nil;
  1302. if not assigned(sym.typedef) then
  1303. internalerror(200509262);
  1304. if sym.typedef.typ in tagtypes then
  1305. stabchar:='Tt'
  1306. else
  1307. stabchar:='t';
  1308. result:=sym_stabstr_evaluate(sym,'"${name}:$1$2",${N_LSYM},0,${line},0',[stabchar,def_stab_number(sym.typedef)]);
  1309. end;
  1310. function procsym_stabstr(sym:tprocsym) : pchar;
  1311. var
  1312. i : longint;
  1313. begin
  1314. result:=nil;
  1315. for i:=0 to sym.ProcdefList.Count-1 do
  1316. write_procdef(list,tprocdef(sym.ProcdefList[i]));
  1317. end;
  1318. var
  1319. stabstr : Pchar;
  1320. begin
  1321. stabstr:=nil;
  1322. case sym.typ of
  1323. labelsym :
  1324. stabstr:=sym_stabstr_evaluate(sym,'"${name}",${N_LSYM},0,${line},0',[]);
  1325. fieldvarsym :
  1326. stabstr:=fieldvarsym_stabstr(tfieldvarsym(sym));
  1327. staticvarsym :
  1328. stabstr:=staticvarsym_stabstr(tstaticvarsym(sym));
  1329. localvarsym :
  1330. stabstr:=localvarsym_stabstr(tlocalvarsym(sym));
  1331. paravarsym :
  1332. stabstr:=paravarsym_stabstr(tparavarsym(sym));
  1333. constsym :
  1334. stabstr:=constsym_stabstr(tconstsym(sym));
  1335. typesym :
  1336. stabstr:=typesym_stabstr(ttypesym(sym));
  1337. procsym :
  1338. stabstr:=procsym_stabstr(tprocsym(sym));
  1339. end;
  1340. if stabstr<>nil then
  1341. list.concat(Tai_stab.create(stab_stabs,stabstr));
  1342. { For object types write also the symtable entries }
  1343. if (sym.typ=typesym) and (ttypesym(sym).typedef.typ=objectdef) then
  1344. write_symtable_syms(list,tobjectdef(ttypesym(sym).typedef).symtable);
  1345. sym.isdbgwritten:=true;
  1346. end;
  1347. procedure TDebugInfoStabs.write_symtable_syms(list:TAsmList;st:TSymtable);
  1348. var
  1349. sym : tsym;
  1350. i : longint;
  1351. begin
  1352. case st.symtabletype of
  1353. staticsymtable :
  1354. list.concat(tai_comment.Create(strpnew('Syms - Begin Staticsymtable')));
  1355. globalsymtable :
  1356. list.concat(tai_comment.Create(strpnew('Syms - Begin unit '+GetSymTableName(st)+' has index '+tostr(st.moduleid))));
  1357. end;
  1358. for i:=0 to st.SymList.Count-1 do
  1359. begin
  1360. sym:=tsym(st.SymList[i]);
  1361. if not(sp_hidden in sym.symoptions) and
  1362. (not sym.isdbgwritten) then
  1363. insertsym(list,sym);
  1364. end;
  1365. case st.symtabletype of
  1366. staticsymtable :
  1367. list.concat(tai_comment.Create(strpnew('Syms - End Staticsymtable')));
  1368. globalsymtable :
  1369. list.concat(tai_comment.Create(strpnew('Syms - End unit '+GetSymTableName(st)+' has index '+tostr(st.moduleid))));
  1370. end;
  1371. end;
  1372. {****************************************************************************
  1373. Proc/Module support
  1374. ****************************************************************************}
  1375. procedure tdebuginfostabs.inserttypeinfo;
  1376. var
  1377. stabsvarlist,
  1378. stabstypelist : TAsmList;
  1379. storefilepos : tfileposinfo;
  1380. i : longint;
  1381. begin
  1382. storefilepos:=current_filepos;
  1383. current_filepos:=current_module.mainfilepos;
  1384. global_stab_number:=0;
  1385. defnumberlist:=TFPObjectlist.create(false);
  1386. stabsvarlist:=TAsmList.create;
  1387. stabstypelist:=TAsmList.create;
  1388. { include symbol that will be referenced from the main to be sure to
  1389. include this debuginfo .o file }
  1390. current_module.flags:=current_module.flags or uf_has_debuginfo;
  1391. if not(target_info.system in systems_darwin) then
  1392. begin
  1393. new_section(current_asmdata.asmlists[al_stabs],sec_data,GetSymTableName(current_module.localsymtable),0);
  1394. current_asmdata.asmlists[al_stabs].concat(tai_symbol.Createname_global(make_mangledname('DEBUGINFO',current_module.localsymtable,''),AT_DATA,0));
  1395. end
  1396. else
  1397. new_section(current_asmdata.asmlists[al_stabs],sec_code,GetSymTableName(current_module.localsymtable),0);
  1398. { first write all global/local symbols. This will flag all required tdefs }
  1399. if assigned(current_module.globalsymtable) then
  1400. write_symtable_syms(stabsvarlist,current_module.globalsymtable);
  1401. if assigned(current_module.localsymtable) then
  1402. write_symtable_syms(stabsvarlist,current_module.localsymtable);
  1403. { reset unit type info flag }
  1404. reset_unit_type_info;
  1405. { write used types from the used units }
  1406. write_used_unit_type_info(stabstypelist,current_module);
  1407. { last write the types from this unit }
  1408. if assigned(current_module.globalsymtable) then
  1409. write_symtable_defs(stabstypelist,current_module.globalsymtable);
  1410. if assigned(current_module.localsymtable) then
  1411. write_symtable_defs(stabstypelist,current_module.localsymtable);
  1412. current_asmdata.asmlists[al_stabs].concatlist(stabstypelist);
  1413. current_asmdata.asmlists[al_stabs].concatlist(stabsvarlist);
  1414. { reset stab numbers }
  1415. for i:=0 to defnumberlist.count-1 do
  1416. begin
  1417. if assigned(defnumberlist[i]) then
  1418. begin
  1419. tdef(defnumberlist[i]).stab_number:=0;
  1420. tdef(defnumberlist[i]).dbg_state:=dbg_state_unused;
  1421. end;
  1422. end;
  1423. defnumberlist.free;
  1424. defnumberlist:=nil;
  1425. stabsvarlist.free;
  1426. stabstypelist.free;
  1427. current_filepos:=storefilepos;
  1428. end;
  1429. procedure tdebuginfostabs.insertlineinfo(list:TAsmList);
  1430. var
  1431. currfileinfo,
  1432. lastfileinfo : tfileposinfo;
  1433. currfuncname : pshortstring;
  1434. currsectype : TAsmSectiontype;
  1435. hlabel : tasmlabel;
  1436. hp : tai;
  1437. infile : tinputfile;
  1438. begin
  1439. FillChar(lastfileinfo,sizeof(lastfileinfo),0);
  1440. currfuncname:=nil;
  1441. currsectype:=sec_code;
  1442. hp:=Tai(list.first);
  1443. while assigned(hp) do
  1444. begin
  1445. case hp.typ of
  1446. ait_section :
  1447. currsectype:=tai_section(hp).sectype;
  1448. ait_function_name :
  1449. currfuncname:=tai_function_name(hp).funcname;
  1450. ait_force_line :
  1451. lastfileinfo.line:=-1;
  1452. end;
  1453. if (currsectype=sec_code) and
  1454. (hp.typ=ait_instruction) then
  1455. begin
  1456. currfileinfo:=tailineinfo(hp).fileinfo;
  1457. { file changed ? (must be before line info) }
  1458. if (currfileinfo.fileindex<>0) and
  1459. (lastfileinfo.fileindex<>currfileinfo.fileindex) then
  1460. begin
  1461. infile:=current_module.sourcefiles.get_file(currfileinfo.fileindex);
  1462. if assigned(infile) then
  1463. begin
  1464. current_asmdata.getlabel(hlabel,alt_dbgfile);
  1465. { emit stabs }
  1466. if (infile.path^<>'') then
  1467. list.insertbefore(Tai_stab.Create_str(stab_stabs,'"'+BsToSlash(FixPath(infile.path^,false))+'",'+tostr(n_includefile)+
  1468. ',0,0,'+hlabel.name),hp);
  1469. list.insertbefore(Tai_stab.Create_str(stab_stabs,'"'+FixFileName(infile.name^)+'",'+tostr(n_includefile)+
  1470. ',0,0,'+hlabel.name),hp);
  1471. list.insertbefore(tai_label.create(hlabel),hp);
  1472. { force new line info }
  1473. lastfileinfo.line:=-1;
  1474. end;
  1475. end;
  1476. { line changed ? }
  1477. if (currfileinfo.line>lastfileinfo.line) and (currfileinfo.line<>0) then
  1478. begin
  1479. if assigned(currfuncname) and
  1480. (tf_use_function_relative_addresses in target_info.flags) then
  1481. begin
  1482. current_asmdata.getlabel(hlabel,alt_dbgline);
  1483. list.insertbefore(Tai_stab.Create_str(stab_stabn,tostr(n_textline)+',0,'+tostr(currfileinfo.line)+','+
  1484. hlabel.name+' - '+{$IFDEF POWERPC64}'.'+{$ENDIF POWERPC64}currfuncname^),hp);
  1485. list.insertbefore(tai_label.create(hlabel),hp);
  1486. end
  1487. else
  1488. list.insertbefore(Tai_stab.Create_str(stab_stabd,tostr(n_textline)+',0,'+tostr(currfileinfo.line)),hp);
  1489. end;
  1490. lastfileinfo:=currfileinfo;
  1491. end;
  1492. hp:=tai(hp.next);
  1493. end;
  1494. end;
  1495. procedure tdebuginfostabs.insertmoduleinfo;
  1496. var
  1497. hlabel : tasmlabel;
  1498. infile : tinputfile;
  1499. begin
  1500. { emit main source n_sourcefile for start of module }
  1501. current_asmdata.getlabel(hlabel,alt_dbgfile);
  1502. infile:=current_module.sourcefiles.get_file(1);
  1503. new_section(current_asmdata.asmlists[al_start],sec_code,make_mangledname('DEBUGSTART',current_module.localsymtable,''),0,secorder_begin);
  1504. if not(target_info.system in systems_darwin) then
  1505. current_asmdata.asmlists[al_start].concat(tai_symbol.Createname_global(make_mangledname('DEBUGSTART',current_module.localsymtable,''),AT_DATA,0));
  1506. if (infile.path^<>'') then
  1507. current_asmdata.asmlists[al_start].concat(Tai_stab.Create_str(stab_stabs,'"'+BsToSlash(FixPath(infile.path^,false))+'",'+tostr(n_sourcefile)+
  1508. ',0,0,'+hlabel.name));
  1509. current_asmdata.asmlists[al_start].concat(Tai_stab.Create_str(stab_stabs,'"'+FixFileName(infile.name^)+'",'+tostr(n_sourcefile)+
  1510. ',0,0,'+hlabel.name));
  1511. current_asmdata.asmlists[al_start].concat(tai_label.create(hlabel));
  1512. { for darwin, you need a "module marker" too to work around }
  1513. { either some assembler or gdb bug (radar 4386531 according to a }
  1514. { comment in dbxout.c of Apple's gcc) }
  1515. if (target_info.system in systems_darwin) then
  1516. current_asmdata.asmlists[al_end].concat(Tai_stab.Create_str(stab_stabs,'"",'+tostr(N_OSO)+',0,0,0'));
  1517. { emit empty n_sourcefile for end of module }
  1518. current_asmdata.getlabel(hlabel,alt_dbgfile);
  1519. new_section(current_asmdata.asmlists[al_end],sec_code,make_mangledname('DEBUGEND',current_module.localsymtable,''),0,secorder_end);
  1520. if not(target_info.system in systems_darwin) then
  1521. current_asmdata.asmlists[al_end].concat(tai_symbol.Createname_global(make_mangledname('DEBUGEND',current_module.localsymtable,''),AT_DATA,0));
  1522. current_asmdata.asmlists[al_end].concat(Tai_stab.Create_str(stab_stabs,'"",'+tostr(n_sourcefile)+',0,0,'+hlabel.name));
  1523. current_asmdata.asmlists[al_end].concat(tai_label.create(hlabel));
  1524. end;
  1525. procedure tdebuginfostabs.referencesections(list:TAsmList);
  1526. var
  1527. hp : tmodule;
  1528. dbgtable : tai_symbol;
  1529. begin
  1530. { Reference all DEBUGINFO sections from the main .fpc section }
  1531. if (target_info.system in ([system_powerpc_macos]+systems_darwin)) then
  1532. exit;
  1533. list.concat(Tai_section.create(sec_fpc,'links',0));
  1534. { make sure the debuginfo doesn't get stripped out }
  1535. if (target_info.system in systems_darwin) then
  1536. begin
  1537. dbgtable:=tai_symbol.createname('DEBUGINFOTABLE',AT_DATA,0);
  1538. list.concat(tai_directive.create(asd_no_dead_strip,dbgtable.sym.name));
  1539. list.concat(dbgtable);
  1540. end;
  1541. { include reference to all debuginfo sections of used units }
  1542. hp:=tmodule(loaded_units.first);
  1543. while assigned(hp) do
  1544. begin
  1545. If (hp.flags and uf_has_debuginfo)=uf_has_debuginfo then
  1546. begin
  1547. list.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',hp.localsymtable,''),0));
  1548. list.concat(Tai_const.Createname(make_mangledname('DEBUGSTART',hp.localsymtable,''),0));
  1549. list.concat(Tai_const.Createname(make_mangledname('DEBUGEND',hp.localsymtable,''),0));
  1550. end;
  1551. hp:=tmodule(hp.next);
  1552. end;
  1553. end;
  1554. const
  1555. dbg_stabs_info : tdbginfo =
  1556. (
  1557. id : dbg_stabs;
  1558. idtxt : 'STABS';
  1559. );
  1560. initialization
  1561. RegisterDebugInfo(dbg_stabs_info,TDebugInfoStabs);
  1562. end.