This is the mail archive of the gcc-bugs@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]

[Bug debug/24943] New: [hppa64] Bad dwarf output using non-preserved base register


Given a program like this:
int foo(int a, int b, int c)
{
  return a+b+c;
}

int bar(int a, int b, int c)
{
  return foo(a, b, c);
}

int main(int argc, char **argv)
{
  return bar(1,2,3);
}

for foo and bar, gcc generates code that stores the arguments a, b, and c on
the stack by using the argument pointer, but it does this indirectly, like so:

foo
        .PROC
        .CALLINFO FRAME=80,NO_CALLS,SAVE_SP,ENTRY_GR=3
        .ENTRY
        copy %r3,%r1
        copy %r30,%r3
        std,ma %r1,80(%r30)
        std %r3,-8(%r30)
        ldo -64(%r29),%r20
        stw %r26,4(%r20)
        stw %r25,12(%r20)
        stw %r24,20(%r20)
        [...]

gcc proceeds to emit debug info for a, b, and c relative to r20:

$ opt/bin/readelf -wi dwarfbug
[...]
 <2><7d>: Abbrev Number: 3 (DW_TAG_formal_parameter)
     DW_AT_name        : a
     DW_AT_decl_file   : 1
     DW_AT_decl_line   : 1
     DW_AT_type        : <a2>
     DW_AT_location    : 2 byte block: 84 4     (DW_OP_breg20: 4)
 <2><89>: Abbrev Number: 3 (DW_TAG_formal_parameter)
     DW_AT_name        : b
     DW_AT_decl_file   : 1
     DW_AT_decl_line   : 1
     DW_AT_type        : <a2>
     DW_AT_location    : 2 byte block: 84 c     (DW_OP_breg20: 12)
 <2><95>: Abbrev Number: 3 (DW_TAG_formal_parameter)
     DW_AT_name        : c
     DW_AT_decl_file   : 1
     DW_AT_decl_line   : 1
     DW_AT_type        : <a2>
     DW_AT_location    : 2 byte block: 84 14    (DW_OP_breg20: 20)

The problem is that since r20 is not a call preserved register, when you are
doing a stack unwind, you have no way to retrieve those variables in anything
other than the topmost frame.

I've seen it do this with r20 and r28, but I guess it can do it with any
available register.

On 32-bit hppa, the parameters are always described relative to the frame base
(DW_OP_fbreg), which works fine.

I'm testing this on hpux, but this looks like it affects all 64-bit hppa
targets.


-- 
           Summary: [hppa64] Bad dwarf output using non-preserved base
                    register
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tausq at debian dot org
 GCC build triplet: hppa64-hp-hpux11.11
  GCC host triplet: hppa64-hp-hpux11.11
GCC target triplet: hppa64-hp-hpux11.11


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24943


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