* Insert DW_AT_low_pc and DW_AT_high_pc attributes for modules on Windows also. It solves debugging problems on Windows with dwarf debug info.

git-svn-id: trunk@13098 -
This commit is contained in:
yury 2009-05-04 18:36:08 +00:00
parent 9acecc0863
commit 9c9462cd5a
4 changed files with 37 additions and 28 deletions

View File

@ -344,7 +344,7 @@ implementation
version,globals,verbose,systems,
cpubase,cgbase,paramgr,
fmodule,
defutil,symconst,symtable
defutil,symconst,symtable,ppu
;
const
@ -2346,23 +2346,14 @@ implementation
fitem : TFileIndexItem;
flist : TFPList;
begin
{ doesn't work for windows, because it puts no code per module in the .text section }
if not(target_info.system in system_all_windows) then
begin
{ insert .Ltext0 label }
templist:=TAsmList.create;
new_section(templist,sec_code,'',0);
templist.concat(tai_symbol.createname(target_asm.labelprefix+'text0',AT_DATA,0));
current_asmdata.asmlists[al_start].insertlist(templist);
templist.free;
{ insert .Letext0 label }
templist:=TAsmList.create;
new_section(templist,sec_code,'',0);
templist.concat(tai_symbol.createname(target_asm.labelprefix+'etext0',AT_DATA,0));
current_asmdata.asmlists[al_end].insertlist(templist);
templist.free;
end;
{ insert DEBUGSTART and DEBUGEND labels }
current_module.flags:=current_module.flags or uf_has_dwarf_debuginfo;
new_section(current_asmdata.asmlists[al_start],sec_code,make_mangledname('DEBUGSTART',current_module.localsymtable,''),0,secorder_begin);
current_asmdata.asmlists[al_start].concat(tai_symbol.Createname_global(make_mangledname('DEBUGSTART',current_module.localsymtable,''),AT_DATA,0));
new_section(current_asmdata.asmlists[al_end],sec_code,make_mangledname('DEBUGEND',current_module.localsymtable,''),0,secorder_end);
current_asmdata.asmlists[al_end].concat(tai_symbol.Createname_global(make_mangledname('DEBUGEND',current_module.localsymtable,''),AT_DATA,0));
{ insert .Ldebug_abbrev0 label }
templist:=TAsmList.create;
@ -2610,12 +2601,8 @@ implementation
current_asmdata.RefAsmSymbol(target_asm.labelprefix+'debug_linesection0'),
current_asmdata.RefAsmSymbol(target_asm.labelprefix+'debug_line0'));
{ see comments above where these labels are created and inserted }
if not(target_info.system in system_all_windows) then
begin
append_labelentry(DW_AT_low_pc,current_asmdata.RefAsmSymbol(target_asm.labelprefix+'text0'));
append_labelentry(DW_AT_high_pc,current_asmdata.RefAsmSymbol(target_asm.labelprefix+'etext0'));
end;
append_labelentry(DW_AT_low_pc,current_asmdata.RefAsmSymbol(make_mangledname('DEBUGSTART',current_module.localsymtable,'')));
append_labelentry(DW_AT_high_pc,current_asmdata.RefAsmSymbol(make_mangledname('DEBUGEND',current_module.localsymtable,'')));
finish_entry;
@ -2676,7 +2663,28 @@ implementation
procedure TDebugInfoDwarf.referencesections(list:TAsmList);
var
hp : tmodule;
begin
{ Reference all DEBUGSTART and DEBUGEND labels from the main .fpc section }
if (target_info.system in ([system_powerpc_macos]+systems_darwin)) then
exit;
list.concat(Tai_section.create(sec_fpc,'links',0));
list.concat(Tai_const.Createname(make_mangledname('DEBUGSTART',main_module.localsymtable,''),0));
list.concat(Tai_const.Createname(make_mangledname('DEBUGEND',main_module.localsymtable,''),0));
{ include reference to all debuginfo sections of used units }
hp:=tmodule(loaded_units.first);
while assigned(hp) do
begin
If (hp.flags and uf_has_dwarf_debuginfo)=uf_has_dwarf_debuginfo then
begin
list.concat(Tai_const.Createname(make_mangledname('DEBUGSTART',hp.localsymtable,''),0));
list.concat(Tai_const.Createname(make_mangledname('DEBUGEND',hp.localsymtable,''),0));
end;
hp:=tmodule(hp.next);
end;
end;

View File

@ -1420,7 +1420,7 @@ implementation
{ include symbol that will be referenced from the main to be sure to
include this debuginfo .o file }
current_module.flags:=current_module.flags or uf_has_debuginfo;
current_module.flags:=current_module.flags or uf_has_stabs_debuginfo;
if not(target_info.system in systems_darwin) then
begin
new_section(current_asmdata.asmlists[al_stabs],sec_data,GetSymTableName(current_module.localsymtable),0);
@ -1599,7 +1599,7 @@ implementation
hp:=tmodule(loaded_units.first);
while assigned(hp) do
begin
If (hp.flags and uf_has_debuginfo)=uf_has_debuginfo then
If (hp.flags and uf_has_stabs_debuginfo)=uf_has_stabs_debuginfo then
begin
list.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',hp.localsymtable,''),0));
list.concat(Tai_const.Createname(make_mangledname('DEBUGSTART',hp.localsymtable,''),0));

View File

@ -1247,7 +1247,7 @@ implementation
else
begin
current_module.flags:=current_module.flags or uf_no_link;
current_module.flags:=current_module.flags and not uf_has_debuginfo;
current_module.flags:=current_module.flags and not (uf_has_stabs_debuginfo or uf_has_dwarf_debuginfo);
end;
if ag then

View File

@ -150,11 +150,12 @@ const
uf_release = $2000; { unit was compiled with -Ur option }
uf_threadvars = $4000; { unit has threadvars }
uf_fpu_emulation = $8000; { this unit was compiled with fpu emulation on }
uf_has_debuginfo = $10000; { this unit has debuginfo generated }
uf_has_stabs_debuginfo = $10000; { this unit has stabs debuginfo generated }
uf_local_symtable = $20000; { this unit has a local symtable stored }
uf_uses_variants = $40000; { this unit uses variants }
uf_has_resourcefiles = $80000; { this unit has external resources (using $R directive)}
uf_has_exports = $100000; { this module or a used unit has exports }
uf_has_dwarf_debuginfo = $200000; { this unit has dwarf debuginfo generated }
type