* dwarf fixes

* reuse of global dwarf entries

git-svn-id: trunk@4780 -
This commit is contained in:
peter 2006-10-04 10:18:14 +00:00
parent 57d5ce9713
commit b66b8ed495
3 changed files with 69 additions and 38 deletions

View File

@ -613,10 +613,6 @@ end;
function TDebugInfoDwarf.def_dwarf_lab(def:tdef) : tasmsymbol;
begin
{ procdefs only need a number, mark them as already written
so they won't be written implicitly }
if (def.deftype=procdef) then
def.dbg_state:=dbg_state_written;
{ dwarf must already be written, or we must be busy writing it }
if writing_def_dwarf and
not(def.dbg_state in [dbg_state_writing,dbg_state_written]) then
@ -627,13 +623,30 @@ end;
if def.dbg_state=dbg_state_unused then
def.dbg_state:=dbg_state_used;
{ Need a new label? }
if def.dwarf_lab=nil then
if not assigned(def.dwarf_lab) then
begin
current_asmdata.getdatalabel(def.dwarf_lab);
if nextdefnumber>=defnumberlist.count then
defnumberlist.count:=nextdefnumber+250;
defnumberlist[nextdefnumber]:=def;
inc(nextdefnumber);
if (df_has_dwarf_dbg_info in def.defoptions) then
begin
if not assigned(def.typesym) then
internalerror(200610011);
def.dwarf_lab:=current_asmdata.RefAsmSymbol(make_mangledname('DBG',def.owner,def.typesym.name));
def.dbg_state:=dbg_state_written;
end
else
begin
{ Create an exported DBG symbol if we are generating a def defined in the
globalsymtable of the current unit }
if assigned(def.typesym) and
(def.owner.symtabletype=globalsymtable) and
(def.owner.iscurrentunit) then
begin
def.dwarf_lab:=current_asmdata.DefineAsmSymbol(make_mangledname('DBG',def.owner,def.typesym.name),AB_GLOBAL,AT_DATA);
include(def.defoptions,df_has_dwarf_dbg_info);
end
else
current_asmdata.getdatalabel(TAsmLabel(def.dwarf_lab));
end;
defnumberlist.Add(def);
end;
result:=def.dwarf_lab;
end;
@ -1372,9 +1385,15 @@ end;
end;
procedure TDebugInfoDwarf.appendtag(list:TAsmList;def:tdef);
var
labsym : tasmsymbol;
begin
list.concat(tai_symbol.create(def_dwarf_lab(def),0));
current_asmdata.asmlists[al_dwarf_info].concat(tai_comment.Create(strpnew('Definition '+def.typename)));
labsym:=def_dwarf_lab(def);
if df_has_dwarf_dbg_info in def.defoptions then
list.concat(tai_symbol.create_global(labsym,0))
else
list.concat(tai_symbol.create(labsym,0));
case def.deftype of
stringdef :
appendtag_stringdef(tstringdef(def));
@ -1555,6 +1574,7 @@ end;
begin
if assigned(pd.procstarttai) then
begin
current_asmdata.asmlists[al_dwarf_info].concat(tai_comment.Create(strpnew('Procdef '+pd.fullprocname(true))));
append_entry(DW_TAG_subprogram,true,
[DW_AT_name,DW_FORM_string,pd.procsym.name+#0
{ data continues below }
@ -1933,6 +1953,7 @@ end;
procedure TDebugInfoDwarf.appendsym(sym:tsym);
begin
current_asmdata.asmlists[al_dwarf_info].concat(tai_comment.Create(strpnew('Symbol '+sym.name)));
case sym.typ of
globalvarsym :
appendsym_var(tglobalvarsym(sym));
@ -1983,7 +2004,10 @@ end;
procedure TDebugInfoDwarf.write_symtable_syms(st:tsymtable);
var
p : tsym;
old_writing_def_dwarf : boolean;
begin
old_writing_def_dwarf:=writing_def_dwarf;
writing_def_dwarf:=false;
p:=tsym(st.symindex.first);
while assigned(p) do
begin
@ -1991,6 +2015,7 @@ end;
appendsym(p);
p:=tsym(p.indexnext);
end;
writing_def_dwarf:=old_writing_def_dwarf;
end;
@ -2305,7 +2330,10 @@ end;
ait_section :
currsectype:=tai_section(hp).sectype;
ait_function_name :
begin
currfuncname:=tai_function_name(hp).funcname;
asmline.concat(tai_comment.Create(strpnew('function: '+currfuncname^)));
end;
ait_force_line : begin
lastfileinfo.line:=-1;
end;
@ -2473,6 +2501,7 @@ end;
end;
def.symtable.foreach(@enum_members_callback,nil);
write_symtable_defs(current_asmdata.asmlists[al_dwarf_info],def.symtable);
finish_children;
end;

View File

@ -154,6 +154,8 @@ type
df_has_inittable,
{ rtti data has been generated }
df_has_rttitable,
{ dwarf debug info has been generated }
df_has_dwarf_dbg_info,
{ type is unique, i.e. declared with type = type <tdef>; }
df_unique,
{ type is a generic }

View File

@ -71,7 +71,7 @@ interface
typesym : tsym; { which type the definition was generated this def }
{ maybe it's useful to merge the dwarf and stabs debugging info with some hacking }
{ dwarf debugging }
dwarf_lab : tasmlabel;
dwarf_lab : tasmsymbol;
{ stabs debugging }
stab_number : word;
dbg_state : tdefdbgstatus;