/* Line completion stuff for GDB, the GNU debugger.
- Copyright (C) 2000-2022 Free Software Foundation, Inc.
+ Copyright (C) 2000-2023 Free Software Foundation, Inc.
This file is part of GDB.
static void
collect_explicit_location_matches (completion_tracker &tracker,
- struct event_location *location,
+ location_spec *locspec,
enum explicit_location_match_type what,
const char *word,
const struct language_defn *language)
{
- const struct explicit_location *explicit_loc
- = get_explicit_location (location);
+ const explicit_location_spec *explicit_loc
+ = as_explicit_location_spec (locspec);
/* True if the option expects an argument. */
bool needs_arg = true;
return -1;
}
-/* A completer function for explicit locations. This function
+/* A completer function for explicit location specs. This function
completes both options ("-source", "-line", etc) and values. If
completing a quoted string, then QUOTED_ARG_START and
QUOTED_ARG_END point to the quote characters. LANGUAGE is the
current language. */
static void
-complete_explicit_location (completion_tracker &tracker,
- struct event_location *location,
- const char *text,
- const language_defn *language,
- const char *quoted_arg_start,
- const char *quoted_arg_end)
+complete_explicit_location_spec (completion_tracker &tracker,
+ location_spec *locspec,
+ const char *text,
+ const language_defn *language,
+ const char *quoted_arg_start,
+ const char *quoted_arg_end)
{
if (*text != '-')
return;
}
/* Now gather matches */
- collect_explicit_location_matches (tracker, location, what, text,
+ collect_explicit_location_matches (tracker, locspec, what, text,
language);
}
}
const char *copy = text;
explicit_completion_info completion_info;
- event_location_up location
- = string_to_explicit_location (©, current_language,
- &completion_info);
+ location_spec_up locspec
+ = string_to_explicit_location_spec (©, current_language,
+ &completion_info);
if (completion_info.quoted_arg_start != NULL
&& completion_info.quoted_arg_end == NULL)
{
tracker.advance_custom_word_point_by (1);
}
- if (completion_info.saw_explicit_location_option)
+ if (completion_info.saw_explicit_location_spec_option)
{
if (*copy != '\0')
{
- text);
text = completion_info.last_option;
- complete_explicit_location (tracker, location.get (), text,
- current_language,
- completion_info.quoted_arg_start,
- completion_info.quoted_arg_end);
+ complete_explicit_location_spec (tracker, locspec.get (), text,
+ current_language,
+ completion_info.quoted_arg_start,
+ completion_info.quoted_arg_end);
}
}
/* This is an address or linespec location. */
- else if (location != NULL)
+ else if (locspec != nullptr)
{
/* Handle non-explicit location options. */
text = copy;
symbol_name_match_type match_type
- = get_explicit_location (location.get ())->func_name_match_type;
+ = as_explicit_location_spec (locspec.get ())->func_name_match_type;
complete_address_and_linespec_locations (tracker, text, match_type);
}
}
if ((targets & complete_reggroup_names) != 0)
{
- struct reggroup *group;
-
- for (group = reggroup_next (gdbarch, NULL);
- group != NULL;
- group = reggroup_next (gdbarch, group))
+ for (const struct reggroup *group : gdbarch_reggroups (gdbarch))
{
- name = reggroup_name (group);
+ name = group->name ();
if (strncmp (word, name, len) == 0)
tracker.add_completion (make_unique_xstrdup (name));
}