This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC][PATCH 10/15] gdb: Add arm_fast_tracepoint_valid_at
- From: henrik dot wallin at windriver dot com
- To: gdb-patches at sourceware dot org
- Date: Wed, 14 Oct 2015 13:14:28 +0200
- Subject: [RFC][PATCH 10/15] gdb: Add arm_fast_tracepoint_valid_at
- Authentication-results: sourceware.org; auth=none
- References: <cover dot 1444820235 dot git dot henrik dot wallin at windriver dot com>
- References: <cover dot 1444820235 dot git dot henrik dot wallin at windriver dot com>
From: Henrik Wallin <henrik.wallin@windriver.com>
This adds the function. No users yet.
A 4 byte jump instruction will be used and the code need to
handle multiple cases as the instruction can be 2, or 4 bytes long and
the mode can be either arm or thumb.
gdb/ChangeLog:
* arm-tdep.c (arm_fast_tracepoint_valid_at): New function.
Signed-off-by: Henrik Wallin <henrik.wallin@windriver.com>
---
gdb/arm-tdep.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index b277c3ef405c..601d589b8a89 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -22,6 +22,7 @@
#include <ctype.h> /* XXX for isupper (). */
#include "frame.h"
+#include "disasm.h"
#include "inferior.h"
#include "infrun.h"
#include "gdbcmd.h"
@@ -10506,6 +10507,52 @@ arm_relocate_instruction (struct gdbarch *gdbarch,
arm_relocate_instruction_func (&rel);
}
+static int
+arm_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
+ CORE_ADDR addr, char **msg)
+{
+ static struct ui_file *gdb_null = NULL;
+ int len;
+
+ /* Check if the instruction is relocatable. */
+ if (arm_check_relocate_instruction (gdbarch, addr, msg) == -1)
+ return 0;
+
+ /* Dummy file descriptor for the disassembler. */
+ if (!gdb_null)
+ gdb_null = ui_file_new ();
+
+ /* A branch instruction used for fast tracepoint takes 4 bytes.
+ (A 2 bytes branch instruction only gets us 4k away,
+ so will not be enough.)
+
+ target gdbserver will validate that the relative branch
+ distance will fit in the instructions.
+ (16M for Thumb, 32M for ARM)
+
+ We only allow to replace one instuction. (4 bytes)
+ Replacing 2 instructions is not safe. Consider
+ the case where code wants to jump to the 2nd instruction - it
+ will jump into the middle of a branch instruction. */
+
+ if (arm_pc_is_thumb (gdbarch, addr))
+ {
+ len = gdb_print_insn (gdbarch, addr, gdb_null, NULL);
+ if (len == 2)
+ {
+ if (msg)
+ *msg = xstrprintf (_("; instruction is only 2 bytes long, "
+ "need 4 bytes for the jump"));
+ return 0;
+ }
+ }
+
+ if (msg)
+ *msg = NULL;
+
+ return 1;
+}
+
/* Initialize the current architecture based on INFO. If possible,
re-use an architecture from ARCHES, which is a list of
--
2.1.4