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.
This commit is contained in:
Keith Seitz
2015-08-11 17:09:35 -07:00
parent 5f700d83f7
commit c7c1b3e998
6 changed files with 385 additions and 3 deletions

View File

@@ -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