aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-11-23 17:32:08 -0700
committerTom Tromey <tom@tromey.com>2019-01-09 18:28:15 -0700
commit5325b9bf1ee283c40f076334eb3ea66e1f0a6ade (patch)
tree4964d0282ac4cb82ed0a6691cbccf4062c3799d8
parentcac85af2467c9bac326b397b150274d95d2916a5 (diff)
downloadgdb-5325b9bf1ee283c40f076334eb3ea66e1f0a6ade.zip
gdb-5325b9bf1ee283c40f076334eb3ea66e1f0a6ade.tar.gz
gdb-5325b9bf1ee283c40f076334eb3ea66e1f0a6ade.tar.bz2
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.
-rw-r--r--gdb/ChangeLog19
-rw-r--r--gdb/ada-lang.c89
-rw-r--r--gdb/coffread.c4
-rw-r--r--gdb/hppa-tdep.c27
-rw-r--r--gdb/minsyms.c40
-rw-r--r--gdb/objc-lang.c137
-rw-r--r--gdb/objfiles.h90
-rw-r--r--gdb/stabsread.c3
-rw-r--r--gdb/symmisc.c3
-rw-r--r--gdb/symtab.c237
10 files changed, 380 insertions, 269 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e51c19c..08a80d8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,24 @@
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
parameter.
* objfiles.h (ALL_OBJFILES_SAFE): Remove.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index f462f68..e23a6fa 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -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;
-
- 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. */
@@ -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;
diff --git a/gdb/coffread.c b/gdb/coffread.c
index e624d90..e6ca7ed 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -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);
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index d825bce..16e4425 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -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;
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 2c3dd80..d090226 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -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;
}
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index ec0ea56..22c12ff 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -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;
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index cb3668a..a3b0e92 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -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) \
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 8d2599f..daba7cb 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -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;
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 14e7649..24f9176 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -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);
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 17ee946..8bd91bc 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -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);