aboutsummaryrefslogtreecommitdiff
path: root/gdb/linespec.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2012-10-11 16:12:05 +0000
committerDoug Evans <dje@google.com>2012-10-11 16:12:05 +0000
commit7c09e5a0f7f3612c42e52d90056f73167cdb4ae5 (patch)
tree84d508aa2a51b164fc6b52d3340b77ccaec0400c /gdb/linespec.c
parent7b0e8ca5467cfa48726f30c6fe4227a9b5a9023e (diff)
downloadfsf-binutils-gdb-7c09e5a0f7f3612c42e52d90056f73167cdb4ae5.zip
fsf-binutils-gdb-7c09e5a0f7f3612c42e52d90056f73167cdb4ae5.tar.gz
fsf-binutils-gdb-7c09e5a0f7f3612c42e52d90056f73167cdb4ae5.tar.bz2
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.
Diffstat (limited to 'gdb/linespec.c')
-rw-r--r--gdb/linespec.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 3edc09f..06634d2 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;
@@ -2024,6 +2035,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;
@@ -2098,6 +2113,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);