+2019-01-09 Tom Tromey <tom@tromey.com>
+
+ * symtab.c (search_symbols)
+ (default_collect_symbol_completion_matches_break_on): Use
+ objfile_msymbols.
+ * ada-lang.c (ada_lookup_simple_minsym)
+ (ada_collect_symbol_completion_matches): Use objfile_msymbols.
+ * minsyms.c (find_solib_trampoline_target): Use objfile_msymbols.
+ * hppa-tdep.c (hppa_lookup_stub_minimal_symbol): Use
+ objfile_msymbols.
+ * coffread.c (coff_symfile_read): Use objfile_msymbols.
+ * symmisc.c (dump_msymbols): Use objfile_msymbols.
+ * objc-lang.c (find_methods): Use objfile_msymbols.
+ (info_selectors_command, info_classes_command): Likewise.
+ * stabsread.c (scan_file_globals): Use objfile_msymbols.
+ * objfiles.h (class objfile_msymbols): New.
+ (ALL_OBJFILE_MSYMBOLS): Remove.
+ (ALL_MSYMBOLS): Remove.
+
2019-01-09 Tom Tromey <tom@tromey.com>
* common/next-iterator.h (next_adapter): Add Iterator template
ada_lookup_simple_minsym (const char *name)
{
struct bound_minimal_symbol result;
- struct objfile *objfile;
- struct minimal_symbol *msymbol;
memset (&result, 0, sizeof (result));
symbol_name_matcher_ftype *match_name
= ada_get_symbol_name_matcher (lookup_name);
- ALL_MSYMBOLS (objfile, msymbol)
- {
- if (match_name (MSYMBOL_LINKAGE_NAME (msymbol), lookup_name, NULL)
- && MSYMBOL_TYPE (msymbol) != mst_solib_trampoline)
- {
- result.minsym = msymbol;
- result.objfile = objfile;
- break;
- }
- }
+ for (objfile *objfile : all_objfiles (current_program_space))
+ {
+ for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+ {
+ if (match_name (MSYMBOL_LINKAGE_NAME (msymbol), lookup_name, NULL)
+ && MSYMBOL_TYPE (msymbol) != mst_solib_trampoline)
+ {
+ result.minsym = msymbol;
+ result.objfile = objfile;
+ break;
+ }
+ }
+ }
return result;
}
{
struct symbol *sym;
struct compunit_symtab *s;
- struct minimal_symbol *msymbol;
- struct objfile *objfile;
const struct block *b, *surrounding_static_block = 0;
struct block_iterator iter;
anything that isn't a text symbol (everything else will be
handled by the psymtab code above). */
- ALL_MSYMBOLS (objfile, msymbol)
- {
- QUIT;
-
- if (completion_skip_symbol (mode, msymbol))
- continue;
-
- language symbol_language = MSYMBOL_LANGUAGE (msymbol);
-
- /* Ada minimal symbols won't have their language set to Ada. If
- we let completion_list_add_name compare using the
- default/C-like matcher, then when completing e.g., symbols in a
- package named "pck", we'd match internal Ada symbols like
- "pckS", which are invalid in an Ada expression, unless you wrap
- them in '<' '>' to request a verbatim match.
-
- Unfortunately, some Ada encoded names successfully demangle as
- C++ symbols (using an old mangling scheme), such as "name__2Xn"
- -> "Xn::name(void)" and thus some Ada minimal symbols end up
- with the wrong language set. Paper over that issue here. */
- if (symbol_language == language_auto
- || symbol_language == language_cplus)
- symbol_language = language_ada;
-
- completion_list_add_name (tracker,
- symbol_language,
- MSYMBOL_LINKAGE_NAME (msymbol),
- lookup_name, text, word);
- }
+ for (objfile *objfile : all_objfiles (current_program_space))
+ {
+ for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+ {
+ QUIT;
+
+ if (completion_skip_symbol (mode, msymbol))
+ continue;
+
+ language symbol_language = MSYMBOL_LANGUAGE (msymbol);
+
+ /* Ada minimal symbols won't have their language set to Ada. If
+ we let completion_list_add_name compare using the
+ default/C-like matcher, then when completing e.g., symbols in a
+ package named "pck", we'd match internal Ada symbols like
+ "pckS", which are invalid in an Ada expression, unless you wrap
+ them in '<' '>' to request a verbatim match.
+
+ Unfortunately, some Ada encoded names successfully demangle as
+ C++ symbols (using an old mangling scheme), such as "name__2Xn"
+ -> "Xn::name(void)" and thus some Ada minimal symbols end up
+ with the wrong language set. Paper over that issue here. */
+ if (symbol_language == language_auto
+ || symbol_language == language_cplus)
+ symbol_language = language_ada;
+
+ completion_list_add_name (tracker,
+ symbol_language,
+ MSYMBOL_LINKAGE_NAME (msymbol),
+ lookup_name, text, word);
+ }
+ }
/* Search upwards from currently selected frame (so that we can
complete on local vars. */
/* Go through the symtabs and check the externs and statics for
symbols which match. */
+ struct objfile *objfile;
ALL_COMPUNITS (objfile, s)
{
QUIT;
if (pe_file)
{
- struct minimal_symbol *msym;
-
- ALL_OBJFILE_MSYMBOLS (objfile, msym)
+ for (minimal_symbol *msym : objfile_msymbols (objfile))
{
const char *name = MSYMBOL_LINKAGE_NAME (msym);
hppa_lookup_stub_minimal_symbol (const char *name,
enum unwind_stub_types stub_type)
{
- struct objfile *objfile;
- struct minimal_symbol *msym;
struct bound_minimal_symbol result = { NULL, NULL };
- ALL_MSYMBOLS (objfile, msym)
+ for (objfile *objfile : all_objfiles (current_program_space))
{
- if (strcmp (MSYMBOL_LINKAGE_NAME (msym), name) == 0)
- {
- struct unwind_table_entry *u;
-
- u = find_unwind_entry (MSYMBOL_VALUE (msym));
- if (u != NULL && u->stub_unwind.stub_type == stub_type)
+ for (minimal_symbol *msym : objfile_msymbols (objfile))
+ {
+ if (strcmp (MSYMBOL_LINKAGE_NAME (msym), name) == 0)
{
- result.objfile = objfile;
- result.minsym = msym;
- return result;
+ struct unwind_table_entry *u;
+
+ u = find_unwind_entry (MSYMBOL_VALUE (msym));
+ if (u != NULL && u->stub_unwind.stub_type == stub_type)
+ {
+ result.objfile = objfile;
+ result.minsym = msym;
+ return result;
+ }
}
- }
+ }
}
return result;
CORE_ADDR
find_solib_trampoline_target (struct frame_info *frame, CORE_ADDR pc)
{
- struct objfile *objfile;
- struct minimal_symbol *msymbol;
struct minimal_symbol *tsymbol = lookup_solib_trampoline_symbol_by_pc (pc);
if (tsymbol != NULL)
{
- ALL_MSYMBOLS (objfile, msymbol)
- {
- /* Also handle minimal symbols pointing to function descriptors. */
- if ((MSYMBOL_TYPE (msymbol) == mst_text
- || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc
- || MSYMBOL_TYPE (msymbol) == mst_data
- || MSYMBOL_TYPE (msymbol) == mst_data_gnu_ifunc)
- && strcmp (MSYMBOL_LINKAGE_NAME (msymbol),
- MSYMBOL_LINKAGE_NAME (tsymbol)) == 0)
- {
- CORE_ADDR func;
+ for (objfile *objfile : all_objfiles (current_program_space))
+ {
+ for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+ {
+ /* Also handle minimal symbols pointing to function
+ descriptors. */
+ if ((MSYMBOL_TYPE (msymbol) == mst_text
+ || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc
+ || MSYMBOL_TYPE (msymbol) == mst_data
+ || MSYMBOL_TYPE (msymbol) == mst_data_gnu_ifunc)
+ && strcmp (MSYMBOL_LINKAGE_NAME (msymbol),
+ MSYMBOL_LINKAGE_NAME (tsymbol)) == 0)
+ {
+ CORE_ADDR func;
- /* Ignore data symbols that are not function
- descriptors. */
- if (msymbol_is_function (objfile, msymbol, &func))
- return func;
- }
- }
+ /* Ignore data symbols that are not function
+ descriptors. */
+ if (msymbol_is_function (objfile, msymbol, &func))
+ return func;
+ }
+ }
+ }
}
return 0;
}
static void
info_selectors_command (const char *regexp, int from_tty)
{
- struct objfile *objfile;
- struct minimal_symbol *msymbol;
const char *name;
char *val;
int matches = 0;
}
/* First time thru is JUST to get max length and count. */
- ALL_MSYMBOLS (objfile, msymbol)
+ for (objfile *objfile : all_objfiles (current_program_space))
{
- QUIT;
- name = MSYMBOL_NATURAL_NAME (msymbol);
- if (name
- && (name[0] == '-' || name[0] == '+')
- && name[1] == '[') /* Got a method name. */
+ for (minimal_symbol *msymbol : objfile_msymbols (objfile))
{
- /* Filter for class/instance methods. */
- if (plusminus && name[0] != plusminus)
- continue;
- /* Find selector part. */
- name = (char *) strchr (name+2, ' ');
- if (name == NULL)
+ QUIT;
+ name = MSYMBOL_NATURAL_NAME (msymbol);
+ if (name
+ && (name[0] == '-' || name[0] == '+')
+ && name[1] == '[') /* Got a method name. */
{
- complaint (_("Bad method name '%s'"),
- MSYMBOL_NATURAL_NAME (msymbol));
- continue;
- }
- if (regexp == NULL || re_exec(++name) != 0)
- {
- const char *mystart = name;
- const char *myend = strchr (mystart, ']');
+ /* Filter for class/instance methods. */
+ if (plusminus && name[0] != plusminus)
+ continue;
+ /* Find selector part. */
+ name = (char *) strchr (name+2, ' ');
+ if (name == NULL)
+ {
+ complaint (_("Bad method name '%s'"),
+ MSYMBOL_NATURAL_NAME (msymbol));
+ continue;
+ }
+ if (regexp == NULL || re_exec(++name) != 0)
+ {
+ const char *mystart = name;
+ const char *myend = strchr (mystart, ']');
- if (myend && (myend - mystart > maxlen))
- maxlen = myend - mystart; /* Get longest selector. */
- matches++;
+ if (myend && (myend - mystart > maxlen))
+ maxlen = myend - mystart; /* Get longest selector. */
+ matches++;
+ }
}
}
}
sym_arr = XALLOCAVEC (struct symbol *, matches);
matches = 0;
- ALL_MSYMBOLS (objfile, msymbol)
+ for (objfile *objfile : all_objfiles (current_program_space))
{
- QUIT;
- name = MSYMBOL_NATURAL_NAME (msymbol);
- if (name &&
- (name[0] == '-' || name[0] == '+') &&
- name[1] == '[') /* Got a method name. */
+ for (minimal_symbol *msymbol : objfile_msymbols (objfile))
{
- /* Filter for class/instance methods. */
- if (plusminus && name[0] != plusminus)
- continue;
- /* Find selector part. */
- name = (char *) strchr(name+2, ' ');
- if (regexp == NULL || re_exec(++name) != 0)
- sym_arr[matches++] = (struct symbol *) msymbol;
+ QUIT;
+ name = MSYMBOL_NATURAL_NAME (msymbol);
+ if (name &&
+ (name[0] == '-' || name[0] == '+') &&
+ name[1] == '[') /* Got a method name. */
+ {
+ /* Filter for class/instance methods. */
+ if (plusminus && name[0] != plusminus)
+ continue;
+ /* Find selector part. */
+ name = (char *) strchr(name+2, ' ');
+ if (regexp == NULL || re_exec(++name) != 0)
+ sym_arr[matches++] = (struct symbol *) msymbol;
+ }
}
}
static void
info_classes_command (const char *regexp, int from_tty)
{
- struct objfile *objfile;
- struct minimal_symbol *msymbol;
const char *name;
char *val;
int matches = 0;
}
/* First time thru is JUST to get max length and count. */
- ALL_MSYMBOLS (objfile, msymbol)
+ for (objfile *objfile : all_objfiles (current_program_space))
{
- QUIT;
- name = MSYMBOL_NATURAL_NAME (msymbol);
- if (name &&
- (name[0] == '-' || name[0] == '+') &&
- name[1] == '[') /* Got a method name. */
- if (regexp == NULL || re_exec(name+2) != 0)
- {
- /* Compute length of classname part. */
- const char *mystart = name + 2;
- const char *myend = strchr (mystart, ' ');
+ for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+ {
+ QUIT;
+ name = MSYMBOL_NATURAL_NAME (msymbol);
+ if (name &&
+ (name[0] == '-' || name[0] == '+') &&
+ name[1] == '[') /* Got a method name. */
+ if (regexp == NULL || re_exec(name+2) != 0)
+ {
+ /* Compute length of classname part. */
+ const char *mystart = name + 2;
+ const char *myend = strchr (mystart, ' ');
- if (myend && (myend - mystart > maxlen))
- maxlen = myend - mystart;
- matches++;
- }
+ if (myend && (myend - mystart > maxlen))
+ maxlen = myend - mystart;
+ matches++;
+ }
+ }
}
if (matches)
{
regexp ? regexp : "*");
sym_arr = XALLOCAVEC (struct symbol *, matches);
matches = 0;
- ALL_MSYMBOLS (objfile, msymbol)
+ for (objfile *objfile : all_objfiles (current_program_space))
{
- QUIT;
- name = MSYMBOL_NATURAL_NAME (msymbol);
- if (name &&
- (name[0] == '-' || name[0] == '+') &&
- name[1] == '[') /* Got a method name. */
- if (regexp == NULL || re_exec(name+2) != 0)
- sym_arr[matches++] = (struct symbol *) msymbol;
+ for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+ {
+ QUIT;
+ name = MSYMBOL_NATURAL_NAME (msymbol);
+ if (name &&
+ (name[0] == '-' || name[0] == '+') &&
+ name[1] == '[') /* Got a method name. */
+ if (regexp == NULL || re_exec(name+2) != 0)
+ sym_arr[matches++] = (struct symbol *) msymbol;
+ }
}
qsort (sym_arr, matches, sizeof (struct minimal_symbol *),
for (objfile *objfile : all_objfiles (current_program_space))
{
unsigned int *objc_csym;
- struct minimal_symbol *msymbol = NULL;
/* The objfile_csym variable counts the number of ObjC methods
that this objfile defines. We save that count as a private
/* There are no ObjC symbols in this objfile. Skip it entirely. */
continue;
- ALL_OBJFILE_MSYMBOLS (objfile, msymbol)
+ for (minimal_symbol *msymbol : objfile_msymbols (objfile))
{
QUIT;
#define ALL_OBJFILE_COMPUNITS(objfile, cu) \
for ((cu) = (objfile) -> compunit_symtabs; (cu) != NULL; (cu) = (cu) -> next)
-/* Traverse all minimal symbols in one objfile. */
+/* A range adapter that makes it possible to iterate over all
+ minimal symbols of an objfile. */
-#define ALL_OBJFILE_MSYMBOLS(objfile, m) \
- for ((m) = (objfile)->per_bfd->msymbols; \
- MSYMBOL_LINKAGE_NAME (m) != NULL; \
- (m)++)
+class objfile_msymbols
+{
+public:
+
+ explicit objfile_msymbols (struct objfile *objfile)
+ : m_objfile (objfile)
+ {
+ }
+
+ struct iterator
+ {
+ typedef iterator self_type;
+ typedef struct minimal_symbol *value_type;
+ typedef struct minimal_symbol *&reference;
+ typedef struct minimal_symbol **pointer;
+ typedef std::forward_iterator_tag iterator_category;
+ typedef int difference_type;
+
+ explicit iterator (struct objfile *objfile)
+ : m_msym (objfile->per_bfd->msymbols)
+ {
+ /* Make sure to properly handle the case where there are no
+ minsyms. */
+ if (MSYMBOL_LINKAGE_NAME (m_msym) == nullptr)
+ m_msym = nullptr;
+ }
+
+ iterator ()
+ : m_msym (nullptr)
+ {
+ }
+
+ value_type operator* () const
+ {
+ return m_msym;
+ }
+
+ bool operator== (const self_type &other) const
+ {
+ return m_msym == other.m_msym;
+ }
+
+ bool operator!= (const self_type &other) const
+ {
+ return m_msym != other.m_msym;
+ }
+
+ self_type &operator++ ()
+ {
+ if (m_msym != nullptr)
+ {
+ ++m_msym;
+ if (MSYMBOL_LINKAGE_NAME (m_msym) == nullptr)
+ m_msym = nullptr;
+ }
+ return *this;
+ }
+
+ private:
+ struct minimal_symbol *m_msym;
+ };
+
+ iterator begin () const
+ {
+ return iterator (m_objfile);
+ }
+
+ iterator end () const
+ {
+ return iterator ();
+ }
+
+private:
+
+ struct objfile *m_objfile;
+};
/* Traverse all symtabs in all objfiles in the current symbol
space. */
ALL_OBJFILES (objfile) \
ALL_OBJFILE_COMPUNITS (objfile, cu)
-/* Traverse all minimal symbols in all objfiles in the current symbol
- space. */
-
-#define ALL_MSYMBOLS(objfile, m) \
- ALL_OBJFILES (objfile) \
- ALL_OBJFILE_MSYMBOLS (objfile, m)
-
#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
if (osect->the_bfd_section == NULL) \
scan_file_globals (struct objfile *objfile)
{
int hash;
- struct minimal_symbol *msymbol;
struct symbol *sym, *prev;
struct objfile *resolve_objfile;
if (hash >= HASHSIZE)
return;
- ALL_OBJFILE_MSYMBOLS (resolve_objfile, msymbol)
+ for (minimal_symbol *msymbol : objfile_msymbols (resolve_objfile))
{
QUIT;
dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
- struct minimal_symbol *msymbol;
int index;
char ms_type;
return;
}
index = 0;
- ALL_OBJFILE_MSYMBOLS (objfile, msymbol)
+ for (minimal_symbol *msymbol : objfile_msymbols (objfile))
{
struct obj_section *section = MSYMBOL_OBJ_SECTION (objfile, msymbol);
int i = 0;
struct block_iterator iter;
struct symbol *sym;
- struct objfile *objfile;
- struct minimal_symbol *msymbol;
int found_misc = 0;
static const enum minimal_symbol_type types[]
= {mst_data, mst_text, mst_abs};
if (nfiles == 0 && (kind == VARIABLES_DOMAIN || kind == FUNCTIONS_DOMAIN))
{
- ALL_MSYMBOLS (objfile, msymbol)
- {
- QUIT;
+ for (objfile *objfile : all_objfiles (current_program_space))
+ {
+ for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+ {
+ QUIT;
- if (msymbol->created_by_gdb)
- continue;
+ if (msymbol->created_by_gdb)
+ continue;
- if (MSYMBOL_TYPE (msymbol) == ourtype
- || MSYMBOL_TYPE (msymbol) == ourtype2
- || MSYMBOL_TYPE (msymbol) == ourtype3
- || MSYMBOL_TYPE (msymbol) == ourtype4)
- {
- if (!preg.has_value ()
- || preg->exec (MSYMBOL_NATURAL_NAME (msymbol), 0,
- NULL, 0) == 0)
- {
- /* Note: An important side-effect of these lookup functions
- is to expand the symbol table if msymbol is found, for the
- benefit of the next loop on ALL_COMPUNITS. */
- if (kind == FUNCTIONS_DOMAIN
- ? (find_pc_compunit_symtab
- (MSYMBOL_VALUE_ADDRESS (objfile, msymbol)) == NULL)
- : (lookup_symbol_in_objfile_from_linkage_name
- (objfile, MSYMBOL_LINKAGE_NAME (msymbol), VAR_DOMAIN)
- .symbol == NULL))
- found_misc = 1;
- }
- }
- }
+ if (MSYMBOL_TYPE (msymbol) == ourtype
+ || MSYMBOL_TYPE (msymbol) == ourtype2
+ || MSYMBOL_TYPE (msymbol) == ourtype3
+ || MSYMBOL_TYPE (msymbol) == ourtype4)
+ {
+ if (!preg.has_value ()
+ || preg->exec (MSYMBOL_NATURAL_NAME (msymbol), 0,
+ NULL, 0) == 0)
+ {
+ /* Note: An important side-effect of these
+ lookup functions is to expand the symbol
+ table if msymbol is found, for the benefit of
+ the next loop on ALL_COMPUNITS. */
+ if (kind == FUNCTIONS_DOMAIN
+ ? (find_pc_compunit_symtab
+ (MSYMBOL_VALUE_ADDRESS (objfile, msymbol))
+ == NULL)
+ : (lookup_symbol_in_objfile_from_linkage_name
+ (objfile, MSYMBOL_LINKAGE_NAME (msymbol),
+ VAR_DOMAIN)
+ .symbol == NULL))
+ found_misc = 1;
+ }
+ }
+ }
+ }
}
- ALL_COMPUNITS (objfile, cust)
{
- bv = COMPUNIT_BLOCKVECTOR (cust);
- for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
+ struct objfile *objfile;
+ ALL_COMPUNITS (objfile, cust)
{
- b = BLOCKVECTOR_BLOCK (bv, i);
- ALL_BLOCK_SYMBOLS (b, iter, sym)
+ bv = COMPUNIT_BLOCKVECTOR (cust);
+ for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
{
- struct symtab *real_symtab = symbol_symtab (sym);
-
- QUIT;
-
- /* Check first sole REAL_SYMTAB->FILENAME. It does not need to be
- a substring of symtab_to_fullname as it may contain "./" etc. */
- if ((file_matches (real_symtab->filename, files, nfiles, 0)
- || ((basenames_may_differ
- || file_matches (lbasename (real_symtab->filename),
- files, nfiles, 1))
- && file_matches (symtab_to_fullname (real_symtab),
- files, nfiles, 0)))
- && ((!preg.has_value ()
- || preg->exec (SYMBOL_NATURAL_NAME (sym), 0,
- NULL, 0) == 0)
- && ((kind == VARIABLES_DOMAIN
- && SYMBOL_CLASS (sym) != LOC_TYPEDEF
- && SYMBOL_CLASS (sym) != LOC_UNRESOLVED
- && SYMBOL_CLASS (sym) != LOC_BLOCK
- /* LOC_CONST can be used for more than just enums,
- e.g., c++ static const members.
- We only want to skip enums here. */
- && !(SYMBOL_CLASS (sym) == LOC_CONST
- && (TYPE_CODE (SYMBOL_TYPE (sym))
- == TYPE_CODE_ENUM))
- && (!treg.has_value ()
- || treg_matches_sym_type_name (*treg, sym)))
- || (kind == FUNCTIONS_DOMAIN
- && SYMBOL_CLASS (sym) == LOC_BLOCK
- && (!treg.has_value ()
- || treg_matches_sym_type_name (*treg, sym)))
- || (kind == TYPES_DOMAIN
- && SYMBOL_CLASS (sym) == LOC_TYPEDEF))))
+ b = BLOCKVECTOR_BLOCK (bv, i);
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
- /* match */
- result.emplace_back (i, sym);
+ struct symtab *real_symtab = symbol_symtab (sym);
+
+ QUIT;
+
+ /* Check first sole REAL_SYMTAB->FILENAME. It does
+ not need to be a substring of symtab_to_fullname as
+ it may contain "./" etc. */
+ if ((file_matches (real_symtab->filename, files, nfiles, 0)
+ || ((basenames_may_differ
+ || file_matches (lbasename (real_symtab->filename),
+ files, nfiles, 1))
+ && file_matches (symtab_to_fullname (real_symtab),
+ files, nfiles, 0)))
+ && ((!preg.has_value ()
+ || preg->exec (SYMBOL_NATURAL_NAME (sym), 0,
+ NULL, 0) == 0)
+ && ((kind == VARIABLES_DOMAIN
+ && SYMBOL_CLASS (sym) != LOC_TYPEDEF
+ && SYMBOL_CLASS (sym) != LOC_UNRESOLVED
+ && SYMBOL_CLASS (sym) != LOC_BLOCK
+ /* LOC_CONST can be used for more than
+ just enums, e.g., c++ static const
+ members. We only want to skip enums
+ here. */
+ && !(SYMBOL_CLASS (sym) == LOC_CONST
+ && (TYPE_CODE (SYMBOL_TYPE (sym))
+ == TYPE_CODE_ENUM))
+ && (!treg.has_value ()
+ || treg_matches_sym_type_name (*treg, sym)))
+ || (kind == FUNCTIONS_DOMAIN
+ && SYMBOL_CLASS (sym) == LOC_BLOCK
+ && (!treg.has_value ()
+ || treg_matches_sym_type_name (*treg,
+ sym)))
+ || (kind == TYPES_DOMAIN
+ && SYMBOL_CLASS (sym) == LOC_TYPEDEF))))
+ {
+ /* match */
+ result.emplace_back (i, sym);
+ }
}
}
}
if ((found_misc || (nfiles == 0 && kind != FUNCTIONS_DOMAIN))
&& !treg.has_value ())
{
- ALL_MSYMBOLS (objfile, msymbol)
- {
- QUIT;
+ for (objfile *objfile : all_objfiles (current_program_space))
+ {
+ for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+ {
+ QUIT;
- if (msymbol->created_by_gdb)
- continue;
+ if (msymbol->created_by_gdb)
+ continue;
- if (MSYMBOL_TYPE (msymbol) == ourtype
- || MSYMBOL_TYPE (msymbol) == ourtype2
- || MSYMBOL_TYPE (msymbol) == ourtype3
- || MSYMBOL_TYPE (msymbol) == ourtype4)
- {
- if (!preg.has_value ()
- || preg->exec (MSYMBOL_NATURAL_NAME (msymbol), 0,
- NULL, 0) == 0)
- {
- /* For functions we can do a quick check of whether the
- symbol might be found via find_pc_symtab. */
- if (kind != FUNCTIONS_DOMAIN
- || (find_pc_compunit_symtab
- (MSYMBOL_VALUE_ADDRESS (objfile, msymbol)) == NULL))
- {
- if (lookup_symbol_in_objfile_from_linkage_name
- (objfile, MSYMBOL_LINKAGE_NAME (msymbol), VAR_DOMAIN)
- .symbol == NULL)
- {
- /* match */
- result.emplace_back (i, msymbol, objfile);
- }
- }
- }
- }
- }
+ if (MSYMBOL_TYPE (msymbol) == ourtype
+ || MSYMBOL_TYPE (msymbol) == ourtype2
+ || MSYMBOL_TYPE (msymbol) == ourtype3
+ || MSYMBOL_TYPE (msymbol) == ourtype4)
+ {
+ if (!preg.has_value ()
+ || preg->exec (MSYMBOL_NATURAL_NAME (msymbol), 0,
+ NULL, 0) == 0)
+ {
+ /* For functions we can do a quick check of whether the
+ symbol might be found via find_pc_symtab. */
+ if (kind != FUNCTIONS_DOMAIN
+ || (find_pc_compunit_symtab
+ (MSYMBOL_VALUE_ADDRESS (objfile, msymbol))
+ == NULL))
+ {
+ if (lookup_symbol_in_objfile_from_linkage_name
+ (objfile, MSYMBOL_LINKAGE_NAME (msymbol),
+ VAR_DOMAIN)
+ .symbol == NULL)
+ {
+ /* match */
+ result.emplace_back (i, msymbol, objfile);
+ }
+ }
+ }
+ }
+ }
+ }
}
return result;
struct symbol *sym;
struct compunit_symtab *cust;
- struct minimal_symbol *msymbol;
- struct objfile *objfile;
const struct block *b;
const struct block *surrounding_static_block, *surrounding_global_block;
struct block_iterator iter;
if (code == TYPE_CODE_UNDEF)
{
- ALL_MSYMBOLS (objfile, msymbol)
+ for (objfile *objfile : all_objfiles (current_program_space))
{
- QUIT;
+ for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+ {
+ QUIT;
- if (completion_skip_symbol (mode, msymbol))
- continue;
+ if (completion_skip_symbol (mode, msymbol))
+ continue;
- completion_list_add_msymbol (tracker, msymbol, lookup_name,
- sym_text, word);
+ completion_list_add_msymbol (tracker, msymbol, lookup_name,
+ sym_text, word);
- completion_list_objc_symbol (tracker, msymbol, lookup_name,
- sym_text, word);
+ completion_list_objc_symbol (tracker, msymbol, lookup_name,
+ sym_text, word);
+ }
}
}
/* Add completions for all currently loaded symbol tables. */
+ struct objfile *objfile;
ALL_COMPUNITS (objfile, cust)
add_symtab_completions (cust, tracker, mode, lookup_name,
sym_text, word, code);