From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1435 invoked by alias); 21 Jun 2004 20:21:46 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 1428 invoked from network); 21 Jun 2004 20:21:45 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 21 Jun 2004 20:21:45 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i5LKLje1024361 for ; Mon, 21 Jun 2004 16:21:45 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i5LKLj026730 for ; Mon, 21 Jun 2004 16:21:45 -0400 Received: from hunt.cipe.redhat.com (hunt.cipe.redhat.com [10.0.0.52]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id i5LKLipI023300 for ; Mon, 21 Jun 2004 16:21:45 -0400 Subject: [RFA] change mips SP_REGNUM to cooked register From: "Martin M. Hunt" To: gdb-patches@sources.redhat.com Content-Type: multipart/mixed; boundary="=-BF40+UYPc7zXPki35lDq" Organization: Red Hat Inc. Message-Id: <1087849304.5508.4.camel@hunt.cipe.redhat.com> Mime-Version: 1.0 Date: Mon, 21 Jun 2004 20:21:00 -0000 X-SW-Source: 2004-06/txt/msg00487.txt.bz2 --=-BF40+UYPc7zXPki35lDq Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 692 This patch is part of the Mips CFI work started by Kevin Buettner. As requested, I am splitting the previously posted patch into multiple small patches. To get DWARF2 CFI unwinding to work, SP_REGNUM needs to refer to the cooked register number, not the raw register number. 2004-06-21 Martin Hunt Kevin Buettner * config/mips/tm-mips.h (SP_REGNUM): Delete define. * mips-tdep.h (MIPS_SP_REGNUM): Define. * mips-tdep.c (mips_gdbarch_init): Set SP_REGNUM via call to set_gdbarch_sp_regnum(). Use cooked register number. (SP_REGNUM): Replace all occurrences with MIPS_SP_REGNUM. -- Martin M. Hunt Red Hat Inc. --=-BF40+UYPc7zXPki35lDq Content-Disposition: attachment; filename=mips_sp_patch Content-Type: text/x-patch; name=mips_sp_patch; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 6085 Index: mips-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/mips-tdep.c,v retrieving revision 1.298 diff -u -r1.298 mips-tdep.c --- mips-tdep.c 15 Jun 2004 15:06:57 -0000 1.298 +++ mips-tdep.c 18 Jun 2004 23:54:34 -0000 @@ -757,7 +757,7 @@ static CORE_ADDR mips_read_sp (void) { - return read_signed_register (SP_REGNUM); + return read_signed_register (MIPS_SP_REGNUM); } /* Should the upper word of 64-bit addresses be zeroed? */ @@ -849,7 +849,7 @@ static struct frame_id mips_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame) { - return frame_id_build (frame_unwind_register_signed (next_frame, NUM_REGS + SP_REGNUM), + return frame_id_build (frame_unwind_register_signed (next_frame, NUM_REGS + MIPS_SP_REGNUM), frame_pc_unwind (next_frame)); } @@ -880,7 +880,7 @@ { /* If function is frameless, then we need to do it the hard way. I strongly suspect that frameless always means prologueless... */ - if (PROC_FRAME_REG (proc_desc) == SP_REGNUM + if (PROC_FRAME_REG (proc_desc) == MIPS_SP_REGNUM && PROC_FRAME_OFFSET (proc_desc) == 0) return 0; } @@ -1683,7 +1683,7 @@ } /* SP_REGNUM, contains the value and not the address. */ - trad_frame_set_value (cache->saved_regs, NUM_REGS + SP_REGNUM, cache->base); + trad_frame_set_value (cache->saved_regs, NUM_REGS + MIPS_SP_REGNUM, cache->base); return (*this_cache); } @@ -1756,8 +1756,8 @@ regcache_cooked_read_signed (current_regcache, regno, &val); return val; } - else if ((regno % NUM_REGS) == SP_REGNUM) - /* The SP_REGNUM is special, its value is stored in saved_regs. + else if ((regno % NUM_REGS) == MIPS_SP_REGNUM) + /* MIPS_SP_REGNUM is special, its value is stored in saved_regs. In fact, it is so special that it can even only be fetched using a raw register number! Once this code as been converted to frame-unwind the problem goes away. */ @@ -2194,7 +2194,7 @@ /* Old gcc frame, r30 is virtual frame pointer. */ if ((long) low_word != PROC_FRAME_OFFSET (&temp_proc_desc)) frame_addr = sp + low_word; - else if (PROC_FRAME_REG (&temp_proc_desc) == SP_REGNUM) + else if (PROC_FRAME_REG (&temp_proc_desc) == MIPS_SP_REGNUM) { unsigned alloca_adjust; PROC_FRAME_REG (&temp_proc_desc) = 30; @@ -2217,7 +2217,7 @@ else if (inst == 0x03A0F021 || inst == 0x03a0f025 || inst == 0x03a0f02d) { /* New gcc frame, virtual frame pointer is at r30 + frame_size. */ - if (PROC_FRAME_REG (&temp_proc_desc) == SP_REGNUM) + if (PROC_FRAME_REG (&temp_proc_desc) == MIPS_SP_REGNUM) { unsigned alloca_adjust; PROC_FRAME_REG (&temp_proc_desc) = 30; @@ -2249,7 +2249,7 @@ CORE_ADDR sp; if (cur_frame) - sp = read_next_frame_reg (next_frame, NUM_REGS + SP_REGNUM); + sp = read_next_frame_reg (next_frame, NUM_REGS + MIPS_SP_REGNUM); else sp = 0; @@ -2259,7 +2259,7 @@ temp_saved_regs = xrealloc (temp_saved_regs, SIZEOF_FRAME_SAVED_REGS); memset (temp_saved_regs, '\0', SIZEOF_FRAME_SAVED_REGS); PROC_LOW_ADDR (&temp_proc_desc) = start_pc; - PROC_FRAME_REG (&temp_proc_desc) = SP_REGNUM; + PROC_FRAME_REG (&temp_proc_desc) = MIPS_SP_REGNUM; PROC_PC_REG (&temp_proc_desc) = RA_REGNUM; if (start_pc + 200 < limit_pc) @@ -3026,7 +3026,7 @@ fprintf_unfiltered (gdb_stdlog, "\n"); } - regcache_cooked_write_signed (regcache, SP_REGNUM, sp); + regcache_cooked_write_signed (regcache, MIPS_SP_REGNUM, sp); /* Return adjusted stack pointer. */ return sp; @@ -3312,7 +3312,7 @@ fprintf_unfiltered (gdb_stdlog, "\n"); } - regcache_cooked_write_signed (regcache, SP_REGNUM, sp); + regcache_cooked_write_signed (regcache, MIPS_SP_REGNUM, sp); /* Return adjusted stack pointer. */ return sp; @@ -3727,7 +3727,7 @@ fprintf_unfiltered (gdb_stdlog, "\n"); } - regcache_cooked_write_signed (regcache, SP_REGNUM, sp); + regcache_cooked_write_signed (regcache, MIPS_SP_REGNUM, sp); /* Return adjusted stack pointer. */ return sp; @@ -4181,7 +4181,7 @@ fprintf_unfiltered (gdb_stdlog, "\n"); } - regcache_cooked_write_signed (regcache, SP_REGNUM, sp); + regcache_cooked_write_signed (regcache, MIPS_SP_REGNUM, sp); /* Return adjusted stack pointer. */ return sp; @@ -5612,7 +5612,8 @@ } /* FIXME: cagney/2003-11-15: For MIPS, hasn't PC_REGNUM been replaced by read_pc? */ - set_gdbarch_pc_regnum (gdbarch, regnum->pc); + set_gdbarch_pc_regnum (gdbarch, regnum->pc + num_regs); + set_gdbarch_sp_regnum (gdbarch, MIPS_SP_REGNUM + num_regs); set_gdbarch_fp0_regnum (gdbarch, regnum->fp0); set_gdbarch_num_regs (gdbarch, num_regs); set_gdbarch_num_pseudo_regs (gdbarch, num_regs); Index: mips-tdep.h =================================================================== RCS file: /cvs/src/src/gdb/mips-tdep.h,v retrieving revision 1.7 diff -u -r1.7 mips-tdep.h --- mips-tdep.h 29 Apr 2004 18:28:43 -0000 1.7 +++ mips-tdep.h 18 Jun 2004 23:54:34 -0000 @@ -62,6 +62,7 @@ extern const struct mips_regnum *mips_regnum (struct gdbarch *gdbarch); enum { + MIPS_SP_REGNUM = 29, MIPS_EMBED_LO_REGNUM = 33, MIPS_EMBED_HI_REGNUM = 34, MIPS_EMBED_BADVADDR_REGNUM = 35, Index: config/mips/tm-mips.h =================================================================== RCS file: /cvs/src/src/gdb/config/mips/tm-mips.h,v retrieving revision 1.59 diff -u -r1.59 tm-mips.h --- config/mips/tm-mips.h 1 May 2004 00:34:55 -0000 1.59 +++ config/mips/tm-mips.h 18 Jun 2004 23:54:34 -0000 @@ -56,7 +56,6 @@ #define V0_REGNUM 2 /* Function integer return value */ #define A0_REGNUM 4 /* Loc of first arg during a subr call */ #define T9_REGNUM 25 /* Contains address of callee in PIC */ -#define SP_REGNUM 29 /* Contains address of top of stack */ #define RA_REGNUM 31 /* Contains return address value */ #define PS_REGNUM 32 /* Contains processor status */ #define UNUSED_REGNUM 73 /* Never used, FIXME */ --=-BF40+UYPc7zXPki35lDq--