[binutils-gdb] [gdb/testsuite] Handle too many watchpoints in gdb.base/watchpoint-adjacent.exp

Tom de Vries via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5b4b8f19c3d2393dc05f13d4b35bc9e6c53b5397

commit 5b4b8f19c3d2393dc05f13d4b35bc9e6c53b5397
Author: Tom de Vries <[email protected]>
Date:   Thu Mar 19 11:11:32 2026 +0100

    [gdb/testsuite] Handle too many watchpoints in gdb.base/watchpoint-adjacent.exp
    
    On i686-linux, with test-case gdb.base/watchpoint-adjacent.exp I run into:
    ...
    (gdb) watch obj.b^M
    Hardware watchpoint 5: obj.b^M
    Warning:^M
    Could not insert hardware watchpoint 5.^M
    Could not insert hardware breakpoints:^M
    You may have requested too many hardware breakpoints/watchpoints.^M
    ^M
    (gdb) FAIL: $exp: var_type=type_ll: test= a {a b} : rwatch_first=true: \
      watch obj.b
    ...
    
    The CPU supports 4 hardware watchpoints of 4 bytes, and the test-case attempts
    to set 3 hardware watchpoints of 8 bytes.
    
    Fix this by making the test unsupported.
    
    Tested on i686-linux and x86_64-linux.
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33949

Diff:
---
 gdb/testsuite/gdb.base/watchpoint-adjacent.exp | 38 +++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.base/watchpoint-adjacent.exp b/gdb/testsuite/gdb.base/watchpoint-adjacent.exp
index 3c3316059ad..2ecbacfd007 100644
--- a/gdb/testsuite/gdb.base/watchpoint-adjacent.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-adjacent.exp
@@ -115,14 +115,44 @@ proc run_read_test { filename var_type rwatch_var rwatch_first watch_vars } {
 	set wp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*"]
     }
 
+    set re_too_many \
+	[multi_line \
+	     [quotemeta "Could not insert hardware watchpoint @DECIMAL."] \
+	     "Could not insert hardware breakpoints:" \
+	     [string_to_regexp \
+		  "You may have requested too many hardware breakpoints/watchpoints."] \
+	     ""]
+
+    set unsupported 0
     foreach v $watch_vars {
-	gdb_test "watch obj.$v" \
-	    "Hardware watchpoint $::decimal: obj.$v"
+	gdb_test_multiple "watch obj.$v" "" {
+	    -re -wrap "Hardware watchpoint $::decimal: obj.$v" {
+		pass $gdb_test_name
+	    }
+	    -re -wrap $re_too_many {
+		unsupported $gdb_test_name
+		set unsupported 1
+	    }
+	}
+    }
+    if {$unsupported} {
+	return
     }
 
     if { !$rwatch_first } {
-	gdb_test "rwatch obj.${rwatch_var}" \
-	    "Hardware read watchpoint $::decimal: obj.$rwatch_var"
+	gdb_test_multiple "rwatch obj.${rwatch_var}" "" {
+	    -re -wrap "Hardware read watchpoint $::decimal: obj.$rwatch_var" {
+		pass $gdb_test_name
+	    }
+	    -re -wrap $re_too_many {
+		unsupported $gdb_test_name
+		set unsupported 1
+	    }
+	}
+	if {$unsupported} {
+	    return
+	}
+
 	set wp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*"]
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.