};
typedef enum ls_token_type linespec_token_type;
-/* List of keywords */
-
-static const char * const linespec_keywords[] = { "if", "thread", "task" };
+/* List of keywords. This is NULL-terminated so that it can be used
+ as enum completer. */
+const char * const linespec_keywords[] = { "if", "thread", "task", NULL };
#define IF_KEYWORD_INDEX 0
/* A token of the linespec lexer */
if (p != NULL)
{
- for (i = 0; i < ARRAY_SIZE (linespec_keywords); ++i)
+ for (i = 0; linespec_keywords[i] != NULL; ++i)
{
int len = strlen (linespec_keywords[i]);
{
p += len;
p = skip_spaces_const (p);
- for (j = 0; j < ARRAY_SIZE (linespec_keywords); ++j)
+ for (j = 0; linespec_keywords[j] != NULL; ++j)
{
int nextlen = strlen (linespec_keywords[j]);
{
if ((PARSER_STATE (parser)->language->la_language
== language_cplus)
- && (PARSER_STREAM (parser) - start) > 8
- /* strlen ("operator") */)
+ && (PARSER_STREAM (parser) - start) > CP_OPERATOR_LEN)
{
- const char *p = strstr (start, "operator");
+ const char *p = strstr (start, CP_OPERATOR_STR);
if (p != NULL && is_operator_name (p))
{
struct symtabs_and_lines *result,
const char *select_mode)
{
- char *args, *prompt;
+ char *args;
+ const char *prompt;
int i;
struct cleanup *old_chain;
VEC (const_char_ptr) *filters = NULL;
if (token.type != LSTOKEN_NUMBER)
unexpected_linespec_error (parser);
- /* Record the lione offset and get the next token. */
+ /* Record the line offset and get the next token. */
name = copy_token_string (token);
cleanup = make_cleanup (xfree, name);
return;
/* Save everything as an explicit location. */
- canon = state->canonical->location
+ state->canonical->location
= new_explicit_location (&ls->explicit_loc);
+ canon = state->canonical->location.get ();
explicit_loc = get_explicit_location (canon);
if (explicit_loc->label_name != NULL)
do_cleanups (cleanup);
}
+/* See linespec.h. */
+
+void
+linespec_complete_function (completion_tracker &tracker,
+ const char *function,
+ const char *source_filename)
+{
+ complete_symbol_mode mode = complete_symbol_mode::LINESPEC;
+
+ if (source_filename != NULL)
+ {
+ collect_file_symbol_completion_matches (tracker, mode,
+ function, function,
+ source_filename);
+ }
+ else
+ collect_symbol_completion_matches (tracker, mode, function, function);
+}
+
/* A helper function for decode_line_full and decode_line_1 to
turn LOCATION into symtabs_and_lines. */
search_pspace, default_symtab,
default_line, canonical);
cleanups = make_cleanup (linespec_parser_delete, &parser);
- save_current_program_space ();
+
+ scoped_restore_current_program_space restore_pspace;
result = event_location_to_sals (&parser, location);
state = PARSER_STATE (&parser);
search_pspace, default_symtab,
default_line, NULL);
cleanups = make_cleanup (linespec_parser_delete, &parser);
- save_current_program_space ();
+
+ scoped_restore_current_program_space restore_pspace;
result = event_location_to_sals (&parser, location);
{
struct symtabs_and_lines sals;
struct symtab_and_line cursal;
- struct event_location *location;
- struct cleanup *cleanup;
if (string == 0)
error (_("Empty line specification."));
and get a default source symtab+line or it will recursively call us! */
cursal = get_current_source_symtab_and_line ();
- location = string_to_event_location (&string, current_language);
- cleanup = make_cleanup_delete_event_location (location);
- sals = decode_line_1 (location, flags, NULL,
+ event_location_up location = string_to_event_location (&string,
+ current_language);
+ sals = decode_line_1 (location.get (), flags, NULL,
cursal.symtab, cursal.line);
if (*string)
error (_("Junk at end of line specification: %s"), string);
- do_cleanups (cleanup);
return sals;
}
decode_line_with_last_displayed (char *string, int flags)
{
struct symtabs_and_lines sals;
- struct event_location *location;
- struct cleanup *cleanup;
if (string == 0)
error (_("Empty line specification."));
- location = string_to_event_location (&string, current_language);
- cleanup = make_cleanup_delete_event_location (location);
+ event_location_up location = string_to_event_location (&string,
+ current_language);
if (last_displayed_sal_is_valid ())
- sals = decode_line_1 (location, flags, NULL,
+ sals = decode_line_1 (location.get (), flags, NULL,
get_last_displayed_symtab (),
get_last_displayed_line ());
else
- sals = decode_line_1 (location, flags, NULL, (struct symtab *) NULL, 0);
+ sals = decode_line_1 (location.get (), flags, NULL,
+ (struct symtab *) NULL, 0);
if (*string)
error (_("Junk at end of line specification: %s"), string);
- do_cleanups (cleanup);
return sals;
}
return values;
}
+namespace {
+
/* A function object that serves as symbol_found_callback_ftype
callback for iterate_over_symbols. This is used by
lookup_prefix_sym to collect type symbols. */
return true; /* Continue iterating. */
}
+} // namespace
+
/* Return any symbols corresponding to CLASS_NAME in FILE_SYMTABS. */
static VEC (symbolp) *
\f
+namespace {
+
/* This function object is a callback for iterate_over_symtabs, used
when collecting all matching symtabs. */
return false;
}
+} // namespace
+
/* Given a file name, return a VEC of all matching symtabs. If
SEARCH_PSPACE is not NULL, the search is restricted to just that
program space. */
for (ix = 0; VEC_iterate (symtab_ptr, ls->file_symtabs, ix, elt); ++ix)
{
- int i;
- VEC (CORE_ADDR) *pcs;
- CORE_ADDR pc;
+ std::vector<CORE_ADDR> pcs;
/* The logic above should ensure this. */
gdb_assert (elt != NULL);
set_current_program_space (SYMTAB_PSPACE (elt));
pcs = find_pcs_for_symtab_line (elt, line, best_entry);
- for (i = 0; VEC_iterate (CORE_ADDR, pcs, i, pc); ++i)
+ for (CORE_ADDR pc : pcs)
{
struct symtab_and_line sal;
sal.pc = pc;
add_sal_to_sals_basic (sals, &sal);
}
-
- VEC_free (CORE_ADDR, pcs);
}
}
return 0;
}
-/* See the comment in linespec.h. */
-
-void
-init_linespec_result (struct linespec_result *lr)
-{
- memset (lr, 0, sizeof (*lr));
-}
-
-/* See the comment in linespec.h. */
-
-void
-destroy_linespec_result (struct linespec_result *ls)
+linespec_result::~linespec_result ()
{
int i;
struct linespec_sals *lsal;
- delete_event_location (ls->location);
- for (i = 0; VEC_iterate (linespec_sals, ls->sals, i, lsal); ++i)
+ for (i = 0; VEC_iterate (linespec_sals, sals, i, lsal); ++i)
{
xfree (lsal->canonical);
xfree (lsal->sals.sals);
}
- VEC_free (linespec_sals, ls->sals);
-}
-
-/* Cleanup function for a linespec_result. */
-
-static void
-cleanup_linespec_result (void *a)
-{
- destroy_linespec_result ((struct linespec_result *) a);
-}
-
-/* See the comment in linespec.h. */
-
-struct cleanup *
-make_cleanup_destroy_linespec_result (struct linespec_result *ls)
-{
- return make_cleanup (cleanup_linespec_result, ls);
+ VEC_free (linespec_sals, sals);
}
/* Return the quote characters permitted by the linespec parser. */