From patchwork Wed Apr 12 18:37:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 19999 Received: (qmail 100738 invoked by alias); 12 Apr 2017 18:37:44 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 100159 invoked by uid 89); 12 Apr 2017 18:37:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=cooked, 679 X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Apr 2017 18:37:42 +0000 Received: from ralph.baldwin.cx.net (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id A532210A7DB for ; Wed, 12 Apr 2017 14:37:41 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH 1/4] Cleanups to FreeBSD/mips native register operations. Date: Wed, 12 Apr 2017 11:37:24 -0700 Message-Id: <20170412183727.22483-2-jhb@FreeBSD.org> In-Reply-To: <20170412183727.22483-1-jhb@FreeBSD.org> References: <20170412183727.22483-1-jhb@FreeBSD.org> X-IsSubscribed: yes Compare against the "raw" PC register number instead of the cooked register number when determining if a register was handled by PT_GETREGS. Previously the register fetch/store operations only tried PT_GETREGS to fetch any individual register. The result was that fetching or storing an individual register not covered by PT_GETREGS (such as floating point registers) did not work. While here, remove an early exit to simplify the code flow from the PT_GETREGS / PT_SETREGS case, and add a getfpregs_supplies similar to getregs_supplies to describe the registers supplied by PT_GETFPREGS and PT_SETFPREGS. gdb/ChangeLog: * mips-fbsd-nat.c (getregs_supplies): Fix upper bound comparison. (getpfpregs_supplies): New function. (mips_fbsd_fetch_inferior_registers): Remove early exit and use getfpregs_supplies. (mips_fbsd_store_inferior_registers): Likewise. --- gdb/ChangeLog | 8 ++++++++ gdb/mips-fbsd-nat.c | 26 ++++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7fcfebbeb7..69c3efa317 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2017-04-11 John Baldwin + + * mips-fbsd-nat.c (getregs_supplies): Fix upper bound comparison. + (getpfpregs_supplies): New function. + (mips_fbsd_fetch_inferior_registers): Remove early exit and use + getfpregs_supplies. + (mips_fbsd_store_inferior_registers): Likewise. + 2017-04-04 John Baldwin * amd64-fbsd-tdep.c: Remove "bsd-uthread.h" include. diff --git a/gdb/mips-fbsd-nat.c b/gdb/mips-fbsd-nat.c index 078df52db6..e2ed63e829 100644 --- a/gdb/mips-fbsd-nat.c +++ b/gdb/mips-fbsd-nat.c @@ -37,7 +37,16 @@ static bool getregs_supplies (struct gdbarch *gdbarch, int regnum) { return (regnum >= MIPS_ZERO_REGNUM - && regnum <= gdbarch_pc_regnum (gdbarch)); + && regnum <= mips_regnum (gdbarch)->pc); +} + +/* Determine if PT_GETFPREGS fetches this register. */ + +static bool +getfpregs_supplies (struct gdbarch *gdbarch, int regnum) +{ + return (regnum >= mips_regnum (gdbarch)->fp0 + && regnum < mips_regnum (gdbarch)->fp_implementation_revision); } /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this @@ -47,9 +56,9 @@ static void mips_fbsd_fetch_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regnum) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache)); - struct gdbarch *gdbarch = get_regcache_arch (regcache); if (regnum == -1 || getregs_supplies (gdbarch, regnum)) { struct reg regs; @@ -58,12 +67,9 @@ mips_fbsd_fetch_inferior_registers (struct target_ops *ops, perror_with_name (_("Couldn't get registers")); mips_fbsd_supply_gregs (regcache, regnum, ®s, sizeof (register_t)); - if (regnum != -1) - return; } - if (regnum == -1 - || regnum >= gdbarch_fp0_regnum (get_regcache_arch (regcache))) + if (regnum == -1 || getfpregs_supplies (gdbarch, regnum)) { struct fpreg fpregs; @@ -82,9 +88,9 @@ static void mips_fbsd_store_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regnum) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache)); - struct gdbarch *gdbarch = get_regcache_arch (regcache); if (regnum == -1 || getregs_supplies (gdbarch, regnum)) { struct reg regs; @@ -97,13 +103,9 @@ mips_fbsd_store_inferior_registers (struct target_ops *ops, if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't write registers")); - - if (regnum != -1) - return; } - if (regnum == -1 - || regnum >= gdbarch_fp0_regnum (get_regcache_arch (regcache))) + if (regnum == -1 || getfpregs_supplies (gdbarch, regnum)) { struct fpreg fpregs;