[patch] Handle signed addresses in the dwarf2 unwinder

Daniel Jacobowitz
2007-04-28T20:42:51Z

This is along the same lines as a patch Kevin wrote (and Martin Hunt
submitted) several years ago. If we have a MIPS binary with 32-bit
addresses, but a 64-bit CORE_ADDR, we should sign extend as necessary.

Unfortunately mips-linux testing doesn't really cover this; userspace
binaries sit below 0x80000000. However, I'm pretty sure this is
necessary to debug programs linked above that point. I'll check it in
when I turn on the CFI unwinder for MIPS, which will be just after we
figure out what to do about store_typed_address (my last message).

Tested on mips64-linux o32 / n32 / n64.

--
Daniel Jacobowitz
CodeSourcery

2007-04-28 Daniel Jacobowitz <dan@codesourcery.com>

* dwarf2-frame.c (read_encoded_value): Correct type. Use
DW_EH_PE_signed if appropriate.

---
dwarf2-frame.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

Index: gdb/dwarf2-frame.c
===================================================================
--- gdb.orig/dwarf2-frame.c 2007-04-27 17:42:37.000000000 -0400
+++ gdb/dwarf2-frame.c 2007-04-27 19:27:15.000000000 -0400
@@ -1446,7 +1446,7 @@ read_encoded_value (struct comp_unit *un
base = 0;
break;
case DW_EH_PE_pcrel:
- base = bfd_get_section_vma (unit->bfd, unit->dwarf_frame_section);
+ base = bfd_get_section_vma (unit->abfd, unit->dwarf_frame_section);
base += (buf - unit->dwarf_frame_buffer);
break;
case DW_EH_PE_datarel:
@@ -1477,7 +1477,11 @@ read_encoded_value (struct comp_unit *un
}

if ((encoding & 0x07) == 0x00)
- encoding |= encoding_for_size (ptr_len);
+ {
+ encoding |= encoding_for_size (ptr_len);
+ if (bfd_get_sign_extend_vma (unit->abfd))
+ encoding |= DW_EH_PE_signed;
+ }

switch (encoding & 0x0f)
{