]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: Make test result accurate in breakpoint-in-ro-region.exp
authorTiezhu Yang <yangtiezhu@loongson.cn>
Sat, 31 Jan 2026 08:24:06 +0000 (16:24 +0800)
committerTiezhu Yang <yangtiezhu@loongson.cn>
Fri, 13 Feb 2026 10:08:07 +0000 (18:08 +0800)
Currently, if no support for hardware breakpoints, when executing:

  make check-gdb TESTS="gdb.base/breakpoint-in-ro-region.exp"

the test results of "hbreak" and "si" command are "PASS":

```
(gdb) hbreak *0x120000628^M
No hardware breakpoint support in the target.^M
(gdb) PASS: 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) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: step in ro region (cannot insert hw break)
```

This is not accurate, obviously it should be "UNSUPPORTED".

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33845
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 c29d2f8654e6cc6665e926c54338d62f0cd3fcb2..e18563ff6eaf433f8e1bbc29d9d9cdc2bdb7ff8e 100644 (file)
@@ -177,10 +177,10 @@ set supports_hbreak 0
 set test "probe hbreak support"
 gdb_test_multiple "hbreak *$main_lo" $test {
     -re "You may have requested too many.*$gdb_prompt $" {
-       pass "$test (no support)"
+       unsupported "$test (no support)"
     }
     -re "No hardware breakpoint support.*$gdb_prompt $" {
-       pass "$test (no support)"
+       unsupported "$test (no support)"
     }
     -re "$gdb_prompt $" {
        pass "$test (support)"
@@ -216,8 +216,11 @@ 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 $" {
-           gdb_assert {!$hw_step && $auto_hw == "on" && !$supports_hbreak} \
-               "$test (cannot insert hw break)"
+           if {!$hw_step && $auto_hw == "on" && !$supports_hbreak} {
+               unsupported "$test (cannot insert hw break)"
+           } else {
+               fail "$test (cannot insert hw break)"
+           }
        }
        -re "Cannot set software breakpoint at read-only address $next_insn.*$gdb_prompt $" {
            gdb_assert {!$hw_step && $auto_hw == "off"} \