aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Hayward <alan.hayward@arm.com>2017-03-24 16:53:05 +0000
committerAlan Hayward <alan.hayward@arm.com>2017-03-24 16:53:05 +0000
commited771251e16c8c66cbdd03738135e76caef6937e (patch)
tree90da838f03344ada7e41de4d09815cf999438b7f
parent568c1b9f503649d19ed1d17e6970f212e6b6317d (diff)
downloadgdb-ed771251e16c8c66cbdd03738135e76caef6937e.zip
gdb-ed771251e16c8c66cbdd03738135e76caef6937e.tar.gz
gdb-ed771251e16c8c66cbdd03738135e76caef6937e.tar.bz2
Remove MAX_REGISTER_SIZE from target.c
gdb/ * regcache.c (regcache_debug_print_register): New function. * regcache.h (regcache_debug_print_register): New declaration. * target.c (debug_print_register): Remove. (target_fetch_registers): Call regcache_debug_print_register. (target_store_registers): Likewise.
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/regcache.c35
-rw-r--r--gdb/regcache.h6
-rw-r--r--gdb/target.c42
4 files changed, 52 insertions, 39 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dd12d3c..a687fae 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2017-03-24 Alan Hayward <alan.hayward@arm.com>
+
+ * regcache.c (regcache_debug_print_register): New function.
+ * regcache.h (regcache_debug_print_register): New declaration.
+ * target.c (debug_print_register): Remove.
+ (target_fetch_registers): Call regcache_debug_print_register.
+ (target_store_registers): Likewise.
+
2017-03-24 Pádraig Brady <pbrady@fb.com>
* dwarf2read.c (setup_type_unit_groups): Ensure dir_index doesn't
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 71223a1..37bc2f0 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -1258,6 +1258,41 @@ regcache_write_pc (struct regcache *regcache, CORE_ADDR pc)
reinit_frame_cache ();
}
+void
+regcache_debug_print_register (const char *func, struct regcache *regcache,
+ int regno)
+{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+
+ fprintf_unfiltered (gdb_stdlog, "%s ", func);
+ if (regno >= 0 && regno < gdbarch_num_regs (gdbarch)
+ && gdbarch_register_name (gdbarch, regno) != NULL
+ && gdbarch_register_name (gdbarch, regno)[0] != '\0')
+ fprintf_unfiltered (gdb_stdlog, "(%s)",
+ gdbarch_register_name (gdbarch, regno));
+ else
+ fprintf_unfiltered (gdb_stdlog, "(%d)", regno);
+ if (regno >= 0 && regno < gdbarch_num_regs (gdbarch))
+ {
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ int size = register_size (gdbarch, regno);
+ gdb_byte *buf = register_buffer (regcache, regno);
+
+ fprintf_unfiltered (gdb_stdlog, " = ");
+ for (int i = 0; i < size; i++)
+ {
+ fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
+ }
+ if (size <= sizeof (LONGEST))
+ {
+ ULONGEST val = extract_unsigned_integer (buf, size, byte_order);
+
+ fprintf_unfiltered (gdb_stdlog, " %s %s",
+ core_addr_to_string_nz (val), plongest (val));
+ }
+ }
+ fprintf_unfiltered (gdb_stdlog, "\n");
+}
static void
reg_flush_command (char *command, int from_tty)
diff --git a/gdb/regcache.h b/gdb/regcache.h
index d0107cd..1d60fa7 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -236,4 +236,10 @@ extern void regcache_cpy (struct regcache *dest, struct regcache *src);
extern void registers_changed (void);
extern void registers_changed_ptid (ptid_t);
+/* Dump the contents of a register from the register cache to the target
+ debug. */
+extern void regcache_debug_print_register (const char *func,
+ struct regcache *regcache,
+ int regno);
+
#endif /* REGCACHE_H */
diff --git a/gdb/target.c b/gdb/target.c
index 0ff8515..7c286ab 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3547,49 +3547,12 @@ target_options_to_string (int target_options)
return ret;
}
-static void
-debug_print_register (const char * func,
- struct regcache *regcache, int regno)
-{
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
-
- fprintf_unfiltered (gdb_stdlog, "%s ", func);
- if (regno >= 0 && regno < gdbarch_num_regs (gdbarch)
- && gdbarch_register_name (gdbarch, regno) != NULL
- && gdbarch_register_name (gdbarch, regno)[0] != '\0')
- fprintf_unfiltered (gdb_stdlog, "(%s)",
- gdbarch_register_name (gdbarch, regno));
- else
- fprintf_unfiltered (gdb_stdlog, "(%d)", regno);
- if (regno >= 0 && regno < gdbarch_num_regs (gdbarch))
- {
- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- int i, size = register_size (gdbarch, regno);
- gdb_byte buf[MAX_REGISTER_SIZE];
-
- regcache_raw_collect (regcache, regno, buf);
- fprintf_unfiltered (gdb_stdlog, " = ");
- for (i = 0; i < size; i++)
- {
- fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
- }
- if (size <= sizeof (LONGEST))
- {
- ULONGEST val = extract_unsigned_integer (buf, size, byte_order);
-
- fprintf_unfiltered (gdb_stdlog, " %s %s",
- core_addr_to_string_nz (val), plongest (val));
- }
- }
- fprintf_unfiltered (gdb_stdlog, "\n");
-}
-
void
target_fetch_registers (struct regcache *regcache, int regno)
{
current_target.to_fetch_registers (&current_target, regcache, regno);
if (targetdebug)
- debug_print_register ("target_fetch_registers", regcache, regno);
+ regcache_debug_print_register ("target_fetch_registers", regcache, regno);
}
void
@@ -3601,7 +3564,8 @@ target_store_registers (struct regcache *regcache, int regno)
current_target.to_store_registers (&current_target, regcache, regno);
if (targetdebug)
{
- debug_print_register ("target_store_registers", regcache, regno);
+ regcache_debug_print_register ("target_store_registers", regcache,
+ regno);
}
}