[rfc] dwarf2 unwinder and MIPS n32
Daniel Jacobowitz
drow@false.org
Sat Apr 28 20:42:00 GMT 2007
The DWARF-2 unwinder uses store_typed_address to store the value of
the CFA or RA into a register-sized buffer. The type of the register
might be a pointer or integer type, so it passes
builtin_type_void_data_ptr and builtin_type_void_func_ptr as
appropriate. But for MIPS N32, sizeof (void *) == 4 and the stack
pointer is 64-bit. So it unwinds writes four bytes into the first
four of the eight byte slot; since I'm testing big-endian, the failure
is quickly obvious.
So what do we do about it? The patch below works for MIPS, but I'm
reasonably sure it's wrong; it avoids the architecture's
ADDRESS_TO_POINTER method entirely. If we pass the register's type to
store_typed_address we'll get various failures if the architecture
doesn't define the relevant register as a pointer. And MIPS doesn't,
partly because the register is 64-bit and the pointer would only be
32-bit.
Maybe if the size of the register != the size of a void * we should
store it as an unsigned integer. But that seems hackish to me.
I'd love comments; I don't want to commit this patch, but I can't turn
on CFI for MIPS without it.
--
Daniel Jacobowitz
CodeSourcery
2007-04-28 Daniel Jacobowitz <dan@codesourcery.com>
* dwarf2-frame.c (dwarf2_frame_prev_register): Use
store_unsigned_integer instead of store_typed_address.
---
dwarf2-frame.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
Index: gdb/dwarf2-frame.c
===================================================================
--- gdb.orig/dwarf2-frame.c 2007-04-27 17:03:21.000000000 -0400
+++ gdb/dwarf2-frame.c 2007-04-27 17:42:37.000000000 -0400
@@ -1137,10 +1137,8 @@ dwarf2_frame_prev_register (struct frame
*addrp = 0;
*realnump = -1;
if (valuep)
- {
- /* Store the value. */
- store_typed_address (valuep, builtin_type_void_data_ptr, cache->cfa);
- }
+ store_unsigned_integer (valuep, register_size (gdbarch, regnum),
+ cache->cfa);
break;
case DWARF2_FRAME_REG_CFA_OFFSET:
@@ -1149,11 +1147,8 @@ dwarf2_frame_prev_register (struct frame
*addrp = 0;
*realnump = -1;
if (valuep)
- {
- /* Store the value. */
- store_typed_address (valuep, builtin_type_void_data_ptr,
- cache->cfa + cache->reg[regnum].loc.offset);
- }
+ store_unsigned_integer (valuep, register_size (gdbarch, regnum),
+ cache->cfa + cache->reg[regnum].loc.offset);
break;
case DWARF2_FRAME_REG_RA_OFFSET:
@@ -1167,7 +1162,7 @@ dwarf2_frame_prev_register (struct frame
regnum = DWARF2_REG_TO_REGNUM (cache->retaddr_reg.loc.reg);
pc += frame_unwind_register_unsigned (next_frame, regnum);
- store_typed_address (valuep, builtin_type_void_func_ptr, pc);
+ store_unsigned_integer (valuep, register_size (gdbarch, regnum), pc);
}
break;
More information about the Gdb-patches
mailing list