- if (target_auxv_search (current_top_target (), AT_PHDR, &at_phdr) <= 0)
+ if (target_auxv_search (current_inferior ()->top_target (),
+ AT_PHDR, &at_phdr) <= 0)
- if (target_auxv_search (current_top_target (), AT_PHENT, &at_phent) <= 0)
+ if (target_auxv_search (current_inferior ()->top_target (),
+ AT_PHENT, &at_phent) <= 0)
- if (target_auxv_search (current_top_target (), AT_PHNUM, &at_phnum) <= 0)
+ if (target_auxv_search (current_inferior ()->top_target (),
+ AT_PHNUM, &at_phnum) <= 0)
- /* If we have an exec_bfd, use its section table. */
- if (exec_bfd
- && bfd_get_flavour (exec_bfd) == bfd_target_elf_flavour)
+ /* If we have a current exec_bfd, use its section table. */
+ if (current_program_space->exec_bfd ()
+ && (bfd_get_flavour (current_program_space->exec_bfd ())
+ == bfd_target_elf_flavour))
- bfd_get_section_contents (exec_bfd, interp_sect, buf.data (), 0,
- sect_size);
+ bfd_get_section_contents (current_program_space->exec_bfd (),
+ interp_sect, buf.data (), 0, sect_size);
Elf32_External_Dyn *x_dynp_32;
Elf64_External_Dyn *x_dynp_64;
struct bfd_section *sect;
Elf32_External_Dyn *x_dynp_32;
Elf64_External_Dyn *x_dynp_64;
struct bfd_section *sect;
- for (target_section = current_target_sections->sections;
- target_section < current_target_sections->sections_end;
- target_section++)
- if (sect == target_section->the_bfd_section)
- break;
- if (target_section < current_target_sections->sections_end)
- dyn_addr = target_section->addr;
- else
+ bool found = false;
+ for (const target_section &target_section
+ : current_program_space->target_sections ())
+ if (sect == target_section.the_bfd_section)
+ {
+ dyn_addr = target_section.addr;
+ found = true;
+ break;
+ }
+ if (!found)
{
/* ABFD may come from OBJFILE acting only as a symbol file without being
loaded into the target (see add_symbol_file_command). This case is
{
/* ABFD may come from OBJFILE acting only as a symbol file without being
loaded into the target (see add_symbol_file_command). This case is
/* Look for DT_MIPS_RLD_MAP first. MIPS executables use this
instead of DT_DEBUG, although they sometimes contain an unused
DT_DEBUG. */
/* Look for DT_MIPS_RLD_MAP first. MIPS executables use this
instead of DT_DEBUG, although they sometimes contain an unused
DT_DEBUG. */
- if (scan_dyntag (DT_MIPS_RLD_MAP, exec_bfd, &dyn_ptr, NULL)
+ if (scan_dyntag (DT_MIPS_RLD_MAP, current_program_space->exec_bfd (),
+ &dyn_ptr, NULL)
|| scan_dyntag_auxv (DT_MIPS_RLD_MAP, &dyn_ptr, NULL))
{
struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
|| scan_dyntag_auxv (DT_MIPS_RLD_MAP, &dyn_ptr, NULL))
{
struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
/* Then check DT_MIPS_RLD_MAP_REL. MIPS executables now use this form
because of needing to support PIE. DT_MIPS_RLD_MAP will also exist
in non-PIE. */
/* Then check DT_MIPS_RLD_MAP_REL. MIPS executables now use this form
because of needing to support PIE. DT_MIPS_RLD_MAP will also exist
in non-PIE. */
- if (scan_dyntag (DT_MIPS_RLD_MAP_REL, exec_bfd, &dyn_ptr, &dyn_ptr_addr)
+ if (scan_dyntag (DT_MIPS_RLD_MAP_REL, current_program_space->exec_bfd (),
+ &dyn_ptr, &dyn_ptr_addr)
|| scan_dyntag_auxv (DT_MIPS_RLD_MAP_REL, &dyn_ptr, &dyn_ptr_addr))
{
struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
|| scan_dyntag_auxv (DT_MIPS_RLD_MAP_REL, &dyn_ptr, &dyn_ptr_addr))
{
struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
- if (scan_dyntag (DT_DEBUG, exec_bfd, &dyn_ptr, NULL)
+ if (scan_dyntag (DT_DEBUG, current_program_space->exec_bfd (), &dyn_ptr, NULL)
|| scan_dyntag_auxv (DT_DEBUG, &dyn_ptr, NULL))
return dyn_ptr;
/* This may be a static executable. Look for the symbol
conventionally named _r_debug, as a last resort. */
|| scan_dyntag_auxv (DT_DEBUG, &dyn_ptr, NULL))
return dyn_ptr;
/* This may be a static executable. Look for the symbol
conventionally named _r_debug, as a last resort. */
- msymbol = lookup_minimal_symbol ("_r_debug", NULL, symfile_objfile);
+ msymbol = lookup_minimal_symbol ("_r_debug", NULL,
+ current_program_space->symfile_object_file);
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
int l_name_size = TYPE_LENGTH (ptr_type);
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
int l_name_size = TYPE_LENGTH (ptr_type);
- target_read_string (l_name, &filename, SO_NAME_MAX_PATH_SIZE - 1, &errcode);
+ gdb::unique_xmalloc_ptr<char> filename
+ = target_read_string (l_name, SO_NAME_MAX_PATH_SIZE - 1);
- = target_read_stralloc (current_top_target (), TARGET_OBJECT_LIBRARIES_SVR4,
+ = target_read_stralloc (current_inferior ()->top_target (),
+ TARGET_OBJECT_LIBRARIES_SVR4,
- inferior executable, so we must ignore it. For some versions of
- SVR4, it has no name. For others (Solaris 2.3 for example), it
- does have a name, so we can no longer use a missing name to
- decide when to ignore it. */
+ inferior executable, so we must ignore it. For some versions of
+ SVR4, it has no name. For others (Solaris 2.3 for example), it
+ does have a name, so we can no longer use a missing name to
+ decide when to ignore it. */
- target_read_string (li->l_name, &buffer, SO_NAME_MAX_PATH_SIZE - 1,
- &errcode);
- if (errcode != 0)
+ gdb::unique_xmalloc_ptr<char> buffer
+ = target_read_string (li->l_name, SO_NAME_MAX_PATH_SIZE - 1);
+ if (buffer == nullptr)
{
/* If this entry's l_name address matches that of the
inferior executable, then this is not a normal shared
object, but (most likely) a vDSO. In this case, silently
skip it; otherwise emit a warning. */
if (first_l_name == 0 || li->l_name != first_l_name)
{
/* If this entry's l_name address matches that of the
inferior executable, then this is not a normal shared
object, but (most likely) a vDSO. In this case, silently
skip it; otherwise emit a warning. */
if (first_l_name == 0 || li->l_name != first_l_name)
/* Assume that everything is a library if the dynamic loader was loaded
late by a static executable. */
/* Assume that everything is a library if the dynamic loader was loaded
late by a static executable. */
solib_add (NULL, 0, auto_solib_add);
/* svr4_current_sos() will set main_lm_addr for the main executable. */
solib_add (NULL, 0, auto_solib_add);
/* svr4_current_sos() will set main_lm_addr for the main executable. */
return info->main_lm_addr;
/* If OBJFILE is a separate debug object file, look for the
return info->main_lm_addr;
/* If OBJFILE is a separate debug object file, look for the
- gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
- sym_addr,
- current_top_target ()));
+ gdbarch_convert_from_func_ptr_addr
+ (target_gdbarch (), sym_addr, current_inferior ()->top_target ()));
/* On at least some versions of Solaris there's a dynamic relocation
on _r_debug.r_brk and SYM_ADDR may not be relocated yet, e.g., if
/* On at least some versions of Solaris there's a dynamic relocation
on _r_debug.r_brk and SYM_ADDR may not be relocated yet, e.g., if
- This address is stored on the stack. However, I've been unable
- to find any magic formula to find it for Solaris (appears to
- be trivial on GNU/Linux). Therefore, we have to try an alternate
- mechanism to find the dynamic linker's base address. */
+ This address is stored on the stack. However, I've been unable
+ to find any magic formula to find it for Solaris (appears to
+ be trivial on GNU/Linux). Therefore, we have to try an alternate
+ mechanism to find the dynamic linker's base address. */
- well as BFD operations can be used. target_bfd_reopen
- acquires its own reference. */
- tmp_bfd_target = target_bfd_reopen (tmp_bfd.get ());
+ well as BFD operations can be used. */
+ tmp_bfd_target = target_bfd_reopen (tmp_bfd);
for (struct so_list *so : current_program_space->solibs ())
{
if (svr4_same_1 (interp_name, so->so_original_name))
for (struct so_list *so : current_program_space->solibs ())
{
if (svr4_same_1 (interp_name, so->so_original_name))
- if (target_auxv_search (current_top_target (), AT_BASE, &load_addr) > 0)
+ if (target_auxv_search (current_inferior ()->top_target (),
+ AT_BASE, &load_addr) > 0)
the current pc (which should point at the entry point for the
dynamic linker) and subtracting the offset of the entry point.
the current pc (which should point at the entry point for the
dynamic linker) and subtracting the offset of the entry point.
- This is more fragile than the previous approaches, but is a good
- fallback method because it has actually been working well in
- most cases. */
+ This is more fragile than the previous approaches, but is a good
+ fallback method because it has actually been working well in
+ most cases. */
- the target closes the underlying bfd, because it holds the
- only remaining reference. */
+ the target closes the underlying bfd, because it holds the
+ only remaining reference. */
- "GDB will be unable to debug shared library initializers\n"
- "and track explicitly loaded dynamic code."));
+ "GDB will be unable to debug shared library initializers\n"
+ "and track explicitly loaded dynamic code."));
}
/* Scan through the lists of symbols, trying to look up the symbol and
set a breakpoint there. Terminate loop when we/if we succeed. */
}
/* Scan through the lists of symbols, trying to look up the symbol and
set a breakpoint there. Terminate loop when we/if we succeed. */
if ((msymbol.minsym != NULL)
&& (BMSYMBOL_VALUE_ADDRESS (msymbol) != 0))
{
sym_addr = BMSYMBOL_VALUE_ADDRESS (msymbol);
if ((msymbol.minsym != NULL)
&& (BMSYMBOL_VALUE_ADDRESS (msymbol) != 0))
{
sym_addr = BMSYMBOL_VALUE_ADDRESS (msymbol);
- sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
- sym_addr,
- current_top_target ());
+ sym_addr = gdbarch_convert_from_func_ptr_addr
+ (target_gdbarch (), sym_addr, current_inferior ()->top_target ());
if ((msymbol.minsym != NULL)
&& (BMSYMBOL_VALUE_ADDRESS (msymbol) != 0))
{
sym_addr = BMSYMBOL_VALUE_ADDRESS (msymbol);
if ((msymbol.minsym != NULL)
&& (BMSYMBOL_VALUE_ADDRESS (msymbol) != 0))
{
sym_addr = BMSYMBOL_VALUE_ADDRESS (msymbol);
- sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
- sym_addr,
- current_top_target ());
+ sym_addr = gdbarch_convert_from_func_ptr_addr
+ (target_gdbarch (), sym_addr,
+ current_inferior ()->top_target ());
a call to gdbarch_convert_from_func_ptr_addr. */
CORE_ADDR entry_point, exec_displacement;
a call to gdbarch_convert_from_func_ptr_addr. */
CORE_ADDR entry_point, exec_displacement;
return 0;
/* Therefore for ELF it is ET_EXEC and not ET_DYN. Both shared libraries
being executed themselves and PIE (Position Independent Executable)
executables are ET_DYN. */
return 0;
/* Therefore for ELF it is ET_EXEC and not ET_DYN. Both shared libraries
being executed themselves and PIE (Position Independent Executable)
executables are ET_DYN. */
- if (target_auxv_search (current_top_target (), AT_ENTRY, &entry_point) <= 0)
+ if (target_auxv_search (current_inferior ()->top_target (),
+ AT_ENTRY, &entry_point) <= 0)
/* Verify the EXEC_DISPLACEMENT candidate complies with the required page
alignment. It is cheaper than the program headers comparison below. */
/* Verify the EXEC_DISPLACEMENT candidate complies with the required page
alignment. It is cheaper than the program headers comparison below. */
looking at a different file than the one used by the kernel - for
instance, "gdb program" connected to "gdbserver :PORT ld.so program". */
looking at a different file than the one used by the kernel - for
instance, "gdb program" connected to "gdbserver :PORT ld.so program". */
gdb::optional<gdb::byte_vector> phdrs_target
= read_program_header (-1, &arch_size, NULL);
gdb::optional<gdb::byte_vector> phdrs_binary
gdb::optional<gdb::byte_vector> phdrs_target
= read_program_header (-1, &arch_size, NULL);
gdb::optional<gdb::byte_vector> phdrs_binary
if (phdrs_target && phdrs_binary)
{
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
if (phdrs_target && phdrs_binary)
{
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
- Elf_Internal_Ehdr *ehdr2 = elf_tdata (exec_bfd)->elf_header;
- Elf_Internal_Phdr *phdr2 = elf_tdata (exec_bfd)->phdr;
+ Elf_Internal_Ehdr *ehdr2
+ = elf_tdata (current_program_space->exec_bfd ())->elf_header;
+ Elf_Internal_Phdr *phdr2
+ = elf_tdata (current_program_space->exec_bfd ())->phdr;
- Elf_Internal_Ehdr *ehdr2 = elf_tdata (exec_bfd)->elf_header;
- Elf_Internal_Phdr *phdr2 = elf_tdata (exec_bfd)->phdr;
+ Elf_Internal_Ehdr *ehdr2
+ = elf_tdata (current_program_space->exec_bfd ())->elf_header;
+ Elf_Internal_Phdr *phdr2
+ = elf_tdata (current_program_space->exec_bfd ())->phdr;
printf_unfiltered (_("Using PIE (Position Independent Executable) "
"displacement %s for \"%s\".\n"),
paddress (target_gdbarch (), exec_displacement),
printf_unfiltered (_("Using PIE (Position Independent Executable) "
"displacement %s for \"%s\".\n"),
paddress (target_gdbarch (), exec_displacement),
for (asect = exec_bfd->sections; asect != NULL; asect = asect->next)
exec_set_section_address (bfd_get_filename (exec_bfd), asect->index,
bfd_section_vma (asect) + displacement);
for (asect = exec_bfd->sections; asect != NULL; asect = asect->next)
exec_set_section_address (bfd_get_filename (exec_bfd), asect->index,
bfd_section_vma (asect) + displacement);
/* No point setting a breakpoint in the dynamic linker if we can't
hit it (e.g., a core file, or a trace file). */
/* No point setting a breakpoint in the dynamic linker if we can't
hit it (e.g., a core file, or a trace file). */
{
struct solib_svr4_ops *ops
= (struct solib_svr4_ops *) gdbarch_data (gdbarch, solib_svr4_data);
{
struct solib_svr4_ops *ops
= (struct solib_svr4_ops *) gdbarch_data (gdbarch, solib_svr4_data);