From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5467 invoked by alias); 23 May 2011 17:36:14 -0000 Received: (qmail 5326 invoked by uid 22791); 23 May 2011 17:36:13 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,TW_EG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 May 2011 17:35:59 +0000 Received: (qmail 20337 invoked from network); 23 May 2011 17:35:58 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 23 May 2011 17:35:58 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: $zero on alpha should always be available Date: Mon, 23 May 2011 17:36:00 -0000 User-Agent: KMail/1.13.5 (Linux/2.6.35-28-generic; KDE/4.6.2; x86_64; ; ) Cc: Mark Kettenis References: <201105211919.p4LJJn5Z013541@glazunov.sibelius.xs4all.nl> <201105221217.12418.pedro@codesourcery.com> In-Reply-To: <201105221217.12418.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201105231835.54370.pedro@codesourcery.com> 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: 2011-05/txt/msg00538.txt.bz2 On Sunday 22 May 2011 12:17:12, Pedro Alves wrote: > On Saturday 21 May 2011 20:19:49, Mark Kettenis wrote: > > Many RISC CPUs have a register that's hardwired to 0. Typically GDB > > code uses regcache_raw_supply(..., ..., NULL) to "transfer" the value > > of such a register. However these days, that marks the register as > > unavailable. This diff fixes that for %g0 on SPARC. > > > > Committed as obvious. > > Thanks! The stuff is going into 7.3 as well. Want > to put the patch there too? > > (I see alpha-tdep.c needs the same treatment for ALPHA_ZERO_REGNUM.) Here's what I came up with by inspection. I have no alpha machine to test this on. The alpha-nat.c change would need checking on an alpha running OSF if we wanted to test this... Pedro Alves 2011-05-23 Pedro Alves gdb/ * alpha-tdep.c (alpha_cannot_fetch_register): Don't return true for ALPHA_ZERO_REGNUM. (alpha_supply_int_regs): Explicitly supply zero as the value for ALPHA_ZERO_REGNUM in the register cache. * alpha-nat.c (fetch_osf_core_registers): Ditto. --- gdb/alpha-nat.c | 9 +++++++++ gdb/alpha-tdep.c | 9 ++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) Index: src/gdb/alpha-tdep.c =================================================================== --- src.orig/gdb/alpha-tdep.c 2011-04-20 16:22:32.000000000 +0100 +++ src/gdb/alpha-tdep.c 2011-05-23 18:24:29.448753681 +0100 @@ -111,8 +111,7 @@ alpha_register_name (struct gdbarch *gdb static int alpha_cannot_fetch_register (struct gdbarch *gdbarch, int regno) { - return (regno == ALPHA_ZERO_REGNUM - || strlen (alpha_register_name (gdbarch, regno)) == 0); + return (strlen (alpha_register_name (gdbarch, regno)) == 0); } static int @@ -1424,7 +1423,11 @@ alpha_supply_int_regs (struct regcache * regcache_raw_supply (regcache, i, regs + i * 8); if (regno == ALPHA_ZERO_REGNUM || regno == -1) - regcache_raw_supply (regcache, ALPHA_ZERO_REGNUM, NULL); + { + const gdb_byte zero[8] = { 0 }; + + regcache_raw_supply (regcache, ALPHA_ZERO_REGNUM, zero); + } if (regno == ALPHA_PC_REGNUM || regno == -1) regcache_raw_supply (regcache, ALPHA_PC_REGNUM, pc); Index: src/gdb/alpha-nat.c =================================================================== --- src.orig/gdb/alpha-nat.c 2011-01-13 15:07:16.000000000 +0000 +++ src/gdb/alpha-nat.c 2011-05-23 18:28:14.428753680 +0100 @@ -101,6 +101,15 @@ fetch_osf_core_registers (struct regcach regcache_raw_supply (regcache, regno, NULL); continue; } + + if (regno == ALPHA_ZERO_REGNUM) + { + const gdb_byte zero[8] = { 0 }; + + regcache_raw_supply (regcache, regno, zero); + continue; + } + addr = 8 * core_reg_mapping[regno]; if (addr < 0 || addr >= core_reg_size) {