From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/4] Use mips_regnum instead of constants for FreeBSD/mips register operations.
Date: Wed, 12 Apr 2017 18:37:00 -0000 [thread overview]
Message-ID: <20170412183727.22483-3-jhb@FreeBSD.org> (raw)
In-Reply-To: <20170412183727.22483-1-jhb@FreeBSD.org>
gdb/ChangeLog:
* mips-fbsd-tdep.c (MIPS_PC_REGNUM): Remove.
(MIPS_FP0_REGNUM): Remove.
(MIPS_FSR_REGNUM): Remove.
(mips_fbsd_supply_fpregs): Use mips_regnum.
(mips_fbsd_supply_gregs): Likewise.
(mips_fbsd_collect_fpregs): Likewise.
(mips_fbsd_collect_gregs): Likewise.
---
gdb/ChangeLog | 10 ++++++++++
gdb/mips-fbsd-tdep.c | 29 ++++++++++++++++-------------
2 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 69c3efa317..73d24d2c9d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,15 @@
2017-04-11 John Baldwin <jhb@FreeBSD.org>
+ * mips-fbsd-tdep.c (MIPS_PC_REGNUM): Remove.
+ (MIPS_FP0_REGNUM): Remove.
+ (MIPS_FSR_REGNUM): Remove.
+ (mips_fbsd_supply_fpregs): Use mips_regnum.
+ (mips_fbsd_supply_gregs): Likewise.
+ (mips_fbsd_collect_fpregs): Likewise.
+ (mips_fbsd_collect_gregs): Likewise.
+
+2017-04-11 John Baldwin <jhb@FreeBSD.org>
+
* mips-fbsd-nat.c (getregs_supplies): Fix upper bound comparison.
(getpfpregs_supplies): New function.
(mips_fbsd_fetch_inferior_registers): Remove early exit and use
diff --git a/gdb/mips-fbsd-tdep.c b/gdb/mips-fbsd-tdep.c
index 00fae0ec60..d5bec3c157 100644
--- a/gdb/mips-fbsd-tdep.c
+++ b/gdb/mips-fbsd-tdep.c
@@ -29,11 +29,6 @@
#include "solib-svr4.h"
-/* Shorthand for some register numbers used below. */
-#define MIPS_PC_REGNUM MIPS_EMBED_PC_REGNUM
-#define MIPS_FP0_REGNUM MIPS_EMBED_FP0_REGNUM
-#define MIPS_FSR_REGNUM MIPS_EMBED_FP0_REGNUM + 32
-
/* Core file support. */
/* Number of registers in `struct reg' from <machine/reg.h>. The
@@ -108,13 +103,16 @@ void
mips_fbsd_supply_fpregs (struct regcache *regcache, int regnum,
const void *fpregs, size_t regsize)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
const gdb_byte *regs = (const gdb_byte *) fpregs;
- int i;
+ int i, fp0num, fsrnum;
- for (i = MIPS_FP0_REGNUM; i <= MIPS_FSR_REGNUM; i++)
+ fp0num = mips_regnum (gdbarch)->fp0;
+ fsrnum = mips_regnum (gdbarch)->fp_control_status;
+ for (i = fp0num; i <= fsrnum; i++)
if (regnum == i || regnum == -1)
mips_fbsd_supply_reg (regcache, i,
- regs + (i - MIPS_FP0_REGNUM) * regsize, regsize);
+ regs + (i - fp0num) * regsize, regsize);
}
/* Supply the general-purpose registers stored in GREGS to REGCACHE.
@@ -125,10 +123,11 @@ void
mips_fbsd_supply_gregs (struct regcache *regcache, int regnum,
const void *gregs, size_t regsize)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
const gdb_byte *regs = (const gdb_byte *) gregs;
int i;
- for (i = 0; i <= MIPS_PC_REGNUM; i++)
+ for (i = 0; i <= mips_regnum (gdbarch)->pc; i++)
if (regnum == i || regnum == -1)
mips_fbsd_supply_reg (regcache, i, regs + i * regsize, regsize);
}
@@ -141,13 +140,16 @@ void
mips_fbsd_collect_fpregs (const struct regcache *regcache, int regnum,
void *fpregs, size_t regsize)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
gdb_byte *regs = (gdb_byte *) fpregs;
- int i;
+ int i, fp0num, fsrnum;
- for (i = MIPS_FP0_REGNUM; i <= MIPS_FSR_REGNUM; i++)
+ fp0num = mips_regnum (gdbarch)->fp0;
+ fsrnum = mips_regnum (gdbarch)->fp_control_status;
+ for (i = fp0num; i <= fsrnum; i++)
if (regnum == i || regnum == -1)
mips_fbsd_collect_reg (regcache, i,
- regs + (i - MIPS_FP0_REGNUM) * regsize, regsize);
+ regs + (i - fp0num) * regsize, regsize);
}
/* Collect the general-purpose registers from REGCACHE and store them
@@ -158,10 +160,11 @@ void
mips_fbsd_collect_gregs (const struct regcache *regcache, int regnum,
void *gregs, size_t regsize)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
gdb_byte *regs = (gdb_byte *) gregs;
int i;
- for (i = 0; i <= MIPS_PC_REGNUM; i++)
+ for (i = 0; i <= mips_regnum (gdbarch)->pc; i++)
if (regnum == i || regnum == -1)
mips_fbsd_collect_reg (regcache, i, regs + i * regsize, regsize);
}
--
2.11.0
next prev parent reply other threads:[~2017-04-12 18:37 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-12 18:37 [PATCH 0/4] Cleanups for MIPS registers (mostly FreeBSD-specific) John Baldwin
2017-04-12 18:37 ` [PATCH 3/4] Consistently use fprintf_filtered when displaying MIPS registers John Baldwin
2017-04-13 16:29 ` Luis Machado
2017-04-27 16:05 ` Pedro Alves
2017-04-28 16:52 ` John Baldwin
2017-04-12 18:37 ` [PATCH 1/4] Cleanups to FreeBSD/mips native register operations John Baldwin
2017-04-13 15:48 ` Luis Machado
2017-04-14 18:02 ` John Baldwin
2017-04-12 18:37 ` John Baldwin [this message]
2017-04-13 16:31 ` [PATCH 2/4] Use mips_regnum instead of constants for FreeBSD/mips " Luis Machado
2017-04-12 18:45 ` [PATCH 4/4] Don't throw an error in 'info registers' for unavailable MIPS GP registers John Baldwin
2017-04-13 16:37 ` Luis Machado
2017-04-14 18:02 ` John Baldwin
2017-04-15 16:02 ` Maciej W. Rozycki
2017-04-15 17:36 ` John Baldwin
2017-04-15 22:07 ` Maciej W. Rozycki
2017-04-17 18:27 ` John Baldwin
2017-04-18 21:33 ` Maciej W. Rozycki
2017-04-18 22:19 ` John Baldwin
2017-04-25 21:02 ` John Baldwin
2017-04-27 0:49 ` Maciej W. Rozycki
2017-04-27 15:50 ` Pedro Alves
2017-04-27 19:38 ` Maciej W. Rozycki
2017-04-28 13:51 ` Pedro Alves
2017-04-28 16:52 ` John Baldwin
2017-05-05 19:51 ` John Baldwin
2017-05-05 20:08 ` Maciej W. Rozycki
2017-06-12 18:47 ` John Baldwin
2017-06-15 23:50 ` Maciej W. Rozycki
2017-06-16 16:17 ` John Baldwin
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=20170412183727.22483-3-jhb@FreeBSD.org \
--to=jhb@freebsd.org \
--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