gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdb / tilegx-linux-nat.c
index 23acba5c62c9d2e8f425dd508285469eaa72716f..219693b966fd37d9b6c7254555c534d2151614ea 100644 (file)
@@ -1,6 +1,6 @@
 /* Native-dependent code for GNU/Linux TILE-Gx.
 
-   Copyright (C) 2012 Free Software Foundation, Inc.
+   Copyright (C) 2012-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "gdbcore.h"
 #include "regcache.h"
 #include "linux-nat.h"
+#include "inf-ptrace.h"
 
-#include <sys/ptrace.h>
-
-#include "gdb_assert.h"
-#include "gdb_string.h"
+#include "nat/gdb_ptrace.h"
 
 #include <sys/procfs.h>
 
+/* Defines ps_err_e, struct ps_prochandle.  */
 #include "gdb_proc_service.h"
-#include <sys/ptrace.h>
 
 /* Prototypes for supply_gregset etc.  */
 #include "gregset.h"
 
-/* Defines ps_err_e, struct ps_prochandle.  */
-#include "gdb_proc_service.h"
+class tilegx_linux_nat_target final : public linux_nat_target
+{
+public:
+  /* Add our register access methods.  */
+  void fetch_registers (struct regcache *, int) override;
+  void store_registers (struct regcache *, int) override;
+};
+
+static tilegx_linux_nat_target the_tilegx_linux_nat_target;
 
 /* The register sets used in GNU/Linux ELF core-dumps are identical to
    the register sets in `struct user' that is used for a.out
@@ -65,7 +70,7 @@ static const int regmap[] =
   40, 41, 42, 43, 44, 45, 46, 47,
   48, 49, 50, 51, 52, 53, 54, 55,
   -1, -1, -1, -1, -1, -1, -1, -1,
-  56
+  56, 58
 };
 
 /* Transfering the general-purpose registers between GDB, inferiors
@@ -83,7 +88,7 @@ supply_gregset (struct regcache* regcache,
 
   for (i = 0; i < sizeof (regmap) / sizeof (regmap[0]); i++)
     if (regmap[i] >= 0)
-      regcache_raw_supply (regcache, i, regp + regmap[i]);
+      regcache->raw_supply (i, regp + regmap[i]);
 }
 
 /* Fill registers in *GREGSETPS with the values in GDB's
@@ -98,7 +103,7 @@ fill_gregset (const struct regcache* regcache,
 
   for (i = 0; i < sizeof (regmap) / sizeof (regmap[0]); i++)
     if (regmap[i] >= 0)
-      regcache_raw_collect (regcache, i, regp + regmap[i]);
+      regcache->raw_collect (i, regp + regmap[i]);
 }
 
 /* Transfering floating-point registers between GDB, inferiors and cores.  */
@@ -127,16 +132,12 @@ fill_fpregset (const struct regcache *regcache,
 /* Fetch register REGNUM from the inferior.  If REGNUM is -1, do this
    for all registers.  */
 
-static void
-fetch_inferior_registers (struct target_ops *ops,
-                         struct regcache *regcache, int regnum)
+void
+tilegx_linux_nat_target::fetch_registers (struct regcache *regcache,
+                                         int regnum)
 {
   elf_gregset_t regs;
-  int tid;
-
-  tid = ptid_get_lwp (inferior_ptid);
-  if (tid == 0)
-    tid = ptid_get_pid (inferior_ptid);
+  pid_t tid = get_ptrace_pid (regcache->ptid ());
 
   if (ptrace (PTRACE_GETREGS, tid, 0, (PTRACE_TYPE_ARG3) &regs) < 0)
     perror_with_name (_("Couldn't get registers"));
@@ -147,16 +148,12 @@ fetch_inferior_registers (struct target_ops *ops,
 /* Store register REGNUM back into the inferior.  If REGNUM is -1, do
    this for all registers.  */
 
-static void
-store_inferior_registers (struct target_ops *ops,
-                         struct regcache *regcache, int regnum)
+void
+tilegx_linux_nat_target::store_registers (struct regcache *regcache,
+                                         int regnum)
 {
   elf_gregset_t regs;
-  int tid;
-
-  tid = ptid_get_lwp (inferior_ptid);
-  if (tid == 0)
-    tid = ptid_get_pid (inferior_ptid);
+  pid_t tid = get_ptrace_pid (regcache->ptid ());
 
   if (ptrace (PTRACE_GETREGS, tid, 0, (PTRACE_TYPE_ARG3) &regs) < 0)
     perror_with_name (_("Couldn't get registers"));
@@ -167,21 +164,10 @@ store_inferior_registers (struct target_ops *ops,
     perror_with_name (_("Couldn't write registers"));
 }
 
-
-extern initialize_file_ftype _initialize_tile_linux_nat;
-
+void _initialize_tile_linux_nat ();
 void
-_initialize_tile_linux_nat (void)
+_initialize_tile_linux_nat ()
 {
-  struct target_ops *t;
-
-  /* Fill in the generic GNU/Linux methods.  */
-  t = linux_target ();
-
-  /* Add our register access methods.  */
-  t->to_fetch_registers = fetch_inferior_registers;
-  t->to_store_registers = store_inferior_registers;
-
-  /* Register the target.  */
-  linux_nat_add_target (t);
+  linux_target = &the_tilegx_linux_nat_target;
+  add_inf_child_target (&the_tilegx_linux_nat_target);
 }
This page took 0.028253 seconds and 4 git commands to generate.