This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] [AArch64] Only check breakpoint alignment on inserting
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 23 Nov 2015 13:50:54 +0000
- Subject: [PATCH] [AArch64] Only check breakpoint alignment on inserting
- Authentication-results: sourceware.org; auth=none
This patch fixes the GDB internal error on AArch64 when running
watchpoint-fork.exp
top?bt 15
at ../../binutils-gdb/gdb/common/errors.c:51
...
...
at ../../binutils-gdb/gdb/nat/aarch64-linux-hw-point.c:465
at ../../binutils-gdb/gdb/aarch64-linux-nat.c:657
at ../../binutils-gdb/gdb/target-delegates.c:492
After the fork, GDB will physically remove the breakpoints from the child
process (in frame #14), but at that time, GDB doesn't create an inferior
yet for child, but inferior_ptid is set to child's ptid (in frame #13).
In aarch64_point_is_aligned, we'll get the regcache of current_lwp_ptid
to determine if the current process is 32-bit or 64-bit, so the inferior
can't be found, and the internal error is caused.
I don't find a better fix other than not checking alignment on removing
breakpoint.
gdb:
2015-11-23 Yao Qi <yao.qi@linaro.org>
* nat/aarch64-linux-hw-point.c (aarch64_dr_state_remove_one_point):
Don't assert on alignment.
(aarch64_handle_breakpoint): Only check alignment when IS_INSERT
is true.
---
gdb/nat/aarch64-linux-hw-point.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/gdb/nat/aarch64-linux-hw-point.c b/gdb/nat/aarch64-linux-hw-point.c
index dcbfa98..466823a 100644
--- a/gdb/nat/aarch64-linux-hw-point.c
+++ b/gdb/nat/aarch64-linux-hw-point.c
@@ -411,7 +411,6 @@ aarch64_dr_state_remove_one_point (struct aarch64_debug_reg_state *state,
/* Set up state pointers. */
is_watchpoint = (type != hw_execute);
- gdb_assert (aarch64_point_is_aligned (is_watchpoint, addr, len));
if (is_watchpoint)
{
num_regs = aarch64_num_wp_regs;
@@ -460,13 +459,21 @@ aarch64_handle_breakpoint (enum target_hw_bp_type type, CORE_ADDR addr,
int len, int is_insert,
struct aarch64_debug_reg_state *state)
{
- /* The hardware breakpoint on AArch64 should always be 4-byte
- aligned, but on AArch32, it can be 2-byte aligned. */
- if (!aarch64_point_is_aligned (0 /* is_watchpoint */ , addr, len))
- return -1;
-
if (is_insert)
- return aarch64_dr_state_insert_one_point (state, type, addr, len);
+ {
+ /* The hardware breakpoint on AArch64 should always be 4-byte
+ aligned, but on AArch32, it can be 2-byte aligned. Note that
+ we only check the alignment on inserting breakpoint because
+ aarch64_point_is_aligned needs the inferior_ptid inferior's
+ regcache to decide whether the inferior is 32-bit or 64-bit.
+ However when GDB follows the parent process and detach breakpoints
+ from child process, inferior_ptid is the child ptid, but the
+ child inferior doesn't exist in GDB's view yet. */
+ if (!aarch64_point_is_aligned (0 /* is_watchpoint */ , addr, len))
+ return -1;
+
+ return aarch64_dr_state_insert_one_point (state, type, addr, len);
+ }
else
return aarch64_dr_state_remove_one_point (state, type, addr, len);
}
--
1.9.1