+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.
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
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
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
#
--- /dev/null
+/* 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;
+}
/* 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. */
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 */
+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
$(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@
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@
fileio.o: ../common/fileio.c
$(COMPILE) $<
$(POSTCOMPILE)
+common-regcache.o: ../common/common-regcache.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
# Arch object files rules form ../arch
= (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
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
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. */
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)
{
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);
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);