* i386 uses dwarf cfi info on linux/win32, so even when omitting the stack frame, trace backs in gdb are correct

git-svn-id: trunk@2316 -
This commit is contained in:
florian 2006-01-21 14:30:57 +00:00
parent 46ff92bb60
commit f5d790f9b6
5 changed files with 34 additions and 12 deletions

View File

@ -80,6 +80,7 @@ interface
public
constructor create;
procedure generate_code(list:taasmoutput);
procedure generate_initial_instructions(list:taasmoutput);virtual;
{ operations }
procedure start_frame(list:taasmoutput);
procedure end_frame(list:taasmoutput);
@ -247,9 +248,32 @@ implementation
FFrameEndLabel:=nil;
FLastLocLabel:=nil;
code_alignment_factor:=1;
data_alignment_factor:=-1;
data_alignment_factor:=-4;
end;
{$ifdef i386}
{ if more cpu dependend stuff is implemented, this needs more refactoring }
procedure tdwarfcfi.generate_initial_instructions(list:taasmoutput);
begin
list.concat(tai_const.create_8bit(DW_CFA_def_cfa));
list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_STACK_POINTER_REG)));
list.concat(tai_const.create_uleb128bit(sizeof(aint)));
list.concat(tai_const.create_8bit(DW_CFA_offset_extended));
list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_RETURN_ADDRESS_REG)));
list.concat(tai_const.create_uleb128bit((-sizeof(aint)) div data_alignment_factor));
end;
{$else i386}
{ if more cpu dependend stuff is implemented, this needs more refactoring }
procedure tdwarfcfi.generate_initial_instructions(list:taasmoutput);
begin
list.concat(tai_const.create_8bit(DW_CFA_def_cfa));
list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_STACK_POINTER_REG)));
list.concat(tai_const.create_uleb128bit(sizeof(aint)));
list.concat(tai_const.create_8bit(DW_CFA_offset_extended));
list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_RETURN_ADDRESS_REG)));
list.concat(tai_const.create_uleb128bit((-sizeof(aint)) div data_alignment_factor));
end;
{$endif i386}
procedure tdwarfcfi.generate_code(list:taasmoutput);
var
@ -286,13 +310,8 @@ implementation
def_cfa(stackpointer,sizeof(aint))
cfa_offset_extended(returnaddres,-sizeof(aint))
}
{$warning TODO This needs to be target dependent}
list.concat(tai_const.create_8bit(DW_CFA_def_cfa));
list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_STACK_POINTER_REG)));
list.concat(tai_const.create_uleb128bit(sizeof(aint)));
list.concat(tai_const.create_8bit(DW_CFA_offset_extended));
list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_RETURN_ADDRESS_REG)));
list.concat(tai_const.create_uleb128bit((-sizeof(aint)) div data_alignment_factor));
generate_initial_instructions(list);
list.concat(cai_align.create_zeros(4));
list.concat(tai_label.create(lenendlabel));
lenstartlabel:=nil;

View File

@ -50,7 +50,8 @@ unit i_linux;
{$ifdef segment_threadvars}
tf_section_threadvars,
{$endif segment_threadvars}
tf_needs_symbol_type,tf_files_case_sensitive,tf_use_function_relative_addresses];
tf_needs_symbol_type,tf_files_case_sensitive,tf_use_function_relative_addresses,
tf_needs_dwarf_cfi];
cpu : cpu_i386;
unit_env : 'LINUXUNITS';
extradefines : 'UNIX;HASUNIX';

View File

@ -33,7 +33,7 @@ unit i_win;
name : 'Win32 for i386';
shortname : 'Win32';
flags : [tf_files_case_aware,tf_has_dllscanner,tf_use_function_relative_addresses
{,tf_smartlink_sections}{,tf_section_threadvars}];
{,tf_smartlink_sections}{,tf_section_threadvars},tf_needs_dwarf_cfi];
cpu : cpu_i386;
unit_env : 'WIN32UNITS';
extradefines : 'MSWINDOWS;WINDOWS';

View File

@ -258,7 +258,7 @@ interface
asmbin : 'as';
asmcmd : '-o $OBJ $ASM';
supported_target : system_any;
flags : [af_allowdirect,af_needar,af_smartlink_sections];
flags : [af_allowdirect,af_needar,af_smartlink_sections,af_supports_dwarf];
labelprefix : '.L';
comment : '# ';
);

View File

@ -1841,7 +1841,7 @@ unit cgx86;
if not nostackframe then
begin
list.concat(tai_regalloc.alloc(current_procinfo.framepointer,nil));
if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then
if current_procinfo.framepointer=NR_STACK_POINTER_REG then
CGmessage(cg_d_stackframe_omited)
else
begin
@ -1858,6 +1858,8 @@ unit cgx86;
if localsize<>0 then
begin
cg.g_stackpointer_alloc(list,localsize);
if current_procinfo.framepointer=NR_STACK_POINTER_REG then
dwarfcfi.cfa_def_cfa_offset(list,localsize+sizeof(aint));
end;
end;
end;