From: Tiezhu Yang Date: Sat, 31 Jan 2026 08:24:07 +0000 (+0800) Subject: gdb: Fix unexpected failures in breakpoint-in-ro-region.exp X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31b974268d17b47a19fc69ae4f73a7dd62192cef;p=thirdparty%2Fbinutils-gdb.git gdb: Fix unexpected failures in breakpoint-in-ro-region.exp Currently, there is no support for hardware breakpoints on a virtual machine of LoongArch. When unseting CONFIG_HAVE_HW_BREAKPOINT of the Linux kernel, there is also no support for hardware breakpoints on a physical machine of LoongArch. For the above cases, when executing: make check-gdb RUNTESTFLAGS="--target_board=native-gdbserver" TESTS="gdb.base/breakpoint-in-ro-region.exp" there are 4 unexpected failures: FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: step in ro region FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: thread advanced FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: step in ro region FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: thread advanced By the way, there are no failures when executing: make check-gdb TESTS="gdb.base/breakpoint-in-ro-region.exp" Here are the gdb log messages if no support for hardware breakpoints: (1) make check-gdb TESTS="gdb.base/breakpoint-in-ro-region.exp" ``` (gdb) hbreak *0x120000628^M No hardware breakpoint support in the target.^M (gdb) UNSUPPORTED: gdb.base/breakpoint-in-ro-region.exp: probe hbreak support (no support) si^M Note: automatically using hardware breakpoints for read-only addresses.^M Warning:^M Cannot insert hardware breakpoint 0.^M Could not insert hardware breakpoints:^M You may have requested too many hardware breakpoints/watchpoints.^M ^M (gdb) UNSUPPORTED: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: step in ro region (cannot insert hw break) ``` (2) make check-gdb RUNTESTFLAGS="--target_board=native-gdbserver" TESTS="gdb.base/breakpoint-in-ro-region.exp" ``` (gdb) hbreak *0x120000628^M Hardware assisted breakpoint 3 at 0x120000628: file /home/fedora/build/gdb/testsuite/../../../gdb/gdb/testsuite/gdb.base/breakpoint-in-ro-region.c, line 22.^M Warning:^M Cannot insert hardware breakpoint 3:Remote failure reply: 01.^M ^M (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: probe hbreak support (support) si^M Note: automatically using hardware breakpoints for read-only addresses.^M Warning:^M Cannot insert hardware breakpoint 0:Remote failure reply: 01.^M ^M (gdb) FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: step in ro region ``` The outputs of "hbreak" and "si" commands are different between gdb and gdbserver, it should check "Cannot insert hardware breakpoint" anyway. In my opinion, this fix is not only for LoongArch but also for the other arch that does not support hardware breakpoints. For example, if disable CONFIG_PERF_EVENTS, then CONFIG_HAVE_HW_BREAKPOINT will be not set due to select HAVE_HW_BREAKPOINT if PERF_EVENTS in arch/loongarch/Kconfig of the Linux kernel code, it can reproduce the unexpected failures. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33845 Co-developed-by: Miao Wang Signed-off-by: Miao Wang Signed-off-by: Tiezhu Yang Approved-By: Tom Tromey --- diff --git a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp index e18563ff6ea..2ab0354ee8c 100644 --- a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp +++ b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp @@ -182,6 +182,9 @@ gdb_test_multiple "hbreak *$main_lo" $test { -re "No hardware breakpoint support.*$gdb_prompt $" { unsupported "$test (no support)" } + -re "Cannot insert hardware breakpoint.*$gdb_prompt $" { + unsupported "$test (no support)" + } -re "$gdb_prompt $" { pass "$test (support)" set supports_hbreak 1 @@ -215,7 +218,7 @@ proc test_single_step { always_inserted auto_hw } { set test "step in ro region" gdb_test_multiple "si" $test { - -re "Could not insert hardware breakpoints.*$gdb_prompt $" { + -re "Cannot insert hardware breakpoint.*$gdb_prompt $" { if {!$hw_step && $auto_hw == "on" && !$supports_hbreak} { unsupported "$test (cannot insert hw break)" } else {