[PATCH 27/40] target_ops/C++: SPARC GNU/Linux
Pedro Alves
palves@redhat.com
Sat Apr 14 19:10:00 GMT 2018
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);
--
2.14.3
More information about the Gdb-patches
mailing list