From: Daniel Jacobowitz <drow@false.org>
To: gdb-patches@sourceware.org
Subject: [rfc] dwarf2 unwinder and MIPS n32
Date: Sat, 28 Apr 2007 20:42:00 -0000 [thread overview]
Message-ID: <20070428202914.GA8077@caradoc.them.org> (raw)
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;
next reply other threads:[~2007-04-28 20:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-28 20:42 Daniel Jacobowitz [this message]
2007-04-28 22:52 ` Ulrich Weigand
2007-04-30 13:28 ` Daniel Jacobowitz
2007-04-30 20:19 ` Ulrich Weigand
2007-05-14 17:22 ` Daniel Jacobowitz
2007-04-30 13:00 ` Maciej W. Rozycki
2007-04-30 13:26 ` Daniel Jacobowitz
2007-04-30 13:44 ` Maciej W. Rozycki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070428202914.GA8077@caradoc.them.org \
--to=drow@false.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox