From patchwork Sat Apr 14 19:09:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 26718 Received: (qmail 125169 invoked by alias); 14 Apr 2018 19:10:18 -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 124992 invoked by uid 89); 14 Apr 2018 19:10:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.2 spammy=our X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 14 Apr 2018 19:10:15 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B4067401DEA8 for ; Sat, 14 Apr 2018 19:10:12 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 646B3215CDC8 for ; Sat, 14 Apr 2018 19:10:12 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 27/40] target_ops/C++: SPARC GNU/Linux Date: Sat, 14 Apr 2018 20:09:40 +0100 Message-Id: <20180414190953.24481-28-palves@redhat.com> In-Reply-To: <20180414190953.24481-1-palves@redhat.com> References: <20180414190953.24481-1-palves@redhat.com> Straighforward conversion. --- gdb/sparc-linux-nat.c | 24 ++++++++++++++---------- gdb/sparc-nat.c | 6 ++---- gdb/sparc-nat.h | 6 ++---- gdb/sparc64-linux-nat.c | 24 +++++++++++++++--------- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/gdb/sparc-linux-nat.c b/gdb/sparc-linux-nat.c index 3a5132c858..de7dda3d14 100644 --- a/gdb/sparc-linux-nat.c +++ b/gdb/sparc-linux-nat.c @@ -28,6 +28,19 @@ #include "target.h" #include "linux-nat.h" +class sparc_linux_nat_target final : public linux_nat_target +{ +public: + /* Add our register access methods. */ + void fetch_registers (struct regcache *regcache, int regnum) override + { sparc_fetch_inferior_registers (regcache, regnum); } + + void store_registers (struct regcache *regcache, int regnum) override; + { sparc_store_inferior_registers (regcache, regnum); } +}; + +static sparc_linux_nat_target the_sparc_linux_nat_target; + void supply_gregset (struct regcache *regcache, const prgregset_t *gregs) { @@ -56,17 +69,8 @@ fill_fpregset (const struct regcache *regcache, void _initialize_sparc_linux_nat (void) { - struct target_ops *t; - - /* Fill in the generic GNU/Linux methods. */ - t = linux_target (); - sparc_fpregmap = &sparc32_bsd_fpregmap; - /* Add our register access methods. */ - t->to_fetch_registers = sparc_fetch_inferior_registers; - t->to_store_registers = sparc_store_inferior_registers; - /* Register the target. */ - linux_nat_add_target (t); + add_target (&the_sparc_linux_nat_target); } diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c index 5dc17b3b64..9aeaf22c5d 100644 --- a/gdb/sparc-nat.c +++ b/gdb/sparc-nat.c @@ -134,8 +134,7 @@ sparc32_fpregset_supplies_p (struct gdbarch *gdbarch, int regnum) for all registers (including the floating-point registers). */ void -sparc_fetch_inferior_registers (struct target_ops *ops, - struct regcache *regcache, int regnum) +sparc_fetch_inferior_registers (struct regcache *regcache, int regnum) { struct gdbarch *gdbarch = regcache->arch (); pid_t pid; @@ -187,8 +186,7 @@ sparc_fetch_inferior_registers (struct target_ops *ops, } void -sparc_store_inferior_registers (struct target_ops *ops, - struct regcache *regcache, int regnum) +sparc_store_inferior_registers (struct regcache *regcache, int regnum) { struct gdbarch *gdbarch = regcache->arch (); pid_t pid; diff --git a/gdb/sparc-nat.h b/gdb/sparc-nat.h index 6960d3dda8..f627fd33ed 100644 --- a/gdb/sparc-nat.h +++ b/gdb/sparc-nat.h @@ -44,9 +44,7 @@ extern int sparc32_fpregset_supplies_p (struct gdbarch *gdbarch, int regnum); extern struct target_ops *sparc_target (void); -extern void sparc_fetch_inferior_registers (struct target_ops *, - struct regcache *, int); -extern void sparc_store_inferior_registers (struct target_ops *, - struct regcache *, int); +extern void sparc_fetch_inferior_registers (struct regcache *, int); +extern void sparc_store_inferior_registers (struct regcache *, int); #endif /* sparc-nat.h */ diff --git a/gdb/sparc64-linux-nat.c b/gdb/sparc64-linux-nat.c index 7f7c5de500..ea7cfb43f6 100644 --- a/gdb/sparc64-linux-nat.c +++ b/gdb/sparc64-linux-nat.c @@ -30,6 +30,19 @@ #include "target.h" #include "linux-nat.h" +class sparc64_linux_nat_target final : public linux_nat_target +{ +public: + /* Add our register access methods. */ + void fetch_registers (struct regcache *regcache, int regnum) override + { sparc_fetch_inferior_registers (this, regcache, regnum); } + + void store_registers (struct regcache *regcache, int regnum) override; + { sparc_store_inferior_registers (this, regcache, regnum); } +}; + +static sparc64_linux_nat_target the_sparc64_linux_nat_target; + static const struct sparc_gregmap sparc64_linux_ptrace_gregmap = { 16 * 8, /* "tstate" */ @@ -72,19 +85,12 @@ fill_fpregset (const struct regcache *regcache, void _initialize_sparc64_linux_nat (void) { - struct target_ops *t; - - /* Fill in the generic GNU/Linux methods. */ - t = linux_target (); + target_ops *t = &the_sparc64_linux_nat_target; sparc_fpregmap = &sparc64_bsd_fpregmap; - /* Add our register access methods. */ - t->to_fetch_registers = sparc_fetch_inferior_registers; - t->to_store_registers = sparc_store_inferior_registers; - /* Register the target. */ - linux_nat_add_target (t); + add_target (t); /* ADI support */ linux_nat_set_forget_process (t, sparc64_forget_process);