[RFC,12/15] gdbserver: Add help functions to get arm/thumb mode
Commit Message
From: Henrik Wallin <henrik.wallin@windriver.com>
This adds new function. No users yet.
This is a quick dirty way to ask gdb what the mode is.
The relocate_instruction function is used with a bogus address.
gdb side advances the to address if arm mode, otherwise not.
gdb/ChangeLog:
* arm-tdep.c (arm_relocate_instruction_func) : Add code
to handle special case address value.
gdb/gdbserver/ChangeLog:
* linux-arm-low.c (is_target_arm) : New function.
Signed-off-by: Henrik Wallin <henrik.wallin@windriver.com>
---
gdb/arm-tdep.c | 9 ++++++++-
gdb/gdbserver/linux-arm-low.c | 9 +++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
@@ -10447,7 +10447,14 @@ arm_relocate_instruction_func (struct relocate_insn *rel)
rel->byte_order_for_code = gdbarch_byte_order_for_code (rel->gdbarch);
rel->result = 0;
- if (arm_pc_is_thumb (rel->gdbarch, rel->oldloc))
+ if (rel->oldloc == 0xFFFFFFFF)
+ {
+ uint32_t tmp = read_memory_unsigned_integer (*(rel->to), 4,
+ rel->byte_order_for_code);
+ if (! arm_pc_is_thumb (rel->gdbarch, tmp))
+ *rel->to += 1;
+ }
+ else if (arm_pc_is_thumb (rel->gdbarch, rel->oldloc))
{
uint16_t insn1;
uint16_t insn2;
@@ -917,6 +917,15 @@ arm_regs_info (void)
return ®s_info_arm;
}
+static int
+is_target_arm (CORE_ADDR to, CORE_ADDR from)
+{
+ CORE_ADDR ptr = to;
+ write_inferior_memory (to, (unsigned char *) &from, 4);
+ relocate_instruction (&ptr, 0xFFFFFFFF);
+ return (to == ptr) ? 0 : 1;
+}
+
static uint32_t
mk_t_b_rel (CORE_ADDR from, CORE_ADDR to)
{