aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
authorAntoine Tremblay <antoine.tremblay@ericsson.com>2015-12-18 11:33:59 -0500
committerAntoine Tremblay <antoine.tremblay@ericsson.com>2015-12-18 11:39:21 -0500
commit68ce205943e0821eacd8028881ced3607cc83c0d (patch)
tree8093767a4f18c019bb1fd94409b083aeb868e7e1 /gdb/gdbserver
parentd0e59a68884ad3a346ff0f6f763636c7245e4cb3 (diff)
downloadgdb-68ce205943e0821eacd8028881ced3607cc83c0d.zip
gdb-68ce205943e0821eacd8028881ced3607cc83c0d.tar.gz
gdb-68ce205943e0821eacd8028881ced3607cc83c0d.tar.bz2
Share regcache function regcache_raw_read_unsigned
This patch is in preparation for software single step support on ARM in GDBServer. It adds a new shared function regcache_raw_read_unsigned and regcache_raw_get_unsigned so that GDB and GDBServer can use the same call to fetch a raw register into an integer. No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/ChangeLog: * 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. gdb/gdbserver/ChangeLog: * 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.
Diffstat (limited to 'gdb/gdbserver')
-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
4 files changed, 40 insertions, 11 deletions
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. */