From c7c1b3e998a77eb077ac3c08c88a97d2e11dfef0 Mon Sep 17 00:00:00 2001 From: Keith Seitz Date: Tue, 11 Aug 2015 17:09:35 -0700 Subject: 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. --- gdb/linespec.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'gdb/linespec.c') 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 -- cgit v1.1