diff options
author | Luis Machado <luis.machado@linaro.org> | 2020-12-10 16:51:20 -0300 |
---|---|---|
committer | Luis Machado <luis.machado@linaro.org> | 2020-12-16 10:05:56 -0300 |
commit | 19007d955670a183fdf79408301d403b43eb7db1 (patch) | |
tree | 4792181fe8ae0bf0fb897646fe30ed98937e100e /gdb/testsuite/gdb.arch | |
parent | c410035d37d8237c641155c4e51e7ccf53decb29 (diff) | |
download | gdb-19007d955670a183fdf79408301d403b43eb7db1.zip gdb-19007d955670a183fdf79408301d403b43eb7db1.tar.gz gdb-19007d955670a183fdf79408301d403b43eb7db1.tar.bz2 |
Fix TBI handling for watchpoints
When inserting hw watchpoints, we take care of masking off the top byte
of the address (and sign-extending it if needed). This guarantees we won't
pass tagged addresses to the kernel via ptrace.
However, from the kernel documentation on tagged pointers...
"Non-zero tags are not preserved when delivering signals. This means that
signal handlers in applications making use of tags cannot rely on the tag
information for user virtual addresses being maintained for fields inside
siginfo_t.
One exception to this rule is for signals raised in response to watchpoint
debug exceptions, where the tag information will be preserved."
So the stopped data address after a hw watchpoint hit can be potentially
tagged, and we don't handle this in GDB at the moment. This results in
GDB missing a hw watchpoint hit and attempting to step over an unsteppable
hw watchpoint, causing it to spin endlessly.
The following patch fixes this by adjusting the stopped data address and adds
some tests to expose the problem.
gdb/ChangeLog:
2020-12-16 Luis Machado <luis.machado@linaro.org>
* aarch64-linux-nat.c
(aarch64_linux_nat_target::stopped_data_address): Handle the TBI.
gdbserver/ChangeLog:
2020-12-16 Luis Machado <luis.machado@linaro.org>
* linux-aarch64-low.cc (address_significant): New function.
(aarch64_target::low_stopped_data_address): Handle the TBI.
gdb/testsuite/ChangeLog:
2020-12-16 Luis Machado <luis.machado@linaro.org>
* gdb.arch/aarch64-tagged-pointer.c (main): Add a few more
pointer-based memory accesses.
* gdb.arch/aarch64-tagged-pointer.exp: Exercise additional
hw watchpoint cases.
Diffstat (limited to 'gdb/testsuite/gdb.arch')
-rw-r--r-- | gdb/testsuite/gdb.arch/aarch64-tagged-pointer.c | 8 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp | 27 |
2 files changed, 24 insertions, 11 deletions
diff --git a/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.c b/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.c index 609d4f2..658c309 100644 --- a/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.c +++ b/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.c @@ -53,5 +53,11 @@ main (void) } sp1->i = 8765; - i = 1; + sp2->i = 4321; + sp1->i = 8765; + sp2->i = 4321; + *p1 = 1; + *p2 = 2; + *p1 = 1; + *p2 = 2; } diff --git a/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp b/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp index 957571f..01c2b57 100644 --- a/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp +++ b/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp @@ -92,14 +92,21 @@ foreach_with_prefix bptype {"hbreak" "break"} { gdb_test "down" gdb_test "finish" -# Watch on tagged pointer. -gdb_test "watch *sp2" -gdb_test "continue" \ - "Continuing\\..*Hardware watchpoint \[0-9\]+.*" \ - "run until watchpoint on s1" -delete_breakpoints -gdb_test "watch *p2" -gdb_test "continue" \ - "Continuing\\..*Hardware watchpoint \[0-9\]+.*" \ - "run until watchpoint on i" +# sp1 and p1 are untagged pointers, but sp2 and p2 are tagged pointers. +# Cycle through all of them to make sure the following combinations work: +# +# hw watch on untagged address, hit on untagged address. +# hw watch on tagged address, hit on untagged address. +# hw watch on untagged address, hit on tagged address. +# hw watch on tagged address, hit on tagged address. +foreach symbol {"sp1" "sp2" "p1" "p2"} { + gdb_test "watch *${symbol}" + gdb_test "continue" \ + "Continuing\\..*Hardware watchpoint \[0-9\]+.*" \ + "run until watchpoint on ${symbol}" + gdb_test "continue" \ + "Continuing\\..*Hardware watchpoint \[0-9\]+.*" \ + "run until watchpoint on ${symbol}, 2nd hit" + delete_breakpoints +} |