Stop condition for execute_cfa_program ?
Olivier Hainque
hainque@act-europe.fr
Tue Aug 14 09:36:00 GMT 2001
Using trunk gcc sources to experiment with DWARF2 unwinding on PA-hpux, we
encountered an infinite loop while unwinding through optimized code in which
a stack frame allocation is scheduled in the delay slot of a function call.
This undesired behavior (infinite loop) seems related to the stop condition
in execute_cfa_program, more specifically the "fs->pc < context->ra" part.
Our real test case is in Ada, but the trivial C code below illustrates what
basically happens. An advice as to how this should be best addressed would be
greatly appreciated (should/could the condition be updated or is this more
likely a problem with the frame notes).
Thanks in advance for your help,
Olivier
--
void bar (void);
void
foo (void)
{
bar ();
}
void
bar ()
{
}
yields (-O1 -fexceptions -dA) the assembly and FDE below for "foo" :
L$FB0001
foo
.PROC
.CALLINFO FRAME=64,CALLS,SAVE_RP
.ENTRY
;# basic block 0
stw %r2,-20(%r30)
L$CFI0000
.CALL
bl bar,%r2 <=== call to bar
ldo 64(%r30),%r30 <=== stack frame allocation in delay slot
L$CFI0001
ldw -84(%r30),%r2
bv %r0(%r2)
ldo -64(%r30),%r30
.EXIT
.PROCEND
...
L$SFDE0001
.word L$EFDE0001-L$ASFDE0001 ;# FDE Length
L$ASFDE0001
.word L$ASFDE0001-__FRAME_BEGIN__ ;# FDE CIE offset
.word L$FB0001 ;# FDE initial location
.word L$FE0001-L$FB0001 ;# FDE address range
.byte 0x4 ;# DW_CFA_advance_loc4
.word L$CFI0000-L$FB0001
.byte 0x2f ;# DW_CFA_GNU_negative_offset_extended
.uleb128 0x2
.uleb128 0x5
.byte 0x4 ;# DW_CFA_advance_loc4
.word L$CFI0001-L$CFI0000
.byte 0xe ;# DW_CFA_def_cfa_offset
.uleb128 0xffffffc0
The CFA offset change is marked effective from the first ldw insn, at
L$CFI0001, though it is actually already in effect from the call insn.
When unwinding from bar, we would get to context->ra == fs->pc == L$CF0001,
and miss the CFA offset update.
More information about the Gcc
mailing list