aboutsummaryrefslogtreecommitdiff
path: root/gdb/arch-utils.c
diff options
context:
space:
mode:
authorMarcin Koƛcielnicki <koriakin@0x04.net>2016-02-18 09:21:38 +0100
committerMarcin Koƛcielnicki <koriakin@0x04.net>2016-02-18 17:21:22 +0100
commit5f034a78b986d30a90030b2409c61a8660b9b48c (patch)
tree312e005927c2673b81ad675d0e46e8b6ac5a5cd2 /gdb/arch-utils.c
parentc304e18e5ca825f57963bd0c5f022fa8f5797b29 (diff)
downloadgdb-5f034a78b986d30a90030b2409c61a8660b9b48c.zip
gdb-5f034a78b986d30a90030b2409c61a8660b9b48c.tar.gz
gdb-5f034a78b986d30a90030b2409c61a8660b9b48c.tar.bz2
gdb: Add guess_tracepoint_registers hook to gdbarch.
When we're looking at a tracefile trace frame where registers are not available, and the tracepoint has only one location, we supply the location's address as the PC register. However, this only works if PC is not a pseudo register, and individual architectures may want to guess more registers. Add a gdbarch hook that will handle that. gdb/ChangeLog: * arch-utils.c (default_guess_tracepoint_registers): New function. * arch-utils.h (default_guess_tracepoint_registers): New prototype. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh: Add guess_tracepoint_registers hook. * tracefile.c (tracefile_fetch_registers): Use the new gdbarch hook.
Diffstat (limited to 'gdb/arch-utils.c')
-rw-r--r--gdb/arch-utils.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index fe64627..c3d7802 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -897,6 +897,29 @@ default_addressable_memory_unit_size (struct gdbarch *gdbarch)
return 1;
}
+void
+default_guess_tracepoint_registers (struct gdbarch *gdbarch,
+ struct regcache *regcache,
+ CORE_ADDR addr)
+{
+ int pc_regno = gdbarch_pc_regnum (gdbarch);
+ gdb_byte *regs;
+
+ /* This guessing code below only works if the PC register isn't
+ a pseudo-register. The value of a pseudo-register isn't stored
+ in the (non-readonly) regcache -- instead it's recomputed
+ (probably from some other cached raw register) whenever the
+ register is read. In this case, a custom method implementation
+ should be used by the architecture. */
+ if (pc_regno < 0 || pc_regno >= gdbarch_num_regs (gdbarch))
+ return;
+
+ regs = (gdb_byte *) alloca (register_size (gdbarch, pc_regno));
+ store_unsigned_integer (regs, register_size (gdbarch, pc_regno),
+ gdbarch_byte_order (gdbarch), addr);
+ regcache_raw_supply (regcache, pc_regno, regs);
+}
+
/* -Wmissing-prototypes */
extern initialize_file_ftype _initialize_gdbarch_utils;