[binutils-gdb/gdb-17-branch] gdb: Fix unexpected failures in breakpoint-in-ro-region.exp

Tiezhu Yang yangtiezhu@sourceware.org
Fri Feb 13 10:16:25 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a4477520f93a760a148aa8f7de52c992ccdf5037

commit a4477520f93a760a148aa8f7de52c992ccdf5037
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
Date:   Sat Jan 31 16:24:07 2026 +0800

    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 <shankerwangmiao@gmail.com>
    Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
    Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp
index e4e8b9b04de..2acf59d52c7 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 {


More information about the Gdb-cvs mailing list