This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Force DW_CFA_def_cfa after DW_CFA_def_cfa_expression if no longer indirect


On Fri, Apr 23, 2010 at 09:49:54AM +0200, Jakub Jelinek wrote:
> DW_CFA_def_cfa_register after DW_CFA_def_cfa_expression is ambiguous,
> it is unclear what offset is actually in effect.
> GCC as producer seems to assume the offset in that case is something
> get_cfa_from_loc_descr computes from the location expression (if
> there is DW_OP_plus_uconst after deref, then it is the offset),
> apparently e.g. libgcc unwinder assumes in that case offset is inherited
> from DW_CFA_def_cfa or DW_CFA_def_cfa_offset{,_sf} valid before
> the DW_CFA_def_cfa_expression.
> 
> The following patch just forces DW_CFA_def_cfa so it is obvious what
> register and offset are in effect.

Minimal testcase is:
// { dg-options "-m32 -O2 -fasynchronous-unwind-tables" }

struct S { };
S operator+ (const char *, S);

int
main ()
{
  S s;
  S t = "abcd" + s;
}

Without the patch the unwind info is:
  DW_CFA_advance_loc: 4 to 00000004
  DW_CFA_def_cfa: r1 (ecx) ofs 0
  DW_CFA_advance_loc: 9 to 0000000d
  DW_CFA_expression: r5 (ebp) (DW_OP_breg5: 0)
  DW_CFA_advance_loc: 1 to 0000000e
  DW_CFA_def_cfa_expression (DW_OP_breg5: -4; DW_OP_deref)
  DW_CFA_advance_loc: 29 to 0000002b
  DW_CFA_def_cfa_register: r1 (ecx)
  DW_CFA_advance_loc: 9 to 00000034
  DW_CFA_def_cfa: r4 (esp) ofs 4
with the patch:
  DW_CFA_advance_loc: 4 to 00000004
  DW_CFA_def_cfa: r1 (ecx) ofs 0
  DW_CFA_advance_loc: 9 to 0000000d
  DW_CFA_expression: r5 (ebp) (DW_OP_breg5: 0)
  DW_CFA_advance_loc: 1 to 0000000e
  DW_CFA_def_cfa_expression (DW_OP_breg5: -4; DW_OP_deref)
  DW_CFA_advance_loc: 29 to 0000002b
  DW_CFA_def_cfa: r1 (ecx) ofs 0
  DW_CFA_advance_loc: 9 to 00000034
  DW_CFA_def_cfa: r4 (esp) ofs 4
  DW_CFA_nop
  DW_CFA_nop
  DW_CFA_nop

Not sure how to test it in the testsuite though, regexp on no
DW_CFA_def_cfa_register would be too fragile.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]