]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Change have_*_symbols functions to methods of program_space
authorTom Tromey <tom@tromey.com>
Fri, 13 Feb 2026 00:13:15 +0000 (17:13 -0700)
committerTom Tromey <tom@tromey.com>
Sat, 14 Feb 2026 17:35:24 +0000 (10:35 -0700)
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 <simon.marchi@efficios.com>
16 files changed:
gdb/ada-exp.y
gdb/c-exp.y
gdb/cli/cli-cmds.c
gdb/d-exp.y
gdb/go-exp.y
gdb/linespec.c
gdb/objfiles.c
gdb/objfiles.h
gdb/p-exp.y
gdb/parse.c
gdb/progspace.c
gdb/progspace.h
gdb/source.c
gdb/symfile.c
gdb/symtab.c
gdb/tui/tui-disasm.c

index e02f1e6d10a2e486d8a660eef7d62ee813a40844..0663de01fda17e78913c595dc44a1c6150b2b31c 100644 (file)
@@ -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)
index 9a37eb5fb692e91d3466623984623f52769688a7..63e98bfb596acb36be49168740113877af2b109b 100644 (file)
@@ -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."),
index 5cf8f87cd752a417527884630ea548f300379a11..362883740b196c0de4d57a5d533f8de49bcc8f29 100644 (file)
@@ -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<symtab_and_line> sals;
index eef87702353c302424d063e2cde19cfdfda31a50..963a853023cbb48ef51367afe33214fe1dbada43 100644 (file)
@@ -466,8 +466,8 @@ PrimaryExpression:
                        = lookup_minimal_symbol (current_program_space, copy.c_str ());
                      if (msymbol.minsym != NULL)
                        pstate->push_new<var_msym_value_operation> (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."),
index d6060c9567de66aab0ca983225ce8031a7546dbe..289fd81db857b3ab398857359cb598d292a34113 100644 (file)
@@ -575,8 +575,8 @@ variable:   name_not_typename
                              if (msymbol.minsym != NULL)
                                pstate->push_new<var_msym_value_operation>
                                  (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
index 4376a769e4944f698273c252c17db683a0801c25..024358c65f597136dde04cf160809aba80c9618b 100644 (file)
@@ -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."));
index 4f5258e971d74f42bd9afa0c5ca437cbb76834bc..ff98cf28ca6b4857dedbde99c9c9e898412bc022 100644 (file)
@@ -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
index 371fd22369332421fbb2a437f9d765f2dff66cd9..89ac559ce813fdc95aeefd83a4b0cf4f0d3780d0 100644 (file)
@@ -912,14 +912,6 @@ extern void objfile_relocate (struct objfile *,
                              gdb::array_view<const CORE_ADDR>);
 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.  */
index 8195a08c1ac70259b8ea3daeaefc78a626ab4105..00b67647fc56fd33754aa320a4bf9ff337c7af41 100644 (file)
@@ -723,8 +723,8 @@ variable:   name_not_typename
                              if (msymbol.minsym != NULL)
                                pstate->push_new<var_msym_value_operation>
                                  (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
index 21a59d0f2be190bf85fcb638591887078283f2fb..9769150a13489f1d51179c1146a27d5291f2c06c 100644 (file)
@@ -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<expr::var_msym_value_operation> (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);
index 3e10e57012bde6a2b2c41425bc9821ec36154920..7fcb2c3d5c9f1ee57c9c3d11cd3fc7767446cb38 100644 (file)
@@ -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.  */
index 3ed33b2e472745f8b5c7fdbb942a1dd7bbd0314a..04cf9680a8a4ef5264b42b5e78a15815db762219 100644 (file)
@@ -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;
 
index f890533b93176f5aed6263c4090875190940a50d..5210bb9699f0ded98476c30c3abc9c775f6ae96b 100644 (file)
@@ -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.  */
index aadb449153eca716fb829a8c68af6be60501d1eb..44a9480d9d90609664e0dfaceecbc636c4bb8fc0 100644 (file)
@@ -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'? "),
index 07436104ce7fad2f361427caddee3c3b3d9af508..cd3bf87655142c43c5a5cc207d8fb1393172ea5f 100644 (file)
@@ -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;
index 2b22ca9efcab659678e06ef8ee0685189c120121..5c68312a91b645070ce9a8b1ffce839b06c4a2c5 100644 (file)
@@ -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