dbgstabs.pas 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690
  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_unicodestring,
  461. st_widestring:
  462. begin
  463. { looks like a pwidechar }
  464. charst:=def_stab_number(cwidechartype);
  465. result:=strpnew('*'+charst);
  466. end;
  467. end;
  468. end;
  469. function enumdef_stabstr(def:tenumdef):pchar;
  470. var
  471. st : Pchar;
  472. p : Tenumsym;
  473. s : string;
  474. memsize,
  475. stl : aint;
  476. begin
  477. memsize:=memsizeinc;
  478. getmem(st,memsize);
  479. { we can specify the size with @s<size>; prefix PM }
  480. if def.size <> std_param_align then
  481. strpcopy(st,'@s'+tostr(def.size*8)+';e')
  482. else
  483. strpcopy(st,'e');
  484. p := tenumsym(def.firstenum);
  485. stl:=strlen(st);
  486. while assigned(p) do
  487. begin
  488. s :=GetSymName(p)+':'+tostr(p.value)+',';
  489. { place for the ending ';' also }
  490. if (stl+length(s)+1>=memsize) then
  491. begin
  492. inc(memsize,memsizeinc);
  493. reallocmem(st,memsize);
  494. end;
  495. strpcopy(st+stl,s);
  496. inc(stl,length(s));
  497. p:=p.nextenum;
  498. end;
  499. st[stl]:=';';
  500. st[stl+1]:=#0;
  501. reallocmem(st,stl+2);
  502. result:=st;
  503. end;
  504. function orddef_stabstr(def:torddef):pchar;
  505. begin
  506. if cs_gdb_valgrind in current_settings.globalswitches then
  507. begin
  508. case def.ordtype of
  509. uvoid :
  510. result:=strpnew(def_stab_number(def));
  511. bool8bit,
  512. bool16bit,
  513. bool32bit,
  514. bool64bit :
  515. result:=def_stabstr_evaluate(def,'r${numberstring};0;255;',[]);
  516. u32bit,
  517. s64bit,
  518. u64bit :
  519. result:=def_stabstr_evaluate(def,'r${numberstring};0;-1;',[]);
  520. else
  521. result:=def_stabstr_evaluate(def,'r${numberstring};$1;$2;',[tostr(longint(def.low.svalue)),tostr(longint(def.high.svalue))]);
  522. end;
  523. end
  524. else
  525. begin
  526. case def.ordtype of
  527. uvoid :
  528. result:=strpnew(def_stab_number(def));
  529. uchar :
  530. result:=strpnew('-20;');
  531. uwidechar :
  532. result:=strpnew('-30;');
  533. bool8bit :
  534. result:=strpnew('-21;');
  535. bool16bit :
  536. result:=strpnew('-22;');
  537. bool32bit :
  538. result:=strpnew('-23;');
  539. bool64bit :
  540. { no clue if this is correct (FK) }
  541. result:=strpnew('-23;');
  542. u64bit :
  543. result:=strpnew('-32;');
  544. s64bit :
  545. result:=strpnew('-31;');
  546. {u32bit : result:=def_stab_number(s32inttype)+';0;-1;'); }
  547. else
  548. result:=def_stabstr_evaluate(def,'r${numberstring};$1;$2;',[tostr(longint(def.low.svalue)),tostr(longint(def.high.svalue))]);
  549. end;
  550. end;
  551. end;
  552. function floatdef_stabstr(def:tfloatdef):Pchar;
  553. begin
  554. case def.floattype of
  555. s32real,
  556. s64real,
  557. s80real:
  558. result:=def_stabstr_evaluate(def,'r$1;${savesize};0;',[def_stab_number(s32inttype)]);
  559. s64currency,
  560. s64comp:
  561. result:=def_stabstr_evaluate(def,'r$1;-${savesize};0;',[def_stab_number(s32inttype)]);
  562. else
  563. internalerror(200509261);
  564. end;
  565. end;
  566. function filedef_stabstr(def:tfiledef):pchar;
  567. begin
  568. {$ifdef cpu64bit}
  569. result:=def_stabstr_evaluate(def,'s${savesize}HANDLE:$1,0,32;MODE:$1,32,32;RECSIZE:$2,64,64;'+
  570. '_PRIVATE:ar$1;1;64;$3,128,256;USERDATA:ar$1;1;16;$3,384,128;'+
  571. 'NAME:ar$1;0;255;$4,512,2048;;',[def_stab_number(s32inttype),
  572. def_stab_number(s64inttype),
  573. def_stab_number(u8inttype),
  574. def_stab_number(cchartype)]);
  575. {$else cpu64bit}
  576. result:=def_stabstr_evaluate(def,'s${savesize}HANDLE:$1,0,32;MODE:$1,32,32;RECSIZE:$1,64,32;'+
  577. '_PRIVATE:ar$1;1;32;$3,96,256;USERDATA:ar$1;1;16;$2,352,128;'+
  578. 'NAME:ar$1;0;255;$3,480,2048;;',[def_stab_number(s32inttype),
  579. def_stab_number(u8inttype),
  580. def_stab_number(cchartype)]);
  581. {$endif cpu64bit}
  582. end;
  583. function procdef_stabstr(def:tprocdef):pchar;
  584. Var
  585. RType : Char;
  586. Obj,Info : String;
  587. stabsstr : string;
  588. p : pchar;
  589. begin
  590. obj := GetSymName(def.procsym);
  591. info := '';
  592. if (po_global in def.procoptions) then
  593. RType := 'F'
  594. else
  595. RType := 'f';
  596. if assigned(def.owner) then
  597. begin
  598. if (def.owner.symtabletype = objecTSymtable) then
  599. obj := GetSymTableName(def.owner)+'__'+GetSymName(def.procsym);
  600. if not(cs_gdb_valgrind in current_settings.globalswitches) and
  601. (def.owner.symtabletype=localsymtable) and
  602. assigned(def.owner.defowner) and
  603. assigned(tprocdef(def.owner.defowner).procsym) then
  604. info := ','+GetSymName(def.procsym)+','+GetSymName(tprocdef(def.owner.defowner).procsym);
  605. end;
  606. stabsstr:=def.mangledname;
  607. getmem(p,length(stabsstr)+255);
  608. strpcopy(p,'"'+obj+':'+RType
  609. +def_stab_number(def.returndef)+info+'",'+tostr(n_function)
  610. +',0,'+
  611. tostr(def.fileinfo.line)
  612. +',');
  613. strpcopy(strend(p),stabsstr);
  614. getmem(result,strlen(p)+1);
  615. move(p^,result^,strlen(p)+1);
  616. freemem(p);
  617. end;
  618. function recorddef_stabstr(def:trecorddef):pchar;
  619. var
  620. state : Trecord_stabgen_state;
  621. begin
  622. getmem(state.stabstring,memsizeinc);
  623. state.staballoc:=memsizeinc;
  624. strpcopy(state.stabstring,'s'+tostr(def.size));
  625. state.recoffset:=0;
  626. state.stabsize:=strlen(state.stabstring);
  627. def.symtable.SymList.ForEachCall(@field_add_stabstr,@state);
  628. state.stabstring[state.stabsize]:=';';
  629. state.stabstring[state.stabsize+1]:=#0;
  630. reallocmem(state.stabstring,state.stabsize+2);
  631. result:=state.stabstring;
  632. end;
  633. function objectdef_stabstr(def:tobjectdef):pchar;
  634. var
  635. anc : tobjectdef;
  636. state :Trecord_stabgen_state;
  637. ts : string;
  638. begin
  639. { Write the invisible pointer for the class? }
  640. if (def.objecttype=odt_class) and
  641. (not def.writing_class_record_dbginfo) then
  642. begin
  643. result:=strpnew('*'+def_stab_classnumber(def));
  644. exit;
  645. end;
  646. state.staballoc:=memsizeinc;
  647. getmem(state.stabstring,state.staballoc);
  648. strpcopy(state.stabstring,'s'+tostr(tobjecTSymtable(def.symtable).datasize));
  649. if assigned(def.childof) then
  650. begin
  651. {only one ancestor not virtual, public, at base offset 0 }
  652. { !1 , 0 2 0 , }
  653. strpcopy(strend(state.stabstring),'!1,020,'+def_stab_classnumber(def.childof)+';');
  654. end;
  655. {virtual table to implement yet}
  656. state.recoffset:=0;
  657. state.stabsize:=strlen(state.stabstring);
  658. def.symtable.symList.ForEachCall(@field_add_stabstr,@state);
  659. if (oo_has_vmt in def.objectoptions) then
  660. if not assigned(def.childof) or not(oo_has_vmt in def.childof.objectoptions) then
  661. begin
  662. ts:='$vf'+def_stab_classnumber(def)+':'+def_stab_number(vmtarraytype)+','+tostr(def.vmt_offset*8)+';';
  663. strpcopy(state.stabstring+state.stabsize,ts);
  664. inc(state.stabsize,length(ts));
  665. end;
  666. def.symtable.symList.ForEachCall(@method_add_stabstr,@state);
  667. if (oo_has_vmt in def.objectoptions) then
  668. begin
  669. anc := def;
  670. while assigned(anc.childof) and (oo_has_vmt in anc.childof.objectoptions) do
  671. anc := anc.childof;
  672. { just in case anc = self }
  673. ts:=';~%'+def_stab_classnumber(anc)+';';
  674. end
  675. else
  676. ts:=';';
  677. strpcopy(state.stabstring+state.stabsize,ts);
  678. inc(state.stabsize,length(ts));
  679. reallocmem(state.stabstring,state.stabsize+1);
  680. result:=state.stabstring;
  681. end;
  682. var
  683. tempstr: pchar;
  684. begin
  685. result:=nil;
  686. case def.typ of
  687. stringdef :
  688. result:=stringdef_stabstr(tstringdef(def));
  689. enumdef :
  690. result:=enumdef_stabstr(tenumdef(def));
  691. orddef :
  692. result:=orddef_stabstr(torddef(def));
  693. floatdef :
  694. result:=floatdef_stabstr(tfloatdef(def));
  695. filedef :
  696. result:=filedef_stabstr(tfiledef(def));
  697. recorddef :
  698. result:=recorddef_stabstr(trecorddef(def));
  699. variantdef :
  700. result:=def_stabstr_evaluate(def,'${numberstring};',[]);
  701. pointerdef :
  702. result:=strpnew('*'+def_stab_number(tpointerdef(def).pointeddef));
  703. classrefdef :
  704. result:=strpnew(def_stab_number(pvmttype));
  705. setdef :
  706. result:=def_stabstr_evaluate(def,'@s$1;S$2',[tostr(def.size*8),def_stab_number(tsetdef(def).elementdef)]);
  707. formaldef :
  708. result:=def_stabstr_evaluate(def,'${numberstring};',[]);
  709. arraydef :
  710. if not is_packed_array(def) then
  711. result:=def_stabstr_evaluate(def,'ar$1;$2;$3;$4',[def_stab_number(tarraydef(def).rangedef),
  712. tostr(tarraydef(def).lowrange),tostr(tarraydef(def).highrange),def_stab_number(tarraydef(def).elementdef)])
  713. else
  714. begin
  715. // the @P seems to be ignored by gdb
  716. // 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)]);
  717. tempstr:=def_stabstr_evaluate(tarraydef(def).rangedef,'r${numberstring};$1;$2;',
  718. [tostr(tarraydef(def).lowrange),tostr(tarraydef(def).highrange)]);
  719. // will only show highrange-lowrange+1 bits in gdb
  720. result:=def_stabstr_evaluate(def,'@s$1;@S;S$2',
  721. [tostr(TConstExprInt(tarraydef(def).elepackedbitsize) * tarraydef(def).elecount),tempstr]);
  722. freemem(tempstr);
  723. end;
  724. procdef :
  725. result:=procdef_stabstr(tprocdef(def));
  726. procvardef :
  727. result:=strpnew('*f'+def_stab_number(tprocvardef(def).returndef));
  728. objectdef :
  729. result:=objectdef_stabstr(tobjectdef(def));
  730. undefineddef :
  731. result:=def_stabstr_evaluate(def,'${numberstring};',[]);
  732. end;
  733. if result=nil then
  734. internalerror(200512203);
  735. end;
  736. procedure TDebugInfoStabs.write_def_stabstr(list:TAsmList;def:tdef);
  737. var
  738. stabchar : string[2];
  739. ss,st,su : pchar;
  740. begin
  741. { procdefs require a different stabs style without type prefix }
  742. if def.typ=procdef then
  743. begin
  744. st:=def_stabstr(def);
  745. { add to list }
  746. list.concat(Tai_stab.create(stab_stabs,st));
  747. end
  748. else
  749. begin
  750. { type prefix }
  751. if def.typ in tagtypes then
  752. stabchar := 'Tt'
  753. else
  754. stabchar := 't';
  755. { Here we maybe generate a type, so we have to use numberstring }
  756. if is_class(def) and
  757. tobjectdef(def).writing_class_record_dbginfo then
  758. st:=def_stabstr_evaluate(def,'"${sym_name}:$1$2=',[stabchar,def_stab_classnumber(tobjectdef(def))])
  759. else
  760. st:=def_stabstr_evaluate(def,'"${sym_name}:$1$2=',[stabchar,def_stab_number(def)]);
  761. ss:=def_stabstr(def);
  762. reallocmem(st,strlen(ss)+512);
  763. { line info is set to 0 for all defs, because the def can be in an other
  764. unit and then the linenumber is invalid in the current sourcefile }
  765. su:=def_stabstr_evaluate(def,'",${N_LSYM},0,0,0',[]);
  766. strcopy(strecopy(strend(st),ss),su);
  767. reallocmem(st,strlen(st)+1);
  768. freemem(ss);
  769. freemem(su);
  770. { add to list }
  771. list.concat(Tai_stab.create(stab_stabs,st));
  772. end;
  773. end;
  774. procedure TDebugInfoStabs.insertdef(list:TAsmList;def:tdef);
  775. var
  776. anc : tobjectdef;
  777. oldtypesym : tsym;
  778. i : longint;
  779. begin
  780. if (def.dbg_state in [dbg_state_writing,dbg_state_written]) then
  781. exit;
  782. { never write generic template defs }
  783. if df_generic in def.defoptions then
  784. begin
  785. def.dbg_state:=dbg_state_written;
  786. exit;
  787. end;
  788. { to avoid infinite loops }
  789. def.dbg_state := dbg_state_writing;
  790. { write dependencies first }
  791. case def.typ of
  792. stringdef :
  793. begin
  794. if tstringdef(def).stringtype in [st_widestring,st_unicodestring] then
  795. insertdef(list,cwidechartype)
  796. else
  797. begin
  798. insertdef(list,cchartype);
  799. insertdef(list,u8inttype);
  800. end;
  801. end;
  802. floatdef :
  803. insertdef(list,s32inttype);
  804. filedef :
  805. begin
  806. insertdef(list,s32inttype);
  807. {$ifdef cpu64bit}
  808. insertdef(list,s64inttype);
  809. {$endif cpu64bit}
  810. insertdef(list,u8inttype);
  811. insertdef(list,cchartype);
  812. end;
  813. classrefdef :
  814. insertdef(list,pvmttype);
  815. pointerdef :
  816. insertdef(list,tpointerdef(def).pointeddef);
  817. setdef :
  818. insertdef(list,tsetdef(def).elementdef);
  819. procvardef :
  820. begin
  821. insertdef(list,tprocvardef(def).returndef);
  822. if assigned(tprocvardef(def).parast) then
  823. write_symtable_defs(list,tprocvardef(def).parast);
  824. end;
  825. procdef :
  826. begin
  827. insertdef(list,tprocdef(def).returndef);
  828. if assigned(tprocdef(def).parast) then
  829. write_symtable_defs(list,tprocdef(def).parast);
  830. if assigned(tprocdef(def).localst) and
  831. (tprocdef(def).localst.symtabletype=localsymtable) then
  832. write_symtable_defs(list,tprocdef(def).localst);
  833. end;
  834. arraydef :
  835. begin
  836. insertdef(list,tarraydef(def).rangedef);
  837. insertdef(list,tarraydef(def).elementdef);
  838. end;
  839. recorddef :
  840. trecorddef(def).symtable.symList.ForEachCall(@field_write_defs,list);
  841. enumdef :
  842. if assigned(tenumdef(def).basedef) then
  843. insertdef(list,tenumdef(def).basedef);
  844. objectdef :
  845. begin
  846. { make sure we don't write child classdefs before their parent }
  847. { classdefs, because this crashes gdb }
  848. anc:=tobjectdef(def);
  849. while assigned(anc.childof) do
  850. begin
  851. anc:=anc.childof;
  852. if (anc.dbg_state=dbg_state_writing) then
  853. { happens in case a field of a parent is of the (forward }
  854. { defined) child type }
  855. begin
  856. { We don't explicitly requeue it, but the fact that }
  857. { a child type was used in a parent before the child }
  858. { type was fully defined means that it was forward }
  859. { declared, and will still be encountered later (it }
  860. { cannot have been declared in another unit, because }
  861. { then this and that other unit would depend on }
  862. { eachother's interface) }
  863. { Setting the state to queued however allows us to }
  864. { get the def number already without an IE }
  865. def.dbg_state:=dbg_state_queued;
  866. exit;
  867. end;
  868. end;
  869. insertdef(list,vmtarraytype);
  870. if assigned(tobjectdef(def).ImplementedInterfaces) then
  871. for i:=0 to tobjectdef(def).ImplementedInterfaces.Count-1 do
  872. insertdef(list,TImplementedInterface(tobjectdef(def).ImplementedInterfaces[i]).IntfDef);
  873. { first the parents }
  874. anc:=tobjectdef(def);
  875. while assigned(anc.childof) do
  876. begin
  877. anc:=anc.childof;
  878. insertdef(list,anc);
  879. if assigned(anc.ImplementedInterfaces) then
  880. for i:=0 to anc.ImplementedInterfaces.Count-1 do
  881. insertdef(list,TImplementedInterface(anc.ImplementedInterfaces[i]).IntfDef);
  882. end;
  883. tobjectdef(def).symtable.symList.ForEachCall(@field_write_defs,list);
  884. tobjectdef(def).symtable.symList.ForEachCall(@method_write_defs,list);
  885. end;
  886. end;
  887. case def.typ of
  888. objectdef :
  889. begin
  890. { classes require special code to write the record and the invisible pointer }
  891. if is_class(def) then
  892. begin
  893. { Write the record class itself }
  894. tobjectdef(def).writing_class_record_dbginfo:=true;
  895. write_def_stabstr(list,def);
  896. tobjectdef(def).writing_class_record_dbginfo:=false;
  897. { Write the invisible pointer class }
  898. oldtypesym:=def.typesym;
  899. def.typesym:=nil;
  900. write_def_stabstr(list,def);
  901. def.typesym:=oldtypesym;
  902. end
  903. else
  904. write_def_stabstr(list,def);
  905. { VMT symbol }
  906. if (oo_has_vmt in tobjectdef(def).objectoptions) and
  907. assigned(def.owner) and
  908. assigned(def.owner.name) then
  909. list.concat(Tai_stab.create(stab_stabs,strpnew('"vmt_'+GetSymTableName(def.owner)+tobjectdef(def).objname^+':S'+
  910. def_stab_number(vmttype)+'",'+tostr(N_STSYM)+',0,0,'+tobjectdef(def).vmt_mangledname)));
  911. end;
  912. procdef :
  913. begin
  914. { procdefs are handled separatly }
  915. end;
  916. else
  917. write_def_stabstr(list,def);
  918. end;
  919. def.dbg_state := dbg_state_written;
  920. end;
  921. procedure TDebugInfoStabs.write_symtable_defs(list:TAsmList;st:TSymtable);
  922. procedure dowritestabs(list:TAsmList;st:TSymtable);
  923. var
  924. def : tdef;
  925. i : longint;
  926. begin
  927. for i:=0 to st.DefList.Count-1 do
  928. begin
  929. def:=tdef(st.DefList[i]);
  930. if (def.dbg_state in [dbg_state_used,dbg_state_queued]) then
  931. insertdef(list,def);
  932. end;
  933. end;
  934. var
  935. old_writing_def_stabs : boolean;
  936. begin
  937. case st.symtabletype of
  938. staticsymtable :
  939. list.concat(tai_comment.Create(strpnew('Defs - Begin Staticsymtable')));
  940. globalsymtable :
  941. list.concat(tai_comment.Create(strpnew('Defs - Begin unit '+GetSymTableName(st)+' has index '+tostr(st.moduleid))));
  942. end;
  943. old_writing_def_stabs:=writing_def_stabs;
  944. writing_def_stabs:=true;
  945. dowritestabs(list,st);
  946. writing_def_stabs:=old_writing_def_stabs;
  947. case st.symtabletype of
  948. staticsymtable :
  949. list.concat(tai_comment.Create(strpnew('Defs - End Staticsymtable')));
  950. globalsymtable :
  951. list.concat(tai_comment.Create(strpnew('Defs - End unit '+GetSymTableName(st)+' has index '+tostr(st.moduleid))));
  952. end;
  953. end;
  954. procedure TDebugInfoStabs.write_procdef(list:TAsmList;pd:tprocdef);
  955. var
  956. templist : TAsmList;
  957. stabsendlabel : tasmlabel;
  958. mangled_length : longint;
  959. p,p1 : pchar;
  960. hs : string;
  961. begin
  962. if assigned(pd.procstarttai) then
  963. begin
  964. { mark as used, so also the local and para defs will be written }
  965. pd.dbg_state:=dbg_state_used;
  966. templist:=TAsmList.create;
  967. { end of procedure }
  968. current_asmdata.getlabel(stabsendlabel,alt_dbgtype);
  969. if assigned(pd.funcretsym) and
  970. (tabstractnormalvarsym(pd.funcretsym).refs>0) then
  971. begin
  972. if tabstractnormalvarsym(pd.funcretsym).localloc.loc=LOC_REFERENCE then
  973. begin
  974. {$warning Need to add gdb support for ret in param register calling}
  975. if paramanager.ret_in_param(pd.returndef,pd.proccalloption) then
  976. hs:='X*'
  977. else
  978. hs:='X';
  979. templist.concat(Tai_stab.create(stab_stabs,strpnew(
  980. '"'+GetSymName(pd.procsym)+':'+hs+def_stab_number(pd.returndef)+'",'+
  981. tostr(N_tsym)+',0,0,'+tostr(tabstractnormalvarsym(pd.funcretsym).localloc.reference.offset))));
  982. if (m_result in current_settings.modeswitches) then
  983. templist.concat(Tai_stab.create(stab_stabs,strpnew(
  984. '"RESULT:'+hs+def_stab_number(pd.returndef)+'",'+
  985. tostr(N_tsym)+',0,0,'+tostr(tabstractnormalvarsym(pd.funcretsym).localloc.reference.offset))));
  986. end;
  987. end;
  988. mangled_length:=length(pd.mangledname);
  989. getmem(p,2*mangled_length+50);
  990. strpcopy(p,tostr(N_LBRAC)+',0,0,');
  991. {$IFDEF POWERPC64}strpcopy(strend(p), '.');{$ENDIF POWERPC64}
  992. strpcopy(strend(p),pd.mangledname);
  993. if (tf_use_function_relative_addresses in target_info.flags) then
  994. begin
  995. strpcopy(strend(p),'-');
  996. {$IFDEF POWERPC64}strpcopy(strend(p), '.');{$ENDIF POWERPC64}
  997. strpcopy(strend(p),pd.mangledname);
  998. end;
  999. getmem(p1,strlen(p)+1);
  1000. move(p^,p1^,strlen(p)+1);
  1001. templist.concat(Tai_stab.Create(stab_stabn,p1));
  1002. strpcopy(p,tostr(N_RBRAC)+',0,0,'+stabsendlabel.name);
  1003. if (tf_use_function_relative_addresses in target_info.flags) then
  1004. begin
  1005. strpcopy(strend(p),'-');
  1006. {$IFDEF POWERPC64}strpcopy(strend(p), '.');{$ENDIF POWERPC64}
  1007. strpcopy(strend(p),pd.mangledname);
  1008. end;
  1009. getmem(p1,strlen(p)+1);
  1010. move(p^,p1^,strlen(p)+1);
  1011. templist.concat(Tai_stab.Create(stab_stabn,p1));
  1012. freemem(p,2*mangled_length+50);
  1013. { the stabsendlabel must come after all other stabs for this }
  1014. { function }
  1015. templist.concat(tai_label.create(stabsendlabel));
  1016. { Add a "size" stab as described in the last paragraph of 2.5 at }
  1017. { http://sourceware.org/gdb/current/onlinedocs/stabs_2.html#SEC12 }
  1018. { This works at least on Darwin (and is needed on Darwin to get }
  1019. { correct smartlinking of stabs), but I don't know which binutils }
  1020. { version is required on other platforms }
  1021. { This stab must come after all other stabs for the procedure, }
  1022. { including the LBRAC/RBRAC ones }
  1023. if (target_info.system in systems_darwin) then
  1024. templist.concat(Tai_stab.create(stab_stabs,
  1025. strpnew('"",'+tostr(N_FUNCTION)+',0,0,'+stabsendlabel.name+'-'+pd.mangledname)));
  1026. current_asmdata.asmlists[al_procedures].insertlistafter(pd.procendtai,templist);
  1027. { "The stab representing a procedure is located immediately
  1028. following the code of the procedure. This stab is in turn
  1029. directly followed by a group of other stabs describing
  1030. elements of the procedure. These other stabs describe the
  1031. procedure's parameters, its block local variables, and its
  1032. block structure." (stab docs) }
  1033. { this is however incorrect in case "include source" statements }
  1034. { appear in the block, in that case the procedure stab must }
  1035. { appear before this include stabs (and we generate such an }
  1036. { stabs for all functions) (JM) }
  1037. { procdef }
  1038. write_def_stabstr(templist,pd);
  1039. current_asmdata.asmlists[al_procedures].insertlistbefore(pd.procstarttai,templist);
  1040. { para types }
  1041. if assigned(pd.parast) then
  1042. write_symtable_syms(templist,pd.parast);
  1043. { local type defs and vars should not be written
  1044. inside the main proc stab }
  1045. if assigned(pd.localst) and
  1046. (pd.localst.symtabletype=localsymtable) then
  1047. write_symtable_syms(templist,pd.localst);
  1048. current_asmdata.asmlists[al_procedures].insertlistbefore(pd.procstarttai,templist);
  1049. templist.free;
  1050. end;
  1051. end;
  1052. {****************************************************************************
  1053. TSym support
  1054. ****************************************************************************}
  1055. function TDebugInfoStabs.sym_var_value(const s:string;arg:pointer):string;
  1056. var
  1057. sym : tsym;
  1058. begin
  1059. sym:=tsym(arg);
  1060. result:='';
  1061. if s='name' then
  1062. result:=GetSymName(sym)
  1063. else if s='mangledname' then
  1064. result:=sym.mangledname
  1065. else if s='ownername' then
  1066. result:=GetSymTableName(sym.owner)
  1067. else if s='line' then
  1068. result:=tostr(sym.fileinfo.line)
  1069. else if s='N_LSYM' then
  1070. result:=tostr(N_LSYM)
  1071. else if s='N_LCSYM' then
  1072. result:=tostr(N_LCSYM)
  1073. else if s='N_RSYM' then
  1074. result:=tostr(N_RSYM)
  1075. else if s='N_TSYM' then
  1076. result:=tostr(N_TSYM)
  1077. else if s='N_STSYM' then
  1078. result:=tostr(N_STSYM)
  1079. else if s='N_FUNCTION' then
  1080. result:=tostr(N_FUNCTION)
  1081. else
  1082. internalerror(200401152);
  1083. end;
  1084. function TDebugInfoStabs.sym_stabstr_evaluate(sym:tsym;const s:string;const vars:array of string):Pchar;
  1085. begin
  1086. result:=string_evaluate(s,@sym_var_value,sym,vars);
  1087. end;
  1088. procedure TDebugInfoStabs.insertsym(list:TAsmList;sym:tsym);
  1089. function fieldvarsym_stabstr(sym:tfieldvarsym):Pchar;
  1090. begin
  1091. result:=nil;
  1092. if (sym.owner.symtabletype=objecTSymtable) and
  1093. (sp_static in sym.symoptions) then
  1094. result:=sym_stabstr_evaluate(sym,'"${ownername}__${name}:S$1",${N_LCSYM},0,${line},${mangledname}',
  1095. [def_stab_number(sym.vardef)]);
  1096. end;
  1097. function staticvarsym_stabstr(sym:tstaticvarsym):Pchar;
  1098. var
  1099. st : string;
  1100. threadvaroffset : string;
  1101. regidx : Tregisterindex;
  1102. nsym : string[7];
  1103. begin
  1104. result:=nil;
  1105. { external symbols can't be resolved at link time, so we
  1106. can't generate stabs for them }
  1107. if vo_is_external in sym.varoptions then
  1108. exit;
  1109. st:=def_stab_number(sym.vardef);
  1110. case sym.localloc.loc of
  1111. LOC_REGISTER,
  1112. LOC_CREGISTER,
  1113. LOC_MMREGISTER,
  1114. LOC_CMMREGISTER,
  1115. LOC_FPUREGISTER,
  1116. LOC_CFPUREGISTER :
  1117. begin
  1118. regidx:=findreg_by_number(sym.localloc.register);
  1119. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1120. { this is the register order for GDB}
  1121. if regidx<>0 then
  1122. result:=sym_stabstr_evaluate(sym,'"${name}:r$1",${N_RSYM},0,${line},$2',[st,tostr(regstabs_table[regidx])]);
  1123. end;
  1124. else
  1125. begin
  1126. if (vo_is_thread_var in sym.varoptions) then
  1127. threadvaroffset:='+'+tostr(sizeof(aint))
  1128. else
  1129. threadvaroffset:='';
  1130. if (vo_is_typed_const in sym.varoptions) then
  1131. nsym:='N_STSYM'
  1132. else
  1133. nsym:='N_LCSYM';
  1134. { Here we used S instead of
  1135. because with G GDB doesn't look at the address field
  1136. but searches the same name or with a leading underscore
  1137. but these names don't exist in pascal !}
  1138. st:='S'+st;
  1139. result:=sym_stabstr_evaluate(sym,'"${name}:$1",${'+nsym+'},0,${line},${mangledname}$2',[st,threadvaroffset]);
  1140. end;
  1141. end;
  1142. end;
  1143. function localvarsym_stabstr(sym:tlocalvarsym):Pchar;
  1144. var
  1145. st : string;
  1146. regidx : Tregisterindex;
  1147. begin
  1148. result:=nil;
  1149. { There is no space allocated for not referenced locals }
  1150. if (sym.owner.symtabletype=localsymtable) and (sym.refs=0) then
  1151. exit;
  1152. st:=def_stab_number(sym.vardef);
  1153. case sym.localloc.loc of
  1154. LOC_REGISTER,
  1155. LOC_CREGISTER,
  1156. LOC_MMREGISTER,
  1157. LOC_CMMREGISTER,
  1158. LOC_FPUREGISTER,
  1159. LOC_CFPUREGISTER :
  1160. begin
  1161. regidx:=findreg_by_number(sym.localloc.register);
  1162. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1163. { this is the register order for GDB}
  1164. if regidx<>0 then
  1165. result:=sym_stabstr_evaluate(sym,'"${name}:r$1",${N_RSYM},0,${line},$2',[st,tostr(regstabs_table[regidx])]);
  1166. end;
  1167. LOC_REFERENCE :
  1168. { offset to ebp => will not work if the framepointer is esp
  1169. so some optimizing will make things harder to debug }
  1170. result:=sym_stabstr_evaluate(sym,'"${name}:$1",${N_TSYM},0,${line},$2',[st,tostr(sym.localloc.reference.offset)])
  1171. else
  1172. internalerror(2003091814);
  1173. end;
  1174. end;
  1175. function paravarsym_stabstr(sym:tparavarsym):Pchar;
  1176. var
  1177. st : string;
  1178. regidx : Tregisterindex;
  1179. c : char;
  1180. begin
  1181. result:=nil;
  1182. { set loc to LOC_REFERENCE to get somewhat usable debugging info for -Or }
  1183. { while stabs aren't adapted for regvars yet }
  1184. if (vo_is_self in sym.varoptions) then
  1185. begin
  1186. case sym.localloc.loc of
  1187. LOC_REGISTER,
  1188. LOC_CREGISTER:
  1189. regidx:=findreg_by_number(sym.localloc.register);
  1190. LOC_REFERENCE: ;
  1191. else
  1192. internalerror(2003091815);
  1193. end;
  1194. if (po_classmethod in tabstractprocdef(sym.owner.defowner).procoptions) or
  1195. (po_staticmethod in tabstractprocdef(sym.owner.defowner).procoptions) then
  1196. begin
  1197. if (sym.localloc.loc=LOC_REFERENCE) then
  1198. result:=sym_stabstr_evaluate(sym,'"pvmt:p$1",${N_TSYM},0,0,$2',
  1199. [def_stab_number(pvmttype),tostr(sym.localloc.reference.offset)])
  1200. else
  1201. begin
  1202. regidx:=findreg_by_number(sym.localloc.register);
  1203. result:=sym_stabstr_evaluate(sym,'"pvmt:r$1",${N_RSYM},0,0,$2',
  1204. [def_stab_number(pvmttype),tostr(regstabs_table[regidx])]);
  1205. end
  1206. end
  1207. else
  1208. begin
  1209. if not(is_class(tprocdef(sym.owner.defowner)._class)) then
  1210. c:='v'
  1211. else
  1212. c:='p';
  1213. if (sym.localloc.loc=LOC_REFERENCE) then
  1214. result:=sym_stabstr_evaluate(sym,'"$$t:$1",${N_TSYM},0,0,$2',
  1215. [c+def_stab_number(tprocdef(sym.owner.defowner)._class),tostr(sym.localloc.reference.offset)])
  1216. else
  1217. begin
  1218. regidx:=findreg_by_number(sym.localloc.register);
  1219. result:=sym_stabstr_evaluate(sym,'"$$t:r$1",${N_RSYM},0,0,$2',
  1220. [c+def_stab_number(tprocdef(sym.owner.defowner)._class),tostr(regstabs_table[regidx])]);
  1221. end
  1222. end;
  1223. end
  1224. else
  1225. begin
  1226. st:=def_stab_number(sym.vardef);
  1227. if paramanager.push_addr_param(sym.varspez,sym.vardef,tprocdef(sym.owner.defowner).proccalloption) and
  1228. not(vo_has_local_copy in sym.varoptions) and
  1229. not is_open_string(sym.vardef) then
  1230. c:='v' { should be 'i' but 'i' doesn't work }
  1231. else
  1232. c:='p';
  1233. case sym.localloc.loc of
  1234. LOC_REGISTER,
  1235. LOC_CREGISTER,
  1236. LOC_MMREGISTER,
  1237. LOC_CMMREGISTER,
  1238. LOC_FPUREGISTER,
  1239. LOC_CFPUREGISTER :
  1240. begin
  1241. if c='p' then
  1242. c:='R'
  1243. else
  1244. c:='a';
  1245. st:=c+st;
  1246. regidx:=findreg_by_number(sym.localloc.register);
  1247. { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
  1248. { this is the register order for GDB}
  1249. if regidx<>0 then
  1250. result:=sym_stabstr_evaluate(sym,'"${name}:$1",${N_RSYM},0,${line},$2',[st,tostr(longint(regstabs_table[regidx]))]);
  1251. end;
  1252. LOC_REFERENCE :
  1253. begin
  1254. st:=c+st;
  1255. { offset to ebp => will not work if the framepointer is esp
  1256. so some optimizing will make things harder to debug }
  1257. result:=sym_stabstr_evaluate(sym,'"${name}:$1",${N_TSYM},0,${line},$2',[st,tostr(sym.localloc.reference.offset)])
  1258. end;
  1259. else
  1260. internalerror(2003091814);
  1261. end;
  1262. end;
  1263. end;
  1264. function constsym_stabstr(sym:tconstsym):Pchar;
  1265. var
  1266. st : string;
  1267. begin
  1268. result:=nil;
  1269. { Don't write info for default parameter values, the N_Func breaks
  1270. the N_Func for the function itself.
  1271. Valgrind does not support constants }
  1272. if (sym.owner.symtabletype=parasymtable) or
  1273. (cs_gdb_valgrind in current_settings.globalswitches) then
  1274. exit;
  1275. case sym.consttyp of
  1276. conststring:
  1277. begin
  1278. if sym.value.len<200 then
  1279. st:='s'''+backspace_quote(octal_quote(strpas(pchar(sym.value.valueptr)),[#0..#9,#11,#12,#14..#31,'''']),['"','\',#10,#13])+''''
  1280. else
  1281. st:='<constant string too long>';
  1282. end;
  1283. constord:
  1284. st:='i'+tostr(sym.value.valueord);
  1285. constpointer:
  1286. st:='i'+tostr(sym.value.valueordptr);
  1287. constreal:
  1288. begin
  1289. system.str(pbestreal(sym.value.valueptr)^,st);
  1290. st := 'r'+st;
  1291. end;
  1292. else
  1293. begin
  1294. { if we don't know just put zero !! }
  1295. st:='i0';
  1296. end;
  1297. end;
  1298. result:=sym_stabstr_evaluate(sym,'"${name}:c=$1;",${N_FUNCTION},0,${line},0',[st]);
  1299. end;
  1300. function typesym_stabstr(sym:ttypesym) : pchar;
  1301. var
  1302. stabchar : string[2];
  1303. begin
  1304. result:=nil;
  1305. if not assigned(sym.typedef) then
  1306. internalerror(200509262);
  1307. if sym.typedef.typ in tagtypes then
  1308. stabchar:='Tt'
  1309. else
  1310. stabchar:='t';
  1311. result:=sym_stabstr_evaluate(sym,'"${name}:$1$2",${N_LSYM},0,${line},0',[stabchar,def_stab_number(sym.typedef)]);
  1312. end;
  1313. function procsym_stabstr(sym:tprocsym) : pchar;
  1314. var
  1315. i : longint;
  1316. begin
  1317. result:=nil;
  1318. for i:=0 to sym.ProcdefList.Count-1 do
  1319. write_procdef(list,tprocdef(sym.ProcdefList[i]));
  1320. end;
  1321. var
  1322. stabstr : Pchar;
  1323. begin
  1324. stabstr:=nil;
  1325. case sym.typ of
  1326. labelsym :
  1327. stabstr:=sym_stabstr_evaluate(sym,'"${name}",${N_LSYM},0,${line},0',[]);
  1328. fieldvarsym :
  1329. stabstr:=fieldvarsym_stabstr(tfieldvarsym(sym));
  1330. staticvarsym :
  1331. stabstr:=staticvarsym_stabstr(tstaticvarsym(sym));
  1332. localvarsym :
  1333. stabstr:=localvarsym_stabstr(tlocalvarsym(sym));
  1334. paravarsym :
  1335. stabstr:=paravarsym_stabstr(tparavarsym(sym));
  1336. constsym :
  1337. stabstr:=constsym_stabstr(tconstsym(sym));
  1338. typesym :
  1339. stabstr:=typesym_stabstr(ttypesym(sym));
  1340. procsym :
  1341. stabstr:=procsym_stabstr(tprocsym(sym));
  1342. end;
  1343. if stabstr<>nil then
  1344. list.concat(Tai_stab.create(stab_stabs,stabstr));
  1345. { For object types write also the symtable entries }
  1346. if (sym.typ=typesym) and (ttypesym(sym).typedef.typ=objectdef) then
  1347. write_symtable_syms(list,tobjectdef(ttypesym(sym).typedef).symtable);
  1348. sym.isdbgwritten:=true;
  1349. end;
  1350. procedure TDebugInfoStabs.write_symtable_syms(list:TAsmList;st:TSymtable);
  1351. var
  1352. sym : tsym;
  1353. i : longint;
  1354. begin
  1355. case st.symtabletype of
  1356. staticsymtable :
  1357. list.concat(tai_comment.Create(strpnew('Syms - Begin Staticsymtable')));
  1358. globalsymtable :
  1359. list.concat(tai_comment.Create(strpnew('Syms - Begin unit '+GetSymTableName(st)+' has index '+tostr(st.moduleid))));
  1360. end;
  1361. for i:=0 to st.SymList.Count-1 do
  1362. begin
  1363. sym:=tsym(st.SymList[i]);
  1364. if not(sp_hidden in sym.symoptions) and
  1365. (not sym.isdbgwritten) then
  1366. insertsym(list,sym);
  1367. end;
  1368. case st.symtabletype of
  1369. staticsymtable :
  1370. list.concat(tai_comment.Create(strpnew('Syms - End Staticsymtable')));
  1371. globalsymtable :
  1372. list.concat(tai_comment.Create(strpnew('Syms - End unit '+GetSymTableName(st)+' has index '+tostr(st.moduleid))));
  1373. end;
  1374. end;
  1375. {****************************************************************************
  1376. Proc/Module support
  1377. ****************************************************************************}
  1378. procedure tdebuginfostabs.inserttypeinfo;
  1379. var
  1380. stabsvarlist,
  1381. stabstypelist : TAsmList;
  1382. storefilepos : tfileposinfo;
  1383. i : longint;
  1384. begin
  1385. storefilepos:=current_filepos;
  1386. current_filepos:=current_module.mainfilepos;
  1387. global_stab_number:=0;
  1388. defnumberlist:=TFPObjectlist.create(false);
  1389. stabsvarlist:=TAsmList.create;
  1390. stabstypelist:=TAsmList.create;
  1391. { include symbol that will be referenced from the main to be sure to
  1392. include this debuginfo .o file }
  1393. current_module.flags:=current_module.flags or uf_has_debuginfo;
  1394. if not(target_info.system in systems_darwin) then
  1395. begin
  1396. new_section(current_asmdata.asmlists[al_stabs],sec_data,GetSymTableName(current_module.localsymtable),0);
  1397. current_asmdata.asmlists[al_stabs].concat(tai_symbol.Createname_global(make_mangledname('DEBUGINFO',current_module.localsymtable,''),AT_DATA,0));
  1398. end
  1399. else
  1400. new_section(current_asmdata.asmlists[al_stabs],sec_code,GetSymTableName(current_module.localsymtable),0);
  1401. { first write all global/local symbols. This will flag all required tdefs }
  1402. if assigned(current_module.globalsymtable) then
  1403. write_symtable_syms(stabsvarlist,current_module.globalsymtable);
  1404. if assigned(current_module.localsymtable) then
  1405. write_symtable_syms(stabsvarlist,current_module.localsymtable);
  1406. { reset unit type info flag }
  1407. reset_unit_type_info;
  1408. { write used types from the used units }
  1409. write_used_unit_type_info(stabstypelist,current_module);
  1410. { last write the types from this unit }
  1411. if assigned(current_module.globalsymtable) then
  1412. write_symtable_defs(stabstypelist,current_module.globalsymtable);
  1413. if assigned(current_module.localsymtable) then
  1414. write_symtable_defs(stabstypelist,current_module.localsymtable);
  1415. current_asmdata.asmlists[al_stabs].concatlist(stabstypelist);
  1416. current_asmdata.asmlists[al_stabs].concatlist(stabsvarlist);
  1417. { reset stab numbers }
  1418. for i:=0 to defnumberlist.count-1 do
  1419. begin
  1420. if assigned(defnumberlist[i]) then
  1421. begin
  1422. tdef(defnumberlist[i]).stab_number:=0;
  1423. tdef(defnumberlist[i]).dbg_state:=dbg_state_unused;
  1424. end;
  1425. end;
  1426. defnumberlist.free;
  1427. defnumberlist:=nil;
  1428. stabsvarlist.free;
  1429. stabstypelist.free;
  1430. current_filepos:=storefilepos;
  1431. end;
  1432. procedure tdebuginfostabs.insertlineinfo(list:TAsmList);
  1433. var
  1434. currfileinfo,
  1435. lastfileinfo : tfileposinfo;
  1436. currfuncname : pshortstring;
  1437. currsectype : TAsmSectiontype;
  1438. hlabel : tasmlabel;
  1439. hp : tai;
  1440. infile : tinputfile;
  1441. begin
  1442. FillChar(lastfileinfo,sizeof(lastfileinfo),0);
  1443. currfuncname:=nil;
  1444. currsectype:=sec_code;
  1445. hp:=Tai(list.first);
  1446. while assigned(hp) do
  1447. begin
  1448. case hp.typ of
  1449. ait_section :
  1450. currsectype:=tai_section(hp).sectype;
  1451. ait_function_name :
  1452. currfuncname:=tai_function_name(hp).funcname;
  1453. ait_force_line :
  1454. lastfileinfo.line:=-1;
  1455. end;
  1456. if (currsectype=sec_code) and
  1457. (hp.typ=ait_instruction) then
  1458. begin
  1459. currfileinfo:=tailineinfo(hp).fileinfo;
  1460. { file changed ? (must be before line info) }
  1461. if (currfileinfo.fileindex<>0) and
  1462. ((lastfileinfo.fileindex<>currfileinfo.fileindex) or
  1463. (lastfileinfo.moduleindex<>currfileinfo.moduleindex)) then
  1464. begin
  1465. infile:=get_module(currfileinfo.moduleindex).sourcefiles.get_file(currfileinfo.fileindex);
  1466. if assigned(infile) then
  1467. begin
  1468. current_asmdata.getlabel(hlabel,alt_dbgfile);
  1469. { emit stabs }
  1470. if (infile.path^<>'') then
  1471. list.insertbefore(Tai_stab.Create_str(stab_stabs,'"'+BsToSlash(FixPath(infile.path^,false))+'",'+tostr(n_includefile)+
  1472. ',0,0,'+hlabel.name),hp);
  1473. list.insertbefore(Tai_stab.Create_str(stab_stabs,'"'+FixFileName(infile.name^)+'",'+tostr(n_includefile)+
  1474. ',0,0,'+hlabel.name),hp);
  1475. list.insertbefore(tai_label.create(hlabel),hp);
  1476. { force new line info }
  1477. lastfileinfo.line:=-1;
  1478. end;
  1479. end;
  1480. { line changed ? }
  1481. if (currfileinfo.line>lastfileinfo.line) and (currfileinfo.line<>0) then
  1482. begin
  1483. if assigned(currfuncname) and
  1484. (tf_use_function_relative_addresses in target_info.flags) then
  1485. begin
  1486. current_asmdata.getlabel(hlabel,alt_dbgline);
  1487. list.insertbefore(Tai_stab.Create_str(stab_stabn,tostr(n_textline)+',0,'+tostr(currfileinfo.line)+','+
  1488. hlabel.name+' - '+{$IFDEF POWERPC64}'.'+{$ENDIF POWERPC64}currfuncname^),hp);
  1489. list.insertbefore(tai_label.create(hlabel),hp);
  1490. end
  1491. else
  1492. list.insertbefore(Tai_stab.Create_str(stab_stabd,tostr(n_textline)+',0,'+tostr(currfileinfo.line)),hp);
  1493. end;
  1494. lastfileinfo:=currfileinfo;
  1495. end;
  1496. hp:=tai(hp.next);
  1497. end;
  1498. end;
  1499. procedure tdebuginfostabs.insertmoduleinfo;
  1500. var
  1501. hlabel : tasmlabel;
  1502. infile : tinputfile;
  1503. begin
  1504. { emit main source n_sourcefile for start of module }
  1505. current_asmdata.getlabel(hlabel,alt_dbgfile);
  1506. infile:=current_module.sourcefiles.get_file(1);
  1507. new_section(current_asmdata.asmlists[al_start],sec_code,make_mangledname('DEBUGSTART',current_module.localsymtable,''),0,secorder_begin);
  1508. if not(target_info.system in systems_darwin) then
  1509. current_asmdata.asmlists[al_start].concat(tai_symbol.Createname_global(make_mangledname('DEBUGSTART',current_module.localsymtable,''),AT_DATA,0));
  1510. if (infile.path^<>'') then
  1511. current_asmdata.asmlists[al_start].concat(Tai_stab.Create_str(stab_stabs,'"'+BsToSlash(FixPath(infile.path^,false))+'",'+tostr(n_sourcefile)+
  1512. ',0,0,'+hlabel.name));
  1513. current_asmdata.asmlists[al_start].concat(Tai_stab.Create_str(stab_stabs,'"'+FixFileName(infile.name^)+'",'+tostr(n_sourcefile)+
  1514. ',0,0,'+hlabel.name));
  1515. current_asmdata.asmlists[al_start].concat(tai_label.create(hlabel));
  1516. { for darwin, you need a "module marker" too to work around }
  1517. { either some assembler or gdb bug (radar 4386531 according to a }
  1518. { comment in dbxout.c of Apple's gcc) }
  1519. if (target_info.system in systems_darwin) then
  1520. current_asmdata.asmlists[al_end].concat(Tai_stab.Create_str(stab_stabs,'"",'+tostr(N_OSO)+',0,0,0'));
  1521. { emit empty n_sourcefile for end of module }
  1522. current_asmdata.getlabel(hlabel,alt_dbgfile);
  1523. new_section(current_asmdata.asmlists[al_end],sec_code,make_mangledname('DEBUGEND',current_module.localsymtable,''),0,secorder_end);
  1524. if not(target_info.system in systems_darwin) then
  1525. current_asmdata.asmlists[al_end].concat(tai_symbol.Createname_global(make_mangledname('DEBUGEND',current_module.localsymtable,''),AT_DATA,0));
  1526. current_asmdata.asmlists[al_end].concat(Tai_stab.Create_str(stab_stabs,'"",'+tostr(n_sourcefile)+',0,0,'+hlabel.name));
  1527. current_asmdata.asmlists[al_end].concat(tai_label.create(hlabel));
  1528. end;
  1529. procedure tdebuginfostabs.referencesections(list:TAsmList);
  1530. var
  1531. hp : tmodule;
  1532. dbgtable : tai_symbol;
  1533. begin
  1534. { Reference all DEBUGINFO sections from the main .fpc section }
  1535. if (target_info.system in ([system_powerpc_macos]+systems_darwin)) then
  1536. exit;
  1537. list.concat(Tai_section.create(sec_fpc,'links',0));
  1538. { make sure the debuginfo doesn't get stripped out }
  1539. if (target_info.system in systems_darwin) then
  1540. begin
  1541. dbgtable:=tai_symbol.createname('DEBUGINFOTABLE',AT_DATA,0);
  1542. list.concat(tai_directive.create(asd_no_dead_strip,dbgtable.sym.name));
  1543. list.concat(dbgtable);
  1544. end;
  1545. { include reference to all debuginfo sections of used units }
  1546. hp:=tmodule(loaded_units.first);
  1547. while assigned(hp) do
  1548. begin
  1549. If (hp.flags and uf_has_debuginfo)=uf_has_debuginfo then
  1550. begin
  1551. list.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',hp.localsymtable,''),0));
  1552. list.concat(Tai_const.Createname(make_mangledname('DEBUGSTART',hp.localsymtable,''),0));
  1553. list.concat(Tai_const.Createname(make_mangledname('DEBUGEND',hp.localsymtable,''),0));
  1554. end;
  1555. hp:=tmodule(hp.next);
  1556. end;
  1557. end;
  1558. const
  1559. dbg_stabs_info : tdbginfo =
  1560. (
  1561. id : dbg_stabs;
  1562. idtxt : 'STABS';
  1563. );
  1564. initialization
  1565. RegisterDebugInfo(dbg_stabs_info,TDebugInfoStabs);
  1566. end.