]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: Fix unexpected failures in breakpoint-in-ro-region.exp
authorTiezhu Yang <yangtiezhu@loongson.cn>
Sat, 31 Jan 2026 08:24:07 +0000 (16:24 +0800)
committerTiezhu Yang <yangtiezhu@loongson.cn>
Fri, 13 Feb 2026 10:08:13 +0000 (18:08 +0800)
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>
gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp

index e18563ff6eaf433f8e1bbc29d9d9cdc2bdb7ff8e..2ab0354ee8c2ed5e26215b3c960df7e54ef3ce24 100644 (file)
@@ -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 {