This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA 2/3] gdb_breakpoint cleanup: Add "pending" option


Hi,

As discussed earlier with Pedro (see http://sourceware.org/ml/gdb-patches/2013-04/msg00806.html), this patch adds a new "pending" option to gdb_breakpoint. When this option is used by test writers, the resultant breakpoint MUST be pending. If it is actually resolved to a real breakpoint, the function will FAIL and return 0.

This patch includes places in the test suite where we are currently using gdb_test{,_multiple} to set pending breakpoints.

Keith

testsuite/ChangeLog
2013-04-26  Keith Seitz  <keiths@redhat.com>

	* lib/gdb.exp (gdb_breakpoint): Add support for required
	pending breakpoints.
	* gdb.base/pending.exp: Set all pending breakpoints with
	gdb_breakpoint.
	* gdb.base/watchpoint-solib.exp: Likewise.
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index cdb7ca2..7a96309 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -342,6 +342,7 @@ proc gdb_start_cmd {args} {
 # temporary -- set a temporary breakpoint, e.g., "tbreak"
 # message -- print PASS messages*
 # no-message -- do not print FAIL messages*
+# pending -- set a pending breakpoint (FAIL if it is not pending)
 #
 # The result is 1 for success, 0 for failure.
 #
@@ -358,6 +359,12 @@ proc gdb_breakpoint { function args } {
 	set pending_response y
     }
 
+    set require_pending 0
+    if {[lsearch -exact $args "pending"] != -1} {
+	set require_pending 1
+	set pending_response "y"
+    }
+
     set break_command "break"
     set break_message "Breakpoint"
     if {[lsearch -exact $args temporary] != -1} {
@@ -376,14 +383,34 @@ proc gdb_breakpoint { function args } {
 	set print_pass 1
     }
 
-    set test_name "setting breakpoint at $function"
+    set what [string tolower $break_message]
+    if {$require_pending} {
+	set test_name "setting pending $what at $function"
+    } else {
+	set test_name "setting $what at $function"
+    }
 
     send_gdb "$break_command $function\n"
     # The first two regexps are what we get with -g, the third is without -g.
     gdb_expect 30 {
-	-re "$break_message \[0-9\]* at .*: file .*, line $decimal.\r\n$gdb_prompt $" {}
-	-re "$break_message \[0-9\]*: file .*, line $decimal.\r\n$gdb_prompt $" {}
-	-re "$break_message \[0-9\]* at .*$gdb_prompt $" {}
+	-re "$break_message \[0-9\]* at .*: file .*, line $decimal.\r\n$gdb_prompt $" {
+	    if {$require_pending} {
+		fail "$test_name (expected pending)"
+		return 0
+	    }
+	}
+	-re "$break_message \[0-9\]*: file .*, line $decimal.\r\n$gdb_prompt $" {
+	    if {$require_pending} {
+		fail "$test_name (expected pending)"
+		return 0
+	    }
+	}
+	-re "$break_message \[0-9\]* at .*$gdb_prompt $" {
+	    if {$require_pending} {
+		fail "$test_name (expected pending)"
+		return 0
+	    }
+	}
 	-re "$break_message \[0-9\]* \\(.*\\) pending.*$gdb_prompt $" {
 		if {$pending_response == "n"} {
 			if { $print_fail } {
@@ -392,7 +419,7 @@ proc gdb_breakpoint { function args } {
 			return 0
 		}
 	}
-	-re "Make breakpoint pending.*y or \\\[n\\\]. $" { 
+	-re "Make $what pending.*y or \\\[n\\\]. $" {
 		send_gdb "$pending_response\n"
 		exp_continue
 	}
diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp
index 68322f5..a185534 100644
--- a/gdb/testsuite/gdb.base/pending.exp
+++ b/gdb/testsuite/gdb.base/pending.exp
@@ -49,16 +49,14 @@ gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 
-gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
-     -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
-	    gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint (without symbols)"
-     }
-}
+with_test_prefix "without symbols" {
+    gdb_breakpoint "pendfunc1" pending message
 
-gdb_test "info break" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
+    gdb_test "info break" \
+	"Num     Type\[ \]+Disp Enb Address\[ \]+What.*
 \[0-9\]+\[\t \]+breakpoint     keep y.*PENDING.*pendfunc1.*" \
-"single pending breakpoint info (without symbols)"
+	"single pending breakpoint info"
+}
 
 gdb_load ${binfile}
 gdb_load_shlibs $lib_sl
@@ -84,11 +82,7 @@ gdb_load_shlibs $lib_sl
 # Test setting, querying, and modifying pending breakpoints
 #
 
-gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
-     -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
-	    gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint"
-     }
-}
+gdb_breakpoint "pendfunc1" pending message
 
 gdb_test "info break" \
     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
@@ -166,12 +160,7 @@ gdb_test "info break" \
 #
 
 set bp2_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
-gdb_test_multiple "break pendshr.c:$bp2_loc if x > 3" "Set pending breakpoint 2" {
-     -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
-	    gdb_test "y" "Breakpoint.*pendshr.c:$bp2_loc.*pending." \
-		"Set pending breakpoint 2"
-     }
-}
+gdb_breakpoint "pendshr.c:$bp2_loc if x > 3" pending message
 
 gdb_test "info break" \
     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
@@ -188,12 +177,7 @@ gdb_test "info break" \
 #
 
 set bp3_loc [gdb_get_line_number "printf" ${libfile}.c]
-gdb_test_multiple "break pendshr.c:$bp3_loc" "Set pending breakpoint 3" {
-     -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
-	    gdb_test "y" "Breakpoint.*pendshr.c:$bp3_loc.*pending." \
-		"Set pending breakpoint 3"
-     }
-}
+gdb_breakpoint "pendshr.c:$bp3_loc" pending message
 
 gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \
     "set ignore count on pending breakpoint 3"
@@ -257,12 +241,7 @@ gdb_breakpoint "main"
 #
 # Set non-existent pending breakpoint
 #
-gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" {
-     -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
-	    gdb_test "y" "Breakpoint.*imaginary.*pending." \
-		"set imaginary pending breakpoint"
-     }
-}
+gdb_breakpoint "imaginary" pending message
 
 #
 # rerun program and make sure that any pending breakpoint remains and no
diff --git a/gdb/testsuite/gdb.base/watchpoint-solib.exp b/gdb/testsuite/gdb.base/watchpoint-solib.exp
index a1a4485..44e12c8 100644
--- a/gdb/testsuite/gdb.base/watchpoint-solib.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-solib.exp
@@ -64,11 +64,7 @@ if [target_info exists gdb,no_hardware_watchpoints] {
 # Test that if we set a watchpoint on a global variable
 # in a explicitly loaded shared library, and then
 # re-run the application, gdb does not crash.
-gdb_test_multiple "break foo" "set pending breakpoint" {
-     -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
-	    gdb_test "y" "Breakpoint.*foo.*pending." "set pending breakpoint"
-     }
-}
+gdb_breakpoint "foo" pending
 
 set prev_timeout $timeout
 set timeout 120

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]