2004-05-02 12:14:02 +02:00
|
|
|
/* Reading symbol files from memory.
|
|
|
|
|
2020-01-01 07:20:01 +01:00
|
|
|
Copyright (C) 1986-2020 Free Software Foundation, Inc.
|
2004-05-02 12:14:02 +02:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-23 20:08:50 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2004-05-02 12:14:02 +02:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 20:08:50 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2004-05-02 12:14:02 +02:00
|
|
|
|
|
|
|
/* This file defines functions (and commands to exercise those
|
|
|
|
functions) for reading debugging information from object files
|
|
|
|
whose images are mapped directly into the inferior's memory. For
|
|
|
|
example, the Linux kernel maps a "syscall DSO" into each process's
|
|
|
|
address space; this DSO provides kernel-specific code for some
|
|
|
|
system calls.
|
|
|
|
|
|
|
|
At the moment, BFD only has functions for parsing object files from
|
|
|
|
memory for the ELF format, even though the general idea isn't
|
|
|
|
ELF-specific. This means that BFD only provides the functions GDB
|
|
|
|
needs when configured for ELF-based targets. So these functions
|
|
|
|
may only be compiled on ELF-based targets.
|
|
|
|
|
|
|
|
GDB has no idea whether it has been configured for an ELF-based
|
|
|
|
target or not: it just tries to handle whatever files it is given.
|
|
|
|
But this means there are no preprocessor symbols on which we could
|
|
|
|
make these functions' compilation conditional.
|
|
|
|
|
|
|
|
So, for the time being, we put these functions alone in this file,
|
|
|
|
and have .mt files reference them as appropriate. In the future, I
|
|
|
|
hope BFD will provide a format-independent bfd_from_remote_memory
|
|
|
|
entry point. */
|
|
|
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "symtab.h"
|
|
|
|
#include "gdbcore.h"
|
|
|
|
#include "objfiles.h"
|
|
|
|
#include "gdbcmd.h"
|
|
|
|
#include "target.h"
|
|
|
|
#include "value.h"
|
|
|
|
#include "symfile.h"
|
Convert observers to C++
This converts observers from using a special source-generating script
to be plain C++. This version of the patch takes advantage of C++11
by using std::function and variadic templates; incorporates Pedro's
patches; and renames the header file to "observable.h" (this change
eliminates the need for a clean rebuild).
Note that Pedro's patches used a template lambda in tui-hooks.c, but
this failed to compile on some buildbot instances (presumably due to
differing C++ versions); I replaced this with an ordinary template
function.
Regression tested on the buildbot.
gdb/ChangeLog
2018-03-19 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* unittests/observable-selftests.c: New file.
* common/observable.h: New file.
* observable.h: New file.
* ada-lang.c, ada-tasks.c, agent.c, aix-thread.c, annotate.c,
arm-tdep.c, auto-load.c, auxv.c, break-catch-syscall.c,
breakpoint.c, bsd-uthread.c, cli/cli-interp.c, cli/cli-setshow.c,
corefile.c, dummy-frame.c, event-loop.c, event-top.c, exec.c,
extension.c, frame.c, gdbarch.c, guile/scm-breakpoint.c,
infcall.c, infcmd.c, inferior.c, inflow.c, infrun.c, jit.c,
linux-tdep.c, linux-thread-db.c, m68klinux-tdep.c,
mi/mi-cmd-break.c, mi/mi-interp.c, mi/mi-main.c, objfiles.c,
ppc-linux-nat.c, ppc-linux-tdep.c, printcmd.c, procfs.c,
python/py-breakpoint.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/py-unwind.c, ravenscar-thread.c,
record-btrace.c, record-full.c, record.c, regcache.c, remote.c,
riscv-tdep.c, sol-thread.c, solib-aix.c, solib-spu.c, solib.c,
spu-multiarch.c, spu-tdep.c, stack.c, symfile-mem.c, symfile.c,
symtab.c, thread.c, top.c, tracepoint.c, tui/tui-hooks.c,
tui/tui-interp.c, valops.c: Update all users.
* tui/tui-hooks.c (tui_bp_created_observer)
(tui_bp_deleted_observer, tui_bp_modified_observer)
(tui_inferior_exit_observer, tui_before_prompt_observer)
(tui_normal_stop_observer, tui_register_changed_observer):
Remove.
(tui_observers_token): New global.
(attach_or_detach, tui_attach_detach_observers): New functions.
(tui_install_hooks, tui_remove_hooks): Use
tui_attach_detach_observers.
* record-btrace.c (record_btrace_thread_observer): Remove.
(record_btrace_thread_observer_token): New global.
* observer.sh: Remove.
* observer.c: Rename to observable.c.
* observable.c (namespace gdb_observers): Define new objects.
(observer_debug): Move into gdb_observers namespace.
(struct observer, struct observer_list, xalloc_observer_list_node)
(xfree_observer_list_node, generic_observer_attach)
(generic_observer_detach, generic_observer_notify): Remove.
(_initialize_observer): Update.
Don't include observer.inc.
* Makefile.in (generated_files): Remove observer.h, observer.inc.
(clean mostlyclean): Likewise.
(observer.h, observer.inc): Remove targets.
(SUBDIR_UNITTESTS_SRCS): Add observable-selftests.c.
(COMMON_SFILES): Use observable.c, not observer.c.
* .gitignore: Remove observer.h.
gdb/doc/ChangeLog
2018-03-19 Tom Tromey <tom@tromey.com>
* observer.texi: Remove.
gdb/testsuite/ChangeLog
2018-03-19 Tom Tromey <tom@tromey.com>
* gdb.gdb/observer.exp: Remove.
2016-10-02 18:50:20 +02:00
|
|
|
#include "observable.h"
|
2004-11-07 22:33:29 +01:00
|
|
|
#include "auxv.h"
|
|
|
|
#include "elf/common.h"
|
* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
(free_dwo_file): Use gdb_bfd_unref.
* cli/cli-dump.c: Include gdb_bfd.h.
(bfd_openw_with_cleanup): Use gdb_bfd_ref.
(bfd_openr_with_cleanup): Likewise.
* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
gdb_bfd_unref.
* utils.c: Include gdb_bfd.h.
(do_bfd_close_cleanup): Use gdb_bfd_unref.
* symfile.c: Include gdb_bfd.h.
(separate_debug_file_exists): Use gdb_bfd_unref.
(bfd_open_maybe_remote): Use gdb_bfd_ref.
(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
(generic_load): Use gdb_bfd_ref.
(reread_symbols): Use gdb_bfd_unref.
* symfile-mem.c: Include gdb_bfd.h.
(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
* solib.c: Include gdb_bfd.h.
(solib_bfd_fopen): Use gdb_bfd_ref.
(solib_bfd_open): Use gdb_bfd_unref.
(free_so_symbols): Use gdb_bfd_unref.
(reload_shared_libraries_1): Use gdb_bfd_unref.
* solib-spu.c: Include gdb_bfd.h.
(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
gdb_bfd_unref.
* solib-frv.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-dsbt.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-darwin.c: Include gdb_bfd.h.
(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
gdb_bfd_unref.
(darwin_bfd_open): Use gdb_bfd_unref.
* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
* remote-mips.c: Include gdb_bfd.h.
(mips_load_srec): Use gdb_bfd_ref.
(pmon_load_fast): Use gdb_bfd_ref.
* remote-m32r-sdi.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
* record.c: Include gdb_bfd.h.
(record_save_cleanups): Use gdb_bfd_unref.
(cmd_record_save): Use gdb_bfd_unref.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
gdb_bfd_unref.
* objfiles.h (gdb_bfd_close_or_warn): Remove.
(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
* objfiles.c: Include gdb_bfd.h.
(free_objfile): Use gdb_bfd_unref.
(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
gdb_bfd.c.
* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
(macho_check_dsym): Likewise.
* m32r-rom.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
(m32r_upload_command): Use gdb_bfd_ref.
* jit.c: Include gdb_bfd.h.
(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
* gdb_bfd.h: New file.
* gdb_bfd.c: New file.
* gcore.c: Include gdb_bfd.h.
(create_gcore_bfd): Use gdb_bfd_ref.
(do_bfd_delete_cleanup): Use gdb_bfd_unref.
(gcore_command): Use gdb_bfd_unref.
* exec.c: Include gdb_bfd.h.
(exec_close): Use gdb_bfd_unref.
(exec_close_1): Use gdb_bfd_unref.
(exec_file_attach): Use gdb_bfd_ref.
* elfread.c: Include gdb_bfd.h.
(build_id_verify): Use gdb_bfd_unref.
* dsrec.c: Include gdb_bfd.h.
(load_srec): Use gdb_bfd_ref.
* corelow.c: Include gdb_bfd.h.
(core_close): Use gdb_bfd_unref.
(core_open): Use gdb_bfd_ref.
* bfd-target.c: Include gdb_bfd.h.
(target_bfd_xclose): Use gdb_bfd_unref.
(target_bfd_reopen): Use gdb_bfd_ref.
* Makefile.in (SFILES): Add gdb_bfd.c.
(HFILES_NO_SRCDIR): Add gdb_bfd.h.
(COMMON_OBS): Add gdb_bfd.o.
2012-07-18 21:33:34 +02:00
|
|
|
#include "gdb_bfd.h"
|
2004-05-02 12:14:02 +02:00
|
|
|
|
2012-06-04 16:35:25 +02:00
|
|
|
/* Verify parameters of target_read_memory_bfd and target_read_memory are
|
|
|
|
compatible. */
|
|
|
|
|
2020-03-12 20:32:15 +01:00
|
|
|
gdb_static_assert (sizeof (CORE_ADDR) >= sizeof (bfd_vma));
|
2012-06-04 16:35:25 +02:00
|
|
|
gdb_static_assert (sizeof (gdb_byte) == sizeof (bfd_byte));
|
2012-06-05 23:18:05 +02:00
|
|
|
gdb_static_assert (sizeof (ssize_t) <= sizeof (bfd_size_type));
|
2012-06-04 16:35:25 +02:00
|
|
|
|
|
|
|
/* Provide bfd/ compatible prototype for target_read_memory. Casting would not
|
|
|
|
be enough as LEN width may differ. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
target_read_memory_bfd (bfd_vma memaddr, bfd_byte *myaddr, bfd_size_type len)
|
|
|
|
{
|
|
|
|
/* MYADDR must be already allocated for the LEN size so it has to fit in
|
2012-06-05 23:18:05 +02:00
|
|
|
ssize_t. */
|
|
|
|
gdb_assert ((ssize_t) len == len);
|
2012-06-04 16:35:25 +02:00
|
|
|
|
|
|
|
return target_read_memory (memaddr, myaddr, len);
|
|
|
|
}
|
2004-05-02 12:14:02 +02:00
|
|
|
|
|
|
|
/* Read inferior memory at ADDR to find the header of a loaded object file
|
2014-04-02 03:37:33 +02:00
|
|
|
and read its in-core symbols out of inferior memory. SIZE, if
|
|
|
|
non-zero, is the known size of the object. TEMPL is a bfd
|
2004-11-07 22:33:29 +01:00
|
|
|
representing the target's format. NAME is the name to use for this
|
PR25993, read of freed memory
ldmain.c:add_archive_element copies file name pointers from the bfd to
a lang_input_statement_type.
input->filename = abfd->filename;
input->local_sym_name = abfd->filename;
This results in stale pointers when twiddling the bfd filename in
places like the pe ld after_open. So don't free the bfd filename,
and make copies using bfd_alloc memory that won't result in small
memory leaks that annoy memory checkers.
PR 25993
bfd/
* archive.c (_bfd_get_elt_at_filepos): Don't strdup filename,
use bfd_set_filename.
* elfcode.h (_bfd_elf_bfd_from_remote_memory): Likewise.
* mach-o.c (bfd_mach_o_fat_member_init): Likewise.
* opncls.c (bfd_fopen, bfd_openstreamr, bfd_openr_iovec, bfd_openw),
(bfd_create): Likewise.
(_bfd_delete_bfd): Don't free filename.
(bfd_set_filename): Copy filename param to bfd_alloc'd memory,
return pointer to the copy or NULL on alloc fail.
* vms-lib.c (_bfd_vms_lib_get_module): Free newname and test
result of bfd_set_filename.
* bfd-in2.h: Regenerate.
gdb/
* solib-darwin.c (darwin_bfd_open): Don't strdup pathname for
bfd_set_filename.
* solib-aix.c (solib_aix_bfd_open): Use std::string for name
passed to bfd_set_filename.
* symfile-mem.c (add_vsyscall_page): Likewise for string
passed to symbol_file_add_from_memory.
(symbol_file_add_from_memory): Make name param a const char* and
don't strdup.
ld/
* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Don't copy
other_bfd_filename for bfd_set_filename, and test result of
bfd_set_filename call. Don't create a new is->filename, simply
copy from bfd filename. Free new_name after bfd_set_filename.
* emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
2020-05-19 05:28:59 +02:00
|
|
|
symbol file in messages; it can be NULL. */
|
2004-05-25 23:55:43 +02:00
|
|
|
static struct objfile *
|
2014-04-02 03:37:33 +02:00
|
|
|
symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr,
|
PR25993, read of freed memory
ldmain.c:add_archive_element copies file name pointers from the bfd to
a lang_input_statement_type.
input->filename = abfd->filename;
input->local_sym_name = abfd->filename;
This results in stale pointers when twiddling the bfd filename in
places like the pe ld after_open. So don't free the bfd filename,
and make copies using bfd_alloc memory that won't result in small
memory leaks that annoy memory checkers.
PR 25993
bfd/
* archive.c (_bfd_get_elt_at_filepos): Don't strdup filename,
use bfd_set_filename.
* elfcode.h (_bfd_elf_bfd_from_remote_memory): Likewise.
* mach-o.c (bfd_mach_o_fat_member_init): Likewise.
* opncls.c (bfd_fopen, bfd_openstreamr, bfd_openr_iovec, bfd_openw),
(bfd_create): Likewise.
(_bfd_delete_bfd): Don't free filename.
(bfd_set_filename): Copy filename param to bfd_alloc'd memory,
return pointer to the copy or NULL on alloc fail.
* vms-lib.c (_bfd_vms_lib_get_module): Free newname and test
result of bfd_set_filename.
* bfd-in2.h: Regenerate.
gdb/
* solib-darwin.c (darwin_bfd_open): Don't strdup pathname for
bfd_set_filename.
* solib-aix.c (solib_aix_bfd_open): Use std::string for name
passed to bfd_set_filename.
* symfile-mem.c (add_vsyscall_page): Likewise for string
passed to symbol_file_add_from_memory.
(symbol_file_add_from_memory): Make name param a const char* and
don't strdup.
ld/
* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Don't copy
other_bfd_filename for bfd_set_filename, and test result of
bfd_set_filename call. Don't create a new is->filename, simply
copy from bfd filename. Free new_name after bfd_set_filename.
* emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
2020-05-19 05:28:59 +02:00
|
|
|
size_t size, const char *name, int from_tty)
|
2004-05-02 12:14:02 +02:00
|
|
|
{
|
|
|
|
struct objfile *objf;
|
2004-05-25 23:55:43 +02:00
|
|
|
struct bfd *nbfd;
|
|
|
|
struct bfd_section *sec;
|
2004-05-02 12:14:02 +02:00
|
|
|
bfd_vma loadbase;
|
Make symfile_add_flags and objfile->flags strongly typed
This makes these flag types be "enum flag" types. The benefit is
making use of C++'s stronger typing -- mixing the flags types by
mistake errors at compile time.
This caught one old bug in symbol_file_add_main_1 already, fixed by
this patch as well:
@@ -1318,7 +1326,7 @@ symbol_file_add_main_1 (const char *args, int from_tty, int flags)
what is frameless. */
reinit_frame_cache ();
- if ((flags & SYMFILE_NO_READ) == 0)
+ if ((add_flags & SYMFILE_NO_READ) == 0)
set_initial_language ();
}
Above, "flags" are objfile flags, not symfile_add_flags. So that was
actually checking for "flag & OBJF_PSYMTABS_READ", which has the same
value as SYMFILE_NO_READ...
I moved the flags definitions to separate files to break circular
dependencies.
Built with --enable-targets=all and tested on x86-64 Fedora 23.
gdb/ChangeLog:
2016-10-26 Pedro Alves <palves@redhat.com>
* coffread.c (coff_symfile_read): Use symfile_add_flags.
* dbxread.c (dbx_symfile_read): Ditto.
* elfread.c (elf_symfile_read): Ditto.
* inferior.h: Include symfile-add-flags.h.
(struct inferior) <symfile_flags>: Now symfile_add_flags.
* machoread.c (macho_add_oso_symfile, macho_symfile_read_all_oso)
(macho_symfile_read, mipscoff_symfile_read): Use
symfile_add_flags.
* objfile-flags.h: New file.
* objfiles.c (allocate_objfile): Use objfile_flags.
* objfiles.h: Include objfile-flags.h.
(struct objfile) <flags>: Now an objfile_flags.
(OBJF_REORDERED, OBJF_SHARED, OBJF_READNOW, OBJF_USERLOADED)
(OBJF_PSYMTABS_READ, OBJF_MAINLINE, OBJF_NOT_FILENAME): Delete.
Converted to an enum-flags in objfile-flags.h.
(allocate_objfile): Use objfile_flags.
* python/py-objfile.c (objfpy_add_separate_debug_file): Remove
unnecessary local.
* solib.c (solib_read_symbols, solib_add)
(reload_shared_libraries_1): Use symfile_add_flags.
* solib.h: Include "symfile-add-flags.h".
(solib_read_symbols): Use symfile_add_flags.
* symfile-add-flags.h: New file.
* symfile-debug.c (debug_sym_read): Use symfile_add_flags.
* symfile-mem.c (symbol_file_add_from_memory): Use
symfile_add_flags.
* symfile.c (read_symbols, syms_from_objfile_1)
(syms_from_objfile, finish_new_objfile): Use symfile_add_flags.
(symbol_file_add_with_addrs): Use symfile_add_flags and
objfile_flags.
(symbol_file_add_separate): Use symfile_add_flags.
(symbol_file_add_from_bfd, symbol_file_add): Use symfile_add_flags
and objfile_flags.
(symbol_file_add_main_1): : Use objfile_flags. Fix add_flags vs
flags confusion.
(symbol_file_command): Use objfile_flags.
(add_symbol_file_command): Use symfile_add_flags and
objfile_flags.
(clear_symtab_users): Use symfile_add_flags.
* symfile.h: Include "symfile-add-flags.h" and "objfile-flags.h".
(struct sym_fns) <sym_read>: Use symfile_add_flags.
(clear_symtab_users): Use symfile_add_flags.
(enum symfile_add_flags): Delete, moved to symfile-add-flags.h and
converted to enum-flags.
(symbol_file_add, symbol_file_add_from_bfd)
(symbol_file_add_separate): Use symfile_add_flags.
* xcoffread.c (xcoff_initial_scan): Use symfile_add_flags.
2016-10-26 17:47:10 +02:00
|
|
|
symfile_add_flags add_flags = 0;
|
2004-05-02 12:14:02 +02:00
|
|
|
|
|
|
|
if (bfd_get_flavour (templ) != bfd_target_elf_flavour)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
error (_("add-symbol-file-from-memory not supported for this target"));
|
2004-05-02 12:14:02 +02:00
|
|
|
|
2014-04-02 03:37:33 +02:00
|
|
|
nbfd = bfd_elf_bfd_from_remote_memory (templ, addr, size, &loadbase,
|
2012-06-04 16:35:25 +02:00
|
|
|
target_read_memory_bfd);
|
2004-05-02 12:14:02 +02:00
|
|
|
if (nbfd == NULL)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
error (_("Failed to read a valid object file image from memory."));
|
2004-05-02 12:14:02 +02:00
|
|
|
|
Use class to manage BFD reference counts
This introduces a new specialization of gdb::ref_ptr that can be used
to manage BFD reference counts. Then it changes most places in gdb to
use this new class, rather than explicit reference-counting or
cleanups. This patch removes make_cleanup_bfd_unref.
If you look you will see a couple of spots using "release" where a use
of gdb_bfd_ref_ptr would be cleaner. These will be fixed in the next
patch.
I think this patch fixes some latent bugs. For example, it seems to
me that previously objfpy_add_separate_debug_file leaked a BFD.
I'm not 100% certain that the macho_symfile_read_all_oso change is
correct. The existing code here is hard for me to follow. One goal
of this sort of automated reference counting, though, is to make it
more difficult to make logic errors; so hopefully the code is clear
now.
2017-01-10 Tom Tromey <tom@tromey.com>
* windows-tdep.c (windows_xfer_shared_library): Update.
* windows-nat.c (windows_make_so): Update.
* utils.h (make_cleanup_bfd_unref): Remove.
* utils.c (do_bfd_close_cleanup, make_cleanup_bfd_unref): Remove.
* symfile.h (symfile_bfd_open)
(find_separate_debug_file_in_section): Return gdb_bfd_ref_ptr.
* symfile.c (read_symbols, symbol_file_add)
(separate_debug_file_exists): Update.
(symfile_bfd_open): Return gdb_bfd_ref_ptr.
(generic_load, reread_symbols): Update.
* symfile-mem.c (symbol_file_add_from_memory): Update.
* spu-linux-nat.c (spu_bfd_open): Return gdb_bfd_ref_ptr.
(spu_symbol_file_add_from_memory): Update.
* solist.h (struct target_so_ops) <bfd_open>: Return
gdb_bfd_ref_ptr.
(solib_bfd_fopen, solib_bfd_open): Return gdb_bfd_ref_ptr.
* solib.c (solib_bfd_fopen, solib_bfd_open): Return
gdb_bfd_ref_ptr.
(solib_map_sections, reload_shared_libraries_1): Update.
* solib-svr4.c (enable_break): Update.
* solib-spu.c (spu_bfd_fopen): Return gdb_bfd_ref_ptr.
* solib-frv.c (enable_break2): Update.
* solib-dsbt.c (enable_break): Update.
* solib-darwin.c (gdb_bfd_mach_o_fat_extract): Return
gdb_bfd_ref_ptr.
(darwin_solib_get_all_image_info_addr_at_init): Update.
(darwin_bfd_open): Return gdb_bfd_ref_ptr.
* solib-aix.c (solib_aix_bfd_open): Return gdb_bfd_ref_ptr.
* record-full.c (record_full_save): Update.
* python/py-objfile.c (objfpy_add_separate_debug_file): Update.
* procfs.c (insert_dbx_link_bpt_in_file): Update.
* minidebug.c (find_separate_debug_file_in_section): Return
gdb_bfd_ref_ptr.
* machoread.c (macho_add_oso_symfile): Change abfd to
gdb_bfd_ref_ptr.
(macho_symfile_read_all_oso): Update.
(macho_check_dsym): Return gdb_bfd_ref_ptr.
(macho_symfile_read): Update.
* jit.c (bfd_open_from_target_memory): Return gdb_bfd_ref_ptr.
(jit_bfd_try_read_symtab): Update.
* gdb_bfd.h (gdb_bfd_open, gdb_bfd_fopen, gdb_bfd_openr)
(gdb_bfd_openw, gdb_bfd_openr_iovec)
(gdb_bfd_openr_next_archived_file, gdb_bfd_fdopenr): Return
gdb_bfd_ref_ptr.
(gdb_bfd_ref_policy): New struct.
(gdb_bfd_ref_ptr): New typedef.
* gdb_bfd.c (gdb_bfd_open, gdb_bfd_fopen, gdb_bfd_openr)
(gdb_bfd_openw, gdb_bfd_openr_iovec)
(gdb_bfd_openr_next_archived_file, gdb_bfd_fdopenr): Return
gdb_bfd_ref_ptr.
* gcore.h (create_gcore_bfd): Return gdb_bfd_ref_ptr.
* gcore.c (create_gcore_bfd): Return gdb_bfd_ref_ptr.
(gcore_command): Update.
* exec.c (exec_file_attach): Update.
* elfread.c (elf_symfile_read): Update.
* dwarf2read.c (dwarf2_get_dwz_file): Update.
(try_open_dwop_file, open_dwo_file): Return gdb_bfd_ref_ptr.
(open_and_init_dwo_file): Update.
(open_dwp_file): Return gdb_bfd_ref_ptr.
(open_and_init_dwp_file): Update.
* corelow.c (core_open): Update.
* compile/compile-object-load.c (compile_object_load): Update.
* common/gdb_ref_ptr.h (ref_ptr::operator->): New operator.
* coffread.c (coff_symfile_read): Update.
* cli/cli-dump.c (bfd_openr_or_error, bfd_openw_or_error): Return
gdb_bfd_ref_ptr. Rename.
(dump_bfd_file, restore_command): Update.
* build-id.h (build_id_to_debug_bfd): Return gdb_bfd_ref_ptr.
* build-id.c (build_id_to_debug_bfd): Return gdb_bfd_ref_ptr.
(find_separate_debug_file_by_buildid): Update.
2016-11-21 19:12:23 +01:00
|
|
|
/* Manage the new reference for the duration of this function. */
|
2018-04-30 05:02:19 +02:00
|
|
|
gdb_bfd_ref_ptr nbfd_holder = gdb_bfd_ref_ptr::new_reference (nbfd);
|
Use class to manage BFD reference counts
This introduces a new specialization of gdb::ref_ptr that can be used
to manage BFD reference counts. Then it changes most places in gdb to
use this new class, rather than explicit reference-counting or
cleanups. This patch removes make_cleanup_bfd_unref.
If you look you will see a couple of spots using "release" where a use
of gdb_bfd_ref_ptr would be cleaner. These will be fixed in the next
patch.
I think this patch fixes some latent bugs. For example, it seems to
me that previously objfpy_add_separate_debug_file leaked a BFD.
I'm not 100% certain that the macho_symfile_read_all_oso change is
correct. The existing code here is hard for me to follow. One goal
of this sort of automated reference counting, though, is to make it
more difficult to make logic errors; so hopefully the code is clear
now.
2017-01-10 Tom Tromey <tom@tromey.com>
* windows-tdep.c (windows_xfer_shared_library): Update.
* windows-nat.c (windows_make_so): Update.
* utils.h (make_cleanup_bfd_unref): Remove.
* utils.c (do_bfd_close_cleanup, make_cleanup_bfd_unref): Remove.
* symfile.h (symfile_bfd_open)
(find_separate_debug_file_in_section): Return gdb_bfd_ref_ptr.
* symfile.c (read_symbols, symbol_file_add)
(separate_debug_file_exists): Update.
(symfile_bfd_open): Return gdb_bfd_ref_ptr.
(generic_load, reread_symbols): Update.
* symfile-mem.c (symbol_file_add_from_memory): Update.
* spu-linux-nat.c (spu_bfd_open): Return gdb_bfd_ref_ptr.
(spu_symbol_file_add_from_memory): Update.
* solist.h (struct target_so_ops) <bfd_open>: Return
gdb_bfd_ref_ptr.
(solib_bfd_fopen, solib_bfd_open): Return gdb_bfd_ref_ptr.
* solib.c (solib_bfd_fopen, solib_bfd_open): Return
gdb_bfd_ref_ptr.
(solib_map_sections, reload_shared_libraries_1): Update.
* solib-svr4.c (enable_break): Update.
* solib-spu.c (spu_bfd_fopen): Return gdb_bfd_ref_ptr.
* solib-frv.c (enable_break2): Update.
* solib-dsbt.c (enable_break): Update.
* solib-darwin.c (gdb_bfd_mach_o_fat_extract): Return
gdb_bfd_ref_ptr.
(darwin_solib_get_all_image_info_addr_at_init): Update.
(darwin_bfd_open): Return gdb_bfd_ref_ptr.
* solib-aix.c (solib_aix_bfd_open): Return gdb_bfd_ref_ptr.
* record-full.c (record_full_save): Update.
* python/py-objfile.c (objfpy_add_separate_debug_file): Update.
* procfs.c (insert_dbx_link_bpt_in_file): Update.
* minidebug.c (find_separate_debug_file_in_section): Return
gdb_bfd_ref_ptr.
* machoread.c (macho_add_oso_symfile): Change abfd to
gdb_bfd_ref_ptr.
(macho_symfile_read_all_oso): Update.
(macho_check_dsym): Return gdb_bfd_ref_ptr.
(macho_symfile_read): Update.
* jit.c (bfd_open_from_target_memory): Return gdb_bfd_ref_ptr.
(jit_bfd_try_read_symtab): Update.
* gdb_bfd.h (gdb_bfd_open, gdb_bfd_fopen, gdb_bfd_openr)
(gdb_bfd_openw, gdb_bfd_openr_iovec)
(gdb_bfd_openr_next_archived_file, gdb_bfd_fdopenr): Return
gdb_bfd_ref_ptr.
(gdb_bfd_ref_policy): New struct.
(gdb_bfd_ref_ptr): New typedef.
* gdb_bfd.c (gdb_bfd_open, gdb_bfd_fopen, gdb_bfd_openr)
(gdb_bfd_openw, gdb_bfd_openr_iovec)
(gdb_bfd_openr_next_archived_file, gdb_bfd_fdopenr): Return
gdb_bfd_ref_ptr.
* gcore.h (create_gcore_bfd): Return gdb_bfd_ref_ptr.
* gcore.c (create_gcore_bfd): Return gdb_bfd_ref_ptr.
(gcore_command): Update.
* exec.c (exec_file_attach): Update.
* elfread.c (elf_symfile_read): Update.
* dwarf2read.c (dwarf2_get_dwz_file): Update.
(try_open_dwop_file, open_dwo_file): Return gdb_bfd_ref_ptr.
(open_and_init_dwo_file): Update.
(open_dwp_file): Return gdb_bfd_ref_ptr.
(open_and_init_dwp_file): Update.
* corelow.c (core_open): Update.
* compile/compile-object-load.c (compile_object_load): Update.
* common/gdb_ref_ptr.h (ref_ptr::operator->): New operator.
* coffread.c (coff_symfile_read): Update.
* cli/cli-dump.c (bfd_openr_or_error, bfd_openw_or_error): Return
gdb_bfd_ref_ptr. Rename.
(dump_bfd_file, restore_command): Update.
* build-id.h (build_id_to_debug_bfd): Return gdb_bfd_ref_ptr.
* build-id.c (build_id_to_debug_bfd): Return gdb_bfd_ref_ptr.
(find_separate_debug_file_by_buildid): Update.
2016-11-21 19:12:23 +01:00
|
|
|
|
2004-11-07 22:33:29 +01:00
|
|
|
if (name == NULL)
|
PR25993, read of freed memory
ldmain.c:add_archive_element copies file name pointers from the bfd to
a lang_input_statement_type.
input->filename = abfd->filename;
input->local_sym_name = abfd->filename;
This results in stale pointers when twiddling the bfd filename in
places like the pe ld after_open. So don't free the bfd filename,
and make copies using bfd_alloc memory that won't result in small
memory leaks that annoy memory checkers.
PR 25993
bfd/
* archive.c (_bfd_get_elt_at_filepos): Don't strdup filename,
use bfd_set_filename.
* elfcode.h (_bfd_elf_bfd_from_remote_memory): Likewise.
* mach-o.c (bfd_mach_o_fat_member_init): Likewise.
* opncls.c (bfd_fopen, bfd_openstreamr, bfd_openr_iovec, bfd_openw),
(bfd_create): Likewise.
(_bfd_delete_bfd): Don't free filename.
(bfd_set_filename): Copy filename param to bfd_alloc'd memory,
return pointer to the copy or NULL on alloc fail.
* vms-lib.c (_bfd_vms_lib_get_module): Free newname and test
result of bfd_set_filename.
* bfd-in2.h: Regenerate.
gdb/
* solib-darwin.c (darwin_bfd_open): Don't strdup pathname for
bfd_set_filename.
* solib-aix.c (solib_aix_bfd_open): Use std::string for name
passed to bfd_set_filename.
* symfile-mem.c (add_vsyscall_page): Likewise for string
passed to symbol_file_add_from_memory.
(symbol_file_add_from_memory): Make name param a const char* and
don't strdup.
ld/
* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Don't copy
other_bfd_filename for bfd_set_filename, and test result of
bfd_set_filename call. Don't create a new is->filename, simply
copy from bfd filename. Free new_name after bfd_set_filename.
* emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
2020-05-19 05:28:59 +02:00
|
|
|
name = "shared object read from target memory";
|
2019-09-08 19:38:24 +02:00
|
|
|
bfd_set_filename (nbfd, name);
|
2004-05-02 12:14:02 +02:00
|
|
|
|
|
|
|
if (!bfd_check_format (nbfd, bfd_object))
|
2012-07-23 16:58:44 +02:00
|
|
|
error (_("Got object file from memory but can't read symbols: %s."),
|
|
|
|
bfd_errmsg (bfd_get_error ()));
|
2004-05-02 12:14:02 +02:00
|
|
|
|
2018-03-13 04:50:33 +01:00
|
|
|
section_addr_info sai;
|
2004-05-02 12:14:02 +02:00
|
|
|
for (sec = nbfd->sections; sec != NULL; sec = sec->next)
|
bfd_section_* macros
This large patch removes the unnecessary bfd parameter from various
bfd section macros and functions. The bfd is hardly ever used and if
needed for the bfd_set_section_* or bfd_rename_section functions can
be found via section->owner except for the com, und, abs, and ind
std_section special sections. Those sections shouldn't be modified
anyway.
The patch also removes various bfd_get_section_<field> macros,
replacing their use with bfd_section_<field>, and adds
bfd_set_section_lma. I've also fixed a minor bug in gas where
compressed section renaming was done directly rather than calling
bfd_rename_section. This would have broken bfd_get_section_by_name
and similar functions, but that hardly mattered at such a late stage
in gas processing.
bfd/
* bfd-in.h (bfd_get_section_name, bfd_get_section_vma),
(bfd_get_section_lma, bfd_get_section_alignment),
(bfd_get_section_size, bfd_get_section_flags),
(bfd_get_section_userdata): Delete.
(bfd_section_name, bfd_section_size, bfd_section_vma),
(bfd_section_lma, bfd_section_alignment): Lose bfd parameter.
(bfd_section_flags, bfd_section_userdata): New.
(bfd_is_com_section): Rename parameter.
* section.c (bfd_set_section_userdata, bfd_set_section_vma),
(bfd_set_section_alignment, bfd_set_section_flags, bfd_rename_section),
(bfd_set_section_size): Delete bfd parameter, rename section parameter.
(bfd_set_section_lma): New.
* bfd-in2.h: Regenerate.
* mach-o.c (bfd_mach_o_init_section_from_mach_o): Delete bfd param,
update callers.
* aoutx.h, * bfd.c, * coff-alpha.c, * coff-arm.c, * coff-mips.c,
* coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c,
* compress.c, * ecoff.c, * elf-eh-frame.c, * elf-hppa.h,
* elf-ifunc.c, * elf-m10200.c, * elf-m10300.c, * elf-properties.c,
* elf-s390-common.c, * elf-vxworks.c, * elf.c, * elf32-arc.c,
* elf32-arm.c, * elf32-avr.c, * elf32-bfin.c, * elf32-cr16.c,
* elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c, * elf32-csky.c,
* elf32-d10v.c, * elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c,
* elf32-ft32.c, * elf32-h8300.c, * elf32-hppa.c, * elf32-i386.c,
* elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c, * elf32-m32c.c,
* elf32-m32r.c, * elf32-m68hc1x.c, * elf32-m68k.c, * elf32-mcore.c,
* elf32-mep.c, * elf32-metag.c, * elf32-microblaze.c,
* elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c,
* elf32-nios2.c, * elf32-or1k.c, * elf32-ppc.c, * elf32-pru.c,
* elf32-rl78.c, * elf32-rx.c, * elf32-s390.c, * elf32-score.c,
* elf32-score7.c, * elf32-sh.c, * elf32-spu.c, * elf32-tic6x.c,
* elf32-tilepro.c, * elf32-v850.c, * elf32-vax.c, * elf32-visium.c,
* elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c,
* elf64-bpf.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mmix.c,
* elf64-ppc.c, * elf64-s390.c, * elf64-sparc.c, * elf64-x86-64.c,
* elflink.c, * elfnn-aarch64.c, * elfnn-ia64.c, * elfnn-riscv.c,
* elfxx-aarch64.c, * elfxx-mips.c, * elfxx-sparc.c,
* elfxx-tilegx.c, * elfxx-x86.c, * i386msdos.c, * linker.c,
* mach-o.c, * mmo.c, * opncls.c, * pdp11.c, * pei-x86_64.c,
* peicode.h, * reloc.c, * section.c, * syms.c, * vms-alpha.c,
* xcofflink.c: Update throughout for bfd section macro and function
changes.
binutils/
* addr2line.c, * bucomm.c, * coffgrok.c, * dlltool.c, * nm.c,
* objcopy.c, * objdump.c, * od-elf32_avr.c, * od-macho.c,
* od-xcoff.c, * prdbg.c, * rdcoff.c, * rddbg.c, * rescoff.c,
* resres.c, * size.c, * srconv.c, * strings.c, * windmc.c: Update
throughout for bfd section macro and function changes.
gas/
* as.c, * as.h, * dw2gencfi.c, * dwarf2dbg.c, * ecoff.c,
* read.c, * stabs.c, * subsegs.c, * subsegs.h, * write.c,
* config/obj-coff-seh.c, * config/obj-coff.c, * config/obj-ecoff.c,
* config/obj-elf.c, * config/obj-macho.c, * config/obj-som.c,
* config/tc-aarch64.c, * config/tc-alpha.c, * config/tc-arc.c,
* config/tc-arm.c, * config/tc-avr.c, * config/tc-bfin.c,
* config/tc-bpf.c, * config/tc-d10v.c, * config/tc-d30v.c,
* config/tc-epiphany.c, * config/tc-fr30.c, * config/tc-frv.c,
* config/tc-h8300.c, * config/tc-hppa.c, * config/tc-i386.c,
* config/tc-ia64.c, * config/tc-ip2k.c, * config/tc-iq2000.c,
* config/tc-lm32.c, * config/tc-m32c.c, * config/tc-m32r.c,
* config/tc-m68hc11.c, * config/tc-mep.c, * config/tc-microblaze.c,
* config/tc-mips.c, * config/tc-mmix.c, * config/tc-mn10200.c,
* config/tc-mn10300.c, * config/tc-msp430.c, * config/tc-mt.c,
* config/tc-nds32.c, * config/tc-or1k.c, * config/tc-ppc.c,
* config/tc-pru.c, * config/tc-rl78.c, * config/tc-rx.c,
* config/tc-s12z.c, * config/tc-s390.c, * config/tc-score.c,
* config/tc-score7.c, * config/tc-sh.c, * config/tc-sparc.c,
* config/tc-spu.c, * config/tc-tic4x.c, * config/tc-tic54x.c,
* config/tc-tic6x.c, * config/tc-tilegx.c, * config/tc-tilepro.c,
* config/tc-v850.c, * config/tc-visium.c, * config/tc-wasm32.c,
* config/tc-xc16x.c, * config/tc-xgate.c, * config/tc-xstormy16.c,
* config/tc-xtensa.c, * config/tc-z8k.c: Update throughout for
bfd section macro and function changes.
* write.c (compress_debug): Use bfd_rename_section.
gdb/
* aarch64-linux-tdep.c, * arm-tdep.c, * auto-load.c,
* coff-pe-read.c, * coffread.c, * corelow.c, * dbxread.c,
* dicos-tdep.c, * dwarf2-frame.c, * dwarf2read.c, * elfread.c,
* exec.c, * fbsd-tdep.c, * gcore.c, * gdb_bfd.c, * gdb_bfd.h,
* hppa-tdep.c, * i386-cygwin-tdep.c, * i386-fbsd-tdep.c,
* i386-linux-tdep.c, * jit.c, * linux-tdep.c, * machoread.c,
* maint.c, * mdebugread.c, * minidebug.c, * mips-linux-tdep.c,
* mips-sde-tdep.c, * mips-tdep.c, * mipsread.c, * nto-tdep.c,
* objfiles.c, * objfiles.h, * osabi.c, * ppc-linux-tdep.c,
* ppc64-tdep.c, * record-btrace.c, * record-full.c, * remote.c,
* rs6000-aix-tdep.c, * rs6000-tdep.c, * s390-linux-tdep.c,
* s390-tdep.c, * solib-aix.c, * solib-dsbt.c, * solib-frv.c,
* solib-spu.c, * solib-svr4.c, * solib-target.c,
* spu-linux-nat.c, * spu-tdep.c, * symfile-mem.c, * symfile.c,
* symmisc.c, * symtab.c, * target.c, * windows-nat.c,
* xcoffread.c, * cli/cli-dump.c, * compile/compile-object-load.c,
* mi/mi-interp.c: Update throughout for bfd section macro and
function changes.
* gcore (gcore_create_callback): Use bfd_set_section_lma.
* spu-tdep.c (spu_overlay_new_objfile): Likewise.
gprof/
* corefile.c, * symtab.c: Update throughout for bfd section
macro and function changes.
ld/
* ldcref.c, * ldctor.c, * ldelf.c, * ldlang.c, * pe-dll.c,
* emultempl/aarch64elf.em, * emultempl/aix.em,
* emultempl/armcoff.em, * emultempl/armelf.em,
* emultempl/cr16elf.em, * emultempl/cskyelf.em,
* emultempl/m68hc1xelf.em, * emultempl/m68kelf.em,
* emultempl/mipself.em, * emultempl/mmix-elfnmmo.em,
* emultempl/mmo.em, * emultempl/msp430.em,
* emultempl/nios2elf.em, * emultempl/pe.em, * emultempl/pep.em,
* emultempl/ppc64elf.em, * emultempl/xtensaelf.em: Update
throughout for bfd section macro and function changes.
libctf/
* ctf-open-bfd.c: Update throughout for bfd section macro changes.
opcodes/
* arc-ext.c: Update throughout for bfd section macro changes.
sim/
* common/sim-load.c, * common/sim-utils.c, * cris/sim-if.c,
* erc32/func.c, * lm32/sim-if.c, * m32c/load.c, * m32c/trace.c,
* m68hc11/interp.c, * ppc/hw_htab.c, * ppc/hw_init.c,
* rl78/load.c, * rl78/trace.c, * rx/gdb-if.c, * rx/load.c,
* rx/trace.c: Update throughout for bfd section macro changes.
2019-09-16 12:55:17 +02:00
|
|
|
if ((bfd_section_flags (sec) & (SEC_ALLOC|SEC_LOAD)) != 0)
|
|
|
|
sai.emplace_back (bfd_section_vma (sec) + loadbase,
|
|
|
|
bfd_section_name (sec),
|
2018-03-13 04:50:33 +01:00
|
|
|
sec->index);
|
2004-05-02 12:14:02 +02:00
|
|
|
|
Make symfile_add_flags and objfile->flags strongly typed
This makes these flag types be "enum flag" types. The benefit is
making use of C++'s stronger typing -- mixing the flags types by
mistake errors at compile time.
This caught one old bug in symbol_file_add_main_1 already, fixed by
this patch as well:
@@ -1318,7 +1326,7 @@ symbol_file_add_main_1 (const char *args, int from_tty, int flags)
what is frameless. */
reinit_frame_cache ();
- if ((flags & SYMFILE_NO_READ) == 0)
+ if ((add_flags & SYMFILE_NO_READ) == 0)
set_initial_language ();
}
Above, "flags" are objfile flags, not symfile_add_flags. So that was
actually checking for "flag & OBJF_PSYMTABS_READ", which has the same
value as SYMFILE_NO_READ...
I moved the flags definitions to separate files to break circular
dependencies.
Built with --enable-targets=all and tested on x86-64 Fedora 23.
gdb/ChangeLog:
2016-10-26 Pedro Alves <palves@redhat.com>
* coffread.c (coff_symfile_read): Use symfile_add_flags.
* dbxread.c (dbx_symfile_read): Ditto.
* elfread.c (elf_symfile_read): Ditto.
* inferior.h: Include symfile-add-flags.h.
(struct inferior) <symfile_flags>: Now symfile_add_flags.
* machoread.c (macho_add_oso_symfile, macho_symfile_read_all_oso)
(macho_symfile_read, mipscoff_symfile_read): Use
symfile_add_flags.
* objfile-flags.h: New file.
* objfiles.c (allocate_objfile): Use objfile_flags.
* objfiles.h: Include objfile-flags.h.
(struct objfile) <flags>: Now an objfile_flags.
(OBJF_REORDERED, OBJF_SHARED, OBJF_READNOW, OBJF_USERLOADED)
(OBJF_PSYMTABS_READ, OBJF_MAINLINE, OBJF_NOT_FILENAME): Delete.
Converted to an enum-flags in objfile-flags.h.
(allocate_objfile): Use objfile_flags.
* python/py-objfile.c (objfpy_add_separate_debug_file): Remove
unnecessary local.
* solib.c (solib_read_symbols, solib_add)
(reload_shared_libraries_1): Use symfile_add_flags.
* solib.h: Include "symfile-add-flags.h".
(solib_read_symbols): Use symfile_add_flags.
* symfile-add-flags.h: New file.
* symfile-debug.c (debug_sym_read): Use symfile_add_flags.
* symfile-mem.c (symbol_file_add_from_memory): Use
symfile_add_flags.
* symfile.c (read_symbols, syms_from_objfile_1)
(syms_from_objfile, finish_new_objfile): Use symfile_add_flags.
(symbol_file_add_with_addrs): Use symfile_add_flags and
objfile_flags.
(symbol_file_add_separate): Use symfile_add_flags.
(symbol_file_add_from_bfd, symbol_file_add): Use symfile_add_flags
and objfile_flags.
(symbol_file_add_main_1): : Use objfile_flags. Fix add_flags vs
flags confusion.
(symbol_file_command): Use objfile_flags.
(add_symbol_file_command): Use symfile_add_flags and
objfile_flags.
(clear_symtab_users): Use symfile_add_flags.
* symfile.h: Include "symfile-add-flags.h" and "objfile-flags.h".
(struct sym_fns) <sym_read>: Use symfile_add_flags.
(clear_symtab_users): Use symfile_add_flags.
(enum symfile_add_flags): Delete, moved to symfile-add-flags.h and
converted to enum-flags.
(symbol_file_add, symbol_file_add_from_bfd)
(symbol_file_add_separate): Use symfile_add_flags.
* xcoffread.c (xcoff_initial_scan): Use symfile_add_flags.
2016-10-26 17:47:10 +02:00
|
|
|
if (from_tty)
|
|
|
|
add_flags |= SYMFILE_VERBOSE;
|
|
|
|
|
2013-09-24 16:00:06 +02:00
|
|
|
objf = symbol_file_add_from_bfd (nbfd, bfd_get_filename (nbfd),
|
2018-03-13 04:50:33 +01:00
|
|
|
add_flags, &sai, OBJF_SHARED, NULL);
|
2004-05-02 12:14:02 +02:00
|
|
|
|
2014-06-02 11:35:22 +02:00
|
|
|
add_target_sections_of_objfile (objf);
|
2014-04-02 09:54:11 +02:00
|
|
|
|
2004-05-02 12:14:02 +02:00
|
|
|
/* This might change our ideas about frames already looked at. */
|
|
|
|
reinit_frame_cache ();
|
|
|
|
|
|
|
|
return objf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2017-09-13 05:17:01 +02:00
|
|
|
add_symbol_file_from_memory_command (const char *args, int from_tty)
|
2004-05-02 12:14:02 +02:00
|
|
|
{
|
|
|
|
CORE_ADDR addr;
|
2004-05-25 23:55:43 +02:00
|
|
|
struct bfd *templ;
|
2004-05-02 12:14:02 +02:00
|
|
|
|
|
|
|
if (args == NULL)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
error (_("add-symbol-file-from-memory requires an expression argument"));
|
2004-05-02 12:14:02 +02:00
|
|
|
|
|
|
|
addr = parse_and_eval_address (args);
|
|
|
|
|
|
|
|
/* We need some representative bfd to know the target we are looking at. */
|
|
|
|
if (symfile_objfile != NULL)
|
|
|
|
templ = symfile_objfile->obfd;
|
|
|
|
else
|
|
|
|
templ = exec_bfd;
|
|
|
|
if (templ == NULL)
|
2011-01-05 23:22:53 +01:00
|
|
|
error (_("Must use symbol-file or exec-file "
|
|
|
|
"before add-symbol-file-from-memory."));
|
2004-05-02 12:14:02 +02:00
|
|
|
|
2014-04-02 03:37:33 +02:00
|
|
|
symbol_file_add_from_memory (templ, addr, 0, NULL, from_tty);
|
2004-11-07 22:33:29 +01:00
|
|
|
}
|
|
|
|
|
2011-01-05 23:22:53 +01:00
|
|
|
/* Try to add the symbols for the vsyscall page, if there is one.
|
|
|
|
This function is called via the inferior_created observer. */
|
2004-11-07 22:33:29 +01:00
|
|
|
|
|
|
|
static void
|
|
|
|
add_vsyscall_page (struct target_ops *target, int from_tty)
|
|
|
|
{
|
2014-10-10 16:57:13 +02:00
|
|
|
struct mem_range vsyscall_range;
|
2004-11-07 22:33:29 +01:00
|
|
|
|
2014-10-10 16:57:13 +02:00
|
|
|
if (gdbarch_vsyscall_range (target_gdbarch (), &vsyscall_range))
|
2004-11-07 22:33:29 +01:00
|
|
|
{
|
|
|
|
struct bfd *bfd;
|
|
|
|
|
|
|
|
if (core_bfd != NULL)
|
|
|
|
bfd = core_bfd;
|
|
|
|
else if (exec_bfd != NULL)
|
|
|
|
bfd = 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
|
|
|
|
page in the inferior. Unfortunately that's the current
|
|
|
|
interface so for the moment bail. Introducing a
|
|
|
|
``bfd_runtime'' (a BFD created using the loaded image) file
|
|
|
|
format should fix this. */
|
|
|
|
{
|
2011-01-05 23:22:53 +01:00
|
|
|
warning (_("Could not load vsyscall page "
|
2016-04-06 15:57:08 +02:00
|
|
|
"because no executable was specified"));
|
2004-11-07 22:33:29 +01:00
|
|
|
return;
|
|
|
|
}
|
Eliminate catch_exceptions/catch_exceptions_with_msg
This patch gets rid of catch_exceptions / catch_exceptions_with_msg.
The latter is done mostly by getting rid of the three remaining
vestigial libgdb wrapper functions, which are really pointless
nowadays. This results in a good number of simplifications.
(I checked that Insight doesn't use those functions.)
The gdb.mi/mi-pthreads.exp change is necessary because this actually
fixes a bug, IMO -- the patch stops MI's -thread-select causing output
on the CLI stream.
I.e., before:
-thread-select 123456789
&"Thread ID 123456789 not known.\n"
^error,msg="Thread ID 123456789 not known."
(gdb)
After:
-thread-select 123456789
^error,msg="Thread ID 123456789 not known."
(gdb)
gdb/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* breakpoint.c (struct captured_breakpoint_query_args)
(do_captured_breakpoint_query, gdb_breakpoint_query): Delete.
(print_breakpoint): New.
* breakpoint.h (print_breakpoint): Declare.
* common/common-exceptions.h (enum return_reason): Remove
references to catch_exceptions.
* exceptions.c (catch_exceptions, catch_exceptions_with_msg):
Delete.
* exceptions.h (catch_exceptions_ftype, catch_exceptions)
(catch_exception_ftype, catch_exceptions_with_msg): Delete.
* gdb.h: Delete.
* gdbthread.h (thread_select): Declare.
* mi/mi-cmd-break.c: Don't include gdb.h.
(breakpoint_notify): Use print_breakpoint.
* mi/mi-cmd-catch.c: Don't include gdb.h.
* mi/mi-interp.c: Don't include gdb.h.
(mi_print_breakpoint_for_event): New.
(mi_breakpoint_created, mi_breakpoint_modified): Use
mi_print_breakpoint_for_event.
* mi/mi-main.c: Don't include gdb.h.
(mi_cmd_thread_select): Parse the global thread ID here. Use
thread_select instead of gdb_thread_select.
(mi_cmd_thread_list_ids): Output "thread-ids" tuple here instead
of using gdb_list_thread_ids.
* remote-fileio.c (do_remote_fileio_request): Change type. Reply
FILEIO_ENOSYS here.
(remote_fileio_request): Use TRY/CATCH instead of
catch_exceptions.
* symfile-mem.c (struct symbol_file_add_from_memory_args)
(symbol_file_add_from_memory_wrapper): Delete.
(add_vsyscall_page): Use TRY/CATCH instead of catch_exceptions.
* thread.c: Don't include gdb.h.
(do_captured_list_thread_ids, gdb_list_thread_ids): Delete.
(thread_alive): Use thread_select.
(do_captured_thread_select): Delete, parts salvaged as ...
(thread_select): ... this new function.
(gdb_thread_select): Delete.
gdb/testsuite/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
* gdb.mi/mi-pthreads.exp (check_mi_thread_command_set): Don't
expect CLI output.
2017-10-10 17:45:51 +02:00
|
|
|
|
PR25993, read of freed memory
ldmain.c:add_archive_element copies file name pointers from the bfd to
a lang_input_statement_type.
input->filename = abfd->filename;
input->local_sym_name = abfd->filename;
This results in stale pointers when twiddling the bfd filename in
places like the pe ld after_open. So don't free the bfd filename,
and make copies using bfd_alloc memory that won't result in small
memory leaks that annoy memory checkers.
PR 25993
bfd/
* archive.c (_bfd_get_elt_at_filepos): Don't strdup filename,
use bfd_set_filename.
* elfcode.h (_bfd_elf_bfd_from_remote_memory): Likewise.
* mach-o.c (bfd_mach_o_fat_member_init): Likewise.
* opncls.c (bfd_fopen, bfd_openstreamr, bfd_openr_iovec, bfd_openw),
(bfd_create): Likewise.
(_bfd_delete_bfd): Don't free filename.
(bfd_set_filename): Copy filename param to bfd_alloc'd memory,
return pointer to the copy or NULL on alloc fail.
* vms-lib.c (_bfd_vms_lib_get_module): Free newname and test
result of bfd_set_filename.
* bfd-in2.h: Regenerate.
gdb/
* solib-darwin.c (darwin_bfd_open): Don't strdup pathname for
bfd_set_filename.
* solib-aix.c (solib_aix_bfd_open): Use std::string for name
passed to bfd_set_filename.
* symfile-mem.c (add_vsyscall_page): Likewise for string
passed to symbol_file_add_from_memory.
(symbol_file_add_from_memory): Make name param a const char* and
don't strdup.
ld/
* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Don't copy
other_bfd_filename for bfd_set_filename, and test result of
bfd_set_filename call. Don't create a new is->filename, simply
copy from bfd filename. Free new_name after bfd_set_filename.
* emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
2020-05-19 05:28:59 +02:00
|
|
|
std::string name = string_printf ("system-supplied DSO at %s",
|
|
|
|
paddress (target_gdbarch (),
|
|
|
|
vsyscall_range.start));
|
2019-04-04 00:02:42 +02:00
|
|
|
try
|
Eliminate catch_exceptions/catch_exceptions_with_msg
This patch gets rid of catch_exceptions / catch_exceptions_with_msg.
The latter is done mostly by getting rid of the three remaining
vestigial libgdb wrapper functions, which are really pointless
nowadays. This results in a good number of simplifications.
(I checked that Insight doesn't use those functions.)
The gdb.mi/mi-pthreads.exp change is necessary because this actually
fixes a bug, IMO -- the patch stops MI's -thread-select causing output
on the CLI stream.
I.e., before:
-thread-select 123456789
&"Thread ID 123456789 not known.\n"
^error,msg="Thread ID 123456789 not known."
(gdb)
After:
-thread-select 123456789
^error,msg="Thread ID 123456789 not known."
(gdb)
gdb/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* breakpoint.c (struct captured_breakpoint_query_args)
(do_captured_breakpoint_query, gdb_breakpoint_query): Delete.
(print_breakpoint): New.
* breakpoint.h (print_breakpoint): Declare.
* common/common-exceptions.h (enum return_reason): Remove
references to catch_exceptions.
* exceptions.c (catch_exceptions, catch_exceptions_with_msg):
Delete.
* exceptions.h (catch_exceptions_ftype, catch_exceptions)
(catch_exception_ftype, catch_exceptions_with_msg): Delete.
* gdb.h: Delete.
* gdbthread.h (thread_select): Declare.
* mi/mi-cmd-break.c: Don't include gdb.h.
(breakpoint_notify): Use print_breakpoint.
* mi/mi-cmd-catch.c: Don't include gdb.h.
* mi/mi-interp.c: Don't include gdb.h.
(mi_print_breakpoint_for_event): New.
(mi_breakpoint_created, mi_breakpoint_modified): Use
mi_print_breakpoint_for_event.
* mi/mi-main.c: Don't include gdb.h.
(mi_cmd_thread_select): Parse the global thread ID here. Use
thread_select instead of gdb_thread_select.
(mi_cmd_thread_list_ids): Output "thread-ids" tuple here instead
of using gdb_list_thread_ids.
* remote-fileio.c (do_remote_fileio_request): Change type. Reply
FILEIO_ENOSYS here.
(remote_fileio_request): Use TRY/CATCH instead of
catch_exceptions.
* symfile-mem.c (struct symbol_file_add_from_memory_args)
(symbol_file_add_from_memory_wrapper): Delete.
(add_vsyscall_page): Use TRY/CATCH instead of catch_exceptions.
* thread.c: Don't include gdb.h.
(do_captured_list_thread_ids, gdb_list_thread_ids): Delete.
(thread_alive): Use thread_select.
(do_captured_thread_select): Delete, parts salvaged as ...
(thread_select): ... this new function.
(gdb_thread_select): Delete.
gdb/testsuite/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
* gdb.mi/mi-pthreads.exp (check_mi_thread_command_set): Don't
expect CLI output.
2017-10-10 17:45:51 +02:00
|
|
|
{
|
|
|
|
/* Pass zero for FROM_TTY, because the action of loading the
|
|
|
|
vsyscall DSO was not triggered by the user, even if the
|
|
|
|
user typed "run" at the TTY. */
|
|
|
|
symbol_file_add_from_memory (bfd,
|
|
|
|
vsyscall_range.start,
|
|
|
|
vsyscall_range.length,
|
PR25993, read of freed memory
ldmain.c:add_archive_element copies file name pointers from the bfd to
a lang_input_statement_type.
input->filename = abfd->filename;
input->local_sym_name = abfd->filename;
This results in stale pointers when twiddling the bfd filename in
places like the pe ld after_open. So don't free the bfd filename,
and make copies using bfd_alloc memory that won't result in small
memory leaks that annoy memory checkers.
PR 25993
bfd/
* archive.c (_bfd_get_elt_at_filepos): Don't strdup filename,
use bfd_set_filename.
* elfcode.h (_bfd_elf_bfd_from_remote_memory): Likewise.
* mach-o.c (bfd_mach_o_fat_member_init): Likewise.
* opncls.c (bfd_fopen, bfd_openstreamr, bfd_openr_iovec, bfd_openw),
(bfd_create): Likewise.
(_bfd_delete_bfd): Don't free filename.
(bfd_set_filename): Copy filename param to bfd_alloc'd memory,
return pointer to the copy or NULL on alloc fail.
* vms-lib.c (_bfd_vms_lib_get_module): Free newname and test
result of bfd_set_filename.
* bfd-in2.h: Regenerate.
gdb/
* solib-darwin.c (darwin_bfd_open): Don't strdup pathname for
bfd_set_filename.
* solib-aix.c (solib_aix_bfd_open): Use std::string for name
passed to bfd_set_filename.
* symfile-mem.c (add_vsyscall_page): Likewise for string
passed to symbol_file_add_from_memory.
(symbol_file_add_from_memory): Make name param a const char* and
don't strdup.
ld/
* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Don't copy
other_bfd_filename for bfd_set_filename, and test result of
bfd_set_filename call. Don't create a new is->filename, simply
copy from bfd filename. Free new_name after bfd_set_filename.
* emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
2020-05-19 05:28:59 +02:00
|
|
|
name.c_str (),
|
Eliminate catch_exceptions/catch_exceptions_with_msg
This patch gets rid of catch_exceptions / catch_exceptions_with_msg.
The latter is done mostly by getting rid of the three remaining
vestigial libgdb wrapper functions, which are really pointless
nowadays. This results in a good number of simplifications.
(I checked that Insight doesn't use those functions.)
The gdb.mi/mi-pthreads.exp change is necessary because this actually
fixes a bug, IMO -- the patch stops MI's -thread-select causing output
on the CLI stream.
I.e., before:
-thread-select 123456789
&"Thread ID 123456789 not known.\n"
^error,msg="Thread ID 123456789 not known."
(gdb)
After:
-thread-select 123456789
^error,msg="Thread ID 123456789 not known."
(gdb)
gdb/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* breakpoint.c (struct captured_breakpoint_query_args)
(do_captured_breakpoint_query, gdb_breakpoint_query): Delete.
(print_breakpoint): New.
* breakpoint.h (print_breakpoint): Declare.
* common/common-exceptions.h (enum return_reason): Remove
references to catch_exceptions.
* exceptions.c (catch_exceptions, catch_exceptions_with_msg):
Delete.
* exceptions.h (catch_exceptions_ftype, catch_exceptions)
(catch_exception_ftype, catch_exceptions_with_msg): Delete.
* gdb.h: Delete.
* gdbthread.h (thread_select): Declare.
* mi/mi-cmd-break.c: Don't include gdb.h.
(breakpoint_notify): Use print_breakpoint.
* mi/mi-cmd-catch.c: Don't include gdb.h.
* mi/mi-interp.c: Don't include gdb.h.
(mi_print_breakpoint_for_event): New.
(mi_breakpoint_created, mi_breakpoint_modified): Use
mi_print_breakpoint_for_event.
* mi/mi-main.c: Don't include gdb.h.
(mi_cmd_thread_select): Parse the global thread ID here. Use
thread_select instead of gdb_thread_select.
(mi_cmd_thread_list_ids): Output "thread-ids" tuple here instead
of using gdb_list_thread_ids.
* remote-fileio.c (do_remote_fileio_request): Change type. Reply
FILEIO_ENOSYS here.
(remote_fileio_request): Use TRY/CATCH instead of
catch_exceptions.
* symfile-mem.c (struct symbol_file_add_from_memory_args)
(symbol_file_add_from_memory_wrapper): Delete.
(add_vsyscall_page): Use TRY/CATCH instead of catch_exceptions.
* thread.c: Don't include gdb.h.
(do_captured_list_thread_ids, gdb_list_thread_ids): Delete.
(thread_alive): Use thread_select.
(do_captured_thread_select): Delete, parts salvaged as ...
(thread_select): ... this new function.
(gdb_thread_select): Delete.
gdb/testsuite/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
* gdb.mi/mi-pthreads.exp (check_mi_thread_command_set): Don't
expect CLI output.
2017-10-10 17:45:51 +02:00
|
|
|
0 /* from_tty */);
|
|
|
|
}
|
2019-04-03 23:59:07 +02:00
|
|
|
catch (const gdb_exception &ex)
|
Eliminate catch_exceptions/catch_exceptions_with_msg
This patch gets rid of catch_exceptions / catch_exceptions_with_msg.
The latter is done mostly by getting rid of the three remaining
vestigial libgdb wrapper functions, which are really pointless
nowadays. This results in a good number of simplifications.
(I checked that Insight doesn't use those functions.)
The gdb.mi/mi-pthreads.exp change is necessary because this actually
fixes a bug, IMO -- the patch stops MI's -thread-select causing output
on the CLI stream.
I.e., before:
-thread-select 123456789
&"Thread ID 123456789 not known.\n"
^error,msg="Thread ID 123456789 not known."
(gdb)
After:
-thread-select 123456789
^error,msg="Thread ID 123456789 not known."
(gdb)
gdb/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* breakpoint.c (struct captured_breakpoint_query_args)
(do_captured_breakpoint_query, gdb_breakpoint_query): Delete.
(print_breakpoint): New.
* breakpoint.h (print_breakpoint): Declare.
* common/common-exceptions.h (enum return_reason): Remove
references to catch_exceptions.
* exceptions.c (catch_exceptions, catch_exceptions_with_msg):
Delete.
* exceptions.h (catch_exceptions_ftype, catch_exceptions)
(catch_exception_ftype, catch_exceptions_with_msg): Delete.
* gdb.h: Delete.
* gdbthread.h (thread_select): Declare.
* mi/mi-cmd-break.c: Don't include gdb.h.
(breakpoint_notify): Use print_breakpoint.
* mi/mi-cmd-catch.c: Don't include gdb.h.
* mi/mi-interp.c: Don't include gdb.h.
(mi_print_breakpoint_for_event): New.
(mi_breakpoint_created, mi_breakpoint_modified): Use
mi_print_breakpoint_for_event.
* mi/mi-main.c: Don't include gdb.h.
(mi_cmd_thread_select): Parse the global thread ID here. Use
thread_select instead of gdb_thread_select.
(mi_cmd_thread_list_ids): Output "thread-ids" tuple here instead
of using gdb_list_thread_ids.
* remote-fileio.c (do_remote_fileio_request): Change type. Reply
FILEIO_ENOSYS here.
(remote_fileio_request): Use TRY/CATCH instead of
catch_exceptions.
* symfile-mem.c (struct symbol_file_add_from_memory_args)
(symbol_file_add_from_memory_wrapper): Delete.
(add_vsyscall_page): Use TRY/CATCH instead of catch_exceptions.
* thread.c: Don't include gdb.h.
(do_captured_list_thread_ids, gdb_list_thread_ids): Delete.
(thread_alive): Use thread_select.
(do_captured_thread_select): Delete, parts salvaged as ...
(thread_select): ... this new function.
(gdb_thread_select): Delete.
gdb/testsuite/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
* gdb.mi/mi-pthreads.exp (check_mi_thread_command_set): Don't
expect CLI output.
2017-10-10 17:45:51 +02:00
|
|
|
{
|
|
|
|
exception_print (gdb_stderr, ex);
|
|
|
|
}
|
2004-11-07 22:33:29 +01:00
|
|
|
}
|
2004-05-02 12:14:02 +02:00
|
|
|
}
|
|
|
|
|
2020-01-13 20:01:38 +01:00
|
|
|
void _initialize_symfile_mem ();
|
2004-05-02 12:14:02 +02:00
|
|
|
void
|
2020-01-13 20:01:38 +01:00
|
|
|
_initialize_symfile_mem ()
|
2004-05-02 12:14:02 +02:00
|
|
|
{
|
|
|
|
add_cmd ("add-symbol-file-from-memory", class_files,
|
2011-01-05 23:22:53 +01:00
|
|
|
add_symbol_file_from_memory_command,
|
|
|
|
_("Load the symbols out of memory from a "
|
|
|
|
"dynamically loaded object file.\n"
|
|
|
|
"Give an expression for the address "
|
|
|
|
"of the file's shared object file header."),
|
2004-05-02 12:14:02 +02:00
|
|
|
&cmdlist);
|
|
|
|
|
2004-11-07 22:33:29 +01:00
|
|
|
/* Want to know of each new inferior so that its vsyscall info can
|
|
|
|
be extracted. */
|
Convert observers to C++
This converts observers from using a special source-generating script
to be plain C++. This version of the patch takes advantage of C++11
by using std::function and variadic templates; incorporates Pedro's
patches; and renames the header file to "observable.h" (this change
eliminates the need for a clean rebuild).
Note that Pedro's patches used a template lambda in tui-hooks.c, but
this failed to compile on some buildbot instances (presumably due to
differing C++ versions); I replaced this with an ordinary template
function.
Regression tested on the buildbot.
gdb/ChangeLog
2018-03-19 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* unittests/observable-selftests.c: New file.
* common/observable.h: New file.
* observable.h: New file.
* ada-lang.c, ada-tasks.c, agent.c, aix-thread.c, annotate.c,
arm-tdep.c, auto-load.c, auxv.c, break-catch-syscall.c,
breakpoint.c, bsd-uthread.c, cli/cli-interp.c, cli/cli-setshow.c,
corefile.c, dummy-frame.c, event-loop.c, event-top.c, exec.c,
extension.c, frame.c, gdbarch.c, guile/scm-breakpoint.c,
infcall.c, infcmd.c, inferior.c, inflow.c, infrun.c, jit.c,
linux-tdep.c, linux-thread-db.c, m68klinux-tdep.c,
mi/mi-cmd-break.c, mi/mi-interp.c, mi/mi-main.c, objfiles.c,
ppc-linux-nat.c, ppc-linux-tdep.c, printcmd.c, procfs.c,
python/py-breakpoint.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/py-unwind.c, ravenscar-thread.c,
record-btrace.c, record-full.c, record.c, regcache.c, remote.c,
riscv-tdep.c, sol-thread.c, solib-aix.c, solib-spu.c, solib.c,
spu-multiarch.c, spu-tdep.c, stack.c, symfile-mem.c, symfile.c,
symtab.c, thread.c, top.c, tracepoint.c, tui/tui-hooks.c,
tui/tui-interp.c, valops.c: Update all users.
* tui/tui-hooks.c (tui_bp_created_observer)
(tui_bp_deleted_observer, tui_bp_modified_observer)
(tui_inferior_exit_observer, tui_before_prompt_observer)
(tui_normal_stop_observer, tui_register_changed_observer):
Remove.
(tui_observers_token): New global.
(attach_or_detach, tui_attach_detach_observers): New functions.
(tui_install_hooks, tui_remove_hooks): Use
tui_attach_detach_observers.
* record-btrace.c (record_btrace_thread_observer): Remove.
(record_btrace_thread_observer_token): New global.
* observer.sh: Remove.
* observer.c: Rename to observable.c.
* observable.c (namespace gdb_observers): Define new objects.
(observer_debug): Move into gdb_observers namespace.
(struct observer, struct observer_list, xalloc_observer_list_node)
(xfree_observer_list_node, generic_observer_attach)
(generic_observer_detach, generic_observer_notify): Remove.
(_initialize_observer): Update.
Don't include observer.inc.
* Makefile.in (generated_files): Remove observer.h, observer.inc.
(clean mostlyclean): Likewise.
(observer.h, observer.inc): Remove targets.
(SUBDIR_UNITTESTS_SRCS): Add observable-selftests.c.
(COMMON_SFILES): Use observable.c, not observer.c.
* .gitignore: Remove observer.h.
gdb/doc/ChangeLog
2018-03-19 Tom Tromey <tom@tromey.com>
* observer.texi: Remove.
gdb/testsuite/ChangeLog
2018-03-19 Tom Tromey <tom@tromey.com>
* gdb.gdb/observer.exp: Remove.
2016-10-02 18:50:20 +02:00
|
|
|
gdb::observers::inferior_created.attach (add_vsyscall_page);
|
2004-05-02 12:14:02 +02:00
|
|
|
}
|