aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog12
-rw-r--r--gdb/Makefile.in8
-rw-r--r--gdb/common/common-regcache.c36
-rw-r--r--gdb/common/common-regcache.h24
-rw-r--r--gdb/gdbserver/ChangeLog11
-rw-r--r--gdb/gdbserver/Makefile.in7
-rw-r--r--gdb/gdbserver/regcache.c26
-rw-r--r--gdb/gdbserver/regcache.h7
-rw-r--r--gdb/regcache.c15
-rw-r--r--gdb/regcache.h24
10 files changed, 119 insertions, 51 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a590a0d..8f078c2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,17 @@
2015-12-18 Antoine Tremblay <antoine.tremblay@ericsson.com>
+ * Makefile.in (SFILES): Append common/common-regcache.c.
+ (COMMON_OBS): Append common/common-regcache.o.
+ (common-regcache.o): New rule.
+ * common/common-regcache.h (register_status) New enum.
+ (regcache_raw_read_unsigned): New declaration.
+ * common/common-regcache.c: New file.
+ * regcache.h (enum register_status): Move to common-regcache.h.
+ (regcache_raw_read_unsigned): Likewise.
+ (regcache_raw_get_unsigned): Likewise.
+
+2015-12-18 Antoine Tremblay <antoine.tremblay@ericsson.com>
+
* arm-linux-tdep.c (arm_linux_sigreturn_next_pc_offset): New function.
(arm_linux_sigreturn_next_pc): Likewise.
(arm_linux_syscall_next_pc): Use regcache instead of frame.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 3eadbbc..014df44 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -894,7 +894,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
common/format.c common/filestuff.c btrace.c record-btrace.c ctf.c \
target/waitstatus.c common/print-utils.c common/rsp-low.c \
common/errors.c common/common-debug.c common/common-exceptions.c \
- common/btrace-common.c common/fileio.c \
+ common/btrace-common.c common/fileio.c common/common-regcache.c \
$(SUBDIR_GCC_COMPILE_SRCS)
LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
@@ -1085,6 +1085,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
format.o registry.o btrace.o record-btrace.o waitstatus.o \
print-utils.o rsp-low.o errors.o common-debug.o debug.o \
common-exceptions.o btrace-common.o fileio.o \
+ common-regcache.o \
$(SUBDIR_GCC_COMPILE_OBS)
TSOBS = inflow.o
@@ -2266,6 +2267,11 @@ btrace-common.o: ${srcdir}/common/btrace-common.c
fileio.o: ${srcdir}/common/fileio.c
$(COMPILE) $(srcdir)/common/fileio.c
$(POSTCOMPILE)
+
+common-regcache.o: ${srcdir}/common/common-regcache.c
+ $(COMPILE) $(srcdir)/common/common-regcache.c
+ $(POSTCOMPILE)
+
#
# gdb/target/ dependencies
#
diff --git a/gdb/common/common-regcache.c b/gdb/common/common-regcache.c
new file mode 100644
index 0000000..9ee1102
--- /dev/null
+++ b/gdb/common/common-regcache.c
@@ -0,0 +1,36 @@
+/* Cache and manage the values of registers for GDB, the GNU debugger.
+
+ Copyright (C) 2015 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 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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, see <http://www.gnu.org/licenses/>. */
+
+#include "common-defs.h"
+#include "common-regcache.h"
+
+/* Return the register's value or throw if it's not available. */
+
+ULONGEST
+regcache_raw_get_unsigned (struct regcache *regcache, int regnum)
+{
+ ULONGEST value;
+ enum register_status status;
+
+ status = regcache_raw_read_unsigned (regcache, regnum, &value);
+ if (status == REG_UNAVAILABLE)
+ throw_error (NOT_AVAILABLE_ERROR,
+ _("Register %d is not available"), regnum);
+ return value;
+}
diff --git a/gdb/common/common-regcache.h b/gdb/common/common-regcache.h
index c470603..97c186c 100644
--- a/gdb/common/common-regcache.h
+++ b/gdb/common/common-regcache.h
@@ -22,6 +22,24 @@
/* This header is a stopgap until we have an independent regcache. */
+enum register_status
+ {
+ /* The register value is not in the cache, and we don't know yet
+ whether it's available in the target (or traceframe). */
+ REG_UNKNOWN = 0,
+
+ /* The register value is valid and cached. */
+ REG_VALID = 1,
+
+ /* The register value is unavailable. E.g., we're inspecting a
+ traceframe, and this register wasn't collected. Note that this
+ is different a different "unavailable" from saying the register
+ does not exist in the target's architecture --- in that case,
+ the target should have given us a target description that does
+ not include the register in the first place. */
+ REG_UNAVAILABLE = -1
+ };
+
/* Return a pointer to the register cache associated with the
thread specified by PTID. This function must be provided by
the client. */
@@ -38,4 +56,10 @@ extern int regcache_register_size (const struct regcache *regcache, int n);
extern CORE_ADDR regcache_read_pc (struct regcache *regcache);
+/* Read a raw register into a unsigned integer. */
+extern enum register_status regcache_raw_read_unsigned
+ (struct regcache *regcache, int regnum, ULONGEST *val);
+
+ULONGEST regcache_raw_get_unsigned (struct regcache *regcache, int regnum);
+
#endif /* COMMON_REGCACHE_H */
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index eebc12e..eab6930 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,16 @@
2015-12-18 Antoine Tremblay <antoine.tremblay@ericsson.com>
+ * Makefile.in (SFILES): Append common/common-regcache.c.
+ (OBS): Append common-regcache.o.
+ (common-regcache.o): New rule.
+ * regcache.c (init_register_cache): Initialize cache to
+ REG_UNAVAILABLE.
+ (regcache_raw_read_unsigned): New function.
+ * regcache.h (REG_UNAVAILABLE, REG_VALID): Replaced by shared
+ register_status enum.
+
+2015-12-18 Antoine Tremblay <antoine.tremblay@ericsson.com>
+
* linux-aarch64-low.c (the_low_targets): Rename
breakpoint_reinsert_addr to get_next_pcs.
* linux-arm-low.c (the_low_targets): Likewise.
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index f18243b..82af44c 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -181,7 +181,7 @@ SFILES= $(srcdir)/gdbreplay.c $(srcdir)/inferiors.c $(srcdir)/dll.c \
$(srcdir)/common/common-exceptions.c $(srcdir)/symbol.c \
$(srcdir)/common/btrace-common.c \
$(srcdir)/common/fileio.c $(srcdir)/nat/linux-namespaces.c \
- $(srcdir)/arch/arm.c
+ $(srcdir)/arch/arm.c $(srcdir)/common/common-regcache.c
DEPFILES = @GDBSERVER_DEPFILES@
@@ -195,7 +195,7 @@ OBS = agent.o ax.o inferiors.o regcache.o remote-utils.o server.o signals.o \
mem-break.o hostio.o event-loop.o tracepoint.o xml-utils.o \
common-utils.o ptid.o buffer.o format.o filestuff.o dll.o notif.o \
tdesc.o print-utils.o rsp-low.o errors.o common-debug.o cleanups.o \
- common-exceptions.o symbol.o btrace-common.o fileio.o \
+ common-exceptions.o symbol.o btrace-common.o fileio.o common-regcache.o \
$(XML_BUILTIN) $(DEPFILES) $(LIBOBJS)
GDBREPLAY_OBS = gdbreplay.o version.o
GDBSERVER_LIBS = @GDBSERVER_LIBS@
@@ -583,6 +583,9 @@ waitstatus.o: ../target/waitstatus.c
fileio.o: ../common/fileio.c
$(COMPILE) $<
$(POSTCOMPILE)
+common-regcache.o: ../common/common-regcache.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
# Arch object files rules form ../arch
diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c
index b9311fe..c608bf3 100644
--- a/gdb/gdbserver/regcache.c
+++ b/gdb/gdbserver/regcache.c
@@ -145,8 +145,9 @@ init_register_cache (struct regcache *regcache,
= (unsigned char *) xcalloc (1, tdesc->registers_size);
regcache->registers_owned = 1;
regcache->register_status
- = (unsigned char *) xcalloc (1, tdesc->num_registers);
- gdb_assert (REG_UNAVAILABLE == 0);
+ = (unsigned char *) xmalloc (tdesc->num_registers);
+ memset ((void *) regcache->register_status, REG_UNAVAILABLE,
+ tdesc->num_registers);
#else
gdb_assert_not_reached ("can't allocate memory from the heap");
#endif
@@ -435,6 +436,27 @@ collect_register (struct regcache *regcache, int n, void *buf)
register_size (regcache->tdesc, n));
}
+enum register_status
+regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
+ ULONGEST *val)
+{
+ int size;
+
+ gdb_assert (regcache != NULL);
+ gdb_assert (regnum >= 0 && regnum < regcache->tdesc->num_registers);
+
+ size = register_size (regcache->tdesc, regnum);
+
+ if (size > (int) sizeof (ULONGEST))
+ error (_("That operation is not available on integers of more than"
+ "%d bytes."),
+ (int) sizeof (ULONGEST));
+
+ collect_register (regcache, regnum, val);
+
+ return REG_VALID;
+}
+
#ifndef IN_PROCESS_AGENT
void
diff --git a/gdb/gdbserver/regcache.h b/gdb/gdbserver/regcache.h
index a0be95e..f4b798b 100644
--- a/gdb/gdbserver/regcache.h
+++ b/gdb/gdbserver/regcache.h
@@ -24,13 +24,6 @@
struct thread_info;
struct target_desc;
-/* The register exists, it has a value, but we don't know what it is.
- Used when inspecting traceframes. */
-#define REG_UNAVAILABLE 0
-
-/* We know the register's value (and we have it cached). */
-#define REG_VALID 1
-
/* The data for the register cache. Note that we have one per
inferior; this is primarily for simplicity, as the performance
benefit is minimal. */
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 7fb9d18..5ee31fb 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -715,21 +715,6 @@ regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
return status;
}
-/* Return the register's value or throw if it's not available. */
-
-ULONGEST
-regcache_raw_get_unsigned (struct regcache *regcache, int regnum)
-{
- ULONGEST value;
- enum register_status status;
-
- status = regcache_raw_read_unsigned (regcache, regnum, &value);
- if (status == REG_UNAVAILABLE)
- throw_error (NOT_AVAILABLE_ERROR,
- _("Register %d is not available"), regnum);
- return value;
-}
-
void
regcache_raw_write_signed (struct regcache *regcache, int regnum, LONGEST val)
{
diff --git a/gdb/regcache.h b/gdb/regcache.h
index c9d9a7d..36bfef8 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -47,24 +47,6 @@ extern struct gdbarch *get_regcache_arch (const struct regcache *regcache);
extern struct address_space *get_regcache_aspace (const struct regcache *);
-enum register_status
- {
- /* The register value is not in the cache, and we don't know yet
- whether it's available in the target (or traceframe). */
- REG_UNKNOWN = 0,
-
- /* The register value is valid and cached. */
- REG_VALID = 1,
-
- /* The register value is unavailable. E.g., we're inspecting a
- traceframe, and this register wasn't collected. Note that this
- is different a different "unavailable" from saying the register
- does not exist in the target's architecture --- in that case,
- the target should have given us a target description that does
- not include the register in the first place. */
- REG_UNAVAILABLE = -1
- };
-
enum register_status regcache_register_status (const struct regcache *regcache,
int regnum);
@@ -78,12 +60,6 @@ void regcache_raw_write (struct regcache *regcache, int rawnum,
extern enum register_status
regcache_raw_read_signed (struct regcache *regcache,
int regnum, LONGEST *val);
-extern enum register_status
- regcache_raw_read_unsigned (struct regcache *regcache,
- int regnum, ULONGEST *val);
-
-ULONGEST regcache_raw_get_unsigned (struct regcache *regcache,
- int regnum);
extern void regcache_raw_write_signed (struct regcache *regcache,
int regnum, LONGEST val);