[27/40] target_ops/C++: SPARC GNU/Linux
Commit Message
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(-)
@@ -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);
}
@@ -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;
@@ -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 */
@@ -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);