This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 1/4] Remove arm_override_mode
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 12 May 2016 17:18:29 +0100
- Subject: [PATCH 1/4] Remove arm_override_mode
- Authentication-results: sourceware.org; auth=none
- References: <1463069912-23472-1-git-send-email-yao dot qi at linaro dot org>
This patch removes global variable arm_override_mode. The rationale is
that if the address is the next address of current pc, we can get the
thumb/arm mode from dest address computed by software single step code.
gdb:
2016-05-12 Yao Qi <yao.qi@linaro.org>
* arm-tdep.c: Include "gdbthread.h".
(arm_override_mode): Remove.
(arm_pc_is_thumb): Remove arm_override_mode. If MEMADDR
is the dest address of current pc, get thumb mode by dest address.
(arm_insert_single_step_breakpoint): Remove arm_override_mode
and cleanup.
---
gdb/arm-tdep.c | 57 +++++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 41 insertions(+), 16 deletions(-)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 0412f71..d529481 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -55,6 +55,7 @@
#include "elf/arm.h"
#include "vec.h"
+#include "gdbthread.h"
#include "record.h"
#include "record-full.h"
@@ -143,13 +144,6 @@ static const char *const arm_mode_strings[] =
static const char *arm_fallback_mode_string = "auto";
static const char *arm_force_mode_string = "auto";
-/* Internal override of the execution mode. -1 means no override,
- 0 means override to ARM mode, 1 means override to Thumb mode.
- The effect is the same as if arm_force_mode has been set by the
- user (except the internal override has precedence over a user's
- arm_force_mode override). */
-static int arm_override_mode = -1;
-
/* Number of different reg name sets (options). */
static int num_disassembly_options;
@@ -422,9 +416,46 @@ arm_pc_is_thumb (struct gdbarch *gdbarch, CORE_ADDR memaddr)
if (IS_THUMB_ADDR (memaddr))
return 1;
- /* Respect internal mode override if active. */
- if (arm_override_mode != -1)
- return arm_override_mode;
+ if (target_has_execution && !is_executing (inferior_ptid))
+ {
+ gdb_byte buf[4];
+ struct regcache *regcache = get_current_regcache ();
+
+ /* Check the memory pointed by PC is readable. */
+ if (target_read_memory (regcache_read_pc (regcache), buf, 4) == 0)
+ {
+ struct arm_get_next_pcs next_pcs_ctx;
+ CORE_ADDR pc;
+ int i;
+ VEC (CORE_ADDR) *next_pcs = NULL;
+ struct cleanup *old_chain
+ = make_cleanup (VEC_cleanup (CORE_ADDR), &next_pcs);
+
+ arm_get_next_pcs_ctor (&next_pcs_ctx,
+ &arm_get_next_pcs_ops,
+ gdbarch_byte_order (gdbarch),
+ gdbarch_byte_order_for_code (gdbarch),
+ 0,
+ regcache);
+
+ next_pcs = arm_get_next_pcs (&next_pcs_ctx);
+
+ /* If MEMADDR is the next instruction of current pc, do the
+ software single step computation, and get the thumb mode by
+ the destination address. */
+ for (i = 0; VEC_iterate (CORE_ADDR, next_pcs, i, pc); i++)
+ {
+ if (UNMAKE_THUMB_ADDR (pc) == memaddr)
+ {
+ do_cleanups (old_chain);
+
+ return IS_THUMB_ADDR (pc);
+ }
+ }
+
+ do_cleanups (old_chain);
+ }
+ }
/* If the user wants to override the symbol table, let him. */
if (strcmp (arm_force_mode_string, "arm") == 0)
@@ -4205,15 +4236,9 @@ arm_insert_single_step_breakpoint (struct gdbarch *gdbarch,
struct address_space *aspace,
CORE_ADDR pc)
{
- struct cleanup *old_chain
- = make_cleanup_restore_integer (&arm_override_mode);
-
- arm_override_mode = IS_THUMB_ADDR (pc);
pc = gdbarch_addr_bits_remove (gdbarch, pc);
insert_single_step_breakpoint (gdbarch, aspace, pc);
-
- do_cleanups (old_chain);
}
/* Given BUF, which is OLD_LEN bytes ending at ENDADDR, expand
--
1.9.1