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]

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


On 04/29/2013 10:47 AM, Pedro Alves wrote:
On 04/26/2013 09:45 PM, Keith Seitz wrote:
but, w/ current mainline:

   $ ./gdb ~/gdb/tests/main
   (gdb) tbreak foo
   Function "foo" not defined.
   Make breakpoint pending on future shared library load? (y or [n]) n
        ^^^^^^^^^^

Not "Make temporary breakpoint pending".

I've addressed that in this revision.


Shouldn't these fails be wrapped in $print_fail checks?

Yes, they should! Also addressed in this next revision.

+gdb_breakpoint "pendshr.c:$bp2_loc if x > 3" pending message

This made me notice that the gdb_breakpoint API has another
weird aspect WRT test messages.  It doesn't allow passing in a custom
fail/pass message text at all.  So in this case, we'll now print the
line number ($bp2_loc) as part of the test message.  We tend to avoid
it for the fact that line numbers aren't that stable over time.
Just noting it.  I don't think this patch should be held for this.

I'm going to add something to my TODO list to address this issue. I'll discuss this more in the next message.

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..827295b 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,8 +359,15 @@ 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"
+    set type "breakpoint"
     if {[lsearch -exact $args temporary] != -1} {
 	set break_command "tbreak"
 	set break_message "Temporary breakpoint"
@@ -376,14 +384,39 @@ proc gdb_breakpoint { function args } {
 	set print_pass 1
     }
 
-    set test_name "setting breakpoint at $function"
+    if {$require_pending} {
+	set test_name "setting pending $type at $function"
+    } else {
+	set test_name "setting $type 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} {
+		if {$print_fail} {
+		    fail "$test_name (expected pending)"
+		}
+		return 0
+	    }
+	}
+	-re "$break_message \[0-9\]*: file .*, line $decimal.\r\n$gdb_prompt $" {
+	    if {$require_pending} {
+		if {$print_fail} {
+		    fail "$test_name (expected pending)"
+		}
+		return 0
+	    }
+	}
+	-re "$break_message \[0-9\]* at .*$gdb_prompt $" {
+	    if {$require_pending} {
+		if {$print_fail} {
+		    fail "$test_name (expected pending)"
+		}
+		return 0
+	    }
+	}
 	-re "$break_message \[0-9\]* \\(.*\\) pending.*$gdb_prompt $" {
 		if {$pending_response == "n"} {
 			if { $print_fail } {
@@ -392,7 +425,7 @@ proc gdb_breakpoint { function args } {
 			return 0
 		}
 	}
-	-re "Make breakpoint pending.*y or \\\[n\\\]. $" { 
+	-re "Make $type 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]