From: Doug Evans Date: Thu, 11 Oct 2012 16:57:44 +0000 (+0000) Subject: PR breakpoints/14643. X-Git-Tag: gdb_7_5_1-2012-11-29-release~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=91c287cd8e60d2882e342cb482647a78f87285a6;p=thirdparty%2Fbinutils-gdb.git PR breakpoints/14643. * linespec.c (struct ls_parser): New member keyword_ok. (linespec_lexer_lex_string): Add comment. (linespec_lexer_lex_one): Ignore keywords if it's the wrong place for one. (parse_linespec): Set keyword_ok. testsuite/ * gdb.linespec/ls-errs.exp: Change tests of "b if|task|thread". * gdb.linespec/thread.c: New file. * gdb.linespec/thread.exp: New file. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e9441c35394..921f6be4c67 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2012-10-11 Doug Evans + + PR breakpoints/14643. + * linespec.c (struct ls_parser): New member keyword_ok. + (linespec_lexer_lex_string): Add comment. + (linespec_lexer_lex_one): Ignore keywords if it's the wrong place + for one. + (parse_linespec): Set keyword_ok. + 2012-10-06 Jan Kratochvil Fix crash during stepping on ppc32. diff --git a/gdb/linespec.c b/gdb/linespec.c index c9b7ecc0093..683299968a5 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -286,6 +286,11 @@ struct ls_parser /* Is the entire linespec quote-enclosed? */ int is_quote_enclosed; + /* Is a keyword syntactically valid at this point? + In, e.g., "break thread thread 1", the leading "keyword" must not + be interpreted as such. */ + int keyword_ok; + /* The state of the parse. */ struct linespec_state state; #define PARSER_STATE(PPTR) (&(PPTR)->state) @@ -607,6 +612,10 @@ linespec_lexer_lex_string (linespec_parser *parser) if (isspace (*PARSER_STREAM (parser))) { p = skip_spaces (PARSER_STREAM (parser)); + /* When we get here we know we've found something followed by + a space (we skip over parens and templates below). + So if we find a keyword now, we know it is a keyword and not, + say, a function name. */ if (linespec_lexer_lex_keyword (p) != NULL) { LS_TOKEN_STOKEN (token).ptr = start; @@ -716,8 +725,10 @@ linespec_lexer_lex_one (linespec_parser *parser) /* Skip any whitespace. */ PARSER_STREAM (parser) = skip_spaces (PARSER_STREAM (parser)); - /* Check for a keyword. */ - keyword = linespec_lexer_lex_keyword (PARSER_STREAM (parser)); + /* Check for a keyword, they end the linespec. */ + keyword = NULL; + if (parser->keyword_ok) + keyword = linespec_lexer_lex_keyword (PARSER_STREAM (parser)); if (keyword != NULL) { parser->lexer.current.type = LSTOKEN_KEYWORD; @@ -2018,6 +2029,10 @@ parse_linespec (linespec_parser *parser, char **argptr) } } + /* A keyword at the start cannot be interpreted as such. + Consider "b thread thread 42". */ + parser->keyword_ok = 0; + parser->lexer.saved_arg = *argptr; parser->lexer.stream = argptr; file_exception.reason = 0; @@ -2092,6 +2107,9 @@ parse_linespec (linespec_parser *parser, char **argptr) else if (token.type != LSTOKEN_STRING && token.type != LSTOKEN_NUMBER) unexpected_linespec_error (parser); + /* Now we can recognize keywords. */ + parser->keyword_ok = 1; + /* Shortcut: If the next token is not LSTOKEN_COLON, we know that this token cannot represent a filename. */ token = linespec_lexer_peek_token (parser); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index c90b1aa0702..1c6156e9d6f 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2012-10-11 Doug Evans + PR breakpoints/14643. + * gdb.linespec/ls-errs.exp: Change tests of "b if|task|thread". + * gdb.linespec/thread.c: New file. + * gdb.linespec/thread.exp: New file. + * lib/gdb.exp (gdb_breakpoint): Fix varargs scan. Recognize "message" -> print pass and fail. Add eof case. (runto): Recognize message, no-message. Print pass/fail if requested, diff --git a/gdb/testsuite/gdb.linespec/ls-errs.exp b/gdb/testsuite/gdb.linespec/ls-errs.exp index 5668397a3b0..7ee2623a9fb 100644 --- a/gdb/testsuite/gdb.linespec/ls-errs.exp +++ b/gdb/testsuite/gdb.linespec/ls-errs.exp @@ -171,7 +171,7 @@ foreach x {"3" "+100" "-100" "foo"} { } foreach x {"if" "task" "thread"} { - add the_tests $x unexpected_opt "keyword" $x + add the_tests $x invalid_function $x } add the_tests "'main.c'flubber" unexpected_opt "string" "flubber"