gdb: pass program space to have_{full,partial}_symbols

Make the current program space reference bubble up one level.

Change-Id: I19c4fc2ca955f9c828ef426a077b43983865697b
Approved-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
This commit is contained in:
Simon Marchi
2024-05-16 16:37:06 -04:00
committed by Simon Marchi
parent cc7541ce5e
commit 9c067e2844
15 changed files with 48 additions and 37 deletions

View File

@@ -1857,7 +1857,9 @@ write_var_or_type (struct parser_state *par_state,
}
}
if (!have_full_symbols () && !have_partial_symbols () && block == NULL)
if (!have_full_symbols (current_program_space)
&& !have_partial_symbols (current_program_space)
&& block == NULL)
error (_("No symbol table is loaded. Use the \"file\" command."));
if (block == par_state->expression_context_block)
error (_("No definition of \"%s\" in current context."), name0.ptr);

View File

@@ -1213,7 +1213,8 @@ variable: name_not_typename
= lookup_bound_minimal_symbol (arg.c_str ());
if (msymbol.minsym == NULL)
{
if (!have_full_symbols () && !have_partial_symbols ())
if (!have_full_symbols (current_program_space)
&& !have_partial_symbols (current_program_space))
error (_("No symbol table is loaded. Use the \"file\" command."));
else
error (_("No symbol \"%s\" in current context."),

View File

@@ -1327,7 +1327,8 @@ list_command (const char *arg, int from_tty)
and clear NO_END; however, if one of the arguments is blank,
set DUMMY_BEG or DUMMY_END to record that fact. */
if (!have_full_symbols () && !have_partial_symbols ())
if (!have_full_symbols (current_program_space)
&& !have_partial_symbols (current_program_space))
error (_("No symbol table is loaded. Use the \"file\" command."));
std::vector<symtab_and_line> sals;

View File

@@ -466,7 +466,8 @@ PrimaryExpression:
msymbol = lookup_bound_minimal_symbol (copy.c_str ());
if (msymbol.minsym != NULL)
pstate->push_new<var_msym_value_operation> (msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
else if (!have_full_symbols (current_program_space)
&& !have_partial_symbols (current_program_space))
error (_("No symbol table is loaded. Use the \"file\" command"));
else
error (_("No symbol \"%s\" in current context."),

View File

@@ -577,8 +577,8 @@ variable: name_not_typename
if (msymbol.minsym != NULL)
pstate->push_new<var_msym_value_operation>
(msymbol);
else if (!have_full_symbols ()
&& !have_partial_symbols ())
else if (!have_full_symbols (current_program_space)
&& !have_partial_symbols (current_program_space))
error (_("No symbol table is loaded. "
"Use the \"file\" command."));
else

View File

@@ -519,7 +519,7 @@ start_command (const char *args, int from_tty)
/* Some languages such as Ada need to search inside the program
minimal symbols for the location where to put the temporary
breakpoint before starting. */
if (!have_minimal_symbols ())
if (!have_minimal_symbols (current_program_space))
error (_("No symbol table loaded. Use the \"file\" command."));
/* Run the program until reaching the main procedure... */

View File

@@ -1550,9 +1550,9 @@ symbol_not_found_error (const char *symbol, const char *filename)
if (symbol == NULL)
symbol = "";
if (!have_full_symbols ()
&& !have_partial_symbols ()
&& !have_minimal_symbols ())
if (!have_full_symbols (current_program_space)
&& !have_partial_symbols (current_program_space)
&& !have_minimal_symbols (current_program_space))
throw_error (NOT_FOUND_ERROR,
_("No symbol table is loaded. Use the \"file\" command."));
@@ -3716,7 +3716,8 @@ symtabs_from_filename (const char *filename,
if (result.empty ())
{
if (!have_full_symbols () && !have_partial_symbols ())
if (!have_full_symbols (current_program_space)
&& !have_partial_symbols (current_program_space))
throw_error (NOT_FOUND_ERROR,
_("No symbol table is loaded. "
"Use the \"file\" command."));

View File

@@ -755,9 +755,9 @@ objfile_has_symbols (objfile *objfile)
/* See objfiles.h. */
bool
have_partial_symbols ()
have_partial_symbols (program_space *pspace)
{
for (objfile *ofp : current_program_space->objfiles ())
for (objfile *ofp : pspace->objfiles ())
if (ofp->has_partial_symbols ())
return true;
@@ -767,9 +767,9 @@ have_partial_symbols ()
/* See objfiles.h. */
bool
have_full_symbols ()
have_full_symbols (program_space *pspace)
{
for (objfile *ofp : current_program_space->objfiles ())
for (objfile *ofp : pspace->objfiles ())
if (objfile_has_full_symbols (ofp))
return true;
@@ -795,9 +795,9 @@ objfile_purge_solibs (program_space *pspace)
/* See objfiles.h. */
bool
have_minimal_symbols ()
have_minimal_symbols (program_space *pspace)
{
for (objfile *ofp : current_program_space->objfiles ())
for (objfile *ofp : pspace->objfiles ())
if (ofp->per_bfd->minimal_symbol_count > 0)
return true;

View File

@@ -932,14 +932,13 @@ extern bool objfile_has_full_symbols (objfile *objfile);
extern bool objfile_has_symbols (objfile *objfile);
/* Return true if any objfile of the current program space has partial
symbols. */
/* Return true if any objfile of PSPACE has partial symbols. */
extern bool have_partial_symbols ();
extern bool have_partial_symbols (program_space *pspace);
/* Return true if any objfile of the current program space has full symbols. */
/* Return true if any objfile of PSPACE has full symbols. */
extern bool have_full_symbols ();
extern bool have_full_symbols (program_space *pspace);
extern void objfile_set_sym_fns (struct objfile *objfile,
const struct sym_fns *sf);
@@ -966,10 +965,9 @@ extern void objfile_purge_solibs (program_space *pspace);
/* Functions for dealing with the minimal symbol table, really a misc
address<->symbol mapping for things we don't have debug symbols for. */
/* Return true if any objfile of the current program space has minimal
symbols. */
/* Return true if any objfile of PSPACE has minimal symbols. */
extern bool have_minimal_symbols ();
extern bool have_minimal_symbols (program_space *pspace);
extern struct obj_section *find_pc_section (CORE_ADDR pc);

View File

@@ -725,8 +725,8 @@ variable: name_not_typename
if (msymbol.minsym != NULL)
pstate->push_new<var_msym_value_operation>
(msymbol);
else if (!have_full_symbols ()
&& !have_partial_symbols ())
else if (!have_full_symbols (current_program_space)
&& !have_partial_symbols (current_program_space))
error (_("No symbol table is loaded. "
"Use the \"file\" command."));
else

View File

@@ -148,7 +148,8 @@ parser_state::push_symbol (const char *name, block_symbol sym)
struct bound_minimal_symbol msymbol = lookup_bound_minimal_symbol (name);
if (msymbol.minsym != NULL)
push_new<expr::var_msym_value_operation> (msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
else if (!have_full_symbols (current_program_space)
&& !have_partial_symbols (current_program_space))
error (_("No symbol table is loaded. Use the \"file\" command."));
else
error (_("No symbol \"%s\" in current context."), name);

View File

@@ -260,8 +260,9 @@ get_current_source_symtab_and_line (void)
void
set_default_source_symtab_and_line (void)
{
if (!have_full_symbols () && !have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
if (!have_full_symbols (current_program_space)
&& !have_partial_symbols (current_program_space))
error (_ ("No symbol table is loaded. Use the \"file\" command."));
/* Pull in a current source symtab if necessary. */
current_source_location *loc = get_source_location (current_program_space);

View File

@@ -1053,9 +1053,10 @@ symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name,
if (from_tty
&& (always_confirm
|| ((have_full_symbols () || have_partial_symbols ())
|| ((have_full_symbols (current_program_space)
|| have_partial_symbols (current_program_space))
&& mainline))
&& !query (_("Load new symbol table from \"%s\"? "), name))
&& !query (_ ("Load new symbol table from \"%s\"? "), name))
error (_("Not confirmed."));
if (mainline)
@@ -1199,7 +1200,8 @@ symbol_file_add_main_1 (const char *args, symfile_add_flags add_flags,
void
symbol_file_clear (int from_tty)
{
if ((have_full_symbols () || have_partial_symbols ())
if ((have_full_symbols (current_program_space)
|| have_partial_symbols (current_program_space))
&& from_tty
&& (current_program_space->symfile_object_file
? !query (_("Discard symbol table from `%s'? "),

View File

@@ -4764,8 +4764,9 @@ info_sources_worker (struct ui_out *uiout,
static void
info_sources_command (const char *args, int from_tty)
{
if (!have_full_symbols () && !have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
if (!have_full_symbols (current_program_space)
&& !have_partial_symbols (current_program_space))
error (_ ("No symbol table is loaded. Use the \"file\" command."));
filename_partial_match_opts match_opts;
auto group = make_info_sources_options_def_group (&match_opts);
@@ -6381,7 +6382,8 @@ make_source_files_completion_list (const char *text, const char *word)
const char *base_name;
struct add_partial_filename_data datum;
if (!have_full_symbols () && !have_partial_symbols ())
if (!have_full_symbols (current_program_space)
&& !have_partial_symbols (current_program_space))
return list;
filename_seen_cache filenames_seen;

View File

@@ -389,7 +389,8 @@ tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
if (tui_location.addr () == 0)
{
if (have_full_symbols () || have_partial_symbols ())
if (have_full_symbols (current_program_space)
|| have_partial_symbols (current_program_space))
{
set_default_source_symtab_and_line ();
struct symtab_and_line sal = get_current_source_symtab_and_line ();