Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: gdb-patches@sourceware.org
Subject: [PATCH] %g0 on sparc should always be available
Date: Sat, 21 May 2011 19:20:00 -0000	[thread overview]
Message-ID: <201105211919.p4LJJn5Z013541@glazunov.sibelius.xs4all.nl> (raw)

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.


2011-05-21  Mark Kettenis  <kettenis@gnu.org>

	* sparc-nat.c (sparc_fetch_inferior_registers): Explicitly supply
	zero as the value for %g0 in the register cache.
	* sparc-tdep.c (sparc32_supply_gregset): Likewise.
	* sparc64-tdep.c (sparc64_supply_gregset): Likewise.

Index: sparc-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-nat.c,v
retrieving revision 1.43
diff -u -p -r1.43 sparc-nat.c
--- sparc-nat.c	1 Jan 2011 15:33:15 -0000	1.43
+++ sparc-nat.c	21 May 2011 19:08:34 -0000
@@ -159,7 +159,9 @@ sparc_fetch_inferior_registers (struct t
 
   if (regnum == SPARC_G0_REGNUM)
     {
-      regcache_raw_supply (regcache, SPARC_G0_REGNUM, NULL);
+      gdb_byte zero[8] = { 0 };
+
+      regcache_raw_supply (regcache, SPARC_G0_REGNUM, &zero);
       return;
     }
 
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.219
diff -u -p -r1.219 sparc-tdep.c
--- sparc-tdep.c	18 Mar 2011 18:52:32 -0000	1.219
+++ sparc-tdep.c	21 May 2011 19:08:34 -0000
@@ -1618,6 +1618,7 @@ sparc32_supply_gregset (const struct spa
 			int regnum, const void *gregs)
 {
   const gdb_byte *regs = gregs;
+  gdb_byte zero[4] = { 0 };
   int i;
 
   if (regnum == SPARC32_PSR_REGNUM || regnum == -1)
@@ -1637,7 +1638,7 @@ sparc32_supply_gregset (const struct spa
 			 regs + gregset->r_y_offset);
 
   if (regnum == SPARC_G0_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, SPARC_G0_REGNUM, NULL);
+    regcache_raw_supply (regcache, SPARC_G0_REGNUM, &zero);
 
   if ((regnum >= SPARC_G1_REGNUM && regnum <= SPARC_O7_REGNUM) || regnum == -1)
     {
Index: sparc64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc64-tdep.c,v
retrieving revision 1.53
diff -u -p -r1.53 sparc64-tdep.c
--- sparc64-tdep.c	18 Mar 2011 18:52:32 -0000	1.53
+++ sparc64-tdep.c	21 May 2011 19:08:35 -0000
@@ -1206,6 +1206,7 @@ sparc64_supply_gregset (const struct spa
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int sparc32 = (gdbarch_ptr_bit (gdbarch) == 32);
   const gdb_byte *regs = gregs;
+  gdb_byte zero[8] = { 0 };
   int i;
 
   if (sparc32)
@@ -1268,7 +1269,7 @@ sparc64_supply_gregset (const struct spa
     }
 
   if (regnum == SPARC_G0_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, SPARC_G0_REGNUM, NULL);
+    regcache_raw_supply (regcache, SPARC_G0_REGNUM, &zero);
 
   if ((regnum >= SPARC_G1_REGNUM && regnum <= SPARC_O7_REGNUM) || regnum == -1)
     {


             reply	other threads:[~2011-05-21 19:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-21 19:20 Mark Kettenis [this message]
2011-05-22 11:17 ` Pedro Alves
2011-05-23 17:36   ` $zero on alpha " Pedro Alves
2011-05-24  4:44     ` Joel Brobecker
2011-05-24 11:16       ` Pedro Alves
2011-05-25 20:51         ` Joel Brobecker
2011-05-26 14:16           ` Pedro Alves

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=201105211919.p4LJJn5Z013541@glazunov.sibelius.xs4all.nl \
    --to=mark.kettenis@xs4all.nl \
    --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