From: Tom Tromey Date: Fri, 13 Feb 2026 00:13:15 +0000 (-0700) Subject: Change have_*_symbols functions to methods of program_space X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52caa25438f412c1a6eb8626ee2a30e281b4d934;p=thirdparty%2Fbinutils-gdb.git Change have_*_symbols functions to methods of program_space This changes the have_*_symbols functions to be methods of program_space. This version also renames the methods to use "has_" rather than "have_". Approved-By: Simon Marchi --- diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index e02f1e6d10a..0663de01fda 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1870,8 +1870,8 @@ write_var_or_type (struct parser_state *par_state, } } - if (!have_full_symbols (current_program_space) - && !have_partial_symbols (current_program_space) + if (!current_program_space->has_full_symbols () + && !current_program_space->has_partial_symbols () && block == NULL) error (_("No symbol table is loaded. Use the \"file\" command.")); if (block == par_state->expression_context_block) diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 9a37eb5fb69..63e98bfb596 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1201,8 +1201,8 @@ variable: name_not_typename = lookup_minimal_symbol (current_program_space, arg.c_str ()); if (msymbol.minsym == NULL) { - if (!have_full_symbols (current_program_space) - && !have_partial_symbols (current_program_space)) + if (!current_program_space->has_full_symbols () + && !current_program_space->has_partial_symbols ()) error (_("No symbol table is loaded. Use the \"file\" command.")); else error (_("No symbol \"%s\" in current context."), diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 5cf8f87cd75..362883740b1 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1349,8 +1349,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 (current_program_space) - && !have_partial_symbols (current_program_space)) + if (!current_program_space->has_full_symbols () + && !current_program_space->has_partial_symbols ()) error (_("No symbol table is loaded. Use the \"file\" command.")); std::vector sals; diff --git a/gdb/d-exp.y b/gdb/d-exp.y index eef87702353..963a853023c 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -466,8 +466,8 @@ PrimaryExpression: = lookup_minimal_symbol (current_program_space, copy.c_str ()); if (msymbol.minsym != NULL) pstate->push_new (msymbol); - else if (!have_full_symbols (current_program_space) - && !have_partial_symbols (current_program_space)) + else if (!current_program_space->has_full_symbols () + && !current_program_space->has_partial_symbols ()) error (_("No symbol table is loaded. Use the \"file\" command")); else error (_("No symbol \"%s\" in current context."), diff --git a/gdb/go-exp.y b/gdb/go-exp.y index d6060c9567d..289fd81db85 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -575,8 +575,8 @@ variable: name_not_typename if (msymbol.minsym != NULL) pstate->push_new (msymbol); - else if (!have_full_symbols (current_program_space) - && !have_partial_symbols (current_program_space)) + else if (!current_program_space->has_full_symbols () + && !current_program_space->has_partial_symbols ()) error (_("No symbol table is loaded. " "Use the \"file\" command.")); else diff --git a/gdb/linespec.c b/gdb/linespec.c index 4376a769e49..024358c65f5 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1524,9 +1524,9 @@ symbol_not_found_error (const char *symbol, const char *filename) if (symbol == NULL) symbol = ""; - if (!have_full_symbols (current_program_space) - && !have_partial_symbols (current_program_space) - && !have_minimal_symbols (current_program_space)) + if (!current_program_space->has_full_symbols () + && !current_program_space->has_partial_symbols () + && !current_program_space->has_minimal_symbols ()) throw_error (NOT_FOUND_ERROR, _("No symbol table is loaded. Use the \"file\" command.")); @@ -3648,8 +3648,8 @@ symtabs_from_filename (const char *filename, if (result.empty ()) { - if (!have_full_symbols (current_program_space) - && !have_partial_symbols (current_program_space)) + if (!current_program_space->has_full_symbols () + && !current_program_space->has_partial_symbols ()) throw_error (NOT_FOUND_ERROR, _("No symbol table is loaded. " "Use the \"file\" command.")); diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 4f5258e971d..ff98cf28ca6 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -611,31 +611,6 @@ objfile::has_symbols () return false; } -/* See objfiles.h. */ - -bool -have_partial_symbols (program_space *pspace) -{ - for (objfile &ofp : pspace->objfiles ()) - if (ofp.has_partial_symbols ()) - return true; - - return false; -} - -/* See objfiles.h. */ - -bool -have_full_symbols (program_space *pspace) -{ - for (objfile &ofp : pspace->objfiles ()) - if (ofp.has_full_symbols ()) - return true; - - return false; -} - - /* See objfiles.h. */ void @@ -651,18 +626,6 @@ objfile_purge_solibs (program_space *pspace) } } -/* See objfiles.h. */ - -bool -have_minimal_symbols (program_space *pspace) -{ - for (objfile &ofp : pspace->objfiles ()) - if (ofp.per_bfd->minimal_symbol_count > 0) - return true; - - return false; -} - /* Qsort comparison function. */ static bool diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 371fd223693..89ac559ce81 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -912,14 +912,6 @@ extern void objfile_relocate (struct objfile *, gdb::array_view); extern void objfile_rebase (struct objfile *, CORE_ADDR); -/* Return true if any objfile of PSPACE has partial symbols. */ - -extern bool have_partial_symbols (program_space *pspace); - -/* Return true if any objfile of PSPACE has full symbols. */ - -extern bool have_full_symbols (program_space *pspace); - extern void objfile_set_sym_fns (struct objfile *objfile, const struct sym_fns *sf); @@ -948,10 +940,6 @@ 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 PSPACE has minimal symbols. */ - -extern bool have_minimal_symbols (program_space *pspace); - extern struct obj_section *find_pc_section (CORE_ADDR pc); /* Return true if PC is in a section called NAME. */ diff --git a/gdb/p-exp.y b/gdb/p-exp.y index 8195a08c1ac..00b67647fc5 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -723,8 +723,8 @@ variable: name_not_typename if (msymbol.minsym != NULL) pstate->push_new (msymbol); - else if (!have_full_symbols (current_program_space) - && !have_partial_symbols (current_program_space)) + else if (!current_program_space->has_full_symbols () + && !current_program_space->has_partial_symbols ()) error (_("No symbol table is loaded. " "Use the \"file\" command.")); else diff --git a/gdb/parse.c b/gdb/parse.c index 21a59d0f2be..9769150a134 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -148,8 +148,8 @@ parser_state::push_symbol (const char *name, block_symbol sym) = lookup_minimal_symbol (current_program_space, name); if (msymbol.minsym != NULL) push_new (msymbol); - else if (!have_full_symbols (current_program_space) - && !have_partial_symbols (current_program_space)) + else if (!current_program_space->has_full_symbols () + && !current_program_space->has_partial_symbols ()) error (_("No symbol table is loaded. Use the \"file\" command.")); else error (_("No symbol \"%s\" in current context."), name); diff --git a/gdb/progspace.c b/gdb/progspace.c index 3e10e57012b..7fcb2c3d5c9 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -311,6 +311,42 @@ program_space::entry_point_address () const return *retval; } +/* See progspace.h. */ + +bool +program_space::has_partial_symbols () +{ + for (objfile &ofp : objfiles ()) + if (ofp.has_partial_symbols ()) + return true; + + return false; +} + +/* See progspace.h. */ + +bool +program_space::has_full_symbols () +{ + for (objfile &ofp : objfiles ()) + if (ofp.has_full_symbols ()) + return true; + + return false; +} + +/* See progspace.h. */ + +bool +program_space::has_minimal_symbols () +{ + for (objfile &ofp : objfiles ()) + if (ofp.per_bfd->minimal_symbol_count > 0) + return true; + + return false; +} + /* Prints the list of program spaces and their details on UIOUT. If REQUESTED is not -1, it's the ID of the pspace that should be printed. Otherwise, all spaces are printed. */ diff --git a/gdb/progspace.h b/gdb/progspace.h index 3ed33b2e472..04cf9680a8a 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -340,6 +340,18 @@ struct program_space it is not known. */ CORE_ADDR entry_point_address () const; + /* Return true if any objfile of this program space has partial + symbols. */ + bool has_partial_symbols (); + + /* Return true if any objfile of this program space has full + symbols. */ + bool has_full_symbols (); + + /* Return true if any objfile of this program space has minimal + symbols. */ + bool has_minimal_symbols (); + /* Unique ID number. */ int num = 0; diff --git a/gdb/source.c b/gdb/source.c index f890533b931..5210bb9699f 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -254,8 +254,8 @@ get_current_source_symtab_and_line (program_space *pspace) void set_default_source_symtab_and_line (void) { - if (!have_full_symbols (current_program_space) - && !have_partial_symbols (current_program_space)) + if (!current_program_space->has_full_symbols () + && !current_program_space->has_partial_symbols ()) error (_("No symbol table is loaded. Use the \"file\" command.")); /* Pull in a current source symtab if necessary. */ diff --git a/gdb/symfile.c b/gdb/symfile.c index aadb449153e..44a9480d9d9 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1040,8 +1040,8 @@ symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name, if (from_tty && (always_confirm - || ((have_full_symbols (current_program_space) - || have_partial_symbols (current_program_space)) + || ((current_program_space->has_full_symbols () + || current_program_space->has_partial_symbols ()) && mainline)) && !query (_("Load new symbol table from \"%s\"? "), name)) error (_("Not confirmed.")); @@ -1189,8 +1189,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 (current_program_space) - || have_partial_symbols (current_program_space)) + if ((current_program_space->has_full_symbols () + || current_program_space->has_partial_symbols ()) && from_tty && (current_program_space->symfile_object_file ? !query (_("Discard symbol table from `%s'? "), diff --git a/gdb/symtab.c b/gdb/symtab.c index 07436104ce7..cd3bf876551 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4573,8 +4573,8 @@ info_sources_worker (struct ui_out *uiout, static void info_sources_command (const char *args, int from_tty) { - if (!have_full_symbols (current_program_space) - && !have_partial_symbols (current_program_space)) + if (!current_program_space->has_full_symbols () + && !current_program_space->has_partial_symbols ()) error (_("No symbol table is loaded. Use the \"file\" command.")); filename_partial_match_opts match_opts; @@ -6258,8 +6258,8 @@ make_source_files_completion_list (const char *text) const char *base_name; struct add_partial_filename_data datum; - if (!have_full_symbols (current_program_space) - && !have_partial_symbols (current_program_space)) + if (!current_program_space->has_full_symbols () + && !current_program_space->has_partial_symbols ()) return list; filename_seen_cache filenames_seen; diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index 2b22ca9efca..5c68312a91b 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -393,8 +393,8 @@ tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p) if (tui_location.addr () == 0) { - if (have_full_symbols (current_program_space) - || have_partial_symbols (current_program_space)) + if (current_program_space->has_full_symbols () + || current_program_space->has_partial_symbols ()) { set_default_source_symtab_and_line (); symtab_and_line sal