]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: pass program space to have_{full,partial}_symbols
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 16 May 2024 20:37:06 +0000 (16:37 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 15 Jul 2024 18:34:12 +0000 (14:34 -0400)
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>
15 files changed:
gdb/ada-exp.y
gdb/c-exp.y
gdb/cli/cli-cmds.c
gdb/d-exp.y
gdb/go-exp.y
gdb/infcmd.c
gdb/linespec.c
gdb/objfiles.c
gdb/objfiles.h
gdb/p-exp.y
gdb/parse.c
gdb/source.c
gdb/symfile.c
gdb/symtab.c
gdb/tui/tui-disasm.c

index 0126db5f2bee5c781488c697b4d9b1c66e2c0354..dfcbb2bebd9802fe597d4c4d77d26c2867e8e44f 100644 (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);
index 60223172a23c91899b481aecb46187490b388d88..a1a74a985a6fa6b36dcd14a06ff96c232b5f3dd8 100644 (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."),
index 450009156d4bbc67fb9bb83c8c9a0df980c36b3e..9d3a90b057d2d48858d468906ba55f54197e8be8 100644 (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;
index 13d2cfa44d8817d1cd8a15aa445d95abc760d459..6feacd8e3648f181cf2fb0a32b23b2d32f114649 100644 (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."),
index 1a6ebbe135bebe744124e2043cad4919f9425f45..115c71ba8ea946058302f95a245176368e9ab2c3 100644 (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
index 4ed55f1342ccc72e55e42bbeff5edb738deb321e..4ce11b5af4685c55e0d977b5c38dd5611b5177c6 100644 (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...  */
index 9769f011fae1f4daba498d68caef5a20c9d11cff..8670e0ac541535958f7ce136baac1bb836b273b7 100644 (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."));
index 25129b2fb31e84ac5688f1fb163bd1a615c71159..ffa730120f57b13001e3065e2102e2cbc0237143 100644 (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;
 
index 5cf73315a9b279fa5673fa8296be38412837611a..252b52e226e9c6e5db19d695838adc1624b949bc 100644 (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);
 
index f334db6b5237a772811ac6860c8691d46685de58..0a0fa95e86888ff8c493703ddf5ddf7f662f02d5 100644 (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
index 0a2b2a5b2abfcee3b627fb945951af8878f87d3a..c10b09af485e823d9b413d2819669d8077e0fa7c 100644 (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);
index bced213171a6ca5ae43e68942e8be6f8a947b2e9..bdbe67d19f5ac8b6fb89db0015b5db7ea0a644a3 100644 (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);
index 69230482da3cde23cc6d057414fa85b5df8664a9..a4f964a8bac16a57dabb820bcca3497b38f89bc0 100644 (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'? "),
index 9ffc1e0b26b063f94258076747f8d4277ef3ac3f..bb2fc049819ceb9820eb9cc19b57e464fa78c80e 100644 (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;
index 0727d3a90a82df3523be9e31e7508199b5c7d082..2f25fedbcab34ce4243ff0d75a537aa352a4e3a2 100644 (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 ();