Remove ALL_MSYMBOLS and ALL_OBJFILE_MSYMBOLS

This removes the ALL_MSYMBOLS and ALL_OBJFILE_MSYMBOLS macros,
replacing their uses with ranged for loops.

In a couple of spots, a new declaration was needed in order to work
around shadowing; these are just temporary and are removed in a
subsequent patch.

gdb/ChangeLog
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.
This commit is contained in:
Tom Tromey 2018-11-23 17:32:08 -07:00
parent cac85af246
commit 5325b9bf1e
10 changed files with 375 additions and 264 deletions

View File

@ -1,3 +1,22 @@
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

View File

@ -4913,8 +4913,6 @@ struct bound_minimal_symbol
ada_lookup_simple_minsym (const char *name)
{
struct bound_minimal_symbol result;
struct objfile *objfile;
struct minimal_symbol *msymbol;
memset (&result, 0, sizeof (result));
@ -4924,16 +4922,19 @@ ada_lookup_simple_minsym (const char *name)
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;
}
@ -6391,8 +6392,6 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
{
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;
@ -6412,35 +6411,38 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
anything that isn't a text symbol (everything else will be
handled by the psymtab code above). */
ALL_MSYMBOLS (objfile, msymbol)
{
QUIT;
for (objfile *objfile : all_objfiles (current_program_space))
{
for (minimal_symbol *msymbol : objfile_msymbols (objfile))
{
QUIT;
if (completion_skip_symbol (mode, msymbol))
continue;
if (completion_skip_symbol (mode, msymbol))
continue;
language symbol_language = MSYMBOL_LANGUAGE (msymbol);
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.
/* 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;
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);
}
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. */
@ -6465,6 +6467,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
/* Go through the symtabs and check the externs and statics for
symbols which match. */
struct objfile *objfile;
ALL_COMPUNITS (objfile, s)
{
QUIT;

View File

@ -661,9 +661,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
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);

View File

@ -2540,24 +2540,25 @@ struct bound_minimal_symbol
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;

View File

@ -1488,30 +1488,32 @@ lookup_solib_trampoline_symbol_by_pc (CORE_ADDR pc)
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;
}

View File

@ -562,8 +562,6 @@ compare_selectors (const void *a, const void *b)
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;
@ -607,33 +605,36 @@ info_selectors_command (const char *regexp, int from_tty)
}
/* 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++;
}
}
}
}
@ -644,21 +645,24 @@ info_selectors_command (const char *regexp, int from_tty)
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;
}
}
}
@ -723,8 +727,6 @@ compare_classes (const void *a, const void *b)
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;
@ -757,23 +759,26 @@ info_classes_command (const char *regexp, int from_tty)
}
/* 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)
{
@ -781,15 +786,18 @@ info_classes_command (const char *regexp, int from_tty)
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 *),
@ -987,7 +995,6 @@ find_methods (char type, const char *theclass, const char *category,
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
@ -1001,7 +1008,7 @@ find_methods (char type, const char *theclass, const char *category,
/* 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;

View File

@ -623,12 +623,85 @@ public:
#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. */
@ -643,13 +716,6 @@ public:
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) \

View File

@ -4573,7 +4573,6 @@ void
scan_file_globals (struct objfile *objfile)
{
int hash;
struct minimal_symbol *msymbol;
struct symbol *sym, *prev;
struct objfile *resolve_objfile;
@ -4599,7 +4598,7 @@ scan_file_globals (struct objfile *objfile)
if (hash >= HASHSIZE)
return;
ALL_OBJFILE_MSYMBOLS (resolve_objfile, msymbol)
for (minimal_symbol *msymbol : objfile_msymbols (resolve_objfile))
{
QUIT;

View File

@ -183,7 +183,6 @@ static void
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;
@ -194,7 +193,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
return;
}
index = 0;
ALL_OBJFILE_MSYMBOLS (objfile, msymbol)
for (minimal_symbol *msymbol : objfile_msymbols (objfile))
{
struct obj_section *section = MSYMBOL_OBJ_SECTION (objfile, msymbol);

View File

@ -4344,8 +4344,6 @@ search_symbols (const char *regexp, enum search_domain kind,
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};
@ -4454,81 +4452,93 @@ search_symbols (const char *regexp, enum search_domain kind,
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);
}
}
}
}
@ -4545,39 +4555,44 @@ search_symbols (const char *regexp, enum search_domain kind,
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;
@ -5188,8 +5203,6 @@ default_collect_symbol_completion_matches_break_on
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;
@ -5259,22 +5272,26 @@ default_collect_symbol_completion_matches_break_on
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);