From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28502 invoked by alias); 28 Apr 2007 20:29:18 -0000 Received: (qmail 28493 invoked by uid 22791); 28 Apr 2007 20:29:18 -0000 X-Spam-Check-By: sourceware.org Received: from return.false.org (HELO return.false.org) (66.207.162.98) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 28 Apr 2007 21:29:16 +0100 Received: from return.false.org (localhost [127.0.0.1]) by return.false.org (Postfix) with ESMTP id 0BD7F4B267 for ; Sat, 28 Apr 2007 15:29:15 -0500 (CDT) Received: from caradoc.them.org (dsl093-172-095.pit1.dsl.speakeasy.net [66.93.172.95]) by return.false.org (Postfix) with ESMTP id C558F4B262 for ; Sat, 28 Apr 2007 15:29:14 -0500 (CDT) Received: from drow by caradoc.them.org with local (Exim 4.67) (envelope-from ) id 1HhtXe-0002EM-8S for gdb-patches@sourceware.org; Sat, 28 Apr 2007 16:29:14 -0400 Date: Sat, 28 Apr 2007 20:42:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sourceware.org Subject: [rfc] dwarf2 unwinder and MIPS n32 Message-ID: <20070428202914.GA8077@caradoc.them.org> Mail-Followup-To: gdb-patches@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.15 (2007-04-09) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-04/txt/msg00380.txt.bz2 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 * 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;