This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA/testsuite] Cleanup pending breakpoints
- From: Keith Seitz <keiths at redhat dot com>
- To: "gdb-patches at sourceware dot org ml" <gdb-patches at sourceware dot org>
- Date: Tue, 23 Apr 2013 16:18:13 -0700
- Subject: [RFA/testsuite] Cleanup pending breakpoints
Hi,
Some types of pending breakpoints are commonly set by using
gdb_test_multiple to respond to the "Make breakpoint pending?" question.
This patch adds support for several breakpoint types to gdb_breakpoint
so that the standard machinery can be used instead.
I've also taken this opportunity to update the neglected documentation
for gdb_breakpoint. AFAICT, "passfail" just appeared out of nowhere, and
it has never been implemented/documented.
Comments/questions?
Keith
testsuite/ChangeLog
2013-04-23 Keith Seitz <keiths@redhat.com>
* lib/gdb.exp (gdb_breakpoint): Add support for dprintf,
trace, and ftrace.
* gdb.base/dprintf-pending.exp: Use gdb_breakpoint to
set all breakpoints/dprintfs/tracepoints/fast tracepoints.
* gdb.base/dprintf.exp: Likewise.
* gdb.base/pending.exp: Likewise.
* gdb.base/watchpoint-solib.exp: Likewise.
* gdb.trace/change-loc.exp (tracepoint_change_loc_2): Likewise.
Remove expected output to delete breakpoint; use
"delete $bpnum" instead.
* gdb.trace/pending.exp (pending_tracepoint_resolved): Use
gdb_breakpoint to set tracepoints.
(pending_tracepoint_works): Likewise.
(pending_tracepoint_resolved_during_trace): Likewise.
(pending_tracepoint_installed_during_trace): Likewise.
(pending_tracepoint_disconnect_during_trace): Likewise.
(pending_tracepoint_disconnect_after_resolved): Likewise.
(pending_tracepoint_with_action_resolved): Likewise.
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 06e1226..34392ab 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -335,15 +335,21 @@ proc gdb_start_cmd {args} {
}
# Set a breakpoint at FUNCTION. If there is an additional argument it is
-# a list of options; the supported options are allow-pending, temporary,
-# message, no-message, and passfail.
+# a list of options; the supported options are:
+#
+# allow-pending -- permit a pending breakpoint to be set
+# temporary -- set a temporary breakpoint, e.g., "tbreak"
+# message -- print out PASS messages*
+# no-message -- do not print FAIL messages*
+# trace -- set a trace tracepoint, e.g, "trace"
+# ftrace -- set a fast tracepoint, e.g., "ftrace"
+# dprintf -- set a dynamic printf, e.g., "dprintf"
+#
# The result is 1 for success, 0 for failure.
#
-# Note: The handling of message vs no-message is messed up, but it's based
+# *Note: The handling of message vs no-message is messed up, but it's based
# on historical usage. By default this function does not print passes,
# only fails.
-# no-message: turns off printing of fails (and passes, but they're already off)
-# message: turns on printing of passes (and fails, but they're already on)
proc gdb_breakpoint { function args } {
global gdb_prompt
@@ -354,11 +360,21 @@ proc gdb_breakpoint { function args } {
set pending_response y
}
- set break_command "break"
- set break_message "Breakpoint"
- if {[lsearch -exact $args temporary] != -1} {
- set break_command "tbreak"
- set break_message "Temporary breakpoint"
+ if {[lsearch -exact $args "dprintf"] != -1} {
+ set break_command "dprintf"
+ set break_message "Dprintf"
+ } elseif {[lsearch -exact $args "temporary"] != -1} {
+ set break_command "tbreak"
+ set break_message "Temporary breakpoint"
+ } elseif {[lsearch -exact $args "trace"] != -1} {
+ set break_command "trace"
+ set break_message "Tracepoint"
+ } elseif {[lsearch -exact $args "ftrace"] != -1} {
+ set break_command "ftrace"
+ set break_message "Fast tracepoint"
+ } else {
+ set break_command "break"
+ set break_message "Breakpoint"
}
set print_pass 0
@@ -372,7 +388,7 @@ proc gdb_breakpoint { function args } {
set print_pass 1
}
- set test_name "setting breakpoint at $function"
+ set test_name "setting [string tolower $break_message] at $function"
send_gdb "$break_command $function\n"
# The first two regexps are what we get with -g, the third is without -g.
@@ -388,7 +404,7 @@ proc gdb_breakpoint { function args } {
return 0
}
}
- -re "Make breakpoint pending.*y or \\\[n\\\]. $" {
+ -re "Make [string tolower $break_message] pending.*y or \\\[n\\\]. $" {
send_gdb "$pending_response\n"
exp_continue
}
diff --git a/gdb/testsuite/gdb.base/dprintf-pending.exp b/gdb/testsuite/gdb.base/dprintf-pending.exp
index 87abfce..dd9e525 100644
--- a/gdb/testsuite/gdb.base/dprintf-pending.exp
+++ b/gdb/testsuite/gdb.base/dprintf-pending.exp
@@ -41,12 +41,7 @@ with_test_prefix "without format" {
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
- gdb_test \
- "dprintf pendfunc" \
- "Dprintf.*pendfunc.*pending." \
- "set pending dprintf" \
- ".*Make dprintf pending.*y or \\\[n\\\]. $" \
- "y"
+ gdb_breakpoint "pendfunc" dprintf allow-pending
gdb_test "file ${binfile}" ".*Error in re-setting breakpoint.*" "resolved dprintf fails to be re-set"
}
@@ -56,12 +51,7 @@ with_test_prefix "without symbols" {
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
- gdb_test \
- "dprintf pendfunc1, \"x=%d\\n\", x" \
- "Dprintf.*pendfunc1.*pending." \
- "set pending dprintf" \
- ".*Make dprintf pending.*y or \\\[n\\\]. $" \
- "y"
+ gdb_breakpoint "pendfunc1, \"x=%d\\n\", x" dprintf allow-pending
gdb_test "info break" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
@@ -83,12 +73,7 @@ gdb_load_shlibs $lib_sl
# Test setting, querying, and modifying pending breakpoints
#
-gdb_test \
- "dprintf pendfunc1, \"x=%d\\n\", x" \
- "Dprintf.*pendfunc1.*pending." \
- "set pending dprintf" \
- ".*Make dprintf pending.*y or \\\[n\\\]. $" \
- "y"
+gdb_breakpoint "pendfunc1, \"x=%d\\n\", x" dprintf allow-pending
gdb_test "info break" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
diff --git a/gdb/testsuite/gdb.base/dprintf.exp b/gdb/testsuite/gdb.base/dprintf.exp
index 71f3554..cbec5c4 100644
--- a/gdb/testsuite/gdb.base/dprintf.exp
+++ b/gdb/testsuite/gdb.base/dprintf.exp
@@ -37,13 +37,11 @@ delete_breakpoints
gdb_breakpoint "main"
-gdb_test "dprintf foo,\"At foo entry\\n\"" \
- "Dprintf .*"
+gdb_breakpoint "foo,\"At foo entry\\n\"" dprintf
gdb_test "ignore \$bpnum 1" ".*Will ignore next crossing of breakpoint.*"
-gdb_test "dprintf $dp_location1,\"arg=%d, g=%d\\n\", arg, g" \
- "Dprintf .*"
+gdb_breakpoint "$dp_location1,\"arg=%d, g=%d\\n\", arg, g" dprintf
gdb_test_sequence "info breakpoints" "dprintf info 1" {
"\[\r\n\]Num Type Disp Enb Address +What"
@@ -56,8 +54,7 @@ gdb_test_sequence "info breakpoints" "dprintf info 1" {
"\[\r\n\] continue"
}
-gdb_test "break $bp_location1" \
- "Breakpoint .*"
+gdb_breakpoint "$bp_location1"
gdb_run_cmd
diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp
index 68322f5..ca84346 100644
--- a/gdb/testsuite/gdb.base/pending.exp
+++ b/gdb/testsuite/gdb.base/pending.exp
@@ -49,11 +49,7 @@ 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)"
- }
-}
+gdb_breakpoint "pendfunc1" allow-pending
gdb_test "info break" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
@@ -84,11 +80,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" allow-pending
gdb_test "info break" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
@@ -166,12 +158,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" allow-pending
gdb_test "info break" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
@@ -188,12 +175,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" allow-pending
gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \
"set ignore count on pending breakpoint 3"
@@ -257,12 +239,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" allow-pending
#
# 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..b87956d 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" allow-pending
set prev_timeout $timeout
set timeout 120
diff --git a/gdb/testsuite/gdb.trace/change-loc.exp b/gdb/testsuite/gdb.trace/change-loc.exp
index 3a79b10..e55254c 100644
--- a/gdb/testsuite/gdb.trace/change-loc.exp
+++ b/gdb/testsuite/gdb.trace/change-loc.exp
@@ -187,11 +187,7 @@ proc tracepoint_change_loc_2 { trace_type } {
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
- gdb_test_multiple "${trace_type} set_tracepoint" "set pending tracepoint" {
- -re ".*Make \(|fast \)tracepoint pending.*y or \\\[n\\\]. $" {
- gdb_test "y" "\(Fast t|T\)racepoint.*set_tracepoint.*pending." "set pending tracepoint"
- }
- }
+ gdb_breakpoint "set_tracepoint" $trace_type allow-pending
gdb_trace_setactions "set action for tracepoint" "" \
"collect \$$pcreg" "^$"
@@ -210,18 +206,13 @@ proc tracepoint_change_loc_2 { trace_type } {
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*func4.*" \
"tracepoint with one location"
- set main_bp 0
- gdb_test_multiple "break main" "set breakpoint on main" {
- -re "Breakpoint (\[0-9\]*) at .*, line.*$gdb_prompt $" {
- set main_bp $expect_out(1,string)
- }
- }
+ gdb_breakpoint "main"
gdb_run_cmd
gdb_test "" \
".*Breakpoint.*main.*at.*$srcfile.*" \
"run to main"
- gdb_test_no_output "delete break $main_bp"
+ gdb_test_no_output "delete break \$bpnum"
# tracepoint has two locations after shlib change-loc-1 is loaded.
gdb_test "info trace" \
diff --git a/gdb/testsuite/gdb.trace/pending.exp b/gdb/testsuite/gdb.trace/pending.exp
index 0308e13..87a2ae0 100644
--- a/gdb/testsuite/gdb.trace/pending.exp
+++ b/gdb/testsuite/gdb.trace/pending.exp
@@ -71,12 +71,7 @@ proc pending_tracepoint_resolved { trace_type } {
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
- gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" {
- -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
- gdb_test "y" "\(Fast t|T\)racepoint.*set_point1.*pending." \
- "set pending tracepoint (without symbols)"
- }
- }
+ gdb_breakpoint "set_point1" $trace_type allow-pending
gdb_test "info trace" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
@@ -113,13 +108,7 @@ proc pending_tracepoint_works { trace_type } {
# Test setting and querying pending tracepoints
- gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" {
- -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
- gdb_test "y" \
- "\(Fast t|T\)racepoint.*set_point1.*pending." \
- "set pending tracepoint"
- }
- }
+ gdb_breakpoint "set_point1" $trace_type allow-pending
gdb_test "info trace" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
@@ -187,12 +176,7 @@ proc pending_tracepoint_resolved_during_trace { trace_type } \
return -1
}
- gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" {
- -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
- gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
- "set pending tracepoint (without symbols)"
- }
- }
+ gdb_breakpoint "set_point2" $trace_type allow-pending
gdb_test "info trace" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
@@ -268,12 +252,7 @@ proc pending_tracepoint_installed_during_trace { trace_type } \
"continue to marker 1"
# Set a pending tracepoint during a tracing experiment.
- gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" {
- -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
- gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
- "set pending tracepoint"
- }
- }
+ gdb_breakpoint "set_point2" $trace_type allow-pending
gdb_test "info trace" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
@@ -329,12 +308,7 @@ proc pending_tracepoint_disconnect_during_trace { trace_type } \
return -1
}
- gdb_test_multiple "trace pendfunc3" "set pending tracepoint on set_point2" {
- -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
- gdb_test "y" "\(Fast t|T\)racepoint.*pendfunc3.*pending." \
- "set pending tracepoint on pendfun3"
- }
- }
+ gdb_breakpoint "pendfunc3" trace allow-pending
gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
"breakpoint on marker"
@@ -377,12 +351,7 @@ proc pending_tracepoint_disconnect_after_resolved { trace_type } \
return -1
}
- gdb_test_multiple "trace set_point2" "set pending tracepoint on set_point2" {
- -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
- gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
- "set pending tracepoint on pendfun2"
- }
- }
+ gdb_breakpoint "set_point2" trace allow-pending
gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
"breakpoint on marker"
@@ -429,12 +398,7 @@ proc pending_tracepoint_with_action_resolved { trace_type } \
return -1
}
- gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" {
- -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
- gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
- "set pending tracepoint (without symbols)"
- }
- }
+ gdb_breakpoint "set_point2" $trace_type allow-pending
set pcreg "pc"
if [is_amd64_regs_target] {