diff options
author | Tom Tromey <tom@tromey.com> | 2020-10-29 15:04:33 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-10-29 15:04:36 -0600 |
commit | 7e10abd146dbd17dc1b4e9701210e5724df2b2b0 (patch) | |
tree | 5926969f2b04c133c37f91cb35764598e0ce8912 /gdb/exec.c | |
parent | b55221abba07302964f697db7eb996ff33b26f5a (diff) | |
download | gdb-7e10abd146dbd17dc1b4e9701210e5724df2b2b0.zip gdb-7e10abd146dbd17dc1b4e9701210e5724df2b2b0.tar.gz gdb-7e10abd146dbd17dc1b4e9701210e5724df2b2b0.tar.bz2 |
Remove the exec_bfd macro
This removes the exec_bfd macro, in favor of new accessors on
program_space. In one spot the accessor can't be used; but this is
still a big improvement over the macro, IMO.
gdb/ChangeLog
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.
Diffstat (limited to 'gdb/exec.c')
-rw-r--r-- | gdb/exec.c | 41 |
1 files changed, 24 insertions, 17 deletions
@@ -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")); } |