Tweak gdb.trace/tfile.c for thumb mode
Commit Message
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.
@@ -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.
@@ -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.) */