if (current_program_space->exec_bfd () == nullptr)
set_gdbarch_from_file (current_program_space->core_bfd ());
- post_create_inferior (from_tty);
+ post_create_inferior (from_tty, true);
/* Now go through the target stack looking for threads since there
may be a thread_stratum target loaded on top of target core by
return make_unique_xstrdup (args);
}
-/* Common actions to take after creating any sort of inferior, by any
- means (running, attaching, connecting, et cetera). The target
- should be stopped. */
+/* See inferior.h. */
void
-post_create_inferior (int from_tty)
+post_create_inferior (int from_tty, bool set_pspace_solib_ops)
{
-
/* Be sure we own the terminal in case write operations are performed. */
target_terminal::ours_for_output ();
throw;
}
+ if (set_pspace_solib_ops)
+ current_program_space->set_solib_ops
+ (*gdbarch_so_ops (current_inferior ()->arch ()));
+
if (current_program_space->exec_bfd ())
{
const unsigned solib_add_generation
/* Pass zero for FROM_TTY, because at this point the "run" command
has done its thing; now we are setting up the running program. */
- post_create_inferior (0);
+ post_create_inferior (0, true);
/* Queue a pending event so that the program stops immediately. */
if (run_how == RUN_STOP_AT_FIRST_INSN)
/* Take any necessary post-attaching actions for this platform. */
target_post_attach (inferior_ptid.pid ());
- post_create_inferior (from_tty);
+ post_create_inferior (from_tty, true);
}
/* What to do after the first program stops after attaching. */
extern void setup_inferior (int from_tty);
-extern void post_create_inferior (int from_tty);
+/* Common actions to take after creating any sort of inferior, by any
+ means (running, attaching, connecting, et cetera). The target
+ should be stopped.
+
+ If SET_PSPACE_SOLIB_OPS is true, initialize the program space's solib
+ provider using the current inferior's architecture. */
+
+extern void post_create_inferior (int from_tty, bool set_pspace_solib_ops);
extern void attach_command (const char *, int);
inferior *parent_inf = current_inferior ();
inferior *child_inf = nullptr;
+ bool child_has_new_pspace = false;
gdb_assert (parent_inf->thread_waiting_for_vfork_done == nullptr);
else
{
child_inf->pspace = new program_space (new_address_space ());
+ child_has_new_pspace = true;
child_inf->aspace = child_inf->pspace->aspace;
child_inf->removable = true;
clone_program_space (child_inf->pspace, parent_inf->pspace);
else
{
child_inf->pspace = new program_space (new_address_space ());
+ child_has_new_pspace = true;
child_inf->aspace = child_inf->pspace->aspace;
child_inf->removable = true;
child_inf->symfile_flags = SYMFILE_NO_READ;
maybe_restore.emplace ();
switch_to_thread (*child_inf->threads ().begin ());
- post_create_inferior (0);
+
+ post_create_inferior (0, child_has_new_pspace);
}
return false;
we don't want those to be satisfied by the libraries of the
previous incarnation of this process. */
no_shared_libraries (current_program_space);
+ current_program_space->unset_solib_ops ();
inferior *execing_inferior = current_inferior ();
inferior *following_inferior;
registers. */
target_find_description ();
+ current_program_space->set_solib_ops
+ (*gdbarch_so_ops (following_inferior->arch ()));
gdb::observers::inferior_execd.notify (execing_inferior, following_inferior);
breakpoint_re_set ();
/* Now that the inferior has stopped, do any bookkeeping like
loading shared libraries. We want to do this before normal_stop,
so that the displayed frame is up to date. */
- post_create_inferior (from_tty);
+ post_create_inferior (from_tty, true);
normal_stop ();
}
is outside all objfiles in this progspace. */
struct objfile *objfile_for_address (CORE_ADDR address);
+ /* Set this program space's solib provider.
+
+ The solib provider must be unset prior to calling this method. */
+ void set_solib_ops (const struct solib_ops &ops)
+ {
+ gdb_assert (m_solib_ops == nullptr);
+ m_solib_ops = &ops;
+ };
+
+ /* Unset this program space's solib provider. */
+ void unset_solib_ops ()
+ { m_solib_ops = nullptr; }
+
+ /* Get this program space's solib provider. */
+ const struct solib_ops *solib_ops () const
+ { return m_solib_ops; }
+
/* Return the list of all the solibs in this program space. */
owning_intrusive_list<solib> &solibs ()
{ return m_solib_list; }
/* All known objfiles are kept in a linked list. */
owning_intrusive_list<objfile> m_objfiles_list;
+ /* solib_ops implementation used to provide solibs in this program space. */
+ const struct solib_ops *m_solib_ops = nullptr;
+
/* List of shared objects mapped into this space. Managed by
solib.c. */
owning_intrusive_list<solib> m_solib_list;
void
update_solib_list (int from_tty)
{
- const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = current_program_space->solib_ops ();
+
+ if (ops == nullptr)
+ return;
/* We can reach here due to changing solib-search-path or the
sysroot, before having any inferior. */
gdbarch *gdbarch = current_inferior ()->arch ();
/* "0x", a little whitespace, and two hex digits per byte of pointers. */
int addr_width = 4 + (gdbarch_ptr_bit (gdbarch) / 4);
- const solib_ops *ops = gdbarch_so_ops (gdbarch);
+ const solib_ops *ops = current_program_space->solib_ops ();
struct ui_out *uiout = current_uiout;
bool so_missing_debug_info = false;
+ if (ops == nullptr)
+ return;
+
/* There are 3 conditions for this command to print solib namespaces,
first PRINT_NAMESPACE has to be true, second the solib_ops has to
support multiple namespaces, and third there must be more than one
active namespace. Fold all these into the PRINT_NAMESPACE condition. */
- print_namespace = print_namespace && ops->num_active_namespaces != nullptr
- && ops->num_active_namespaces () > 1;
+ print_namespace = (print_namespace
+ && ops != nullptr
+ && ops->num_active_namespaces != nullptr
+ && ops->num_active_namespaces () > 1);
int num_cols = 4;
if (print_namespace)
static void
info_linker_namespace_command (const char *pattern, int from_tty)
{
- const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = current_program_space->solib_ops ();
+
/* This command only really makes sense for inferiors that support
linker namespaces, so we can leave early. */
- if (ops->num_active_namespaces == nullptr)
+ if (ops == nullptr || ops->num_active_namespaces == nullptr)
error (_("Current inferior does not support linker namespaces. "
"Use \"info sharedlibrary\" instead."));
bool
solib_keep_data_in_core (CORE_ADDR vaddr, unsigned long size)
{
- const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = current_program_space->solib_ops ();
- if (ops->keep_data_in_core)
+ if (ops != nullptr && ops->keep_data_in_core != nullptr)
return ops->keep_data_in_core (vaddr, size) != 0;
else
return false;
void
clear_solib (program_space *pspace)
{
- const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
-
for (solib &so : pspace->solibs ())
{
bool still_in_use
pspace->solibs ().clear ();
- if (ops->clear_solib != nullptr)
+ const solib_ops *ops = pspace->solib_ops ();
+
+ if (ops != nullptr && ops->clear_solib != nullptr)
ops->clear_solib (pspace);
}
void
solib_create_inferior_hook (int from_tty)
{
- const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = current_program_space->solib_ops ();
- if (ops->solib_create_inferior_hook != nullptr)
+ if (ops != nullptr && ops->solib_create_inferior_hook != nullptr)
ops->solib_create_inferior_hook (from_tty);
}
bool
in_solib_dynsym_resolve_code (CORE_ADDR pc)
{
- const auto in_dynsym_resolve_code
- = gdbarch_so_ops (current_inferior ()->arch ())->in_dynsym_resolve_code;
+ const solib_ops *ops = current_program_space->solib_ops ();
- return in_dynsym_resolve_code && in_dynsym_resolve_code (pc);
+ return (ops != nullptr && ops->in_dynsym_resolve_code != nullptr
+ && ops->in_dynsym_resolve_code (pc));
}
/* Implements the "sharedlibrary" command. */
void
update_solib_breakpoints (void)
{
- const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = current_program_space->solib_ops ();
- if (ops->update_breakpoints != NULL)
+ if (ops != nullptr && ops->update_breakpoints != nullptr)
ops->update_breakpoints ();
}
void
handle_solib_event (void)
{
- const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+ const solib_ops *ops = current_program_space->solib_ops ();
- if (ops->handle_event != NULL)
+ if (ops != nullptr && ops->handle_event != nullptr)
ops->handle_event ();
current_inferior ()->pspace->clear_solib_cache ();
{
reload_shared_libraries_1 (from_tty);
- const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
-
/* Creating inferior hooks here has two purposes. First, if we reload
shared libraries then the address of solib breakpoint we've computed
previously might be no longer valid. For example, if we forgot to set
about ld.so. */
if (target_has_execution ())
{
+ const solib_ops *ops = current_program_space->solib_ops ();
+
/* Reset or free private data structures not associated with
solib entries. */
- if (ops->clear_solib != nullptr)
+ if (ops != nullptr && ops->clear_solib != nullptr)
ops->clear_solib (current_program_space);
/* Remove any previous solib event breakpoint. This is usually
if (!gdbarch_has_global_solist (current_inferior ()->arch ()))
{
no_shared_libraries (current_program_space);
+ current_program_space->unset_solib_ops ();
invalidate_target_mem_regions ();
# Check that "info linker-namespaces" while the inferior is not running
# doesn't crash.
- gdb_test "info linker-namespaces" "" \
+ gdb_test "info linker-namespaces" \
+ "Current inferior does not support linker namespaces\\. Use \"info sharedlibrary\" instead\\." \
"info linker-namespaces before running"
if { ![runto_main] } {
merge_uploaded_trace_state_variables (&uploaded_tsvs);
merge_uploaded_tracepoints (&uploaded_tps);
- post_create_inferior (from_tty);
+ post_create_inferior (from_tty, true);
}
/* This is the implementation of target_ops method to_close. Destroy
merge_uploaded_tracepoints (&uploaded_tps);
- post_create_inferior (from_tty);
+ post_create_inferior (from_tty, true);
}
/* Interpret the given line from the definitions part of the trace