diff options
-rw-r--r-- | gdb/ChangeLog | 43 | ||||
-rw-r--r-- | gdb/arch-utils.c | 4 | ||||
-rw-r--r-- | gdb/arm-tdep.c | 7 | ||||
-rw-r--r-- | gdb/corefile.c | 12 | ||||
-rw-r--r-- | gdb/corelow.c | 4 | ||||
-rw-r--r-- | gdb/exec.c | 41 | ||||
-rw-r--r-- | gdb/exec.h | 2 | ||||
-rw-r--r-- | gdb/gcore.c | 13 | ||||
-rw-r--r-- | gdb/infcmd.c | 2 | ||||
-rw-r--r-- | gdb/linux-thread-db.c | 4 | ||||
-rw-r--r-- | gdb/maint.c | 10 | ||||
-rw-r--r-- | gdb/nto-procfs.c | 4 | ||||
-rw-r--r-- | gdb/proc-service.c | 6 | ||||
-rw-r--r-- | gdb/progspace.c | 6 | ||||
-rw-r--r-- | gdb/progspace.h | 12 | ||||
-rw-r--r-- | gdb/remote-sim.c | 17 | ||||
-rw-r--r-- | gdb/remote.c | 13 | ||||
-rw-r--r-- | gdb/rs6000-nat.c | 7 | ||||
-rw-r--r-- | gdb/sol-thread.c | 6 | ||||
-rw-r--r-- | gdb/solib-darwin.c | 12 | ||||
-rw-r--r-- | gdb/solib-dsbt.c | 11 | ||||
-rw-r--r-- | gdb/solib-frv.c | 10 | ||||
-rw-r--r-- | gdb/solib-svr4.c | 75 | ||||
-rw-r--r-- | gdb/source-cache.c | 2 | ||||
-rw-r--r-- | gdb/symfile-mem.c | 6 | ||||
-rw-r--r-- | gdb/symfile.c | 4 | ||||
-rw-r--r-- | gdb/tracefile-tfile.c | 2 | ||||
-rw-r--r-- | gdb/windows-tdep.c | 3 |
28 files changed, 218 insertions, 120 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3ab3564..028329e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,48 @@ 2020-10-29 Tom Tromey <tom@tromey.com> + * windows-tdep.c (windows_solib_create_inferior_hook): Update. + * symfile.c (reread_symbols): Update. + * symfile-mem.c (add_symbol_file_from_memory_command) + (add_vsyscall_page): Update. + * source-cache.c (source_cache::get_plain_source_lines): Update. + * solib-svr4.c (find_program_interpreter, elf_locate_base) + (svr4_current_sos_direct, svr4_exec_displacement) + (svr4_relocate_main_executable): Update. + (svr4_iterate_over_objfiles_in_search_order): Update. + * solib-frv.c (enable_break2, enable_break): Update. + * solib-dsbt.c (lm_base, enable_break): Update. + * solib-darwin.c (find_program_interpreter) + (darwin_solib_create_inferior_hook): Update. + * sol-thread.c (rw_common, ps_pdmodel): Update. + * rs6000-nat.c (rs6000_nat_target::create_inferior): Update. + * remote.c (compare_sections_command) + (remote_target::trace_set_readonly_regions): Update. + * remote-sim.c (get_sim_inferior_data) + (gdbsim_target::create_inferior, gdbsim_target::create_inferior): Update. + (gdbsim_target_open, gdbsim_target::files_info): Update. + * exec.h (exec_bfd): Remove macro. + * progspace.c (initialize_progspace): Update. + * proc-service.c (ps_addr_to_core_addr, core_addr_to_ps_addr): + Update. + * nto-procfs.c (nto_procfs_target::post_attach) + (nto_procfs_target::create_inferior): Update. + * maint.c (maintenance_info_sections): Update. + * linux-thread-db.c (thread_db_target::get_thread_local_address): + Update. + * infcmd.c (post_create_inferior): Update. + * gcore.c (default_gcore_arch, default_gcore_target): Update. + (objfile_find_memory_regions): Update. + * exec.c (validate_exec_file, exec_file_attach) + (exec_read_partial_read_only, print_section_info): Update. + * corelow.c (core_target_open): Update. + * corefile.c (reopen_exec_file, validate_files): Update. + * arm-tdep.c (gdb_print_insn_arm): Update. + * arch-utils.c (gdbarch_update_p, default_print_insn): Update. + * progspace.h (struct program_space) <exec_bfd, set_exec_bfd>: New + methods. + +2020-10-29 Tom Tromey <tom@tromey.com> + * progspace.h (current_target_sections): Remove macro. * solib-svr4.c (scan_dyntag): Update. * solib-dsbt.c (scan_dyntag): Update. diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 27ac2f7..1f66e03 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -527,7 +527,7 @@ gdbarch_update_p (struct gdbarch_info info) /* Check for the current file. */ if (info.abfd == NULL) - info.abfd = exec_bfd; + info.abfd = current_program_space->exec_bfd (); if (info.abfd == NULL) info.abfd = core_bfd; @@ -989,7 +989,7 @@ default_print_insn (bfd_vma memaddr, disassemble_info *info) disassembler_ftype disassemble_fn; disassemble_fn = disassembler (info->arch, info->endian == BFD_ENDIAN_BIG, - info->mach, exec_bfd); + info->mach, current_program_space->exec_bfd ()); gdb_assert (disassemble_fn != NULL); return (*disassemble_fn) (memaddr, info); diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index a214f22..c007a38 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -7756,9 +7756,10 @@ gdb_print_insn_arm (bfd_vma memaddr, disassemble_info *info) /* GDB is able to get bfd_mach from the exe_bfd, info->mach is accurate, so mark USER_SPECIFIED_MACHINE_TYPE bit. Otherwise, opcodes/arm-dis.c:print_insn reset info->mach, and it will trigger - the assert on the mismatch of info->mach and bfd_get_mach (exec_bfd) - in default_print_insn. */ - if (exec_bfd != NULL) + the assert on the mismatch of info->mach and + bfd_get_mach (current_program_space->exec_bfd ()) in + default_print_insn. */ + if (current_program_space->exec_bfd () != NULL) info->flags |= USER_SPECIFIED_MACHINE_TYPE; return default_print_insn (memaddr, info); diff --git a/gdb/corefile.c b/gdb/corefile.c index 1586e9f..78abbd0 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -108,11 +108,11 @@ reopen_exec_file (void) struct stat st; /* Don't do anything if there isn't an exec file. */ - if (exec_bfd == NULL) + if (current_program_space->exec_bfd () == NULL) return; /* If the timestamp of the exec file has changed, reopen it. */ - std::string filename = bfd_get_filename (exec_bfd); + std::string filename = bfd_get_filename (current_program_space->exec_bfd ()); res = stat (filename.c_str (), &st); if (res == 0 @@ -132,11 +132,13 @@ reopen_exec_file (void) void validate_files (void) { - if (exec_bfd && core_bfd) + if (current_program_space->exec_bfd () && core_bfd) { - if (!core_file_matches_executable_p (core_bfd, exec_bfd)) + if (!core_file_matches_executable_p (core_bfd, + current_program_space->exec_bfd ())) warning (_("core file may not match specified executable file.")); - else if (bfd_get_mtime (exec_bfd) > bfd_get_mtime (core_bfd)) + else if (bfd_get_mtime (current_program_space->exec_bfd ()) + > bfd_get_mtime (core_bfd)) warning (_("exec file is newer than core file.")); } } diff --git a/gdb/corelow.c b/gdb/corelow.c index 4f3c880..e284efc 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -454,7 +454,7 @@ core_target_open (const char *arg, int from_tty) core file. We don't do this unconditionally since an exec file typically contains more information that helps us determine the architecture than a core file. */ - if (!exec_bfd) + if (!current_program_space->exec_bfd ()) set_gdbarch_from_file (core_bfd); push_target (std::move (target_holder)); @@ -495,7 +495,7 @@ core_target_open (const char *arg, int from_tty) switch_to_thread (thread); } - if (exec_bfd == nullptr) + if (current_program_space->exec_bfd () == nullptr) locate_exec_from_corefile_build_id (core_bfd, from_tty); post_create_inferior (from_tty); @@ -240,7 +240,8 @@ validate_exec_file (int from_tty) reopen_exec_file (); current_exec_file = get_exec_file (0); - const bfd_build_id *exec_file_build_id = build_id_bfd_get (exec_bfd); + const bfd_build_id *exec_file_build_id + = build_id_bfd_get (current_program_space->exec_bfd ()); if (exec_file_build_id != nullptr) { /* Prepend the target prefix, to force gdb_bfd_open to open the @@ -367,10 +368,11 @@ exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty) void exec_file_attach (const char *filename, int from_tty) { - /* First, acquire a reference to the current exec_bfd. We release + /* First, acquire a reference to the exec_bfd. We release this at the end of the function; but acquiring it now lets the BFD cache return it if this call refers to the same file. */ - gdb_bfd_ref_ptr exec_bfd_holder = gdb_bfd_ref_ptr::new_reference (exec_bfd); + gdb_bfd_ref_ptr exec_bfd_holder + = gdb_bfd_ref_ptr::new_reference (current_program_space->exec_bfd ()); /* Remove any previous exec file. */ current_program_space->exec_close (); @@ -451,9 +453,9 @@ exec_file_attach (const char *filename, int from_tty) FOPEN_RUB, scratch_chan); else temp = gdb_bfd_open (canonical_pathname, gnutarget, scratch_chan); - exec_bfd = temp.release (); + current_program_space->set_exec_bfd (temp.release ()); - if (!exec_bfd) + if (!current_program_space->exec_bfd ()) { error (_("\"%ps\": could not open as an executable file: %s."), styled_string (file_name_style.style (), scratch_pathname), @@ -465,12 +467,14 @@ exec_file_attach (const char *filename, int from_tty) gdb_assert (current_program_space->exec_filename == nullptr); if (load_via_target) current_program_space->exec_filename - = make_unique_xstrdup (bfd_get_filename (exec_bfd)); + = (make_unique_xstrdup + (bfd_get_filename (current_program_space->exec_bfd ()))); else current_program_space->exec_filename = gdb_realpath_keepfile (scratch_pathname); - if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching)) + if (!bfd_check_format_matches (current_program_space->exec_bfd (), + bfd_object, &matching)) { /* Make sure to close exec_bfd, or else "run" might try to use it. */ @@ -480,18 +484,20 @@ exec_file_attach (const char *filename, int from_tty) gdb_bfd_errmsg (bfd_get_error (), matching).c_str ()); } - target_section_table sections = build_section_table (exec_bfd); + target_section_table sections + = build_section_table (current_program_space->exec_bfd ()); - current_program_space->ebfd_mtime = bfd_get_mtime (exec_bfd); + current_program_space->ebfd_mtime + = bfd_get_mtime (current_program_space->exec_bfd ()); validate_files (); - set_gdbarch_from_file (exec_bfd); + set_gdbarch_from_file (current_program_space->exec_bfd ()); /* Add the executable's sections to the current address spaces' list of sections. This possibly pushes the exec_ops target. */ - add_target_sections (&exec_bfd, sections); + add_target_sections (¤t_program_space->ebfd, sections); /* Tell display code (if any) about the changed file name. */ if (deprecated_exec_file_display_hook) @@ -701,13 +707,13 @@ exec_read_partial_read_only (gdb_byte *readbuf, ULONGEST offset, /* It's unduly pedantic to refuse to look at the executable for read-only pieces; so do the equivalent of readonly regions aka QTro packet. */ - if (exec_bfd != NULL) + if (current_program_space->exec_bfd () != NULL) { asection *s; bfd_size_type size; bfd_vma vma; - for (s = exec_bfd->sections; s; s = s->next) + for (s = current_program_space->exec_bfd ()->sections; s; s = s->next) { if ((s->flags & SEC_LOAD) == 0 || (s->flags & SEC_READONLY) == 0) @@ -723,7 +729,7 @@ exec_read_partial_read_only (gdb_byte *readbuf, ULONGEST offset, if (amt > len) amt = len; - amt = bfd_get_section_contents (exec_bfd, s, + amt = bfd_get_section_contents (current_program_space->exec_bfd (), s, readbuf, offset - vma, amt); if (amt == 0) @@ -925,7 +931,7 @@ print_section_info (target_section_table *t, bfd *abfd) bfd_get_filename (abfd))); wrap_here (" "); printf_filtered (_("file type %s.\n"), bfd_get_target (abfd)); - if (abfd == exec_bfd) + if (abfd == current_program_space->exec_bfd ()) { /* gcc-3.4 does not like the initialization in <p == t->sections_end>. */ @@ -990,8 +996,9 @@ print_section_info (target_section_table *t, bfd *abfd) void exec_target::files_info () { - if (exec_bfd) - print_section_info (¤t_program_space->target_sections, exec_bfd); + if (current_program_space->exec_bfd ()) + print_section_info (¤t_program_space->target_sections, + current_program_space->exec_bfd ()); else puts_filtered (_("\t<no file loaded>\n")); } @@ -30,8 +30,6 @@ struct target_ops; struct bfd; struct objfile; -#define exec_bfd current_program_space->ebfd - /* Builds a section table, given args BFD. */ extern target_section_table build_section_table (struct bfd *); diff --git a/gdb/gcore.c b/gdb/gcore.c index 54b43aa..b97a54a 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -171,10 +171,10 @@ default_gcore_arch (void) if (bfdarch != NULL) return bfdarch->arch; - if (exec_bfd == NULL) + if (current_program_space->exec_bfd () == NULL) error (_("Can't find bfd architecture for corefile (need execfile).")); - return bfd_get_arch (exec_bfd); + return bfd_get_arch (current_program_space->exec_bfd ()); } static const char * @@ -184,12 +184,12 @@ default_gcore_target (void) if (gdbarch_gcore_bfd_target_p (target_gdbarch ())) return gdbarch_gcore_bfd_target (target_gdbarch ()); - /* Otherwise, try to fall back to the exec_bfd target. This will probably + /* Otherwise, try to fall back to the exec target. This will probably not work for non-ELF targets. */ - if (exec_bfd == NULL) + if (current_program_space->exec_bfd () == NULL) return NULL; else - return bfd_get_target (exec_bfd); + return bfd_get_target (current_program_space->exec_bfd ()); } /* Derive a reasonable stack segment by unwinding the target stack, @@ -500,7 +500,8 @@ objfile_find_memory_regions (struct target_ops *self, obfd); /* Make a heap segment. */ - if (derive_heap_segment (exec_bfd, &temp_bottom, &temp_top)) + if (derive_heap_segment (current_program_space->exec_bfd (), &temp_bottom, + &temp_top)) (*func) (temp_bottom, temp_top - temp_bottom, 1, /* Heap section will be readable. */ 1, /* Heap section will be writable. */ diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 068de96..1180490 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -308,7 +308,7 @@ post_create_inferior (int from_tty) throw; } - if (exec_bfd) + if (current_program_space->exec_bfd ()) { const unsigned solib_add_generation = current_program_space->solib_add_generation; diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 7cbdfa5..0af813f 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -1800,8 +1800,8 @@ thread_db_target::get_thread_local_address (ptid_t ptid, /* Cast assuming host == target. Joy. */ /* Do proper sign extension for the target. */ - gdb_assert (exec_bfd); - return (bfd_get_sign_extend_vma (exec_bfd) > 0 + gdb_assert (current_program_space->exec_bfd ()); + return (bfd_get_sign_extend_vma (current_program_space->exec_bfd ()) > 0 ? (CORE_ADDR) (intptr_t) address : (CORE_ADDR) (uintptr_t) address); } diff --git a/gdb/maint.c b/gdb/maint.c index 46dd99f..e8cdda3 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -380,14 +380,16 @@ print_bfd_section_info_maybe_relocated (bfd *abfd, asection *asect, static void maintenance_info_sections (const char *arg, int from_tty) { - if (exec_bfd) + if (current_program_space->exec_bfd ()) { bool allobj = false; printf_filtered (_("Exec file:\n")); - printf_filtered (" `%s', ", bfd_get_filename (exec_bfd)); + printf_filtered (" `%s', ", + bfd_get_filename (current_program_space->exec_bfd ())); wrap_here (" "); - printf_filtered (_("file type %s.\n"), bfd_get_target (exec_bfd)); + printf_filtered (_("file type %s.\n"), + bfd_get_target (current_program_space->exec_bfd ())); /* Only this function cares about the 'ALLOBJ' argument; if 'ALLOBJ' is the only argument, discard it rather than @@ -404,7 +406,7 @@ maintenance_info_sections (const char *arg, int from_tty) if (allobj) printf_filtered (_(" Object file: %s\n"), bfd_get_filename (ofile->obfd)); - else if (ofile->obfd != exec_bfd) + else if (ofile->obfd != current_program_space->exec_bfd ()) continue; int section_count = gdb_bfd_count_sections (ofile->obfd); diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c index ef1615d..5ecf9b5 100644 --- a/gdb/nto-procfs.c +++ b/gdb/nto-procfs.c @@ -728,7 +728,7 @@ nto_procfs_target::attach (const char *args, int from_tty) void nto_procfs_target::post_attach (pid_t pid) { - if (exec_bfd) + if (current_program_space->exec_bfd ()) solib_create_inferior_hook (0); } @@ -1322,7 +1322,7 @@ nto_procfs_target::create_inferior (const char *exec_file, push_target (ops); target_terminal::init (); - if (exec_bfd != NULL + if (current_program_space->exec_bfd () != NULL || (symfile_objfile != NULL && symfile_objfile->obfd != NULL)) solib_create_inferior_hook (0); } diff --git a/gdb/proc-service.c b/gdb/proc-service.c index e038370..2025f3a 100644 --- a/gdb/proc-service.c +++ b/gdb/proc-service.c @@ -42,7 +42,8 @@ static CORE_ADDR ps_addr_to_core_addr (psaddr_t addr) { - if (exec_bfd && bfd_get_sign_extend_vma (exec_bfd)) + if (current_program_space->exec_bfd () + && bfd_get_sign_extend_vma (current_program_space->exec_bfd ())) return (intptr_t) addr; else return (uintptr_t) addr; @@ -53,7 +54,8 @@ ps_addr_to_core_addr (psaddr_t addr) static psaddr_t core_addr_to_ps_addr (CORE_ADDR addr) { - if (exec_bfd && bfd_get_sign_extend_vma (exec_bfd)) + if (current_program_space->exec_bfd () + && bfd_get_sign_extend_vma (current_program_space->exec_bfd ())) return (psaddr_t) (intptr_t) addr; else return (psaddr_t) (uintptr_t) addr; diff --git a/gdb/progspace.c b/gdb/progspace.c index 8a15c40..57edc29 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -233,7 +233,7 @@ program_space::exec_close () gdb_bfd_unref (ebfd); /* Removing target sections may close the exec_ops target. - Clear exec_bfd before doing so to prevent recursion. */ + Clear ebfd before doing so to prevent recursion. */ ebfd = NULL; ebfd_mtime = 0; @@ -471,7 +471,7 @@ initialize_progspace (void) _initialize_foo routines may need to install their per-pspace data keys. We can only allocate a progspace when all those modules have done that. Do this before - initialize_current_architecture, because that accesses exec_bfd, - which in turn dereferences current_program_space. */ + initialize_current_architecture, because that accesses the ebfd + of current_program_space. */ current_program_space = new program_space (new_address_space ()); } diff --git a/gdb/progspace.h b/gdb/progspace.h index 0363403..5e49083 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -276,6 +276,18 @@ struct program_space to read memory from, this unpushes the exec_ops target. */ void exec_close (); + /* Return the exec BFD for this program space. */ + bfd *exec_bfd () const + { + return ebfd; + } + + /* Set the exec BFD for this program space to ABFD. */ + void set_exec_bfd (bfd *abfd) + { + ebfd = abfd; + } + /* Unique ID number. */ int num = 0; diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 9e1c2b1..d0e19b0 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -211,7 +211,8 @@ get_sim_inferior_data (struct inferior *inf, int sim_instance_needed) if (sim_instance_needed == SIM_INSTANCE_NEEDED && (sim_data == NULL || sim_data->gdbsim_desc == NULL)) { - sim_desc = sim_open (SIM_OPEN_DEBUG, &gdb_callback, exec_bfd, sim_argv); + sim_desc = sim_open (SIM_OPEN_DEBUG, &gdb_callback, + current_program_space->exec_bfd (), sim_argv); if (sim_desc == NULL) error (_("Unable to create simulator instance for inferior %d."), inf->num); @@ -620,7 +621,7 @@ gdbsim_target::create_inferior (const char *exec_file, char *arg_buf; const char *args = allargs.c_str (); - if (exec_file == 0 || exec_bfd == 0) + if (exec_file == 0 || current_program_space->exec_bfd () == 0) warning (_("No executable file specified.")); if (!sim_data->program_loaded) warning (_("No program loaded.")); @@ -648,7 +649,8 @@ gdbsim_target::create_inferior (const char *exec_file, built_argv.reset (arg_buf); } - if (sim_create_inferior (sim_data->gdbsim_desc, exec_bfd, + if (sim_create_inferior (sim_data->gdbsim_desc, + current_program_space->exec_bfd (), built_argv.get (), env) != SIM_RC_OK) error (_("Unable to create sim inferior.")); @@ -738,7 +740,8 @@ gdbsim_target_open (const char *args, int from_tty) sim_argv = argv.release (); init_callbacks (); - gdbsim_desc = sim_open (SIM_OPEN_DEBUG, &gdb_callback, exec_bfd, sim_argv); + gdbsim_desc = sim_open (SIM_OPEN_DEBUG, &gdb_callback, + current_program_space->exec_bfd (), sim_argv); if (gdbsim_desc == 0) { @@ -1104,13 +1107,13 @@ gdbsim_target::files_info () = get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NEEDED); const char *file = "nothing"; - if (exec_bfd) - file = bfd_get_filename (exec_bfd); + if (current_program_space->exec_bfd ()) + file = bfd_get_filename (current_program_space->exec_bfd ()); if (remote_debug) fprintf_unfiltered (gdb_stdlog, "gdbsim_files_info: file \"%s\"\n", file); - if (exec_bfd) + if (current_program_space->exec_bfd ()) { fprintf_unfiltered (gdb_stdlog, "\tAttached to %s running program %s\n", target_shortname, file); diff --git a/gdb/remote.c b/gdb/remote.c index 9ee1e8c..291b7c6 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -56,7 +56,7 @@ #include <signal.h> #include "serial.h" -#include "gdbcore.h" /* for exec_bfd */ +#include "gdbcore.h" #include "remote-fileio.h" #include "gdb/fileio.h" @@ -10770,7 +10770,7 @@ compare_sections_command (const char *args, int from_tty) int res; int read_only = 0; - if (!exec_bfd) + if (!current_program_space->exec_bfd ()) error (_("command cannot be used without an exec file")); if (args != NULL && strcmp (args, "-r") == 0) @@ -10779,7 +10779,7 @@ compare_sections_command (const char *args, int from_tty) args = NULL; } - for (s = exec_bfd->sections; s; s = s->next) + for (s = current_program_space->exec_bfd ()->sections; s; s = s->next) { if (!(s->flags & SEC_LOAD)) continue; /* Skip non-loadable section. */ @@ -10799,7 +10799,8 @@ compare_sections_command (const char *args, int from_tty) lma = s->lma; gdb::byte_vector sectdata (size); - bfd_get_section_contents (exec_bfd, s, sectdata.data (), 0, size); + bfd_get_section_contents (current_program_space->exec_bfd (), s, + sectdata.data (), 0, size); res = target_verify_memory (sectdata.data (), lma, size); @@ -13180,14 +13181,14 @@ remote_target::trace_set_readonly_regions () int anysecs = 0; int offset = 0; - if (!exec_bfd) + if (!current_program_space->exec_bfd ()) return; /* No information to give. */ struct remote_state *rs = get_remote_state (); strcpy (rs->buf.data (), "QTro"); offset = strlen (rs->buf.data ()); - for (s = exec_bfd->sections; s; s = s->next) + for (s = current_program_space->exec_bfd ()->sections; s; s = s->next) { char tmp1[40], tmp2[40]; int sec_length; diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c index c49e64b..82b7eff 100644 --- a/gdb/rs6000-nat.c +++ b/gdb/rs6000-nat.c @@ -581,11 +581,12 @@ rs6000_nat_target::create_inferior (const char *exec_file, Blindly calling rs6000_gdbarch_init used to work in older versions of GDB, as rs6000_gdbarch_init incorrectly used the previous tdep to determine the wordsize. */ - if (exec_bfd) + if (current_program_space->exec_bfd ()) { const struct bfd_arch_info *exec_bfd_arch_info; - exec_bfd_arch_info = bfd_get_arch_info (exec_bfd); + exec_bfd_arch_info + = bfd_get_arch_info (current_program_space->exec_bfd ()); if (arch == exec_bfd_arch_info->arch) return; } @@ -594,7 +595,7 @@ rs6000_nat_target::create_inferior (const char *exec_file, gdbarch_info_init (&info); info.bfd_arch_info = bfd_get_arch_info (&abfd); - info.abfd = exec_bfd; + info.abfd = current_program_space->exec_bfd (); if (!gdbarch_update_p (info)) internal_error (__FILE__, __LINE__, diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index bb33a20..69a3ac1 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -794,7 +794,7 @@ rw_common (int dowrite, const struct ps_prochandle *ph, psaddr_t addr, #if defined (__sparcv9) /* For Sparc64 cross Sparc32, make sure the address has not been accidentally sign-extended (or whatever) to beyond 32 bits. */ - if (bfd_get_arch_size (exec_bfd) == 32) + if (bfd_get_arch_size (current_program_space->exec_bfd ()) == 32) addr &= 0xffffffff; #endif @@ -950,9 +950,9 @@ ps_lsetfpregs (struct ps_prochandle *ph, lwpid_t lwpid, ps_err_e ps_pdmodel (struct ps_prochandle *ph, int *data_model) { - if (exec_bfd == 0) + if (current_program_space->exec_bfd () == 0) *data_model = PR_MODEL_UNKNOWN; - else if (bfd_get_arch_size (exec_bfd) == 32) + else if (bfd_get_arch_size (current_program_space->exec_bfd ()) == 32) *data_model = PR_MODEL_ILP32; else *data_model = PR_MODEL_LP64; diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c index 3806c7e..e784e56 100644 --- a/gdb/solib-darwin.c +++ b/gdb/solib-darwin.c @@ -192,12 +192,13 @@ find_program_interpreter (void) { char *buf = NULL; - /* If we have an exec_bfd, get the interpreter from the load commands. */ - if (exec_bfd) + /* If we have an current exec_bfd, get the interpreter from the load + commands. */ + if (current_program_space->exec_bfd ()) { bfd_mach_o_load_command *cmd; - if (bfd_mach_o_lookup_command (exec_bfd, + if (bfd_mach_o_lookup_command (current_program_space->exec_bfd (), BFD_MACH_O_LC_LOAD_DYLINKER, &cmd) == 1) return cmd->command.dylinker.name_str; } @@ -543,7 +544,7 @@ darwin_solib_create_inferior_hook (int from_tty) CORE_ADDR vmaddr; /* Find the base address of the executable. */ - vmaddr = bfd_mach_o_get_base_address (exec_bfd); + vmaddr = bfd_mach_o_get_base_address (current_program_space->exec_bfd ()); /* Relocate. */ if (vmaddr != load_addr) @@ -557,7 +558,8 @@ darwin_solib_create_inferior_hook (int from_tty) { /* Dyld hasn't yet relocated itself, so the notifier address may be incorrect (as it has to be relocated). */ - CORE_ADDR start = bfd_get_start_address (exec_bfd); + CORE_ADDR start + = bfd_get_start_address (current_program_space->exec_bfd ()); if (start == 0) notifier = 0; else diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index 6f610c5..8e1da5d 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -562,7 +562,7 @@ lm_base (void) "lm_base: get addr %x by _GLOBAL_OFFSET_TABLE_.\n", (unsigned int) addr); } - else if (scan_dyntag (DT_PLTGOT, exec_bfd, &addr)) + else if (scan_dyntag (DT_PLTGOT, current_program_space->exec_bfd (), &addr)) { struct int_elf32_dsbt_loadmap *ldm; @@ -778,7 +778,7 @@ enable_break (void) asection *interp_sect; struct dsbt_info *info; - if (exec_bfd == NULL) + if (current_program_space->exec_bfd () == NULL) return 0; if (!target_has_execution ()) @@ -793,7 +793,8 @@ enable_break (void) /* Find the .interp section; if not found, warn the user and drop into the old breakpoint at symbol code. */ - interp_sect = bfd_get_section_by_name (exec_bfd, ".interp"); + interp_sect = bfd_get_section_by_name (current_program_space->exec_bfd (), + ".interp"); if (interp_sect) { unsigned int interp_sect_size; @@ -806,8 +807,8 @@ enable_break (void) the contents specify the dynamic linker this program uses. */ interp_sect_size = bfd_section_size (interp_sect); buf = (char *) alloca (interp_sect_size); - bfd_get_section_contents (exec_bfd, interp_sect, - buf, 0, interp_sect_size); + bfd_get_section_contents (current_program_space->exec_bfd (), + interp_sect, buf, 0, interp_sect_size); /* Now we need to figure out where the dynamic linker was loaded so that we can load its symbols and place a breakpoint diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index bce33a3..08c9cf7 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -531,7 +531,8 @@ enable_break2 (void) /* Find the .interp section; if not found, warn the user and drop into the old breakpoint at symbol code. */ - interp_sect = bfd_get_section_by_name (exec_bfd, ".interp"); + interp_sect = bfd_get_section_by_name (current_program_space->exec_bfd (), + ".interp"); if (interp_sect) { unsigned int interp_sect_size; @@ -545,8 +546,8 @@ enable_break2 (void) the contents specify the dynamic linker this program uses. */ interp_sect_size = bfd_section_size (interp_sect); buf = (char *) alloca (interp_sect_size); - bfd_get_section_contents (exec_bfd, interp_sect, - buf, 0, interp_sect_size); + bfd_get_section_contents (current_program_space->exec_bfd (), + interp_sect, buf, 0, interp_sect_size); /* Now we need to figure out where the dynamic linker was loaded so that we can load its symbols and place a breakpoint @@ -735,7 +736,8 @@ enable_break (void) /* Check for the presence of a .interp section. If there is no such section, the executable is statically linked. */ - interp_sect = bfd_get_section_by_name (exec_bfd, ".interp"); + interp_sect = bfd_get_section_by_name (current_program_space->exec_bfd (), + ".interp"); if (interp_sect == NULL) { diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index faaba47..637a0fc 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -554,20 +554,22 @@ read_program_header (int type, int *p_arch_size, CORE_ADDR *base_addr) static gdb::optional<gdb::byte_vector> find_program_interpreter (void) { - /* 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)) { struct bfd_section *interp_sect; - interp_sect = bfd_get_section_by_name (exec_bfd, ".interp"); + interp_sect = bfd_get_section_by_name (current_program_space->exec_bfd (), + ".interp"); if (interp_sect != NULL) { int sect_size = bfd_section_size (interp_sect); gdb::byte_vector buf (sect_size); - 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); return buf; } } @@ -762,7 +764,8 @@ elf_locate_base (void) /* 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; @@ -780,7 +783,8 @@ elf_locate_base (void) /* 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; @@ -796,7 +800,7 @@ elf_locate_base (void) } /* Find DT_DEBUG. */ - 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; @@ -1399,7 +1403,9 @@ svr4_current_sos_direct (struct svr4_info *info) /* Assume that everything is a library if the dynamic loader was loaded late by a static executable. */ - if (exec_bfd && bfd_get_section_by_name (exec_bfd, ".dynamic") == NULL) + if (current_program_space->exec_bfd () + && bfd_get_section_by_name (current_program_space->exec_bfd (), + ".dynamic") == NULL) ignore_first = 0; else ignore_first = 1; @@ -2564,27 +2570,30 @@ svr4_exec_displacement (CORE_ADDR *displacementp) a call to gdbarch_convert_from_func_ptr_addr. */ CORE_ADDR entry_point, exec_displacement; - if (exec_bfd == NULL) + if (current_program_space->exec_bfd () == NULL) 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 ((bfd_get_file_flags (exec_bfd) & DYNAMIC) == 0) + if ((bfd_get_file_flags (current_program_space->exec_bfd ()) & DYNAMIC) == 0) return 0; if (target_auxv_search (current_top_target (), AT_ENTRY, &entry_point) <= 0) return 0; - exec_displacement = entry_point - bfd_get_start_address (exec_bfd); + exec_displacement + = entry_point - bfd_get_start_address (current_program_space->exec_bfd ()); /* Verify the EXEC_DISPLACEMENT candidate complies with the required page alignment. It is cheaper than the program headers comparison below. */ - if (bfd_get_flavour (exec_bfd) == bfd_target_elf_flavour) + if (bfd_get_flavour (current_program_space->exec_bfd ()) + == bfd_target_elf_flavour) { - const struct elf_backend_data *elf = get_elf_backend_data (exec_bfd); + const struct elf_backend_data *elf + = get_elf_backend_data (current_program_space->exec_bfd ()); /* p_align of PT_LOAD segments does not specify any alignment but only congruency of addresses: @@ -2601,7 +2610,8 @@ svr4_exec_displacement (CORE_ADDR *displacementp) looking at a different file than the one used by the kernel - for instance, "gdb program" connected to "gdbserver :PORT ld.so program". */ - if (bfd_get_flavour (exec_bfd) == bfd_target_elf_flavour) + if (bfd_get_flavour (current_program_space->exec_bfd ()) + == bfd_target_elf_flavour) { /* Be optimistic and return 0 only if GDB was able to verify the headers really do not match. */ @@ -2610,7 +2620,7 @@ svr4_exec_displacement (CORE_ADDR *displacementp) gdb::optional<gdb::byte_vector> phdrs_target = read_program_header (-1, &arch_size, NULL); gdb::optional<gdb::byte_vector> phdrs_binary - = read_program_headers_from_bfd (exec_bfd); + = read_program_headers_from_bfd (current_program_space->exec_bfd ()); if (phdrs_target && phdrs_binary) { enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); @@ -2629,14 +2639,16 @@ svr4_exec_displacement (CORE_ADDR *displacementp) content offset for the verification purpose. */ if (phdrs_target->size () != phdrs_binary->size () - || bfd_get_arch_size (exec_bfd) != arch_size) + || bfd_get_arch_size (current_program_space->exec_bfd ()) != arch_size) return 0; else if (arch_size == 32 && phdrs_target->size () >= sizeof (Elf32_External_Phdr) && phdrs_target->size () % sizeof (Elf32_External_Phdr) == 0) { - 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; CORE_ADDR displacement = 0; int i; @@ -2736,6 +2748,7 @@ svr4_exec_displacement (CORE_ADDR *displacementp) } /* prelink can convert .plt SHT_NOBITS to SHT_PROGBITS. */ + bfd *exec_bfd = current_program_space->exec_bfd (); plt2_asect = bfd_get_section_by_name (exec_bfd, ".plt"); if (plt2_asect) { @@ -2770,8 +2783,10 @@ svr4_exec_displacement (CORE_ADDR *displacementp) && phdrs_target->size () >= sizeof (Elf64_External_Phdr) && phdrs_target->size () % sizeof (Elf64_External_Phdr) == 0) { - 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; CORE_ADDR displacement = 0; int i; @@ -2870,7 +2885,9 @@ svr4_exec_displacement (CORE_ADDR *displacementp) } /* prelink can convert .plt SHT_NOBITS to SHT_PROGBITS. */ - plt2_asect = bfd_get_section_by_name (exec_bfd, ".plt"); + plt2_asect + = bfd_get_section_by_name (current_program_space->exec_bfd (), + ".plt"); if (plt2_asect) { int content2; @@ -2883,8 +2900,9 @@ svr4_exec_displacement (CORE_ADDR *displacementp) filesz = extract_unsigned_integer (buf_filesz_p, 8, byte_order); - /* PLT2_ASECT is from on-disk file (exec_bfd) while - FILESZ is from the in-memory image. */ + /* PLT2_ASECT is from on-disk file (current + exec_bfd) while FILESZ is from the in-memory + image. */ if (content2) filesz += bfd_section_size (plt2_asect); else @@ -2914,7 +2932,7 @@ svr4_exec_displacement (CORE_ADDR *displacementp) printf_unfiltered (_("Using PIE (Position Independent Executable) " "displacement %s for \"%s\".\n"), paddress (target_gdbarch (), exec_displacement), - bfd_get_filename (exec_bfd)); + bfd_get_filename (current_program_space->exec_bfd ())); } *displacementp = exec_displacement; @@ -2969,10 +2987,11 @@ svr4_relocate_main_executable (void) displacement); objfile_relocate (symfile_objfile, new_offsets); } - else if (exec_bfd) + else if (current_program_space->exec_bfd ()) { asection *asect; + bfd *exec_bfd = current_program_space->exec_bfd (); 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); @@ -3228,7 +3247,7 @@ svr4_iterate_over_objfiles_in_search_order current_objfile = current_objfile->separate_debug_objfile_backlink; if (current_objfile == symfile_objfile) - abfd = exec_bfd; + abfd = current_program_space->exec_bfd (); else abfd = current_objfile->obfd; diff --git a/gdb/source-cache.c b/gdb/source-cache.c index c67d087..098fcf7 100644 --- a/gdb/source-cache.c +++ b/gdb/source-cache.c @@ -68,7 +68,7 @@ source_cache::get_plain_source_lines (struct symtab *s, time_t mtime = 0; if (SYMTAB_OBJFILE (s) != NULL && SYMTAB_OBJFILE (s)->obfd != NULL) mtime = SYMTAB_OBJFILE (s)->mtime; - else if (exec_bfd) + else if (current_program_space->exec_bfd ()) mtime = current_program_space->ebfd_mtime; if (mtime && mtime < st.st_mtime) diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c index 62c5664..02761df 100644 --- a/gdb/symfile-mem.c +++ b/gdb/symfile-mem.c @@ -146,7 +146,7 @@ add_symbol_file_from_memory_command (const char *args, int from_tty) if (symfile_objfile != NULL) templ = symfile_objfile->obfd; else - templ = exec_bfd; + templ = current_program_space->exec_bfd (); if (templ == NULL) error (_("Must use symbol-file or exec-file " "before add-symbol-file-from-memory.")); @@ -168,8 +168,8 @@ add_vsyscall_page (inferior *inf) if (core_bfd != NULL) bfd = core_bfd; - else if (exec_bfd != NULL) - bfd = exec_bfd; + else if (current_program_space->exec_bfd () != NULL) + bfd = current_program_space->exec_bfd (); else /* FIXME: cagney/2004-05-06: Should not require an existing BFD when trying to create a run-time BFD of the VSYSCALL diff --git a/gdb/symfile.c b/gdb/symfile.c index 3332e7f..434ecb9 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2460,9 +2460,9 @@ reread_symbols (void) /* We need to do this whenever any symbols go away. */ clear_symtab_users_cleanup defer_clear_users (0); - if (exec_bfd != NULL + if (current_program_space->exec_bfd () != NULL && filename_cmp (bfd_get_filename (objfile->obfd), - bfd_get_filename (exec_bfd)) == 0) + bfd_get_filename (current_program_space->exec_bfd ())) == 0) { /* Reload EXEC_BFD without asking anything. */ diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index 9cf68c5..c26d99a 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -25,7 +25,7 @@ #include "regcache.h" #include "inferior.h" #include "gdbthread.h" -#include "exec.h" /* exec_bfd */ +#include "exec.h" #include "completer.h" #include "filenames.h" #include "remote.h" diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index 984f139..5f2b10a 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -914,7 +914,8 @@ windows_solib_create_inferior_hook (int from_tty) /* Rebase executable if the base address changed because of ASLR. */ if (symfile_objfile != nullptr && exec_base != 0) { - CORE_ADDR vmaddr = pe_data (exec_bfd)->pe_opthdr.ImageBase; + CORE_ADDR vmaddr + = pe_data (current_program_space->exec_bfd ())->pe_opthdr.ImageBase; if (vmaddr != exec_base) objfile_rebase (symfile_objfile, exec_base - vmaddr); } |