aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.linespec/ls-errs.exp
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2015-08-11 17:09:36 -0700
committerKeith Seitz <keiths@redhat.com>2015-08-11 17:09:36 -0700
commit87f0e7204722a986f79f245eee716f0870832d47 (patch)
tree80936c86b139d303a7139c46ae00b55f89c91f8d /gdb/testsuite/gdb.linespec/ls-errs.exp
parent00e52e5376c7ec604a739e6242e6be36221162d7 (diff)
downloadgdb-87f0e7204722a986f79f245eee716f0870832d47.zip
gdb-87f0e7204722a986f79f245eee716f0870832d47.tar.gz
gdb-87f0e7204722a986f79f245eee716f0870832d47.tar.bz2
Explicit locations: add UI features for CLI
This patch exposes explicit locations to the CLI user. This enables users to "explicitly" specify attributes of the breakpoint location to avoid any ambiguity that might otherwise exist with linespecs. The general syntax of explicit locations is: -source SOURCE_FILENAME -line {+-}LINE -function FUNCTION_NAME -label LABEL_NAME Option names may be abbreviated, e.g., "-s SOURCE_FILENAME -li 3" and users may use the completer with either options or values. gdb/ChangeLog: * completer.c: Include location.h. (enum match_type): New enum. (location_completer): Rename to ... (linespec_completer): ... this. (collect_explicit_location_matches, backup_text_ptr) (explicit_location_completer): New functions. (location_completer): "New" function; handle linespec and explicit location completions. (complete_line_internal): Remove all location completer-specific handling. * linespec.c (linespec_lexer_lex_keyword, is_ada_operator) (find_toplevel_char): Export. (linespec_parse_line_offset): Export. Issue error if STRING is not numerical. (gdb_get_linespec_parser_quote_characters): New function. * linespec.h (linespec_parse_line_offset): Declare. (get_gdb_linespec_parser_quote_characters): Declare. (is_ada_operator): Declare. (find_toplevel_char): Declare. (linespec_lexer_lex_keyword): Declare. * location.c (explicit_to_event_location): New function. (explicit_location_lex_one): New function. (string_to_explicit_location): New function. (string_to_event_location): Handle explicit locations. * location.h (explicit_to_event_location): Declare. (string_to_explicit_location): Declare. gdb/testsuite/ChangeLog: * gdb.linespec/3explicit.c: New file. * gdb.linespec/cpexplicit.cc: New file. * gdb.linespec/cpexplicit.exp: New file. * gdb.linespec/explicit.c: New file. * gdb.linespec/explicit.exp: New file. * gdb.linespec/explicit2.c: New file. * gdb.linespec/ls-errs.exp: Add explicit location tests. * lib/gdb.exp (capture_command_output): Regexp-escape `command' before using in the matching pattern. Clarify that `prefix' is a regular expression.
Diffstat (limited to 'gdb/testsuite/gdb.linespec/ls-errs.exp')
-rw-r--r--gdb/testsuite/gdb.linespec/ls-errs.exp57
1 files changed, 49 insertions, 8 deletions
diff --git a/gdb/testsuite/gdb.linespec/ls-errs.exp b/gdb/testsuite/gdb.linespec/ls-errs.exp
index 019312c..9b30720 100644
--- a/gdb/testsuite/gdb.linespec/ls-errs.exp
+++ b/gdb/testsuite/gdb.linespec/ls-errs.exp
@@ -49,11 +49,16 @@ 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\"."
+ malformed_line_offset "malformed line offset: \"%s\""
+ source_incomplete \
+ "Source filename requires function, label, or line 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 ':'.
@@ -80,6 +85,7 @@ foreach x $invalid_offsets {
incr offset 16
}
test_break $x invalid_offset $offset
+ test_break "-line $x" invalid_offset $offset
}
# Test offsets with trailing tokens w/ and w/o spaces.
@@ -91,13 +97,17 @@ foreach x $spaces {
foreach x {1 +1 +100 -10} {
test_break "3 $x" unexpected_opt "number" $x
+ test_break "-line 3 $x" garbage $x
test_break "+10 $x" unexpected_opt "number" $x
+ test_break "-line +10 $x" garbage $x
test_break "-10 $x" unexpected_opt "number" $x
+ test_break "-line -10 $x" garbage $x
}
-test_break "3 foo" unexpected_opt "string" "foo"
-test_break "+10 foo" unexpected_opt "string" "foo"
-test_break "-10 foo" unexpected_opt "string" "foo"
+foreach x {3 +10 -10} {
+ test_break "$x foo" unexpected_opt "string" "foo"
+ test_break "-line $x foo" garbage "foo"
+}
# Test invalid linespecs starting with filename.
foreach x [list "this_file_doesn't_exist.c" \
@@ -113,6 +123,25 @@ foreach x [list "this_file_doesn't_exist.c" \
# Remove any quoting from FILENAME for the error message.
test_break "$x:3" invalid_file [string trim $x \"']
}
+foreach x [list "this_file_doesn't_exist.c" \
+ "file::colons.c" \
+ "'file::colons.c'"] {
+ test_break "-source $x -line 3" \
+ invalid_file [string trim $x \"']
+}
+
+# Test that option lexing stops at whitespace boundaries
+test_break "-source this file has spaces.c -line 3" \
+ invalid_file "this"
+
+test_break "-function function whitespace" \
+ invalid_function "function"
+
+test_break "-source $srcfile -function function whitespace" \
+ invalid_function_f "function" $srcfile
+
+test_break "-function main -label label whitespace" \
+ invalid_label "label" "main"
# Test unmatched quotes.
foreach x {"\"src-file.c'" "'src-file.c"} {
@@ -123,7 +152,11 @@ test_break $srcfile invalid_function $srcfile
foreach x {"foo" " foo" " foo "} {
# Trim any leading/trailing whitespace for error messages.
test_break "$srcfile:$x" invalid_function_f [string trim $x] $srcfile
+ test_break "-source $srcfile -function $x" \
+ invalid_function_f [string trim $x] $srcfile
test_break "$srcfile:main:$x" invalid_label [string trim $x] "main"
+ test_break "-source $srcfile -function main -label $x" \
+ invalid_label [string trim $x] "main"
}
foreach x $spaces {
@@ -133,20 +166,26 @@ foreach x $spaces {
test_break "${srcfile}::" invalid_function "${srcfile}::"
test_break "$srcfile:3 1" unexpected_opt "number" "1"
+test_break "-source $srcfile -line 3 1" garbage "1"
test_break "$srcfile:3 +100" unexpected_opt "number" "+100"
+test_break "-source $srcfile -line 3 +100" garbage "+100"
test_break "$srcfile:3 -100" unexpected_opt "number" "-100"
test_break "$srcfile:3 foo" unexpected_opt "string" "foo"
+test_break "-source $srcfile -line 3 foo" garbage "foo"
foreach x $invalid_offsets {
test_break "$srcfile:$x" invalid_offset_f $x $srcfile
test_break "\"$srcfile:$x\"" invalid_offset_f $x $srcfile
test_break "'$srcfile:$x'" invalid_offset_f $x $srcfile
+ test_break "-source $srcfile -line $x" invalid_offset_f $x $srcfile
}
+test_break "-source $srcfile -line -x" malformed_line_offset "-x"
# 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"} {
test_break $x invalid_function $x
+ test_break "-function \"$x\"" invalid_function $x
}
foreach x $spaces {
@@ -155,13 +194,12 @@ foreach x $spaces {
test_break "main:here${x}" unexpected "end of input"
}
-test_break "main 3" invalid_function "main 3"
-test_break "main +100" invalid_function "main +100"
-test_break "main -100" invalid_function "main -100"
-test_break "main foo" invalid_function "main foo"
-
foreach x {"3" "+100" "-100" "foo"} {
+ test_break "main 3" invalid_function "main 3"
+ test_break "-function \"main $x\"" invalid_function "main $x"
test_break "main:here $x" invalid_label "here $x" "main"
+ test_break "-function main -label \"here $x\"" \
+ invalid_label "here $x" "main"
}
foreach x {"if" "task" "thread"} {
@@ -178,3 +216,6 @@ test_break "'main.c'+3" unexpected_opt "number" "+3"
set x {$zippo}
test_break $x invalid_var_or_func $x
test_break "$srcfile:$x" invalid_var_or_func_f $x $srcfile
+
+# Explicit linespec-specific tests
+test_break "-source $srcfile" source_incomplete