Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH/RFA] ppc-linux-nat.c cleanup
@ 2002-02-17 19:47 Elena Zannoni
  2002-02-17 20:08 ` Kevin Buettner
  0 siblings, 1 reply; 2+ messages in thread
From: Elena Zannoni @ 2002-02-17 19:47 UTC (permalink / raw)
  To: gdb-patches


This is a mini cleanup, in preparation for the new version of the
altivec register support.

OK to check in?

Elena

2002-02-17  Elena Zannoni  <ezannoni@redhat.com>

	* ppc-linux-nat.c: Update copyright.
	(fetch_register, store_register): Add tid parameter, don't compute
	tid here.
	(fetch_ppc_registers, store_ppc_registers): Add tid
	parameter. Pass it along to callees.
	(fetch_inferior_registers, store_inferior_registers): Compute tid
	here, and pass it to calleed functions.
	(fill_gregset, supply_fpregset): Clean up formatting.

Index: ppc-linux-nat.c
===================================================================
RCS file: /cvs/uberbaum/gdb/ppc-linux-nat.c,v
retrieving revision 1.14
diff -u -p -r1.14 ppc-linux-nat.c
--- ppc-linux-nat.c	2002/01/24 02:58:24	1.14
+++ ppc-linux-nat.c	2002/02/18 03:42:29
@@ -1,5 +1,5 @@
 /* PPC linux native support.
-   Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001
+   Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -16,7 +16,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
 #include "frame.h"
@@ -109,14 +110,13 @@ ppc_ptrace_cannot_fetch_store_register (
 }
 
 static void
-fetch_register (int regno)
+fetch_register (int tid, int regno)
 {
   /* This isn't really an address.  But ptrace thinks of it as one.  */
   char mess[128];              /* For messages */
   register int i;
   unsigned int offset;         /* Offset of registers within the u area. */
   char *buf = alloca (MAX_REGISTER_RAW_SIZE);
-  int tid;
   CORE_ADDR regaddr = ppc_register_u_addr (regno);
 
   if (regaddr == -1)
@@ -126,10 +126,6 @@ fetch_register (int regno)
       return;
     }
 
-  /* Overload thread id onto process id */
-  if ((tid = TIDGET (inferior_ptid)) == 0)
-    tid = PIDGET (inferior_ptid);      /* no thread id, just use process id */
-
   for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE))
     {
       errno = 0;
@@ -147,13 +143,13 @@ fetch_register (int regno)
 }
 
 static void 
-fetch_ppc_registers (void)
+fetch_ppc_registers (int tid)
 {
   int i;
   int last_register = gdbarch_tdep (current_gdbarch)->ppc_mq_regnum;
   
   for (i = 0; i <= last_register; i++)
-    fetch_register (i);
+    fetch_register (tid, i);
 }
 
 /* Fetch registers from the child process.  Fetch all registers if
@@ -162,22 +158,28 @@ fetch_ppc_registers (void)
 void
 fetch_inferior_registers (int regno)
 {
-  if (regno == -1)
-    fetch_ppc_registers ();
+ /* Overload thread id onto process id */
+  int tid = TIDGET (inferior_ptid);
+
+  /* No thread id, just use process id */
+  if (tid == 0)
+    tid = PIDGET (inferior_ptid);
+
+   if (regno == -1)
+    fetch_ppc_registers (tid);
   else 
-    fetch_register (regno);
+    fetch_register (tid, regno);
 }
 
 /* Store one register. */
 static void
-store_register (int regno)
+store_register (int tid, int regno)
 {
   /* This isn't really an address.  But ptrace thinks of it as one.  */
   CORE_ADDR regaddr = ppc_register_u_addr (regno);
   char mess[128];              /* For messages */
   register int i;
   unsigned int offset;         /* Offset of registers within the u area.  */
-  int tid;
   char *buf = alloca (MAX_REGISTER_RAW_SIZE);
 
   if (regaddr == -1)
@@ -185,10 +187,6 @@ store_register (int regno)
       return;
     }
 
-  /* Overload thread id onto process id */
-  if ((tid = TIDGET (inferior_ptid)) == 0)
-    tid = PIDGET (inferior_ptid);      /* no thread id, just use process id */
-
   regcache_collect (regno, buf);
   for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE))
     {
@@ -206,22 +204,29 @@ store_register (int regno)
 }
 
 static void
-store_ppc_registers (void)
+store_ppc_registers (int tid)
 {
   int i;
   int last_register = gdbarch_tdep (current_gdbarch)->ppc_mq_regnum;
   
   for (i = 0; i <= last_register; i++)
-    store_register (i);
+    store_register (tid, i);
 }
 
 void
 store_inferior_registers (int regno)
 {
+  /* Overload thread id onto process id */
+  int tid = TIDGET (inferior_ptid);
+
+  /* No thread id, just use process id */
+  if (tid == 0)
+    tid = PIDGET (inferior_ptid);
+
   if (regno >= 0)
-    store_register (regno);
+    store_register (tid, regno);
   else
-    store_ppc_registers ();
+    store_ppc_registers (tid);
 }
 
 void
@@ -258,23 +263,17 @@ fill_gregset (gdb_gregset_t *gregsetp, i
 
   if ((regno == -1) || regno == PC_REGNUM)
     regcache_collect (PC_REGNUM, regp + PT_NIP);
-  if ((regno == -1) 
-      || regno == tdep->ppc_lr_regnum)
+  if ((regno == -1) || regno == tdep->ppc_lr_regnum)
     regcache_collect (tdep->ppc_lr_regnum, regp + PT_LNK);
-  if ((regno == -1)
-      || regno == tdep->ppc_cr_regnum)
+  if ((regno == -1) || regno == tdep->ppc_cr_regnum)
     regcache_collect (tdep->ppc_cr_regnum, regp + PT_CCR);
-  if ((regno == -1)
-      || regno == tdep->ppc_xer_regnum)
+  if ((regno == -1) || regno == tdep->ppc_xer_regnum)
     regcache_collect (tdep->ppc_xer_regnum, regp + PT_XER);
-  if ((regno == -1)
-      || regno == tdep->ppc_ctr_regnum)
+  if ((regno == -1) || regno == tdep->ppc_ctr_regnum)
     regcache_collect (tdep->ppc_ctr_regnum, regp + PT_CTR);
-  if ((regno == -1)
-      || regno == tdep->ppc_mq_regnum)
+  if ((regno == -1) || regno == tdep->ppc_mq_regnum)
     regcache_collect (tdep->ppc_mq_regnum, regp + PT_MQ);
-  if ((regno == -1)
-      || regno == tdep->ppc_ps_regnum)
+  if ((regno == -1) || regno == tdep->ppc_ps_regnum)
     regcache_collect (tdep->ppc_ps_regnum, regp + PT_MSR);
 }
 
@@ -283,9 +282,7 @@ supply_fpregset (gdb_fpregset_t * fpregs
 {
   int regi;
   for (regi = 0; regi < 32; regi++)
-    {
-      supply_register (FP0_REGNUM + regi, (char *) (*fpregsetp + regi));
-    }
+    supply_register (FP0_REGNUM + regi, (char *) (*fpregsetp + regi));
 }
 
 /*  Given a pointer to a floating point register set in /proc format


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH/RFA] ppc-linux-nat.c cleanup
  2002-02-17 19:47 [PATCH/RFA] ppc-linux-nat.c cleanup Elena Zannoni
@ 2002-02-17 20:08 ` Kevin Buettner
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Buettner @ 2002-02-17 20:08 UTC (permalink / raw)
  To: Elena Zannoni, gdb-patches

On Feb 17, 10:46pm, Elena Zannoni wrote:

> 2002-02-17  Elena Zannoni  <ezannoni@redhat.com>
> 
> 	* ppc-linux-nat.c: Update copyright.
> 	(fetch_register, store_register): Add tid parameter, don't compute
> 	tid here.
> 	(fetch_ppc_registers, store_ppc_registers): Add tid
> 	parameter. Pass it along to callees.
> 	(fetch_inferior_registers, store_inferior_registers): Compute tid
> 	here, and pass it to calleed functions.
> 	(fill_gregset, supply_fpregset): Clean up formatting.
>
> This is a mini cleanup, in preparation for the new version of the
> altivec register support.
> 
> OK to check in?

Looks good.  Commit away...

(BTW, with regard to the tid stuff, I'm convinced it's necessary at all
due to the way that we currently do thread support.  However, there's
no harm in reorganizing it the way you did...)

Kevin


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-02-18  4:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-17 19:47 [PATCH/RFA] ppc-linux-nat.c cleanup Elena Zannoni
2002-02-17 20:08 ` Kevin Buettner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox