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


I have committed the following cleanup as obvious. I hope it can be
considered so. If not, I'll be happy to change it.


This patch cleans up the many uses of gdbarch_tdep(). No functionality
changes.

Elena

2002-01-23  Elena Zannoni  <ezannoni@redhat.com>

	* ppc-linux-nat.c (ppc_register_u_addr, supply_gregset,
	fill_gregset): Call gdbarch_tdep() just once, assign result to
	variable and use that, instead of calling the function several
	times.

Index: ppc-linux-nat.c
===================================================================
RCS file: /cvs/uberbaum/gdb/ppc-linux-nat.c,v
retrieving revision 1.13
diff -u -p -r1.13 ppc-linux-nat.c
--- ppc-linux-nat.c	2001/12/20 23:31:26	1.13
+++ ppc-linux-nat.c	2002/01/24 02:47:24
@@ -73,10 +73,10 @@ static int
 ppc_register_u_addr (int regno)
 {
   int u_addr = -1;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
 
   /* General purpose registers occupy 1 slot each in the buffer */
-  if (regno >= gdbarch_tdep (current_gdbarch)->ppc_gp0_regnum
-      && regno <= gdbarch_tdep (current_gdbarch)->ppc_gplast_regnum )
+  if (regno >= tdep->ppc_gp0_regnum && regno <= tdep->ppc_gplast_regnum )
     u_addr =  ((PT_R0 + regno) * 4);
 
   /* Floating point regs: 2 slots each */
@@ -86,17 +86,17 @@ ppc_register_u_addr (int regno)
   /* UISA special purpose registers: 1 slot each */
   if (regno == PC_REGNUM)
     u_addr = PT_NIP * 4;
-  if (regno == gdbarch_tdep (current_gdbarch)->ppc_lr_regnum)
+  if (regno == tdep->ppc_lr_regnum)
     u_addr = PT_LNK * 4;
-  if (regno == gdbarch_tdep (current_gdbarch)->ppc_cr_regnum)
+  if (regno == tdep->ppc_cr_regnum)
     u_addr = PT_CCR * 4;
-  if (regno == gdbarch_tdep (current_gdbarch)->ppc_xer_regnum)
+  if (regno == tdep->ppc_xer_regnum)
     u_addr = PT_XER * 4;
-  if (regno == gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum)
+  if (regno == tdep->ppc_ctr_regnum)
     u_addr = PT_CTR * 4;
-  if (regno == gdbarch_tdep (current_gdbarch)->ppc_mq_regnum)
+  if (regno == tdep->ppc_mq_regnum)
     u_addr = PT_MQ * 4;
-  if (regno == gdbarch_tdep (current_gdbarch)->ppc_ps_regnum)
+  if (regno == tdep->ppc_ps_regnum)
     u_addr = PT_MSR * 4;
 
   return u_addr;
@@ -229,23 +229,18 @@ supply_gregset (gdb_gregset_t *gregsetp)
 {
   int regi;
   register elf_greg_t *regp = (elf_greg_t *) gregsetp;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); 
 
   for (regi = 0; regi < 32; regi++)
     supply_register (regi, (char *) (regp + regi));
 
   supply_register (PC_REGNUM, (char *) (regp + PT_NIP));
-  supply_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum,
-		   (char *) (regp + PT_LNK));
-  supply_register (gdbarch_tdep (current_gdbarch)->ppc_cr_regnum,
-		   (char *) (regp + PT_CCR));
-  supply_register (gdbarch_tdep (current_gdbarch)->ppc_xer_regnum,
-		   (char *) (regp + PT_XER));
-  supply_register (gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum,
-		   (char *) (regp + PT_CTR));
-  supply_register (gdbarch_tdep (current_gdbarch)->ppc_mq_regnum,
-		   (char *) (regp + PT_MQ));
-  supply_register (gdbarch_tdep (current_gdbarch)->ppc_ps_regnum,
-		   (char *) (regp + PT_MSR));
+  supply_register (tdep->ppc_lr_regnum, (char *) (regp + PT_LNK));
+  supply_register (tdep->ppc_cr_regnum, (char *) (regp + PT_CCR));
+  supply_register (tdep->ppc_xer_regnum, (char *) (regp + PT_XER));
+  supply_register (tdep->ppc_ctr_regnum, (char *) (regp + PT_CTR));
+  supply_register (tdep->ppc_mq_regnum, (char *) (regp + PT_MQ));
+  supply_register (tdep->ppc_ps_regnum, (char *) (regp + PT_MSR));
 }
 
 void
@@ -253,6 +248,7 @@ fill_gregset (gdb_gregset_t *gregsetp, i
 {
   int regi;
   elf_greg_t *regp = (elf_greg_t *) gregsetp;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); 
 
   for (regi = 0; regi < 32; regi++)
     {
@@ -263,29 +259,23 @@ fill_gregset (gdb_gregset_t *gregsetp, i
   if ((regno == -1) || regno == PC_REGNUM)
     regcache_collect (PC_REGNUM, regp + PT_NIP);
   if ((regno == -1) 
-      || regno == gdbarch_tdep (current_gdbarch)->ppc_lr_regnum)
-    regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum,
-		      regp + PT_LNK);
+      || regno == tdep->ppc_lr_regnum)
+    regcache_collect (tdep->ppc_lr_regnum, regp + PT_LNK);
   if ((regno == -1)
-      || regno == gdbarch_tdep (current_gdbarch)->ppc_cr_regnum)
-    regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_cr_regnum,
-		      regp + PT_CCR);
+      || regno == tdep->ppc_cr_regnum)
+    regcache_collect (tdep->ppc_cr_regnum, regp + PT_CCR);
   if ((regno == -1)
-      || regno == gdbarch_tdep (current_gdbarch)->ppc_xer_regnum)
-    regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_xer_regnum,
-		      regp + PT_XER);
+      || regno == tdep->ppc_xer_regnum)
+    regcache_collect (tdep->ppc_xer_regnum, regp + PT_XER);
   if ((regno == -1)
-      || regno == gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum)
-    regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum,
-		      regp + PT_CTR);
+      || regno == tdep->ppc_ctr_regnum)
+    regcache_collect (tdep->ppc_ctr_regnum, regp + PT_CTR);
   if ((regno == -1)
-      || regno == gdbarch_tdep (current_gdbarch)->ppc_mq_regnum)
-    regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_mq_regnum,
-		      regp + PT_MQ);
+      || regno == tdep->ppc_mq_regnum)
+    regcache_collect (tdep->ppc_mq_regnum, regp + PT_MQ);
   if ((regno == -1)
-      || regno == gdbarch_tdep (current_gdbarch)->ppc_ps_regnum)
-    regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_ps_regnum,
-		      regp + PT_MSR);
+      || regno == tdep->ppc_ps_regnum)
+    regcache_collect (tdep->ppc_ps_regnum, regp + PT_MSR);
 }
 
 void


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

* Re: [PATCH] ppc-linux-nat.c: gdbarch_tdep cleanup
  2002-01-23 18:58 [PATCH] ppc-linux-nat.c: gdbarch_tdep cleanup Elena Zannoni
@ 2002-01-23 19:31 ` Kevin Buettner
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Buettner @ 2002-01-23 19:31 UTC (permalink / raw)
  To: Elena Zannoni, gdb-patches

On Jan 23,  9:11pm, Elena Zannoni wrote:

> I have committed the following cleanup as obvious. I hope it can be
> considered so. If not, I'll be happy to change it.

It's fine.

Kevin


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

end of thread, other threads:[~2002-01-24  3:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-23 18:58 [PATCH] ppc-linux-nat.c: gdbarch_tdep cleanup Elena Zannoni
2002-01-23 19:31 ` Kevin Buettner

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