From: Elena Zannoni <ezannoni@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: [PATCH] ppc-linux-nat.c: gdbarch_tdep cleanup
Date: Wed, 23 Jan 2002 18:58:00 -0000 [thread overview]
Message-ID: <15439.27970.705362.381140@localhost.cygnus.com> (raw)
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
next reply other threads:[~2002-01-24 2:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-23 18:58 Elena Zannoni [this message]
2002-01-23 19:31 ` Kevin Buettner
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=15439.27970.705362.381140@localhost.cygnus.com \
--to=ezannoni@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/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