void
validate_files (void)
{
- if (current_program_space->exec_bfd () && current_program_space->core_bfd ())
+ bfd *ebfd = current_program_space->exec_bfd ();
+ bfd *cbfd = get_inferior_core_bfd (current_inferior ());
+
+ if (ebfd != nullptr && cbfd != nullptr)
{
- if (!core_file_matches_executable_p (current_program_space->core_bfd (),
- current_program_space->exec_bfd ()))
+ if (!core_file_matches_executable_p (cbfd, ebfd))
warning (_("core file may not match specified executable file."));
- else if (gdb_bfd_get_mtime (current_program_space->exec_bfd ())
- > gdb_bfd_get_mtime (current_program_space->core_bfd ()))
+ else if (gdb_bfd_get_mtime (ebfd) > gdb_bfd_get_mtime (cbfd))
warning (_("exec file is newer than core file."));
}
}
gdb_assert (current_inferior ()->process_target () == nullptr);
/* Which will clear up any existing core file BFD. */
- gdb_assert (current_program_space->core_bfd () == nullptr);
+ gdb_assert (get_inferior_core_bfd (current_inferior ()) == nullptr);
std::string filename = extract_single_filename_arg (arg);
if (!target_has_execution ())
{
/* Search for the ending address in the NT_PROCSTAT_VMMAP note. */
- bfd *cbfd = current_program_space->core_bfd ();
+ bfd *cbfd = get_inferior_core_bfd (current_inferior ());
asection *section = bfd_get_section_by_name (cbfd,
".note.freebsdcore.vmmap");
if (section == nullptr)
static bool
linux_core_file_address_in_memtag_page (CORE_ADDR address)
{
- if (current_program_space->core_bfd () == nullptr)
+ bfd *cbfd = get_inferior_core_bfd (current_inferior ());
+
+ if (cbfd == nullptr)
return false;
memtag_section_info info;
- return get_next_core_memtag_section (current_program_space->core_bfd (),
- nullptr, address, info);
+ return get_next_core_memtag_section (cbfd, nullptr, address, info);
}
/* See linux-tdep.h. */
long phdrs_size;
int num_phdrs, i;
- phdrs_size
- = bfd_get_elf_phdr_upper_bound (current_program_space->core_bfd ());
+ bfd *cbfd = get_inferior_core_bfd (current_inferior ());
+ phdrs_size = bfd_get_elf_phdr_upper_bound (cbfd);
if (phdrs_size == -1)
return 0;
gdb::unique_xmalloc_ptr<Elf_Internal_Phdr>
phdrs ((Elf_Internal_Phdr *) xmalloc (phdrs_size));
- num_phdrs = bfd_get_elf_phdrs (current_program_space->core_bfd (),
- phdrs.get ());
+ num_phdrs = bfd_get_elf_phdrs (cbfd, phdrs.get ());
if (num_phdrs == -1)
return 0;
return false;
/* Don't attempt to use thread_db for remote targets. */
- if (!(target_can_run () || current_program_space->core_bfd () != nullptr))
+ if (!(target_can_run ()
+ || get_inferior_core_bfd (current_inferior ()) != nullptr))
return false;
if (thread_db_load_search ())
#include "gdbsupport/thread-pool.h"
#include "event-top.h"
#include "cp-support.h"
+#include "gdbcore.h"
#include "cli/cli-decode.h"
#include "cli/cli-utils.h"
&ofile, arg);
}
- if (current_program_space->core_bfd () != nullptr)
- maint_print_all_sections (_("Core file: "),
- current_program_space->core_bfd (), nullptr, arg);
+ bfd *cbfd = get_inferior_core_bfd (current_inferior ());
+ if (cbfd != nullptr)
+ maint_print_all_sections (_("Core file: "), cbfd, nullptr, arg);
}
/* Implement the "maintenance info target-sections" command. */
/* See progspace.h. */
-bfd *
-program_space::core_bfd () const
-{
- /* This only works because we (currently) never call the core_bfd method
- on anything other than the current program space. Don't worry too
- much, this is a temporary bodge, and will be removed in the next
- commit. */
- gdb_assert (this == current_program_space);
- return get_inferior_core_bfd (current_inferior ());
-}
-
-/* See progspace.h. */
-
void
program_space::clear_solib_cache ()
{
ebfd = std::move (abfd);
}
- bfd *core_bfd () const;
-
/* Reset saved solib data at the start of an solib event. This lets
us properly collect the data when calling solib_add, so it can then
later be printed. */
record_full_list = &record_full_first;
record_full_list->next = NULL;
- if (current_program_space->core_bfd () != nullptr)
- record_full_core_open_1 (*current_program_space->core_bfd ());
+ bfd *cbfd = get_inferior_core_bfd (current_inferior ());
+ if (cbfd != nullptr)
+ record_full_core_open_1 (*cbfd);
else
record_full_open_1 ();
ptid_t ptid;
/* Don't attempt to use thread_db for remote targets. */
- if (!(target_can_run () || current_program_space->core_bfd () != nullptr))
+ if (!(target_can_run ()
+ || get_inferior_core_bfd(current_inferior ()) != nullptr))
return;
/* Do nothing if we couldn't load libthread_db.so.1. */
#include "solib-dsbt.h"
#include "elf/common.h"
#include "cli/cli-cmds.h"
+#include "gdbcore.h"
#define GOT_MODULE_OFFSET 4
solib_create_inferior_hook. (See post_create_inferior in
infcmd.c.) */
if (info->main_executable_lm_info == 0
- && current_program_space->core_bfd () != nullptr)
+ && get_inferior_core_bfd (current_inferior ()) != nullptr)
dsbt_relocate_main_executable ();
/* Locate the address of the first link map struct. */
#include "gdb_bfd.h"
#include "inferior.h"
#include "solib-frv.h"
+#include "gdbcore.h"
/* solib_ops for FR-V systems. */
solib_create_inferior_hook(). (See post_create_inferior() in
infcmd.c.) */
if (main_executable_lm_info == 0
- && current_program_space->core_bfd () != nullptr)
+ && get_inferior_core_bfd (current_inferior ()) != nullptr)
frv_relocate_main_executable ();
/* Fetch the GOT corresponding to the main executable. */
{
struct bfd *bfd;
- if (current_program_space->core_bfd () != nullptr)
- bfd = current_program_space->core_bfd ();
+ if (get_inferior_core_bfd (current_inferior ()) != nullptr)
+ bfd = get_inferior_core_bfd (current_inferior ());
else if (current_program_space->exec_bfd () != nullptr)
bfd = current_program_space->exec_bfd ();
else