From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: gdb-patches@sourceware.org, brobecker@adacore.com
Subject: [ARM, commit, RFA 7.5] Fix HW breakpoints on unaligned addresses
Date: Mon, 30 Jul 2012 15:15:00 -0000 [thread overview]
Message-ID: <201207301515.q6UFFSCS012933@d06av02.portsmouth.uk.ibm.com> (raw)
Hello,
the new hbreak2.exp tests are failing on ARM. It turns out that when
attempting to set a HW breakpoint on an address that is not aligned
to 4 bytes (on Thumb), the kernel rejects GDB's ptrace calls as invalid.
After some discussion with Will Deacon (who implemented the kernel side
of this interface), we've decided to fix this on the GDB side: GDB
tries to align the address to 4 bytes and uses the "byte address select"
feature to specify only the two upper bytes in that range. However,
the kernel interface does not (yet) support this use of the BAS field.
On the other hand, the kernel *does* support just specifying the
unaligned address in the address field, and setting up the BAS field
for a normal 2-byte access. (This use is not supported by the hardware,
but will get fixed up by the kernel.)
Since this alternative way is supported by all existing kernels (that
support the HW breakpoint ptrace interface), and will remain supported
in the future (even once kernels may start supporting more general
use of the BAS field), we can fix this simply by changing GDB to use
that alternative.
The patch below implements this in both GDB and gdbserver. Tested on
arm-linux-gnueabi (Cortex-A9), fixes the hbreak2 regressions.
Committed to mainline.
Joel, would this be OK for the 7.5 branch at this point?
In general, what's the timeline for 7.5? I've noticed a couple of
other test case regressions when testing the branch on ARM, s390,
and Cell ...
Bye,
Ulrich
ChangeLog:
* arm-linux-nat.c (arm_linux_hw_breakpoint_initialize): Do not
attempt to 4-byte-align HW breakpoint addresses for Thumb.
gdbserver/ChangeLog:
* linux-arm-low.c (arm_linux_hw_point_initialize): Do not attempt
to 4-byte-align HW breakpoint addresses for Thumb.
Index: gdb/arm-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-linux-nat.c,v
retrieving revision 1.55
diff -u -p -r1.55 arm-linux-nat.c
--- gdb/arm-linux-nat.c 6 Jul 2012 16:49:43 -0000 1.55
+++ gdb/arm-linux-nat.c 30 Jul 2012 15:00:33 -0000
@@ -896,11 +896,17 @@ arm_linux_hw_breakpoint_initialize (stru
/* We have to create a mask for the control register which says which bits
of the word pointed to by address to break on. */
if (arm_pc_is_thumb (gdbarch, address))
- mask = 0x3 << (address & 2);
+ {
+ mask = 0x3;
+ address &= ~1;
+ }
else
- mask = 0xf;
+ {
+ mask = 0xf;
+ address &= ~3;
+ }
- p->address = (unsigned int) (address & ~3);
+ p->address = (unsigned int) address;
p->control = arm_hwbp_control_initialize (mask, arm_hwbp_break, 1);
}
Index: gdb/gdbserver/linux-arm-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-arm-low.c,v
retrieving revision 1.34
diff -u -p -r1.34 linux-arm-low.c
--- gdb/gdbserver/linux-arm-low.c 24 Apr 2012 15:03:43 -0000 1.34
+++ gdb/gdbserver/linux-arm-low.c 30 Jul 2012 15:00:33 -0000
@@ -474,17 +474,17 @@ arm_linux_hw_point_initialize (char type
{
case 2: /* 16-bit Thumb mode breakpoint */
case 3: /* 32-bit Thumb mode breakpoint */
- mask = 0x3 << (addr & 2);
+ mask = 0x3;
+ addr &= ~1;
break;
case 4: /* 32-bit ARM mode breakpoint */
mask = 0xf;
+ addr &= ~3;
break;
default:
/* Unsupported. */
return -1;
}
-
- addr &= ~3;
}
else
{
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
next reply other threads:[~2012-07-30 15:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-30 15:15 Ulrich Weigand [this message]
2012-08-01 5:55 ` Joel Brobecker
2012-08-01 13:35 ` Remaining 7.5 regressions (Re: [ARM, commit, RFA 7.5] Fix HW breakpoints on unaligned addresses) Ulrich Weigand
2012-08-02 6:50 ` Sergio Durigan Junior
2012-08-02 10:24 ` Ulrich Weigand
2012-08-02 15:04 ` Joel Brobecker
2012-08-02 19:50 ` Ulrich Weigand
2012-08-02 20:40 ` Sergio Durigan Junior
2012-08-03 13:42 ` Joel Brobecker
2012-08-02 16:38 ` Ulrich Weigand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201207301515.q6UFFSCS012933@d06av02.portsmouth.uk.ibm.com \
--to=uweigand@de.ibm.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox