This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Tweak gdb.trace/tfile.c for thumb mode
- From: Yao Qi <yao at codesourcery dot com>
- To: Pedro Alves <palves at redhat dot com>, <gdb-patches at sourceware dot org>
- Date: Thu, 10 Jul 2014 09:26:48 +0800
- Subject: Re: [PATCH] Tweak gdb.trace/tfile.c for thumb mode
- Authentication-results: sourceware.org; auth=none
- References: <1404100222-2312-1-git-send-email-yao at codesourcery dot com> <53BD5710 dot 5040105 at redhat dot com>
On 07/09/2014 10:52 PM, Pedro Alves wrote:
> #if defined(__thumb__) || defined(__thumb2__)
> /* Although Thumb functions are two-byte aligned, function
> pointers have the Thumb bit set. Clear it. */
> func_addr &= ~1;
> #endif
>
> (This bit is widely known as the "Thumb bit", so call it that,
> and remove a few "the"'s that sound odd to me, and say
> "two-byte aligned".)
I often associate "Thumb bit" with the bit in CPSR. Look into
arm-tdep.c and arm-linux-tdep.c, "Thumb bit" is used for both cases
(LSB of function address and the bit in CPSR). It shouldn't cause any
confusion.
Patch is updated as you suggested and pushed in.
--
Yao (éå)
gdb/testsuite:
2014-07-10 Yao Qi <yao@codesourcery.com>
* gdb.trace/tfile.c (write_basic_trace_file)
[__thumb__||__thumb2__]: Clear the Thumb bit of the function
address written to trace file.
---
gdb/testsuite/ChangeLog | 6 ++++++
gdb/testsuite/gdb.trace/tfile.c | 11 +++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 19e6232..2278496 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2014-07-10 Yao Qi <yao@codesourcery.com>
+
+ * gdb.trace/tfile.c (write_basic_trace_file)
+ [__thumb__||__thumb2__]: Clear the Thumb bit of the function
+ address written to trace file.
+
2014-07-09 Pedro Alves <palves@redhat.com>
* gdb.base/attach-wait-input.exp: New file.
diff --git a/gdb/testsuite/gdb.trace/tfile.c b/gdb/testsuite/gdb.trace/tfile.c
index ac65901..bc25b80 100644
--- a/gdb/testsuite/gdb.trace/tfile.c
+++ b/gdb/testsuite/gdb.trace/tfile.c
@@ -91,6 +91,7 @@ write_basic_trace_file (void)
{
int fd, int_x;
short short_x;
+ long func_addr;
fd = start_trace_file (TFILE_DIR "tfile-basic.tf");
@@ -109,8 +110,14 @@ write_basic_trace_file (void)
/* Dump tracepoint definitions, in syntax similar to that used
for reconnection uploads. */
/* FIXME need a portable way to print function address in hex */
- snprintf (spbuf, sizeof spbuf, "tp T1:%lx:E:0:0\n",
- (long) &write_basic_trace_file);
+ func_addr = (long) &write_basic_trace_file;
+#if defined(__thumb__) || defined(__thumb2__)
+ /* Although Thumb functions are two-byte aligned, function
+ pointers have the Thumb bit set. Clear it. */
+ func_addr &= ~1;
+#endif
+
+ snprintf (spbuf, sizeof spbuf, "tp T1:%lx:E:0:0\n", func_addr);
write (fd, spbuf, strlen (spbuf));
/* (Note that we would only need actions defined if we wanted to
test tdump.) */
--
1.9.0