[PATCH] Expand keyword lexing intelligence in the linespec parser.
Joel Brobecker
brobecker@adacore.com
Mon Mar 23 13:31:00 GMT 2015
> gdb/ChangeLog
>
> * breakpoint.c (parse_breakpoint_sals): Use
> linespec_lexer_lex_keyword to ascertain if the user specified
> a NULL location.
> * linespec.c [IF_KEYWORD_INDEX]: Define.
> (linespec_lexer_lex_keyword): Export.
> (struct ls_parser) <keyword_ok>: Remove.
> A keyword is only a keyword if not followed by another keyword.
> (linespec_lexer_lex_one): Remove keyword_ok handling.
> Add comment explaining why the parsing stream is not advanced
> when a keyword is seen.
> (parse_linespec): Remove parser->keyword_ok.
> * linespec.h (linespec_lexer_lex_keyword): Add declaration.
>
> gdb/testsuite/ChangeLog
>
> * gdb.linespec/keywords.c: New file.
> * gdb.linespec/keywords.exp: New file.
LGTM. A few minor comments, but otherwise pre-approved.
> +++ b/gdb/linespec.h
> @@ -152,4 +152,8 @@ extern struct symtabs_and_lines decode_line_with_current_source (char *, int);
>
> extern struct symtabs_and_lines decode_line_with_last_displayed (char *, int);
>
> +/* Does P represent one of the keywords? If so, return
> + the keyword. If not, return NULL. */
> +
> +extern const char *linespec_lexer_lex_keyword (const char *p);
You already have the function documented in linespec.c, so no need
to duplicate it here.
> +gdb_test "break thread 123" "Unknown thread 123\."
I think that "\." should be "\\.", no? Likewise for the expected
output of the remaining tests.
> +gdb_test "break thread foo" "Junk after thread keyword\."
> +gdb_test "break task 123" "Unknown task 123\."
> +gdb_test "break task foo" "Junk after task keyword\."
> +gdb_breakpoint "thread if 0" "message"
> +
> +# These are also NULL locations, but using a subsequent keyword
> +# as the "junk".
> +gdb_test "break thread thread" "Junk after thread keyword\."
> +gdb_test "break thread task" "Junk after thread keyword\."
> +gdb_test "break thread if" "Junk after thread keyword\."
> +gdb_test "break task task" "Junk after task keyword\."
> +gdb_test "break task thread" "Junk after task keyword\."
> +gdb_test "break task if" "Junk after task keyword\."
> +
> +# Test locations containing keyword followed by keyword.
> +gdb_test "break thread thread 123" "Unknown thread 123\."
> +gdb_test "break task task 123" "Unknown task 123\."
> +
> +# Test NULL location with valid conditional containing a keyword.
> +gdb_breakpoint "thread if thread == 0"
> +gdb_breakpoint "task if task == 0"
--
Joel
More information about the Gdb-patches
mailing list