diff options
author | Keith Seitz <keiths@redhat.com> | 2015-03-23 12:59:18 -0700 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2015-03-23 13:16:39 -0700 |
commit | 0578b14e990e76f3c2dd9010c4cb9201bc9fa4b4 (patch) | |
tree | f1d3015cb60449da8288124ca8634ac7aa13a584 /gdb/linespec.h | |
parent | 7e993ebf2343a5b39d6d1df29fdebc2818064ae5 (diff) | |
download | gdb-0578b14e990e76f3c2dd9010c4cb9201bc9fa4b4.zip gdb-0578b14e990e76f3c2dd9010c4cb9201bc9fa4b4.tar.gz gdb-0578b14e990e76f3c2dd9010c4cb9201bc9fa4b4.tar.bz2 |
Expand keyword lexing intelligence in the linespec parser.
This patch changes the heuristic the linespec lexer uses to
detect a keyword in the input stream.
Currently, the heuristic is: a word is a keyword if it
1) points to a string that is a keyword
2) is followed by a non-identifier character
This is strictly more correct than using whitespace. For example,
it allows constructs such as "break foo if(i == 1)". However,
find_condition_and_thread in breakpoint.c does not support this expanded
usage. It requires whitespace to follow the keyword.
The proposed new heuristic is: a word is a keyword if it
1) points to a string that is a keyword
2) is followed by whitespace
3) is not followed by another keyword string followed by whitespace
This additional complexity allows constructs such as
"break thread thread 3" and "break thread 3". In the former case,
the actual location is a symbol named "thread" to be set on thread #3.
In the later case, the location is NULL, i.e., the default location,
to be set on thread #3.
In order to pass all the new tests added here, I've also had to add a
new feature to parse_breakpoint_sals, which expands recognition of the
default location to keywords other than "if", which is the only keyword
currently permitted with the default (NULL) location, but there is no
reason to exclude other keywords.
Consequently, it will be possible to use "break thread 1" or
"break task 1".
In addition to all of this, it is now possible to remove the keyword_ok
state from the linespec parser.
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.
Diffstat (limited to 'gdb/linespec.h')
-rw-r--r-- | gdb/linespec.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gdb/linespec.h b/gdb/linespec.h index 5520afa..7e66024 100644 --- a/gdb/linespec.h +++ 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); #endif /* defined (LINESPEC_H) */ |