aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/solib.c')
-rw-r--r--gdb/solib.c105
1 files changed, 60 insertions, 45 deletions
diff --git a/gdb/solib.c b/gdb/solib.c
index 7782c8d..4876f1a 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1,6 +1,6 @@
/* Handle shared libraries for GDB, the GNU Debugger.
- Copyright (C) 1990-2024 Free Software Foundation, Inc.
+ Copyright (C) 1990-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -68,7 +68,7 @@ show_solib_search_path (struct ui_file *file, int from_tty,
value);
}
-/* Same as HAVE_DOS_BASED_FILE_SYSTEM, but useable as an rvalue. */
+/* Same as HAVE_DOS_BASED_FILE_SYSTEM, but usable as an rvalue. */
#if (HAVE_DOS_BASED_FILE_SYSTEM)
#define DOS_BASED_FILE_SYSTEM 1
#else
@@ -694,14 +694,17 @@ notify_solib_loaded (solib &so)
/* Notify interpreters and observers that solib SO has been unloaded.
When STILL_IN_USE is true, the objfile backing SO is still in use,
this indicates that SO was loaded multiple times, but only mapped
- in once (the mapping was reused). */
+ in once (the mapping was reused).
+
+ When SILENT is true, don't announce to the user if any breakpoints are
+ disabled as a result of unloading SO. */
static void
notify_solib_unloaded (program_space *pspace, const solib &so,
- bool still_in_use)
+ bool still_in_use, bool silent)
{
interps_notify_solib_unloaded (so, still_in_use);
- gdb::observers::solib_unloaded.notify (pspace, so, still_in_use);
+ gdb::observers::solib_unloaded.notify (pspace, so, still_in_use, silent);
}
/* See solib.h. */
@@ -803,7 +806,7 @@ update_solib_list (int from_tty)
/* Notify any observer that the shared object has been
unloaded before we remove it from GDB's tables. */
notify_solib_unloaded (current_program_space, *gdb_iter,
- still_in_use);
+ still_in_use, false);
/* Unless the user loaded it explicitly, free SO's objfile. */
if (gdb_iter->objfile != nullptr
@@ -1048,12 +1051,24 @@ info_sharedlibrary_command (const char *pattern, int from_tty)
}
}
+ /* How many columns the table should have. If the inferior has
+ more than one namespace active, we need a column to show that. */
+ int num_cols = 4;
+ const solib_ops *ops = gdbarch_so_ops (gdbarch);
+ if (ops->num_active_namespaces != nullptr
+ && ops->num_active_namespaces () > 1)
+ num_cols++;
+
{
- ui_out_emit_table table_emitter (uiout, 4, nr_libs, "SharedLibraryTable");
+ ui_out_emit_table table_emitter (uiout, num_cols, nr_libs,
+ "SharedLibraryTable");
/* The "- 1" is because ui_out adds one space between columns. */
uiout->table_header (addr_width - 1, ui_left, "from", "From");
uiout->table_header (addr_width - 1, ui_left, "to", "To");
+ if (ops->num_active_namespaces != nullptr
+ && ops->num_active_namespaces () > 1)
+ uiout->table_header (5, ui_left, "namespace", "NS");
uiout->table_header (12 - 1, ui_left, "syms-read", "Syms Read");
uiout->table_header (0, ui_noalign, "name", "Shared Object Library");
@@ -1080,6 +1095,19 @@ info_sharedlibrary_command (const char *pattern, int from_tty)
uiout->field_skip ("to");
}
+ if (ops->num_active_namespaces != nullptr
+ && ops->num_active_namespaces ()> 1)
+ {
+ try
+ {
+ uiout->field_fmt ("namespace", "[[%d]]", ops->find_solib_ns (so));
+ }
+ catch (const gdb_exception_error &er)
+ {
+ uiout->field_skip ("namespace");
+ }
+ }
+
if (!top_level_interpreter ()->interp_ui_out ()->is_mi_like_p ()
&& so.symbols_loaded && !objfile_has_symbols (so.objfile))
{
@@ -1163,14 +1191,12 @@ clear_solib (program_space *pspace)
{
const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
- disable_breakpoints_in_shlibs (pspace);
-
for (solib &so : pspace->so_list)
{
bool still_in_use
= (so.objfile != nullptr && solib_used (pspace, so));
- notify_solib_unloaded (pspace, so, still_in_use);
+ notify_solib_unloaded (pspace, so, still_in_use, true);
pspace->remove_target_sections (&so);
};
@@ -1431,49 +1457,38 @@ CORE_ADDR
gdb_bfd_lookup_symbol_from_symtab (
bfd *abfd, gdb::function_view<bool (const asymbol *)> match_sym)
{
- long storage_needed = bfd_get_symtab_upper_bound (abfd);
CORE_ADDR symaddr = 0;
+ gdb::array_view<asymbol *> symbol_table
+ = gdb_bfd_canonicalize_symtab (abfd, false);
- if (storage_needed > 0)
+ for (asymbol *sym : symbol_table)
{
- unsigned int i;
-
- gdb::def_vector<asymbol *> storage (storage_needed / sizeof (asymbol *));
- asymbol **symbol_table = storage.data ();
- unsigned int number_of_symbols
- = bfd_canonicalize_symtab (abfd, symbol_table);
-
- for (i = 0; i < number_of_symbols; i++)
+ if (match_sym (sym))
{
- asymbol *sym = *symbol_table++;
-
- if (match_sym (sym))
+ gdbarch *gdbarch = current_inferior ()->arch ();
+ symaddr = sym->value;
+
+ /* Some ELF targets fiddle with addresses of symbols they
+ consider special. They use minimal symbols to do that
+ and this is needed for correct breakpoint placement,
+ but we do not have full data here to build a complete
+ minimal symbol, so just set the address and let the
+ targets cope with that. */
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
+ && gdbarch_elf_make_msymbol_special_p (gdbarch))
{
- gdbarch *gdbarch = current_inferior ()->arch ();
- symaddr = sym->value;
-
- /* Some ELF targets fiddle with addresses of symbols they
- consider special. They use minimal symbols to do that
- and this is needed for correct breakpoint placement,
- but we do not have full data here to build a complete
- minimal symbol, so just set the address and let the
- targets cope with that. */
- if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
- && gdbarch_elf_make_msymbol_special_p (gdbarch))
+ struct minimal_symbol msym
{
- struct minimal_symbol msym
- {
- };
+ };
- msym.set_value_address (symaddr);
- gdbarch_elf_make_msymbol_special (gdbarch, sym, &msym);
- symaddr = CORE_ADDR (msym.unrelocated_address ());
- }
-
- /* BFD symbols are section relative. */
- symaddr += sym->section->vma;
- break;
+ msym.set_value_address (symaddr);
+ gdbarch_elf_make_msymbol_special (gdbarch, sym, &msym);
+ symaddr = CORE_ADDR (msym.unrelocated_address ());
}
+
+ /* BFD symbols are section relative. */
+ symaddr += sym->section->vma;
+ break;
}
}