Make the current program space references bubble up.
In collect_symtabs_from_filename, remove the calls to
set_current_program_space and just pass the relevant pspaces.
This appears safe to do, because nothing in the `collector` callback
cares about the current pspace.
Change-Id: I00a7ed484bfbe5264f01a6abf0d33b51de373cbb
Reviewed-by: Keith Seitz <keiths@redhat.com>
if (context == NULL
&& (syms.empty () || syms[0].symbol->aclass () != LOC_BLOCK))
- symtab = lookup_symtab (name);
+ symtab = lookup_symtab (current_program_space, name);
else
symtab = NULL;
|| is_quoted_name)
{
/* See if it's a file name. */
- struct symtab *symtab;
-
- symtab = lookup_symtab (copy.c_str ());
- if (symtab)
+ if (auto symtab = lookup_symtab (current_program_space, copy.c_str ());
+ symtab != nullptr)
{
yylval.bval
= symtab->compunit ()->blockvector ()->static_block ();
if (pspace->executing_startup)
continue;
- set_current_program_space (pspace);
- iterate_over_symtabs (file, collector);
+ iterate_over_symtabs (pspace, file, collector);
}
}
else
- {
- set_current_program_space (search_pspace);
- iterate_over_symtabs (file, collector);
- }
+ iterate_over_symtabs (search_pspace, file, collector);
return collector.release_symtabs ();
}
std::string tmp = copy_name (yylval.sval);
struct symbol *sym;
- if (lookup_symtab (tmp.c_str ()))
+ if (lookup_symtab (current_program_space, tmp.c_str ()) != nullptr)
return BLOCKNAME;
+
sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
SEARCH_VFT, 0).symbol;
if (sym && sym->aclass () == LOC_BLOCK)
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "arch-utils.h"
+#include "progspace.h"
#include "target.h"
#include "value.h"
#include "mi-cmds.h"
if (line_seen && file_seen)
{
- s = lookup_symtab (file_string);
+ s = lookup_symtab (current_program_space, file_string);
if (s == NULL)
error (_("-data-disassemble: Invalid filename."));
if (!find_line_pc (s, line_num, &start))
error (_("-symbol-list-lines: Usage: SOURCE_FILENAME"));
filename = argv[0];
- s = lookup_symtab (filename);
+ s = lookup_symtab (current_program_space, filename);
if (s == NULL)
error (_("-symbol-list-lines: Unknown source file name."));
{
std::string copy = copy_name ($1.stoken);
struct symtab *tem =
- lookup_symtab (copy.c_str ());
+ lookup_symtab (current_program_space, copy.c_str ());
if (tem)
$$ = (tem->compunit ()->blockvector ()
->static_block ());
no psymtabs (coff, xcoff, or some future change to blow away the
psymtabs once once symbols are read). */
if ((sym && sym->aclass () == LOC_BLOCK)
- || lookup_symtab (tmp.c_str ()))
+ || lookup_symtab (current_program_space, tmp.c_str ()))
{
yylval.ssym.sym.symbol = sym;
yylval.ssym.sym.block = NULL;
return false;
}
-/* Check for a symtab of a specific name; first in symtabs, then in
- psymtabs. *If* there is no '/' in the name, a match after a '/'
- in the symtab filename will also work.
-
- Calls CALLBACK with each symtab that is found. If CALLBACK returns
- true, the search stops. */
+/* See symtab.h. */
void
-iterate_over_symtabs (const char *name,
+iterate_over_symtabs (program_space *pspace, const char *name,
gdb::function_view<bool (symtab *)> callback)
{
gdb::unique_xmalloc_ptr<char> real_path;
gdb_assert (IS_ABSOLUTE_PATH (real_path.get ()));
}
- for (objfile *objfile : current_program_space->objfiles ())
- {
- if (iterate_over_some_symtabs (name, real_path.get (),
- objfile->compunit_symtabs, NULL,
- callback))
+ for (objfile *objfile : pspace->objfiles ())
+ if (iterate_over_some_symtabs (name, real_path.get (),
+ objfile->compunit_symtabs, nullptr,
+ callback))
return;
- }
/* Same search rules as above apply here, but now we look thru the
psymtabs. */
-
- for (objfile *objfile : current_program_space->objfiles ())
- {
- if (objfile->map_symtabs_matching_filename (name, real_path.get (),
- callback))
- return;
- }
+ for (objfile *objfile : pspace->objfiles ())
+ if (objfile->map_symtabs_matching_filename (name, real_path.get (),
+ callback))
+ return;
}
-/* A wrapper for iterate_over_symtabs that returns the first matching
- symtab, or NULL. */
+/* See symtab.h. */
-struct symtab *
-lookup_symtab (const char *name)
+symtab *
+lookup_symtab (program_space *pspace, const char *name)
{
struct symtab *result = NULL;
- iterate_over_symtabs (name, [&] (symtab *symtab)
+ iterate_over_symtabs (pspace, name, [&] (symtab *symtab)
{
result = symtab;
return true;
/* Go through symtabs for SRCFILE and check the externs and statics
for symbols which match. */
- iterate_over_symtabs (srcfile, [&] (symtab *s)
+ iterate_over_symtabs (current_program_space, srcfile, [&] (symtab *s)
{
add_symtab_completions (s->compunit (),
tracker, mode, lookup_name,
const char *multiple_symbols_select_mode (void);
-/* lookup a symbol table by source file name. */
+/* Lookup a symbol table in PSPACE by source file name. */
-extern struct symtab *lookup_symtab (const char *);
+extern symtab *lookup_symtab (program_space *pspace, const char *name);
/* An object of this type is passed as the 'is_a_field_of_this'
argument to lookup_symbol and lookup_symbol_in_language. */
struct compunit_symtab *after_last,
gdb::function_view<bool (symtab *)> callback);
-void iterate_over_symtabs (const char *name,
- gdb::function_view<bool (symtab *)> callback);
+/* Check in PSPACE for a symtab of a specific name; first in symtabs, then in
+ psymtabs. *If* there is no '/' in the name, a match after a '/' in the
+ symtab filename will also work.
+
+ Call CALLBACK with each symtab that is found. If CALLBACK returns
+ true, the search stops. */
+void iterate_over_symtabs (program_space *pspace, const char *name,
+ gdb::function_view<bool (symtab *)> callback);
std::vector<CORE_ADDR> find_pcs_for_symtab_line
(struct symtab *symtab, int line, const linetable_entry **best_entry);