]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/breakpoints] Fix gdb.base/scope-hw-watch-disable.exp on arm-linux
authorTom de Vries <tdevries@suse.de>
Thu, 10 Oct 2024 10:41:40 +0000 (12:41 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 10 Oct 2024 10:41:40 +0000 (12:41 +0200)
commitf04b2702faf409b0d54a1dacd4ef4beb4272c35d
tree9f1109770ed7728e2af2fb6982f2cc42c5197aa9
parenta98a6fa2d8ef5eb61534b07db80850dcdf07bdb4
[gdb/breakpoints] Fix gdb.base/scope-hw-watch-disable.exp on arm-linux

On arm-linux, with test-case gdb.base/scope-hw-watch-disable.exp I run into:
...
(gdb) awatch a^M
Can't set read/access watchpoint when hardware watchpoints are disabled.^M
(gdb) PASS: $exp: unsuccessful attempt to create an access watchpoint
rwatch b^M
Can't set read/access watchpoint when hardware watchpoints are disabled.^M
(gdb) PASS: $exp: unsuccessful attempt to create a read watchpoint
continue^M
Continuing.^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
0xf7ec82c8 in ?? () from /lib/arm-linux-gnueabihf/libc.so.6^M
(gdb) FAIL: $exp: continue until exit
...

Using "maint info break", we can see that the two failed attempts to set a
watchpoint each left behind a stale "watchpoint scope" breakpoint:
...
-5      watchpoint scope del  y   0xf7ec569a  inf 1
-5.1                          y   0xf7ec569a  inf 1
stop only in stack frame at 0xfffef4f8
-6      watchpoint scope del  y   0xf7ec569a  inf 1
-6.1                          y   0xf7ec569a  inf 1
stop only in stack frame at 0xfffef4f8
...

The SIGSEGV is a consequence of the stale "watchpoint scope" breakpoint: the
same happens if we:
- have can-use-hw-watchpoints == 1,
- set one of the watchpoints, and
- continue to exit.
The problem is missing symbol info on libc which is supposed to tell which
code is thumb.  After doing "set arm fallback-mode thumb" the SIGSEGV
disappears.

Extend the test-case to check the "maint info break" command before and after
the two failed attempts, to make sure that we catch the stale
"watchpoint scope" breakpoints also on x86_64-linux.

Fix this in watch_command_1 by moving creation of the "watchpoint scope"
breakpoint after the call to update_watchpoint.

Tested on x86_64-linux.

PR breakpoints/31860
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31860
gdb/breakpoint.c
gdb/testsuite/gdb.base/scope-hw-watch-disable.exp