diff options
author | Keith Seitz <keiths@redhat.com> | 2015-08-11 17:09:35 -0700 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2015-08-11 17:09:35 -0700 |
commit | c7c1b3e998a77eb077ac3c08c88a97d2e11dfef0 (patch) | |
tree | b096b0ee0c2de1ab36dd9215c6a20e75534d0175 /gdb/linespec.c | |
parent | 5f700d83f7f3ea422d789c51a25f04818bf788d7 (diff) | |
download | gdb-c7c1b3e998a77eb077ac3c08c88a97d2e11dfef0.zip gdb-c7c1b3e998a77eb077ac3c08c88a97d2e11dfef0.tar.gz gdb-c7c1b3e998a77eb077ac3c08c88a97d2e11dfef0.tar.bz2 |
Explicit locations: introduce new struct event_location-based API
This patch introduces the new breakpoint/"linespec" API based on
a new struct event_location. This API currently only supports
traditional linespecs, maintaining the status quo of the code base.
Future patches will add additional functionality for other location
types such as address locations.
gdb/ChangeLog:
* Makefile.in (SFILES): Add location.c.
(HFILES_NO_SRCDIR): Add location.h.
(COMMON_OBS): Add location.o.
* linespec.c (linespec_lex_to_end): New function.
* linespec.h (linespec_lex_to_end): Declare.
* location.c: New file.
* location.h: New file.
Diffstat (limited to 'gdb/linespec.c')
-rw-r--r-- | gdb/linespec.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/gdb/linespec.c b/gdb/linespec.c index 2fe845f..5c4ed3f 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2435,6 +2435,54 @@ linespec_parser_delete (void *arg) linespec_state_destructor (PARSER_STATE (parser)); } +/* See description in linespec.h. */ + +void +linespec_lex_to_end (char **stringp) +{ + linespec_parser parser; + struct cleanup *cleanup; + linespec_token token; + volatile struct gdb_exception e; + const char *orig; + + if (stringp == NULL || *stringp == NULL) + return; + + linespec_parser_new (&parser, 0, current_language, NULL, 0, NULL); + cleanup = make_cleanup (linespec_parser_delete, &parser); + parser.lexer.saved_arg = *stringp; + PARSER_STREAM (&parser) = orig = *stringp; + + do + { + /* Stop before any comma tokens; we need it to keep it + as the next token in the string. */ + token = linespec_lexer_peek_token (&parser); + if (token.type == LSTOKEN_COMMA) + break; + + /* For addresses advance the parser stream past + any parsed input and stop lexing. */ + if (token.type == LSTOKEN_STRING + && *LS_TOKEN_STOKEN (token).ptr == '*') + { + const char *arg; + + arg = *stringp; + (void) linespec_expression_to_pc (&arg); + PARSER_STREAM (&parser) = arg; + break; + } + + token = linespec_lexer_consume_token (&parser); + } + while (token.type != LSTOKEN_EOI && token.type != LSTOKEN_KEYWORD); + + *stringp += PARSER_STREAM (&parser) - orig; + do_cleanups (cleanup); +} + /* See linespec.h. */ void |