X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fhppa-linux-nat.c;h=aea21d1c84badcf9eff98753d6615948a4e29ab6;hb=762c164d754fc456aa4764d2ed19cc4a3ec625fb;hp=d88c142dd0a61100681cbc11f47bcc657f22d48e;hpb=959464ff2ccd5263594a24a65b073f6d11eb6784;p=deliverable%2Fbinutils-gdb.git
diff --git a/gdb/hppa-linux-nat.c b/gdb/hppa-linux-nat.c
index d88c142dd0..aea21d1c84 100644
--- a/gdb/hppa-linux-nat.c
+++ b/gdb/hppa-linux-nat.c
@@ -1,11 +1,12 @@
-/* Functions specific to running gdb native on HPPA running Linux.
- Copyright 2004 Free Software Foundation, Inc.
+/* Functions specific to running GDB native on HPPA running GNU/Linux.
+
+ Copyright (C) 2004-2019 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -14,24 +15,36 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ along with this program. If not, see . */
#include "defs.h"
#include "gdbcore.h"
#include "regcache.h"
-#include "gdb_string.h"
#include "inferior.h"
+#include "target.h"
+#include "linux-nat.h"
+#include "inf-ptrace.h"
#include
-#include
-#include
-#include
+#include "nat/gdb_ptrace.h"
+#include
+
+#include
+#include "hppa-linux-offsets.h"
#include "hppa-tdep.h"
-/* Prototypes for supply_gregset etc. */
+class hppa_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 hppa_linux_nat_target the_hppa_linux_nat_target;
+
+/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/* These must match the order of the register names.
@@ -145,13 +158,13 @@ static const int u_offsets[] =
PT_FR31, PT_FR31 + 4,
};
-CORE_ADDR
-register_addr (int regno, CORE_ADDR blockend)
+static CORE_ADDR
+hppa_linux_register_addr (int regno, CORE_ADDR blockend)
{
CORE_ADDR addr;
- if ((unsigned) regno >= NUM_REGS)
- error ("Invalid register number %d.", regno);
+ if ((unsigned) regno >= ARRAY_SIZE (u_offsets))
+ error (_("Invalid register number %d."), regno);
if (u_offsets[regno] == -1)
addr = 0;
@@ -208,52 +221,50 @@ static const int greg_map[] =
/* Fetch one register. */
static void
-fetch_register (int regno)
+fetch_register (struct regcache *regcache, int regno)
{
- int tid;
+ struct gdbarch *gdbarch = regcache->arch ();
+ pid_t tid;
int val;
- if (CANNOT_FETCH_REGISTER (regno))
+ if (gdbarch_cannot_fetch_register (gdbarch, regno))
{
- supply_register (regno, NULL);
+ regcache->raw_supply (regno, NULL);
return;
}
- /* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
- if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = get_ptrace_pid (regcache->ptid ());
errno = 0;
- val = ptrace (PTRACE_PEEKUSER, tid, register_addr (regno, 0), 0);
+ val = ptrace (PTRACE_PEEKUSER, tid, hppa_linux_register_addr (regno, 0), 0);
if (errno != 0)
- error ("Couldn't read register %s (#%d): %s.", REGISTER_NAME (regno),
+ error (_("Couldn't read register %s (#%d): %s."),
+ gdbarch_register_name (gdbarch, regno),
regno, safe_strerror (errno));
- regcache_raw_supply (current_regcache, regno, &val);
+ regcache->raw_supply (regno, &val);
}
-/* Store one register. */
+/* Store one register. */
static void
-store_register (int regno)
+store_register (const struct regcache *regcache, int regno)
{
- int tid;
+ struct gdbarch *gdbarch = regcache->arch ();
+ pid_t tid;
int val;
- if (CANNOT_STORE_REGISTER (regno))
+ if (gdbarch_cannot_store_register (gdbarch, regno))
return;
- /* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
- if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = get_ptrace_pid (regcache->ptid ());
errno = 0;
- regcache_raw_collect (current_regcache, regno, &val);
- ptrace (PTRACE_POKEUSER, tid, register_addr (regno, 0), val);
+ regcache->raw_collect (regno, &val);
+ ptrace (PTRACE_POKEUSER, tid, hppa_linux_register_addr (regno, 0), val);
if (errno != 0)
- error ("Couldn't write register %s (#%d): %s.", REGISTER_NAME (regno),
+ error (_("Couldn't write register %s (#%d): %s."),
+ gdbarch_register_name (gdbarch, regno),
regno, safe_strerror (errno));
}
@@ -262,16 +273,18 @@ store_register (int regno)
point registers depending upon the value of regno. */
void
-fetch_inferior_registers (int regno)
+hppa_linux_nat_target::fetch_registers (struct regcache *regcache, int regno)
{
if (-1 == regno)
{
- for (regno = 0; regno < NUM_REGS; regno++)
- fetch_register (regno);
+ for (regno = 0;
+ regno < gdbarch_num_regs (regcache->arch ());
+ regno++)
+ fetch_register (regcache, regno);
}
else
{
- fetch_register (regno);
+ fetch_register (regcache, regno);
}
}
@@ -280,16 +293,18 @@ fetch_inferior_registers (int regno)
point registers depending upon the value of regno. */
void
-store_inferior_registers (int regno)
+hppa_linux_nat_target::store_registers (struct regcache *regcache, int regno)
{
if (-1 == regno)
{
- for (regno = 0; regno < NUM_REGS; regno++)
- store_register (regno);
+ for (regno = 0;
+ regno < gdbarch_num_regs (regcache->arch ());
+ regno++)
+ store_register (regcache, regno);
}
else
{
- store_register (regno);
+ store_register (regcache, regno);
}
}
@@ -297,15 +312,15 @@ store_inferior_registers (int regno)
in *gregsetp. */
void
-supply_gregset (gdb_gregset_t *gregsetp)
+supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
{
int i;
- greg_t *regp = (elf_greg_t *) gregsetp;
+ const greg_t *regp = (const elf_greg_t *) gregsetp;
for (i = 0; i < sizeof (greg_map) / sizeof (greg_map[0]); i++, regp++)
{
int regno = greg_map[i];
- supply_register (regno, regp);
+ regcache->raw_supply (regno, regp);
}
}
@@ -314,7 +329,8 @@ supply_gregset (gdb_gregset_t *gregsetp)
If regno is -1, do this for all registers. */
void
-fill_gregset (gdb_gregset_t *gregsetp, int regno)
+fill_gregset (const struct regcache *regcache,
+ gdb_gregset_t *gregsetp, int regno)
{
int i;
@@ -323,37 +339,36 @@ fill_gregset (gdb_gregset_t *gregsetp, int regno)
int mregno = greg_map[i];
if (regno == -1 || regno == mregno)
- {
- regcache_collect(mregno, &(*gregsetp)[i]);
- }
+ regcache->raw_collect (mregno, &(*gregsetp)[i]);
}
}
/* Given a pointer to a floating point register set in /proc format
(fpregset_t *), unpack the register contents and supply them as gdb's
- idea of the current floating point register values. */
+ idea of the current floating point register values. */
void
-supply_fpregset (gdb_fpregset_t *fpregsetp)
+supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
{
- register int regi;
- char *from;
+ int regi;
+ const char *from;
for (regi = 0; regi <= 31; regi++)
{
- from = (char *) &((*fpregsetp)[regi]);
- supply_register (2*regi + HPPA_FP0_REGNUM, from);
- supply_register (2*regi + HPPA_FP0_REGNUM + 1, from + 4);
+ from = (const char *) &((*fpregsetp)[regi]);
+ regcache->raw_supply (2*regi + HPPA_FP0_REGNUM, from);
+ regcache->raw_supply (2*regi + HPPA_FP0_REGNUM + 1, from + 4);
}
}
/* Given a pointer to a floating point register set in /proc format
(fpregset_t *), update the register specified by REGNO from gdb's idea
of the current floating point register set. If REGNO is -1, update
- them all. */
+ them all. */
void
-fill_fpregset (gdb_fpregset_t *fpregsetp, int regno)
+fill_fpregset (const struct regcache *regcache,
+ gdb_fpregset_t *fpregsetp, int regno)
{
int i;
@@ -364,6 +379,14 @@ fill_fpregset (gdb_fpregset_t *fpregsetp, int regno)
char *to = (char *) &((*fpregsetp)[(i - HPPA_FP0_REGNUM) / 2]);
if ((i - HPPA_FP0_REGNUM) & 1)
to += 4;
- regcache_collect (i, to);
+ regcache->raw_collect (i, to);
}
}
+
+void
+_initialize_hppa_linux_nat (void)
+{
+ /* Register the target. */
+ linux_target = &the_hppa_linux_nat_target;
+ add_inf_child_target (&the_hppa_linux_nat_target);
+}