This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA 4/5] Explicit linespecs - tests
- From: Keith Seitz <keiths at redhat dot com>
- To: "gdb-patches at sourceware dot org ml" <gdb-patches at sourceware dot org>
- Date: Thu, 26 Jul 2012 20:49:17 -0700
- Subject: [RFA 4/5] Explicit linespecs - tests
Hi,
This patch simply adds all the tests that I've been using while
developing this feature.
For MI, I had to add some minor support for conditions to
mi_create_breakpoint. [I will adapt Marc's recent conditional breakpoint
patch to use this, once accepted.]
Questions/comments/concerns?
Keith
testsuite/ChangeLog
2012-07-24 Keith Seitz <keiths@redhat.com>
* lib/mi-support.exp (mi_create_breakpoint): Add support
for conditions.
* gdb.linespec/ls-errs.exp: Add explicit linespec tests.
* gdb.linespec/explicit.exp: New tests for explicit linespecs.
* gdb.linespec/cpexplicit.exp: Likewise.
* gdb.linespec/explicit.c: New file.
* gdb.linespec/cpexplicit.cc: New file.
* gdb.mi/mi-cmd-break.exp: Add explicit linespec tests.
diff --git a/gdb/testsuite/gdb.linespec/cpexplicit.cc b/gdb/testsuite/gdb.linespec/cpexplicit.cc
new file mode 100644
index 0000000..77a3c8c
--- /dev/null
+++ b/gdb/testsuite/gdb.linespec/cpexplicit.cc
@@ -0,0 +1,57 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2012 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+class myclass
+{
+public:
+ static int myfunction (int arg) /* entry location */
+ {
+ int i, j, r;
+
+ j = 0; /* myfunction location */
+ r = arg;
+
+ top:
+ ++j; /* top location */
+
+ if (j == 10)
+ goto done;
+
+ for (i = 0; i < 10; ++i)
+ {
+ r += i;
+ if (j % 2)
+ goto top;
+ }
+
+ done:
+ return r;
+ }
+};
+
+int
+main (void)
+{
+ int i, j;
+
+ /* Call the test function repeatedly, enough times for all our tests
+ without running forever if something goes wrong. */
+ for (i = 0, j = 0; i < 1000; ++i)
+ j += myclass::myfunction (0);
+
+ return j;
+}
diff --git a/gdb/testsuite/gdb.linespec/cpexplicit.exp b/gdb/testsuite/gdb.linespec/cpexplicit.exp
new file mode 100644
index 0000000..6678f08
--- /dev/null
+++ b/gdb/testsuite/gdb.linespec/cpexplicit.exp
@@ -0,0 +1,94 @@
+# Copyright 2012 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Tests for explicit linespecs
+
+set base cpexplicit
+set srcfile "$base.cc"
+set testfile "$base.exp"
+set exefile $base
+
+if {[skip_cplus_tests]} {
+ unsupported "skipping C++ tests"
+ return
+}
+
+if {[prepare_for_testing $testfile $exefile $srcfile \
+ {c++ debug nowarnings}]} {
+ return -1
+}
+
+# Test the given (explicit) LINESPEC which should cause gdb to break
+# at LOCATION.
+proc test_breakpoint {linespec location} {
+
+ # Delete all breakpoints, set a new breakpoint at LINESPEC,
+ # and attempt to run to it.
+ delete_breakpoints
+ gdb_breakpoint $linespec
+ gdb_continue_to_breakpoint $linespec $location
+}
+
+# Add the given LINESPEC to the array named in THEARRAY. GDB is expected
+# to stop at LOCATION.
+proc add {thearray linespec location} {
+ upvar $thearray ar
+
+ lappend ar(linespecs) $linespec
+ lappend ar(locations) $location
+}
+
+# Make sure variables are not already in use
+unset -nocomplain lineno location linespecs
+
+# Some locations used in this test
+set lineno(normal) [gdb_get_line_number "myfunction location" $srcfile]
+set lineno(entry) [gdb_get_line_number "entry location" $srcfile]
+set lineno(top) [gdb_get_line_number "top location" $srcfile]
+foreach v [array names lineno] {
+ set location($v) ".*[string_to_regexp "$srcfile:$lineno($v)"].*"
+}
+
+# A list of explicit linespecs and the corresponding location
+set linespecs(linespecs) {}
+set linespecs(location) {}
+
+add linespecs "-source $srcfile -function myclass::myfunction" $location(normal)
+add linespecs "-source $srcfile -function myclass::myfunction -label top" \
+ $location(top)
+
+# This isn't implemented yet; -offset is silently ignored.
+add linespecs "-source $srcfile -function myclass::myfunction -label top -offset 3" \
+ $location(top)
+add linespecs "-source $srcfile -offset $lineno(top)" $location(top)
+add linespecs "-function myclass::myfunction" $location(normal)
+add linespecs "-function myclass::myfunction -label top" $location(top)
+
+# These are also not yet supported; -offset is silently ignored.
+add linespecs "-function myclass::myfunction -offset 3" $location(normal)
+add linespecs "-function myclass::myfunction -label top -offset 3" $location(top)
+add linespecs "-offset 3" $location(normal)
+add linespecs "-address myclass::myfunction" $location(entry)
+
+# Fire up gdb.
+if {![runto_main]} {
+ return -1
+}
+
+# Test explicit linespecs, with and without conditions.
+foreach linespec $linespecs(linespecs) loc_pattern $linespecs(locations) {
+ # Test the linespec
+ test_breakpoint $linespec $loc_pattern
+}
diff --git a/gdb/testsuite/gdb.linespec/explicit.c b/gdb/testsuite/gdb.linespec/explicit.c
new file mode 100644
index 0000000..5e2c20d
--- /dev/null
+++ b/gdb/testsuite/gdb.linespec/explicit.c
@@ -0,0 +1,54 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2012 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+static int
+myfunction (int arg)
+{
+ int i, j, r;
+
+ j = 0; /* myfunction location */
+ r = arg;
+
+ top:
+ ++j; /* top location */
+
+ if (j == 10)
+ goto done;
+
+ for (i = 0; i < 10; ++i)
+ {
+ r += i;
+ if (j % 2)
+ goto top;
+ }
+
+ done:
+ return r;
+}
+
+int
+main (void)
+{
+ int i, j;
+
+ /* Call the test function repeatedly, enough times for all our tests
+ without running forever if something goes wrong. */
+ for (i = 0, j = 0; i < 1000; ++i)
+ j += myfunction (0);
+
+ return j;
+}
diff --git a/gdb/testsuite/gdb.linespec/explicit.exp b/gdb/testsuite/gdb.linespec/explicit.exp
new file mode 100644
index 0000000..bf06910
--- /dev/null
+++ b/gdb/testsuite/gdb.linespec/explicit.exp
@@ -0,0 +1,200 @@
+# Copyright 2012 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Tests for explicit linespecs
+
+set base explicit
+set srcfile "$base.c"
+set testfile "$base.exp"
+set exefile $base
+
+if {[prepare_for_testing $testfile $exefile $srcfile \
+ {debug nowarnings}]} {
+ return -1
+}
+
+# Test the given (explicit) LINESPEC which should cause gdb to break
+# at LOCATION.
+proc test_breakpoint {linespec location} {
+
+ set testname "set breakpoint at \"$linespec\""
+ # Delete all breakpoints, set a new breakpoint at LINESPEC,
+ # and attempt to run to it.
+ delete_breakpoints
+ if {[gdb_breakpoint $linespec]} {
+ pass $testname
+ send_log "\nexpecting locpattern \"$location\"\n"
+ gdb_continue_to_breakpoint $linespec $location
+ } else {
+ fail $testname
+ }
+}
+
+# Add the given LINESPEC to the array named in THEARRAY. GDB is expected
+# to stop at LOCATION.
+proc add {thearray linespec location} {
+ upvar $thearray ar
+
+ lappend ar(linespecs) $linespec
+ lappend ar(locations) $location
+}
+
+# Make sure variables are not already in use
+unset -nocomplain all_arguments lineno location linespecs
+
+# A list of all explicit linespec arguments.
+set all_arguments {"source" "function" "label" "offset" "address"}
+
+# Some locations used in this test
+set lineno(normal) [gdb_get_line_number "myfunction location" $srcfile]
+set lineno(top) [gdb_get_line_number "top location" $srcfile]
+foreach v [array names lineno] {
+ set location($v) ".*[string_to_regexp "$srcfile:$lineno($v)"].*"
+}
+
+# A list of explicit linespecs and the corresponding location.
+set linespecs(linespecs) {}
+set linespecs(location) {}
+
+add linespecs "-source $srcfile -function myfunction" $location(normal)
+add linespecs "-source $srcfile -function myfunction -label top" \
+ $location(top)
+
+# This isn't implemented yet; -offset is silently ignored.
+add linespecs "-source $srcfile -function myfunction -label top -offset 3" \
+ $location(top)
+add linespecs "-source $srcfile -offset $lineno(top)" $location(top)
+add linespecs "-function myfunction" $location(normal)
+add linespecs "-function myfunction -label top" $location(top)
+
+# These are also not yet supported; -offset is silently ignored.
+add linespecs "-function myfunction -offset 3" $location(normal)
+add linespecs "-function myfunction -label top -offset 3" $location(top)
+add linespecs "-offset 3" $location(normal)
+add linespecs "-address myfunction" ".*"
+
+# Fire up gdb.
+if {![runto_main]} {
+ return -1
+}
+
+# Simple error tests (many more are tested in ls-err.exp)
+foreach arg $all_arguments {
+ # Test missing argument
+ gdb_test "break -$arg" [string_to_regexp "missing argument for \"-$arg\""]
+
+ # Test abbreviations
+ set short [string range $arg 0 3]
+ gdb_test "break -$short" \
+ [string_to_regexp "missing argument for \"-$short\""]
+}
+
+# Test invalid arguments
+foreach arg {"-foo" "-foo bar" "-function myfunction -foo" \
+ "-function -myfunction -foo bar"} {
+ gdb_test "break $arg" \
+ [string_to_regexp "invalid linespec argument, \"-foo\""]
+}
+
+# Test explicit linespecs, with and without conditions.
+foreach linespec $linespecs(linespecs) loc_pattern $linespecs(locations) {
+
+ # Test the linespec
+ test_breakpoint $linespec $loc_pattern
+
+ # Test with a valid condition
+ delete_breakpoints
+ set tst "set breakpoint at \"$linespec\" with valid condition"
+ if {[gdb_breakpoint "$linespec if arg == 0"]} {
+ pass $tst
+
+ gdb_test "info break" ".*stop only if arg == 0.*" \
+ "info break of conditional breakpoint at \"$linespec\""
+ } else {
+ fail $tst
+ }
+
+ # Test with invalid condition
+ gdb_test "break $linespec if foofoofoo == 1" \
+ ".*No symbol \"foofoofoo\" in current context.*" \
+ "set breakpoint at \"$linespec\" with invalid condition"
+
+ # Test with thread
+ delete_breakpoints
+ gdb_test "break $linespec thread 123" "Unknown thread 123."
+}
+
+# Test pending explicit breakpoints
+gdb_exit
+gdb_start
+
+set tst "pending invalid conditional explicit breakpoint"
+if {![gdb_breakpoint "-func myfunction if foofoofoo == 1" \
+ allow-pending]} {
+ fail "set $tst"
+} else {
+ gdb_test "info break" ".*PENDING.*myfunction if foofoofoo == 1.*" $tst
+}
+
+gdb_exit
+gdb_start
+
+set tst "pending valid conditional explicit breakpoint"
+if {![gdb_breakpoint "-func myfunction if arg == 0" \
+ allow-pending]} {
+ fail "set $tst"
+} else {
+ gdb_test "info break" ".*PENDING.*myfunction if arg == 0" $tst
+
+ gdb_load $objdir/$subdir/$exefile
+ gdb_test "info break" \
+ ".*in myfunction at .*$srcfile:.*stop only if arg == 0.*" \
+ "$tst resolved"
+}
+
+
+# Test interaction of condition command and explicit linespec conditons.
+gdb_exit
+gdb_start
+gdb_load $objdir/$subdir/$exefile
+
+set tst "condition_command overrides explicit linespec condition"
+if {![runto main]} {
+ fail $tst
+} else {
+ if {![gdb_breakpoint "-func myfunction if arg == 1"]} {
+ fail "set breakpoint with condition 'arg == 1'"
+ } else {
+ gdb_test_no_output "cond 2 arg == 0" \
+ "set new breakpoint condition for explicit linespec"
+
+ gdb_continue_to_breakpoint $tst $location(normal)
+ }
+}
+
+gdb_test "cond 2" [string_to_regexp "Breakpoint 2 now unconditional."] \
+ "clear condition for explicit breakpoint"
+set tst "info break of cleared condition of explicit breakpoint"
+gdb_test_multiple "info break" $tst {
+ -re ".*in myfunction at .*$srcfile:.*stop only if arg == 0.*" {
+ fail $tst
+ }
+ -re ".*in myfunction at .*$srcfile:.*$gdb_prompt $" {
+ pass $tst
+ }
+}
+
+unset -nocomplain lineno
+
diff --git a/gdb/testsuite/gdb.linespec/ls-errs.exp b/gdb/testsuite/gdb.linespec/ls-errs.exp
index 7db8ae4..e8fae50 100644
--- a/gdb/testsuite/gdb.linespec/ls-errs.exp
+++ b/gdb/testsuite/gdb.linespec/ls-errs.exp
@@ -50,11 +50,14 @@ array set error_messages {
invalid_var_or_func_f \
"Undefined convenience variable or function \"%s\" not defined in \"%s\"."
invalid_label "No label \"%s\" defined in function \"%s\"."
+ invalid_parm "invalid linespec argument, \"%s\""
invalid_offset "No line %d in the current file."
invalid_offset_f "No line %d in file \"%s\"."
+ source_incomplete "Source filename requires function, label, or offset."
unexpected "malformed linespec error: unexpected %s"
unexpected_opt "malformed linespec error: unexpected %s, \"%s\""
unmatched_quote "unmatched quote"
+ garbage "Garbage '%s' at end of command"
}
# Some commonly used whitespace tests around ':'.
@@ -87,6 +90,7 @@ foreach x $invalid_offsets {
incr offset 16
}
add the_tests $x invalid_offset $offset
+ add the_tests "-offset $x" invalid_offset $offset
}
# Test offsets with trailing tokens w/ and w/o spaces.
@@ -98,13 +102,17 @@ foreach x $spaces {
foreach x {1 +1 +100 -10} {
add the_tests "3 $x" unexpected_opt "number" $x
+ add the_tests "-offset 3 $x" garbage $x
add the_tests "+10 $x" unexpected_opt "number" $x
+ add the_tests "-offset +10 $x" garbage $x
add the_tests "-10 $x" unexpected_opt "number" $x
+ add the_tests "-offset -10 $x" garbage $x
}
-add the_tests "3 foo" unexpected_opt "string" "foo"
-add the_tests "+10 foo" unexpected_opt "string" "foo"
-add the_tests "-10 foo" unexpected_opt "string" "foo"
+foreach x {3 +10 -10} {
+ add the_tests "$x foo" unexpected_opt "string" "foo"
+ add the_tests "-offset $x foo" garbage "foo"
+}
# Test invalid linespecs starting with filename.
foreach x [list "this_file_doesn't_exist.c" \
@@ -120,6 +128,13 @@ foreach x [list "this_file_doesn't_exist.c" \
# Remove any quoting from FILENAME for the error message.
add the_tests "$x:3" invalid_file [string trim $x \"']
}
+foreach x [list "this_file_doesn't_exist.c" \
+ "this file has spaces.c" \
+ "file::colons.c" \
+ "'file::colons.c'"] {
+ add the_tests "-source $x -offset 3" \
+ invalid_file [string trim $x \"']
+}
# Test unmatched quotes.
foreach x {"\"src-file.c'" "'src-file.c"} {
@@ -130,7 +145,11 @@ add the_tests $srcfile invalid_function $srcfile
foreach x {"foo" " foo" " foo "} {
# Trim any leading/trailing whitespace for error messages.
add the_tests "$srcfile:$x" invalid_function_f [string trim $x] $srcfile
+ add the_tests "-source $srcfile -function $x" \
+ invalid_function_f [string trim $x] $srcfile
add the_tests "$srcfile:main:$x" invalid_label [string trim $x] "main"
+ add the_tests "-source $srcfile -function main -label $x" \
+ invalid_label [string trim $x] "main"
}
foreach x $spaces {
@@ -140,18 +159,25 @@ foreach x $spaces {
add the_tests "${srcfile}::" invalid_function "${srcfile}::"
add the_tests "$srcfile:3 1" unexpected_opt "number" "1"
+add the_tests "-source $srcfile -offset 3 1" garbage "1"
add the_tests "$srcfile:3 +100" unexpected_opt "number" "+100"
+add the_tests "-source $srcfile -offset 3 +100" garbage "+100"
add the_tests "$srcfile:3 -100" unexpected_opt "number" "-100"
+add the_tests "-source $srcfile -offset 3 -100" garbage "-100"
add the_tests "$srcfile:3 foo" unexpected_opt "string" "foo"
+add the_tests "-source $srcfile -offset 3 foo" garbage "foo"
foreach x $invalid_offsets {
add the_tests "$srcfile:$x" invalid_offset_f $x $srcfile
+ add the_tests "-source $srcfile -offset $x" invalid_offset_f \
+ $x $srcfile
}
# Test invalid filespecs starting with function.
foreach x {"foobar" "foo::bar" "foo.bar" "foo ." "foo bar" "foo 1" \
"foo 0" "foo +10" "foo -10" "foo +100" "foo -100"} {
add the_tests $x invalid_function $x
+ add the_tests "-function \"$x\"" invalid_function $x
}
foreach x $spaces {
@@ -159,13 +185,12 @@ foreach x $spaces {
add the_tests "main:here${x}" unexpected "end of input"
}
-add the_tests "main 3" invalid_function "main 3"
-add the_tests "main +100" invalid_function "main +100"
-add the_tests "main -100" invalid_function "main -100"
-add the_tests "main foo" invalid_function "main foo"
-
foreach x {"3" "+100" "-100" "foo"} {
+ add the_tests "main $x" invalid_function "main $x"
+ add the_tests "-function \"main $x\"" invalid_function "main $x"
add the_tests "main:here $x" invalid_label "here $x" "main"
+ add the_tests "-function main -label \"here $x\"" \
+ invalid_label "here $x" "main"
}
foreach x {"if" "task" "thread"} {
@@ -183,6 +208,9 @@ set x {$zippo}
add the_tests $x invalid_var_or_func $x
add the_tests "$srcfile:$x" invalid_var_or_func_f $x $srcfile
+# Explicit linespec specific tests
+add the_tests "-source $srcfile" source_incomplete
+
# Run the tests
foreach linespec $the_tests(linespecs) {
gdb_test "break $linespec" $the_tests("$linespec")
diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp
index 573f484..cb4f4a2 100644
--- a/gdb/testsuite/gdb.mi/mi-break.exp
+++ b/gdb/testsuite/gdb.mi/mi-break.exp
@@ -245,6 +245,88 @@ proc test_breakpoint_commands {} {
mi_expect_stop "exited-normally" "" "" "" "" "" "test hitting breakpoint with commands"
}
+# Test explicit breakpoints. These tests only test the MI portion of the
+# code. In-depth testing of explicit breakpoints is accomplished in
+# gdb.linespec tests.
+
+proc test_explicit_breakpoints {} {
+ global mi_gdb_prompt
+ global srcfile
+ global hex
+ global line_callee4_head line_callee4_body
+ global line_callee3_head line_callee3_body
+ global line_callee2_head line_callee2_body
+ global line_callee1_head line_callee1_body
+ global line_main_head line_main_body
+ global fullname
+
+ mi_delete_breakpoints
+
+ # First check mixed explicit/parsed linespecs.
+ mi_gdb_test "-break-insert -m main $srcfile:$line_callee3_head" \
+ ".*Garbage following explicit linespec"
+
+ # Insert some breakpoints and list them
+ # Also, disable some so they do not interfere with other tests
+ # Tests:
+ # -break-insert -t -m main
+ # -break-insert -t -s basics.c -m callee2
+ # -break-insert -t -s basics.c -o $line_callee3_head
+ # -break-insert -t -s srcfile -o $line_callee4_head
+ # -break-list
+
+ mi_create_breakpoint "-t -m main" 10 del main ".*$srcfile" \
+ $line_main_body $hex "insert temp explicit breakpoint at -m main"
+
+ mi_create_breakpoint "-t -s $srcfile -m callee2" 11 del \
+ callee2 ".*$srcfile" $line_callee2_body $hex \
+ "insert temp explicit breakpoint at -s $srcfile -m callee2"
+
+ mi_create_breakpoint "-t -s $srcfile -o $line_callee3_head" \
+ 12 del callee3 ".*$srcfile" $line_callee3_head $hex \
+ "insert temp explicit breakpoint at -s $srcfile -o $line_callee3_head"
+
+ mi_create_breakpoint \
+ "-t -s \"$srcfile\" -o $line_callee4_head" \
+ 13 del callee4 ".*$srcfile" $line_callee4_head $hex \
+ "insert temp explicit breakpoint at -s \"$srcfile\" -o $line_callee4_head"
+
+ mi_gdb_test "-break-list" \
+ "\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"10\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*$srcfile\",${fullname},line=\"$line_main_body\",times=\"0\",original-location=\".*\"\}.*\\\]\}" \
+ "list of explicit breakpoints"
+
+ mi_gdb_test "-break-delete" \
+ "\\^done" \
+ "delete temp breakpoints"
+
+ mi_create_breakpoint "-c \"intarg == 3\" -m callee2" \
+ 14 keep callee2 ".*$srcfile" $line_callee2_body $hex \
+ "insert explicit conditional breakpoint at -f callee2" \
+ "intarg == 3"
+
+ # mi_create_breakpoint cannot deal with displaying canonical
+ # linespecs.
+ mi_gdb_test \
+ "-break-insert -c \"foo == 3\" -s $srcfile -m main -l label" \
+ ".*No symbol \"foo\" in current context.*"
+
+ mi_gdb_test \
+ "-break-insert -s foobar.c -offset 3" \
+ ".*No source file named foobar.c.*"
+
+ mi_gdb_test \
+ "-break-insert -s $srcfile -m foobar" \
+ ".*Function \"foobar\" not defined in \"$srcfile\".*"
+
+ mi_gdb_test \
+ "-break-insert -s $srcfile -m main -label foobar" \
+ ".*No label \"foobar\" defined in function \"main\".*"
+
+ mi_gdb_test \
+ "-break-insert -s $srcfile" \
+ ".*Source filename requires function, label, or offset.*"
+}
+
test_tbreak_creation_and_listing
test_rbreak_creation_and_listing
@@ -256,5 +338,7 @@ test_disabled_creation
test_breakpoint_commands
+test_explicit_breakpoints
+
mi_gdb_exit
return 0
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 9de27dd..170e174 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -1204,11 +1204,14 @@ proc mi0_continue_to { bkptno func args file line test } {
}
# Creates a breakpoint and checks the reported fields are as expected
-proc mi_create_breakpoint { location number disp func file line address test } {
- verbose -log "Expecting: 222\\^done,bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$disp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\"$file\",fullname=\".*\",line=\"$line\",times=\"0\",original-location=\".*\"\}"
- mi_gdb_test "222-break-insert $location" \
- "222\\^done,bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$disp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\"$file\",fullname=\".*\",line=\"$line\",times=\"0\",original-location=\".*\"\}" \
- $test
+proc mi_create_breakpoint { location number disp func file line address test {cond ""} } {
+ set expected "222\\^done,bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$disp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\"$file\",fullname=\".*\",line=\"$line\","
+ if {[string length $cond]} {
+ append expected "cond=\"$cond\","
+ }
+ append expected "times=\"0\",original-location=\".*\"\}"
+ verbose -log "Expecting: $expected"
+ mi_gdb_test "222-break-insert $location" $expected $test
}
proc mi_list_breakpoints { expected test } {