/* Parser for linespec for the GNU debugger, GDB.
- Copyright (C) 1986-2020 Free Software Foundation, Inc.
+ Copyright (C) 1986-2021 Free Software Foundation, Inc.
This file is part of GDB.
#include "gdbsupport/function-view.h"
#include "gdbsupport/def-vector.h"
#include <algorithm>
+#include "inferior.h"
/* An enumeration of the various things a user might attempt to
complete for a linespec location. */
std::vector<block_symbol> *function_symbols;
} labels;
};
-typedef struct linespec *linespec_p;
/* A canonical linespec represented as a symtab-related string.
/* A token of the linespec lexer */
-struct ls_token
+struct linespec_token
{
/* The type of the token */
linespec_token_type type;
const char *keyword;
} data;
};
-typedef struct ls_token linespec_token;
#define LS_TOKEN_STOKEN(TOK) (TOK).data.string
#define LS_TOKEN_KEYWORD(TOK) (TOK).data.keyword
CORE_ADDR linespec_expression_to_pc (const char **exp_ptr);
static std::vector<symtab_and_line> decode_objc (struct linespec_state *self,
- linespec_p ls,
+ linespec *ls,
const char *arg);
static std::vector<symtab *> symtabs_from_filename
static std::vector<symtab_and_line> decode_digits_ordinary
(struct linespec_state *self,
- linespec_p ls,
+ linespec *ls,
int line,
linetable_entry **best_entry);
static std::vector<symtab_and_line> decode_digits_list_mode
(struct linespec_state *self,
- linespec_p ls,
+ linespec *ls,
struct symtab_and_line val);
static void minsym_found (struct linespec_state *self, struct objfile *objfile,
{
int len = strlen (linespec_keywords[i]);
- /* If P begins with one of the keywords and the next
- character is whitespace, we may have found a keyword.
- It is only a keyword if it is not followed by another
- keyword. */
- if (strncmp (p, linespec_keywords[i], len) == 0
- && isspace (p[len]))
+ /* If P begins with
+
+ - "thread" or "task" and the next character is
+ whitespace, we may have found a keyword. It is only a
+ keyword if it is not followed by another keyword.
+
+ - "-force-condition", the next character may be EOF
+ since this keyword does not take any arguments. Otherwise,
+ it should be followed by a keyword.
+
+ - "if", ALWAYS stop the lexer, since it is not possible to
+ predict what is going to appear in the condition, which can
+ only be parsed after SaLs have been found. */
+ if (strncmp (p, linespec_keywords[i], len) == 0)
{
int j;
- /* Special case: "-force" is always followed by an "if". */
+ if (i == FORCE_KEYWORD_INDEX && p[len] == '\0')
+ return linespec_keywords[i];
+
+ if (!isspace (p[len]))
+ continue;
+
if (i == FORCE_KEYWORD_INDEX)
{
p += len;
p = skip_spaces (p);
- int nextlen = strlen (linespec_keywords[IF_KEYWORD_INDEX]);
- if (!(strncmp (p, linespec_keywords[IF_KEYWORD_INDEX], nextlen) == 0
- && isspace (p[nextlen])))
- return NULL;
- }
+ for (j = 0; linespec_keywords[j] != NULL; ++j)
+ {
+ int nextlen = strlen (linespec_keywords[j]);
- /* Special case: "if" ALWAYS stops the lexer, since it
- is not possible to predict what is going to appear in
- the condition, which can only be parsed after SaLs have
- been found. */
+ if (strncmp (p, linespec_keywords[j], nextlen) == 0
+ && isspace (p[nextlen]))
+ return linespec_keywords[i];
+ }
+ }
else if (i != IF_KEYWORD_INDEX)
{
+ /* We matched a "thread" or "task". */
p += len;
p = skip_spaces (p);
for (j = 0; linespec_keywords[j] != NULL; ++j)
case '+': case '-':
case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- if (!linespec_lexer_lex_number (parser, &(parser->lexer.current)))
+ case '5': case '6': case '7': case '8': case '9':
+ if (!linespec_lexer_lex_number (parser, &(parser->lexer.current)))
parser->lexer.current = linespec_lexer_lex_string (parser);
- break;
+ break;
case ':':
/* If we have a scope operator, lex the input as a string.
for (objfile *objfile : current_program_space->objfiles ())
{
- if (objfile->sf)
- objfile->sf->qf->expand_symtabs_matching (objfile,
- NULL,
- &lookup_name,
- NULL, NULL,
- search_domain);
+ objfile->expand_symtabs_matching (NULL, &lookup_name, NULL, NULL,
+ (SEARCH_GLOBAL_BLOCK
+ | SEARCH_STATIC_BLOCK),
+ UNDEF_DOMAIN,
+ search_domain);
for (compunit_symtab *cu : objfile->compunits ())
{
t = check_typedef (t);
/* Loop over each method name. At this level, all overloads of a name
- are counted as a single name. There is an inner loop which loops over
- each overload. */
+ are counted as a single name. There is an inner loop which loops over
+ each overload. */
for (method_counter = TYPE_NFN_FIELDS (t) - 1;
method_counter >= 0;
{
if (function != NULL)
throw_error (NOT_FOUND_ERROR,
- _("No label \"%s\" defined in function \"%s\"."),
- label, function);
+ _("No label \"%s\" defined in function \"%s\"."),
+ label, function);
else
throw_error (NOT_FOUND_ERROR,
- _("No label \"%s\" defined in current function."),
- label);
+ _("No label \"%s\" defined in current function."),
+ label);
}
/* Throw a source file not found error. */
= new std::vector<block_symbol> (std::move (symbols));
PARSER_RESULT (parser)->minimal_symbols
= new std::vector<bound_minimal_symbol>
- (std::move (minimal_symbols));
+ (std::move (minimal_symbols));
PARSER_EXPLICIT (parser)->function_name = name.release ();
}
else
locations. */
static void
-canonicalize_linespec (struct linespec_state *state, const linespec_p ls)
+canonicalize_linespec (struct linespec_state *state, const linespec *ls)
{
struct event_location *canon;
struct explicit_location *explicit_loc;
static std::vector<symtab_and_line>
create_sals_line_offset (struct linespec_state *self,
- linespec_p ls)
+ linespec *ls)
{
int use_default = 0;
/* Create and return SALs from the linespec LS. */
static std::vector<symtab_and_line>
-convert_linespec_to_sals (struct linespec_state *state, linespec_p ls)
+convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
{
std::vector<symtab_and_line> sals;
= (gdbarch_convert_from_func_ptr_addr
(gdbarch,
msym_addr,
- current_top_target ()));
+ current_inferior ()->top_target ()));
}
if (msym_addr == addr)
static void
convert_explicit_location_to_linespec (struct linespec_state *self,
- linespec_p result,
+ linespec *result,
const char *source_filename,
const char *function_name,
symbol_name_match_type fname_match_type,
static std::vector<symtab_and_line>
convert_explicit_location_to_sals (struct linespec_state *self,
- linespec_p result,
+ linespec *result,
const struct explicit_location *explicit_loc)
{
convert_explicit_location_to_linespec (self, result,
label_name_spec -> STRING
function_name_spec -> STRING
offset_spec -> NUMBER
- -> '+' NUMBER
+ -> '+' NUMBER
-> '-' NUMBER
This may all be followed by several keywords such as "if EXPR",
if (*default_symtab == 0)
{
/* Use whatever we have for the default source line. We don't use
- get_current_or_default_symtab_and_line as it can recurse and call
+ get_current_or_default_symtab_and_line as it can recurse and call
us back! */
struct symtab_and_line cursal =
get_current_source_symtab_and_line ();
the existing C++ code to let the user choose one. */
static std::vector<symtab_and_line>
-decode_objc (struct linespec_state *self, linespec_p ls, const char *arg)
+decode_objc (struct linespec_state *self, linespec *ls, const char *arg)
{
struct collect_info info;
std::vector<const char *> symbol_names;
if (search_pspace == NULL)
{
for (struct program_space *pspace : program_spaces)
- {
+ {
if (pspace->executing_startup)
continue;
static std::vector<symtab_and_line>
decode_digits_list_mode (struct linespec_state *self,
- linespec_p ls,
+ linespec *ls,
struct symtab_and_line val)
{
gdb_assert (self->list_mode);
static std::vector<symtab_and_line>
decode_digits_ordinary (struct linespec_state *self,
- linespec_p ls,
+ linespec *ls,
int line,
struct linetable_entry **best_entry)
{
sal.pspace = current_program_space;
}
- sal.section = MSYMBOL_OBJ_SECTION (objfile, msymbol);
+ sal.section = msymbol->obj_section (objfile);
if (maybe_add_address (self->addr_set, objfile->pspace, sal.pc))
add_sal_to_sals (self, result, &sal, msymbol->natural_name (), 0);