binutils-gdb/gdb/solib.c

1615 lines
48 KiB
C
Raw Normal View History

2000-10-24 22:05:36 +02:00
/* Handle shared libraries for GDB, the GNU Debugger.
Copyright (C) 1990-2020 Free Software Foundation, Inc.
1999-07-07 22:19:36 +02:00
This file is part of GDB.
1999-07-07 22:19:36 +02:00
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
the Free Software Foundation; either version 3 of the License, or
1999-07-07 22:19:36 +02:00
(at your option) any later version.
1999-07-07 22:19:36 +02:00
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
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include <sys/types.h>
#include <fcntl.h>
#include "symtab.h"
#include "bfd.h"
#include "symfile.h"
#include "objfiles.h"
#include "gdbcore.h"
#include "command.h"
#include "target.h"
#include "frame.h"
#include "gdb_regex.h"
#include "inferior.h"
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/environ.h"
#include "language.h"
#include "gdbcmd.h"
#include "completer.h"
#include "filenames.h" /* for DOSish file names */
#include "exec.h"
2000-10-24 22:05:36 +02:00
#include "solist.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"
#include "readline/tilde.h"
#include "remote.h"
2008-02-21 Pedro Alves <pedro@codesorcery.com> Silence a few -Wmissing-prototypes warnings. PR build/9877: * amd64-nat.c: Include "amd64-nat.h". * fork-child.c (_initialize_fork_child): Ditto. * gcore.c (_initialize_gcore): Ditto. * inf-ptrace.c: Include "inf-ptrace.h". (inf_ptrace_store_registers): Make it static. * linux-nat.c (linux_nat_terminal_ours): Make it static. (_initialize_linux_nat): Declare before definition. * linux-tdep.c: Include "linux-tdep.h". * linux-thread-db.c (_initialize_thread_db): Declare before definition. * proc-service.c (_initialize_proc_service): Ditto. * remote.c (remote_send_printf): Make it static. * solib.c: Include "solib.h". * symfile-mem.c (_initialize_symfile_mem): Declare before definition. * ada-lang.c (ada_la_decode, ada_match_name) (ada_suppress_symbol_printing, ada_is_array_type) (ada_value_ptr_subscript, ada_array_length) (ada_to_static_fixed_value): Make them static. (_initialize_ada_language): Declare before definition. * ada-tasks.c (ada_get_task_number, ada_get_environment_task) (ada_task_list_changed, ada_new_objfile_observer): Make them static. (_initialize_tasks): Declare before definition. * addrmap.c (_initialize_addrmap): Declare before definition. * auxv.c (default_auxv_parse): Make it static. * bfd-target.c (target_bfd_xfer_partial, target_bfd_xclose): Make them static. * breakpoint.c (remove_sal): Add line break. (expand_line_sal_maybe): Make it static. * cp-name-parser.y: Include "cp-support.h". * cp-valprint.c (cp_find_class_member): Make it static. * eval.c (value_f90_subarray): Ditto. * exceptions.c (print_any_exception): Ditto. * findcmd.c (_initialize_mem_search): Declare before definition. * frame.c (frame_observer_target_changed): Make it static. * gnu-v3-abi.c (gnuv3_find_method_in): Make it static. * inf-child.c: Include "inf-child.h". * inferior.h (valid_inferior_id): Rename to ... (valid_gdb_inferior_id): ... this. * infrun.c (infrun_thread_stop_requested, siginfo_make_value): Make them static. * jv-lang.c (java_language_arch_info): Make it static. * m2-typeprint.c (m2_get_discrete_bounds): Ditto. * osdata.c (info_osdata_command): Make it static. * regcache.c (regcache_observer_target_changed): Make it static. * reverse.c (_initialize_reverse): Declare before definition. * stabsread.c (cleanup_undefined_types_noname) (cleanup_undefined_types_1): Make them static. * symfile.c (place_section): Make it static. * symtab.c (find_pc_sect_psymtab_closer): Make it static. * target-descriptions.c (_initialize_target_descriptions): Declare before definition. * target.c (default_get_ada_task_ptid, find_default_can_async_p) (find_default_is_async_p, find_default_supports_non_stop): Make them static. (target_supports_non_stop): Add prototype. (dummy_pid_to_str): Make it static. * utils.c (_initialize_utils): Declare before definition. * ada-exp.y (_initialize_ada_exp): Declare before definition. * solib-svr4.c (HAS_LM_DYNAMIC_FROM_LINK_MAP): Add a prototype. * target.h (struct target_ops): Add a prototype to the to_can_execute_reverse callback. * macroscope.c (_initialize_macroscope): Declare before definition. * cp-namespace.c (_initialize_cp_namespace): Declare before definition. * python/python.c (_initialize_python): Declare before definition. * tui/tui-command.c: Include "tui/tui-command.h". * tui/tui-data.c (init_content_element, init_win_info): Make them static. * tui/tui-disasm.c: Include "tui/tui-disasm.h". * tui/tui-interp.c (_initialize_tui_interp): Declare before definition. * tui/tui-layout.c: Include "tui/tui-layout.h". (_initialize_tui_layout): Declare before definition. * tui/tui-regs.c: Include "tui/tui-regs.h". (tui_display_reg_element_at_line): Make it static. (_initialize_tui_regs): Declare before definition. * tui/tui-stack.c (_initialize_tui_stack): Declare before definition. * tui/tui-win.c: Include "tui/tui-win.h". (_initialize_tui_win): Declare before definition. (tui_sigwinch_handler): Make it static. Wrap in ifdef SIGWINCH. * tui/tui-win.h (tui_sigwinch_handler): Delete declaration. (tui_get_cmd_list): Add a prototype. * tui/tui-windata.c: Include tui-windata.h. * tui/tui-wingeneral.c (box_win): Make it static. * cli/cli-logging.c (show_logging_command): Make it static. (_initialize_cli_logging): Declare before definition. * mi/mi-common.c (_initialize_gdb_mi_common): Declare before definition.
2009-02-21 17:14:50 +01:00
#include "solib.h"
#include "interps.h"
#include "filesystem.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"
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/filestuff.h"
#include "source.h"
Remove the ui_out_style_kind enum This removes the ui_out_style_kind enum, in favor of simply using ui_file_style references. This simplifies the code somewhat. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * ui-out.h (enum class ui_out_style_kind): Remove. (class ui_out) <field_string, field_stsream, do_field_string>: Change type of "style". * ui-out.c (ui_out::field_core_addr, ui_out::field_stream) (ui_out::field_string): Update. * tui/tui-out.h (class tui_ui_out) <do_field_string>: Change type of "style". * tui/tui-out.c (tui_ui_out::do_field_string): Update. * tracepoint.c (print_one_static_tracepoint_marker): Update. * stack.c (print_frame_arg, print_frame_info, print_frame): Update. * source.c (print_source_lines_base): Update. * solib.c (info_sharedlibrary_command): Update. * skip.c (info_skip_command): Update. * record-btrace.c (btrace_call_history_src_line) (btrace_call_history): Update. * python/py-framefilter.c (py_print_frame): Update. * mi/mi-out.h (class mi_ui_out) <do_field_string>: Change type of "style". * mi/mi-out.c (mi_ui_out::do_table_header) (mi_ui_out::do_field_signed, mi_ui_out::do_field_unsigned) (mi_ui_out::do_field_string): Update. * disasm.c (gdb_pretty_print_disassembler::pretty_print_insn): Update. * cli-out.h (class cli_ui_out) <do_field_string>: Change type of "style". * cli-out.c (cli_ui_out::do_table_header) (cli_ui_out::do_field_signed, cli_ui_out::do_field_unsigned) (cli_ui_out::do_field_skip, cli_ui_out::do_field_string) (cli_ui_out::do_field_fmt): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update.
2019-06-06 00:21:24 +02:00
#include "cli/cli-style.h"
/* Architecture-specific operations. */
/* Per-architecture data key. */
static struct gdbarch_data *solib_data;
static void *
solib_init (struct obstack *obstack)
{
struct target_so_ops **ops;
ops = OBSTACK_ZALLOC (obstack, struct target_so_ops *);
*ops = current_target_so_ops;
return ops;
}
static const struct target_so_ops *
solib_ops (struct gdbarch *gdbarch)
{
Add some more casts (2/2) See previous patch's description. gdb/ChangeLog: * macrocmd.c (print_macro_callback): Add cast(s). * macrotab.c (macro_bcache_str): Likewise. (new_macro_definition): Likewise. * main.c (captured_main): Likewise. * maint.c (print_bfd_section_info): Likewise. * mdebugread.c (mdebug_build_psymtabs): Likewise. (basic_type): Likewise. * memattr.c (mem_region_cmp): Likewise. * memory-map.c (memory_map_start_memory): Likewise. (memory_map_end_memory): Likewise. (memory_map_start_property): Likewise. (memory_map_end_property): Likewise. (clear_result): Likewise. * memrange.c (compare_mem_ranges): Likewise. * mep-tdep.c (mep_analyze_frame_prologue): Likewise. * mi/mi-cmd-var.c (mi_cmd_var_update_iter): Likewise. * mi/mi-console.c (mi_console_file_delete): Likewise. (mi_console_file_fputs): Likewise. (mi_console_raw_packet): Likewise. (mi_console_file_flush): Likewise. (mi_console_set_raw): Likewise. * mi/mi-interp.c (mi_interpreter_resume): Likewise. (mi_new_thread): Likewise. (mi_thread_exit): Likewise. (mi_record_changed): Likewise. (mi_inferior_added): Likewise. (mi_inferior_appeared): Likewise. (mi_inferior_exit): Likewise. (mi_inferior_removed): Likewise. (mi_interp_data): Likewise. (mi_on_normal_stop): Likewise. (mi_traceframe_changed): Likewise. (mi_tsv_created): Likewise. (mi_tsv_deleted): Likewise. (mi_tsv_modified): Likewise. (mi_breakpoint_created): Likewise. (mi_breakpoint_deleted): Likewise. (mi_breakpoint_modified): Likewise. (mi_output_running_pid): Likewise. (mi_inferior_count): Likewise. (mi_solib_loaded): Likewise. (mi_solib_unloaded): Likewise. (mi_command_param_changed): Likewise. (mi_memory_changed): Likewise. (report_initial_inferior): Likewise. (mi_ui_out): Likewise. (mi_set_logging): Likewise. * mi/mi-main.c (collect_cores): Likewise. (print_one_inferior): Likewise. (free_vector_of_ints): Likewise. (free_splay_tree): Likewise. (mi_execute_command): Likewise. * mi/mi-out.c (mi_table_body): Likewise. (mi_table_end): Likewise. (mi_table_header): Likewise. (mi_begin): Likewise. (mi_end): Likewise. (mi_field_int): Likewise. (mi_field_string): Likewise. (mi_field_fmt): Likewise. (mi_flush): Likewise. (mi_redirect): Likewise. (field_separator): Likewise. (mi_open): Likewise. (mi_close): Likewise. (mi_out_buffered): Likewise. (mi_out_rewind): Likewise. (mi_out_put): Likewise. (mi_version): Likewise. (mi_out_data_dtor): Likewise. * mi/mi-parse.c (mi_parse_cleanup): Likewise. * microblaze-tdep.c (microblaze_frame_cache): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. (lzma_close): Likewise. (lzma_stat): Likewise. * mips-linux-tdep.c (mips_linux_init_abi): Likewise. * mips-sde-tdep.c (mips_sde_frame_cache): Likewise. (mips_sde_elf_osabi_sniff_abi_tag_sections): Likewise. * mips-tdep.c (mips_insn16_frame_cache): Likewise. (mips_micro_frame_cache): Likewise. (mips_insn32_frame_cache): Likewise. (mips_stub_frame_cache): Likewise. (gdb_print_insn_mips): Likewise. (value_of_mips_user_reg): Likewise. (mips_gdbarch_init): Likewise. * mips64obsd-tdep.c (mips64obsd_supply_gregset): Likewise. * mipsnbsd-tdep.c (mipsnbsd_supply_fpregset): Likewise. (mipsnbsd_supply_gregset): Likewise. * mn10300-linux-tdep.c (am33_supply_fpregset_method): Likewise. (am33_collect_gregset_method): Likewise. (am33_collect_fpregset_method): Likewise. * mn10300-tdep.c (mn10300_analyze_frame_prologue): Likewise. * moxie-tdep.c (moxie_frame_cache): Likewise. * msp430-tdep.c (msp430_get_opcode_byte): Likewise. (msp430_analyze_frame_prologue): Likewise. * mt-tdep.c (mt_frame_unwind_cache): Likewise. * nios2-linux-tdep.c (nios2_supply_gregset): Likewise. (nios2_collect_gregset): Likewise. * nios2-tdep.c (nios2_frame_unwind_cache): Likewise. (nios2_stub_frame_cache): Likewise. * objc-lang.c (find_methods): Likewise. * objfiles.c (objfiles_pspace_data_cleanup): Likewise. (get_objfile_pspace_data): Likewise. (get_objfile_bfd_data): Likewise. (objfile_bfd_data_free): Likewise. (add_to_objfile_sections): Likewise. (do_free_objfile_cleanup): Likewise. (resume_section_map_updates_cleanup): Likewise. * opencl-lang.c (builtin_opencl_type): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * osdata.c (osdata_start_osdata): Likewise. (osdata_start_item): Likewise. (osdata_start_column): Likewise. (osdata_end_column): Likewise. (clear_parsing_data): Likewise. (osdata_free_cleanup): Likewise. * parse.c (type_stack_cleanup): Likewise. (exp_uses_objfile_iter): Likewise. * ppc-linux-tdep.c (ppc_linux_supply_gregset): Likewise. (ppc_linux_collect_gregset): Likewise. (ppu2spu_prev_arch): Likewise. (ppu2spu_this_id): Likewise. (ppu2spu_prev_register): Likewise. (ppu2spu_unwind_register): Likewise. (ppu2spu_sniffer): Likewise. (ppu2spu_dealloc_cache): Likewise. (ppc_linux_init_abi): Likewise. * ppcfbsd-tdep.c (ppcfbsd_sigtramp_frame_cache): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * progspace.c (restore_program_space): Likewise. * psymtab.c (find_pc_sect_psymtab): Likewise. (compare_psymbols): Likewise. (psymbol_bcache_full): Likewise. (allocate_psymtab): Likewise. (discard_psymtabs_upto): Likewise. * python/py-block.c (set_block): Likewise. (del_objfile_blocks): Likewise. * python/py-breakpoint.c (build_bp_list): Likewise. * python/py-inferior.c (inferior_to_inferior_object): Likewise. (build_inferior_list): Likewise. (py_free_inferior): Likewise. * python/py-objfile.c (py_free_objfile): Likewise. (objfile_to_objfile_object): Likewise. * python/py-prettyprint.c (py_restore_tstate): Likewise. * python/py-progspace.c (py_free_pspace): Likewise. (pspace_to_pspace_object): Likewise. * python/py-symbol.c (set_symbol): Likewise. (del_objfile_symbols): Likewise. * python/py-symtab.c (set_sal): Likewise. (set_symtab): Likewise. (del_objfile_symtab): Likewise. (del_objfile_sal): Likewise. * python/py-type.c (save_objfile_types): Likewise. (set_type): Likewise. * python/py-unwind.c (pyuw_prev_register): Likewise. (pyuw_on_new_gdbarch): Likewise. * python/py-utils.c (py_decref): Likewise. (py_xdecref): Likewise. (gdb_py_generic_dict): Likewise. * python/py-xmethods.c (gdbpy_free_xmethod_worker_data): Likewise. (gdbpy_clone_xmethod_worker_data): Likewise. (gdbpy_get_xmethod_arg_types): Likewise. (gdbpy_get_xmethod_result_type): Likewise. (gdbpy_invoke_xmethod): Likewise. * python/python.c (gdbpy_apply_type_printers): Likewise. (gdbpy_free_type_printers): Likewise. * record-btrace.c (record_btrace_disable_callback): Likewise. (bfcache_hash): Likewise. (bfcache_eq): Likewise. (btrace_get_frame_function): Likewise. (record_btrace_frame_unwind_stop_reason): Likewise. (record_btrace_frame_this_id): Likewise. (record_btrace_frame_prev_register): Likewise. (record_btrace_frame_dealloc_cache): Likewise. * record-full.c (record_full_message_wrapper): Likewise. (record_full_save_cleanups): Likewise. * regcache.c (regcache_descr): Likewise. (do_regcache_xfree): Likewise. (do_regcache_invalidate): Likewise. (do_cooked_read): Likewise. (regcache_transfer_regset): Likewise. * reggroups.c (reggroup_add): Likewise. (reggroup_next): Likewise. (reggroup_prev): Likewise. * remote-fileio.c (do_remote_fileio_request): Likewise. * remote-notif.c (remote_async_get_pending_events_handler): Likewise. (do_notif_event_xfree): Likewise. * remote.c (get_remote_arch_state): Likewise. (remote_pspace_data_cleanup): Likewise. (get_remote_exec_file): Likewise. (set_pspace_remote_exec_file): Likewise. (compare_pnums): Likewise. (clear_threads_listing_context): Likewise. (remote_newthread_step): Likewise. (start_thread): Likewise. (end_thread): Likewise. (remove_child_of_pending_fork): Likewise. (remove_stop_reply_for_inferior): Likewise. (remove_stop_reply_of_remote_state): Likewise. (remote_notif_remove_once_on_match): Likewise. (stop_reply_match_ptid_and_ws): Likewise. (kill_child_of_pending_fork): Likewise. (register_remote_g_packet_guess): Likewise. (remote_read_description_p): Likewise. (remote_read_description): Likewise. (free_actions_list_cleanup_wrapper): Likewise. (remote_async_serial_handler): Likewise. * rl78-tdep.c (rl78_get_opcode_byte): Likewise. (rl78_analyze_frame_prologue): Likewise. * rs6000-tdep.c (ppc_supply_gregset): Likewise. (ppc_supply_fpregset): Likewise. (ppc_supply_vsxregset): Likewise. (ppc_supply_vrregset): Likewise. (ppc_collect_gregset): Likewise. (ppc_collect_fpregset): Likewise. (ppc_collect_vsxregset): Likewise. (ppc_collect_vrregset): Likewise. (e500_move_ev_register): Likewise. (do_regcache_raw_write): Likewise. (rs6000_frame_cache): Likewise. (rs6000_epilogue_frame_cache): Likewise. (rs6000_gdbarch_init): Likewise. * rx-tdep.c (rx_get_opcode_byte): Likewise. (rx_analyze_frame_prologue): Likewise. (rx_frame_type): Likewise. (rx_frame_sniffer_common): Likewise. * s390-linux-tdep.c (s390_check_for_saved): Likewise. (s390_frame_unwind_cache): Likewise. (s390_stub_frame_unwind_cache): Likewise. (s390_sigtramp_frame_unwind_cache): Likewise. * score-tdep.c (score_make_prologue_cache): Likewise. * sentinel-frame.c (sentinel_frame_prev_register): Likewise. (sentinel_frame_prev_arch): Likewise. * ser-base.c (fd_event): Likewise. (push_event): Likewise. (ser_base_write): Likewise. * ser-pipe.c (pipe_close): Likewise. * serial.c (serial_write): Likewise. * sh-tdep.c (sh_frame_cache): Likewise. (sh_stub_this_id): Likewise. * sh64-tdep.c (sh64_frame_cache): Likewise. * solib-aix.c (get_solib_aix_inferior_data): Likewise. (library_list_start_library): Likewise. (library_list_start_list): Likewise. (solib_aix_free_library_list): Likewise. * solib-darwin.c (get_darwin_info): Likewise. * solib-dsbt.c (get_dsbt_info): Likewise. * solib-spu.c (append_ocl_sos): Likewise. * solib-svr4.c (svr4_pspace_data_cleanup): Likewise. (get_svr4_info): Likewise. (library_list_start_library): Likewise. (svr4_library_list_start_list): Likewise. (hash_probe_and_action): Likewise. (equal_probe_and_action): Likewise. (svr4_update_solib_event_breakpoint): Likewise. (set_solib_svr4_fetch_link_map_offsets): Likewise. (svr4_fetch_link_map_offsets): Likewise. (svr4_have_link_map_offsets): Likewise. * solib-target.c (library_list_start_segment): Likewise. (library_list_start_section): Likewise. (library_list_start_library): Likewise. (library_list_end_library): Likewise. (library_list_start_list): Likewise. (solib_target_free_library_list): Likewise. * solib.c (solib_ops): Likewise. (set_solib_ops): Likewise. * sparc-sol2-tdep.c (sparc32_sol2_sigtramp_frame_cache): Likewise. * sparc-tdep.c (sparc_frame_cache): Likewise. (sparc32_frame_cache): Likewise. (sparc32_supply_gregset): Likewise. (sparc32_collect_gregset): Likewise. (sparc32_supply_fpregset): Likewise. (sparc32_collect_fpregset): Likewise. * sparc64-sol2-tdep.c (sparc64_sol2_sigtramp_frame_cache): Likewise. * sparc64-tdep.c (sparc64_supply_gregset): Likewise. (sparc64_collect_gregset): Likewise. (sparc64_supply_fpregset): Likewise. (sparc64_collect_fpregset): Likewise. * sparc64fbsd-tdep.c (sparc64fbsd_sigtramp_frame_cache): Likewise. * sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_frame_cache): Likewise. * sparc64obsd-tdep.c (sparc64obsd_frame_cache): Likewise. (sparc64obsd_trapframe_cache): Likewise. * sparcnbsd-tdep.c (sparc32nbsd_sigcontext_frame_cache): Likewise. * sparcobsd-tdep.c (sparc32obsd_sigtramp_frame_cache): Likewise. * spu-multiarch.c (spu_gdbarch): Likewise. * spu-tdep.c (spu_frame_unwind_cache): Likewise. (spu2ppu_prev_arch): Likewise. (spu2ppu_this_id): Likewise. (spu2ppu_prev_register): Likewise. (spu2ppu_dealloc_cache): Likewise. (spu_dis_asm_print_address): Likewise. (gdb_print_insn_spu): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (rs6000_builtin_type): Likewise. * stack.c (do_print_variable_and_value): Likewise. * stap-probe.c (get_stap_base_address_1): Likewise. * symfile-debug.c (debug_qf_has_symbols): Likewise. (debug_qf_find_last_source_symtab): Likewise. (debug_qf_forget_cached_source_info): Likewise. (debug_qf_map_symtabs_matching_filename): Likewise. (debug_qf_lookup_symbol): Likewise. (debug_qf_print_stats): Likewise. (debug_qf_dump): Likewise. (debug_qf_relocate): Likewise. (debug_qf_expand_symtabs_for_function): Likewise. (debug_qf_expand_all_symtabs): Likewise. (debug_qf_expand_symtabs_with_fullname): Likewise. (debug_qf_map_matching_symbols): Likewise. (debug_qf_expand_symtabs_matching): Likewise. (debug_qf_find_pc_sect_compunit_symtab): Likewise. (debug_qf_map_symbol_filenames): Likewise. (debug_sym_get_probes): Likewise. (debug_sym_new_init): Likewise. (debug_sym_init): Likewise. (debug_sym_read): Likewise. (debug_sym_read_psymbols): Likewise. (debug_sym_finish): Likewise. (debug_sym_offsets): Likewise. (debug_sym_read_linetable): Likewise. (debug_sym_relocate): Likewise. (uninstall_symfile_debug_logging): Likewise. * symfile-mem.c (symbol_file_add_from_memory_wrapper): Likewise. * symfile.c (place_section): Likewise. (add_section_size_callback): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (clear_memory_write_data): Likewise. (allocate_symtab): Likewise. * symmisc.c (maintenance_expand_file_matcher): Likewise. * symtab.c (lookup_symtab_callback): Likewise. (hash_demangled_name_entry): Likewise. (eq_demangled_name_entry): Likewise. (get_symbol_cache): Likewise. (symbol_cache_cleanup): Likewise. (set_symbol_cache_size): Likewise. (symbol_cache_flush): Likewise. (maintenance_print_symbol_cache): Likewise. (maintenance_print_symbol_cache_statistics): Likewise. (delete_filename_seen_cache): Likewise. (output_partial_symbol_filename): Likewise. (search_symbols_file_matches): Likewise. (search_symbols_name_matches): Likewise. (do_free_completion_list): Likewise. (maybe_add_partial_symtab_filename): Likewise. (get_main_info): Likewise. (main_info_cleanup): Likewise. * target-dcache.c (target_dcache_cleanup): Likewise. (target_dcache_init_p): Likewise. (target_dcache_invalidate): Likewise. (target_dcache_get): Likewise. (target_dcache_get_or_init): Likewise. * target-descriptions.c (target_find_description): Likewise. (tdesc_find_type): Likewise. (tdesc_data_cleanup): Likewise. (tdesc_find_arch_register): Likewise. (tdesc_register_name): Likewise. (tdesc_register_type): Likewise. (tdesc_register_reggroup_p): Likewise. (set_tdesc_pseudo_register_name): Likewise. (set_tdesc_pseudo_register_type): Likewise. (set_tdesc_pseudo_register_reggroup_p): Likewise. (tdesc_use_registers): Likewise. (free_target_description): Likewise. * target-memory.c (compare_block_starting_address): Likewise. (cleanup_request_data): Likewise. (cleanup_write_requests_vector): Likewise. * target.c (open_target): Likewise. (cleanup_restore_target_terminal): Likewise. (free_memory_read_result_vector): Likewise. * thread.c (disable_thread_stack_temporaries): Likewise. (finish_thread_state_cleanup): Likewise. (do_restore_current_thread_cleanup): Likewise. (restore_current_thread_cleanup_dtor): Likewise. (set_thread_refcount): Likewise. (tp_array_compar): Likewise. (do_captured_thread_select): Likewise. * tic6x-tdep.c (tic6x_frame_unwind_cache): Likewise. (tic6x_stub_this_id): Likewise. * tilegx-tdep.c (tilegx_frame_cache): Likewise. * top.c (do_restore_instream_cleanup): Likewise. (gdb_readline_wrapper_cleanup): Likewise. (kill_or_detach): Likewise. (print_inferior_quit_action): Likewise. * tracefile-tfile.c (match_blocktype): Likewise. (build_traceframe_info): Likewise. * tracefile.c (trace_file_writer_xfree): Likewise. * tracepoint.c (memrange_cmp): Likewise. (do_collect_symbol): Likewise. (do_clear_collection_list): Likewise. (do_restore_current_traceframe_cleanup): Likewise. (restore_current_traceframe_cleanup_dtor): Likewise. (free_current_marker): Likewise. (traceframe_info_start_memory): Likewise. (traceframe_info_start_tvar): Likewise. (free_result): Likewise. * tramp-frame.c (tramp_frame_cache): Likewise. * tui/tui-file.c (tui_file_delete): Likewise. (tui_fileopen): Likewise. (tui_sfileopen): Likewise. (tui_file_isatty): Likewise. (tui_file_rewind): Likewise. (tui_file_put): Likewise. (tui_file_fputs): Likewise. (tui_file_get_strbuf): Likewise. (tui_file_adjust_strbuf): Likewise. (tui_file_flush): Likewise. * tui/tui-layout.c (make_command_window): Likewise. (make_data_window): Likewise. (show_source_disasm_command): Likewise. (show_data): Likewise. (make_source_or_disasm_window): Likewise. (show_source_or_disasm_and_command): Likewise. * tui/tui-out.c (tui_field_int): Likewise. (tui_field_string): Likewise. (tui_field_fmt): Likewise. (tui_text): Likewise. * typeprint.c (hash_typedef_field): Likewise. (eq_typedef_field): Likewise. (do_free_typedef_hash): Likewise. (copy_typedef_hash_element): Likewise. (do_free_global_table): Likewise. (find_global_typedef): Likewise. (find_typedef_in_hash): Likewise. * ui-file.c (ui_file_write_for_put): Likewise. (do_ui_file_xstrdup): Likewise. (mem_file_delete): Likewise. (mem_file_rewind): Likewise. (mem_file_put): Likewise. (mem_file_write): Likewise. (stdio_file_delete): Likewise. (stdio_file_flush): Likewise. (stdio_file_read): Likewise. (stdio_file_write): Likewise. (stdio_file_write_async_safe): Likewise. (stdio_file_fputs): Likewise. (stdio_file_isatty): Likewise. (stdio_file_fseek): Likewise. (tee_file_delete): Likewise. (tee_file_flush): Likewise. (tee_file_write): Likewise. (tee_file_fputs): Likewise. (tee_file_isatty): Likewise. * ui-out.c (do_cleanup_table_end): Likewise. (do_cleanup_end): Likewise. * user-regs.c (user_reg_add): Likewise. (user_reg_map_name_to_regnum): Likewise. (usernum_to_user_reg): Likewise. (maintenance_print_user_registers): Likewise. * utils.c (do_bfd_close_cleanup): Likewise. (do_fclose_cleanup): Likewise. (do_obstack_free): Likewise. (do_ui_file_delete): Likewise. (do_ui_out_redirect_pop): Likewise. (do_free_section_addr_info): Likewise. (restore_integer): Likewise. (do_unpush_target): Likewise. (do_htab_delete_cleanup): Likewise. (do_restore_ui_file): Likewise. (do_value_free): Likewise. (do_free_so): Likewise. (free_current_contents): Likewise. (do_regfree_cleanup): Likewise. (core_addr_hash): Likewise. (core_addr_eq): Likewise. (do_free_char_ptr_vec): Likewise. * v850-tdep.c (v850_frame_cache): Likewise. * varobj.c (do_free_variable_cleanup): Likewise. * vax-tdep.c (vax_supply_gregset): Likewise. (vax_frame_cache): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_frame_cache): Likewise. * xml-support.c (gdb_xml_body_text): Likewise. (gdb_xml_values_cleanup): Likewise. (gdb_xml_start_element): Likewise. (gdb_xml_start_element_wrapper): Likewise. (gdb_xml_end_element): Likewise. (gdb_xml_end_element_wrapper): Likewise. (gdb_xml_cleanup): Likewise. (gdb_xml_fetch_external_entity): Likewise. (gdb_xml_parse_attr_enum): Likewise. (xinclude_start_include): Likewise. (xinclude_end_include): Likewise. (xml_xinclude_default): Likewise. (xml_xinclude_start_doctype): Likewise. (xml_xinclude_end_doctype): Likewise. (xml_xinclude_cleanup): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (free_syscalls_info): Likewise. (syscall_start_syscall): Likewise. * xml-tdesc.c (tdesc_end_arch): Likewise. (tdesc_end_osabi): Likewise. (tdesc_end_compatible): Likewise. (tdesc_start_target): Likewise. (tdesc_start_feature): Likewise. (tdesc_start_reg): Likewise. (tdesc_start_union): Likewise. (tdesc_start_struct): Likewise. (tdesc_start_flags): Likewise. (tdesc_start_field): Likewise. (tdesc_start_vector): Likewise. (fetch_available_features_from_target): Likewise. * xstormy16-tdep.c (xstormy16_frame_cache): Likewise. * xtensa-tdep.c (xtensa_supply_gregset): Likewise. (xtensa_frame_cache): Likewise. (xtensa_frame_prev_register): Likewise. (xtensa_extract_return_value): Likewise.
2015-09-25 20:08:07 +02:00
const struct target_so_ops **ops
= (const struct target_so_ops **) gdbarch_data (gdbarch, solib_data);
return *ops;
}
/* Set the solib operations for GDBARCH to NEW_OPS. */
void
set_solib_ops (struct gdbarch *gdbarch, const struct target_so_ops *new_ops)
{
Add some more casts (2/2) See previous patch's description. gdb/ChangeLog: * macrocmd.c (print_macro_callback): Add cast(s). * macrotab.c (macro_bcache_str): Likewise. (new_macro_definition): Likewise. * main.c (captured_main): Likewise. * maint.c (print_bfd_section_info): Likewise. * mdebugread.c (mdebug_build_psymtabs): Likewise. (basic_type): Likewise. * memattr.c (mem_region_cmp): Likewise. * memory-map.c (memory_map_start_memory): Likewise. (memory_map_end_memory): Likewise. (memory_map_start_property): Likewise. (memory_map_end_property): Likewise. (clear_result): Likewise. * memrange.c (compare_mem_ranges): Likewise. * mep-tdep.c (mep_analyze_frame_prologue): Likewise. * mi/mi-cmd-var.c (mi_cmd_var_update_iter): Likewise. * mi/mi-console.c (mi_console_file_delete): Likewise. (mi_console_file_fputs): Likewise. (mi_console_raw_packet): Likewise. (mi_console_file_flush): Likewise. (mi_console_set_raw): Likewise. * mi/mi-interp.c (mi_interpreter_resume): Likewise. (mi_new_thread): Likewise. (mi_thread_exit): Likewise. (mi_record_changed): Likewise. (mi_inferior_added): Likewise. (mi_inferior_appeared): Likewise. (mi_inferior_exit): Likewise. (mi_inferior_removed): Likewise. (mi_interp_data): Likewise. (mi_on_normal_stop): Likewise. (mi_traceframe_changed): Likewise. (mi_tsv_created): Likewise. (mi_tsv_deleted): Likewise. (mi_tsv_modified): Likewise. (mi_breakpoint_created): Likewise. (mi_breakpoint_deleted): Likewise. (mi_breakpoint_modified): Likewise. (mi_output_running_pid): Likewise. (mi_inferior_count): Likewise. (mi_solib_loaded): Likewise. (mi_solib_unloaded): Likewise. (mi_command_param_changed): Likewise. (mi_memory_changed): Likewise. (report_initial_inferior): Likewise. (mi_ui_out): Likewise. (mi_set_logging): Likewise. * mi/mi-main.c (collect_cores): Likewise. (print_one_inferior): Likewise. (free_vector_of_ints): Likewise. (free_splay_tree): Likewise. (mi_execute_command): Likewise. * mi/mi-out.c (mi_table_body): Likewise. (mi_table_end): Likewise. (mi_table_header): Likewise. (mi_begin): Likewise. (mi_end): Likewise. (mi_field_int): Likewise. (mi_field_string): Likewise. (mi_field_fmt): Likewise. (mi_flush): Likewise. (mi_redirect): Likewise. (field_separator): Likewise. (mi_open): Likewise. (mi_close): Likewise. (mi_out_buffered): Likewise. (mi_out_rewind): Likewise. (mi_out_put): Likewise. (mi_version): Likewise. (mi_out_data_dtor): Likewise. * mi/mi-parse.c (mi_parse_cleanup): Likewise. * microblaze-tdep.c (microblaze_frame_cache): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. (lzma_close): Likewise. (lzma_stat): Likewise. * mips-linux-tdep.c (mips_linux_init_abi): Likewise. * mips-sde-tdep.c (mips_sde_frame_cache): Likewise. (mips_sde_elf_osabi_sniff_abi_tag_sections): Likewise. * mips-tdep.c (mips_insn16_frame_cache): Likewise. (mips_micro_frame_cache): Likewise. (mips_insn32_frame_cache): Likewise. (mips_stub_frame_cache): Likewise. (gdb_print_insn_mips): Likewise. (value_of_mips_user_reg): Likewise. (mips_gdbarch_init): Likewise. * mips64obsd-tdep.c (mips64obsd_supply_gregset): Likewise. * mipsnbsd-tdep.c (mipsnbsd_supply_fpregset): Likewise. (mipsnbsd_supply_gregset): Likewise. * mn10300-linux-tdep.c (am33_supply_fpregset_method): Likewise. (am33_collect_gregset_method): Likewise. (am33_collect_fpregset_method): Likewise. * mn10300-tdep.c (mn10300_analyze_frame_prologue): Likewise. * moxie-tdep.c (moxie_frame_cache): Likewise. * msp430-tdep.c (msp430_get_opcode_byte): Likewise. (msp430_analyze_frame_prologue): Likewise. * mt-tdep.c (mt_frame_unwind_cache): Likewise. * nios2-linux-tdep.c (nios2_supply_gregset): Likewise. (nios2_collect_gregset): Likewise. * nios2-tdep.c (nios2_frame_unwind_cache): Likewise. (nios2_stub_frame_cache): Likewise. * objc-lang.c (find_methods): Likewise. * objfiles.c (objfiles_pspace_data_cleanup): Likewise. (get_objfile_pspace_data): Likewise. (get_objfile_bfd_data): Likewise. (objfile_bfd_data_free): Likewise. (add_to_objfile_sections): Likewise. (do_free_objfile_cleanup): Likewise. (resume_section_map_updates_cleanup): Likewise. * opencl-lang.c (builtin_opencl_type): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * osdata.c (osdata_start_osdata): Likewise. (osdata_start_item): Likewise. (osdata_start_column): Likewise. (osdata_end_column): Likewise. (clear_parsing_data): Likewise. (osdata_free_cleanup): Likewise. * parse.c (type_stack_cleanup): Likewise. (exp_uses_objfile_iter): Likewise. * ppc-linux-tdep.c (ppc_linux_supply_gregset): Likewise. (ppc_linux_collect_gregset): Likewise. (ppu2spu_prev_arch): Likewise. (ppu2spu_this_id): Likewise. (ppu2spu_prev_register): Likewise. (ppu2spu_unwind_register): Likewise. (ppu2spu_sniffer): Likewise. (ppu2spu_dealloc_cache): Likewise. (ppc_linux_init_abi): Likewise. * ppcfbsd-tdep.c (ppcfbsd_sigtramp_frame_cache): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * progspace.c (restore_program_space): Likewise. * psymtab.c (find_pc_sect_psymtab): Likewise. (compare_psymbols): Likewise. (psymbol_bcache_full): Likewise. (allocate_psymtab): Likewise. (discard_psymtabs_upto): Likewise. * python/py-block.c (set_block): Likewise. (del_objfile_blocks): Likewise. * python/py-breakpoint.c (build_bp_list): Likewise. * python/py-inferior.c (inferior_to_inferior_object): Likewise. (build_inferior_list): Likewise. (py_free_inferior): Likewise. * python/py-objfile.c (py_free_objfile): Likewise. (objfile_to_objfile_object): Likewise. * python/py-prettyprint.c (py_restore_tstate): Likewise. * python/py-progspace.c (py_free_pspace): Likewise. (pspace_to_pspace_object): Likewise. * python/py-symbol.c (set_symbol): Likewise. (del_objfile_symbols): Likewise. * python/py-symtab.c (set_sal): Likewise. (set_symtab): Likewise. (del_objfile_symtab): Likewise. (del_objfile_sal): Likewise. * python/py-type.c (save_objfile_types): Likewise. (set_type): Likewise. * python/py-unwind.c (pyuw_prev_register): Likewise. (pyuw_on_new_gdbarch): Likewise. * python/py-utils.c (py_decref): Likewise. (py_xdecref): Likewise. (gdb_py_generic_dict): Likewise. * python/py-xmethods.c (gdbpy_free_xmethod_worker_data): Likewise. (gdbpy_clone_xmethod_worker_data): Likewise. (gdbpy_get_xmethod_arg_types): Likewise. (gdbpy_get_xmethod_result_type): Likewise. (gdbpy_invoke_xmethod): Likewise. * python/python.c (gdbpy_apply_type_printers): Likewise. (gdbpy_free_type_printers): Likewise. * record-btrace.c (record_btrace_disable_callback): Likewise. (bfcache_hash): Likewise. (bfcache_eq): Likewise. (btrace_get_frame_function): Likewise. (record_btrace_frame_unwind_stop_reason): Likewise. (record_btrace_frame_this_id): Likewise. (record_btrace_frame_prev_register): Likewise. (record_btrace_frame_dealloc_cache): Likewise. * record-full.c (record_full_message_wrapper): Likewise. (record_full_save_cleanups): Likewise. * regcache.c (regcache_descr): Likewise. (do_regcache_xfree): Likewise. (do_regcache_invalidate): Likewise. (do_cooked_read): Likewise. (regcache_transfer_regset): Likewise. * reggroups.c (reggroup_add): Likewise. (reggroup_next): Likewise. (reggroup_prev): Likewise. * remote-fileio.c (do_remote_fileio_request): Likewise. * remote-notif.c (remote_async_get_pending_events_handler): Likewise. (do_notif_event_xfree): Likewise. * remote.c (get_remote_arch_state): Likewise. (remote_pspace_data_cleanup): Likewise. (get_remote_exec_file): Likewise. (set_pspace_remote_exec_file): Likewise. (compare_pnums): Likewise. (clear_threads_listing_context): Likewise. (remote_newthread_step): Likewise. (start_thread): Likewise. (end_thread): Likewise. (remove_child_of_pending_fork): Likewise. (remove_stop_reply_for_inferior): Likewise. (remove_stop_reply_of_remote_state): Likewise. (remote_notif_remove_once_on_match): Likewise. (stop_reply_match_ptid_and_ws): Likewise. (kill_child_of_pending_fork): Likewise. (register_remote_g_packet_guess): Likewise. (remote_read_description_p): Likewise. (remote_read_description): Likewise. (free_actions_list_cleanup_wrapper): Likewise. (remote_async_serial_handler): Likewise. * rl78-tdep.c (rl78_get_opcode_byte): Likewise. (rl78_analyze_frame_prologue): Likewise. * rs6000-tdep.c (ppc_supply_gregset): Likewise. (ppc_supply_fpregset): Likewise. (ppc_supply_vsxregset): Likewise. (ppc_supply_vrregset): Likewise. (ppc_collect_gregset): Likewise. (ppc_collect_fpregset): Likewise. (ppc_collect_vsxregset): Likewise. (ppc_collect_vrregset): Likewise. (e500_move_ev_register): Likewise. (do_regcache_raw_write): Likewise. (rs6000_frame_cache): Likewise. (rs6000_epilogue_frame_cache): Likewise. (rs6000_gdbarch_init): Likewise. * rx-tdep.c (rx_get_opcode_byte): Likewise. (rx_analyze_frame_prologue): Likewise. (rx_frame_type): Likewise. (rx_frame_sniffer_common): Likewise. * s390-linux-tdep.c (s390_check_for_saved): Likewise. (s390_frame_unwind_cache): Likewise. (s390_stub_frame_unwind_cache): Likewise. (s390_sigtramp_frame_unwind_cache): Likewise. * score-tdep.c (score_make_prologue_cache): Likewise. * sentinel-frame.c (sentinel_frame_prev_register): Likewise. (sentinel_frame_prev_arch): Likewise. * ser-base.c (fd_event): Likewise. (push_event): Likewise. (ser_base_write): Likewise. * ser-pipe.c (pipe_close): Likewise. * serial.c (serial_write): Likewise. * sh-tdep.c (sh_frame_cache): Likewise. (sh_stub_this_id): Likewise. * sh64-tdep.c (sh64_frame_cache): Likewise. * solib-aix.c (get_solib_aix_inferior_data): Likewise. (library_list_start_library): Likewise. (library_list_start_list): Likewise. (solib_aix_free_library_list): Likewise. * solib-darwin.c (get_darwin_info): Likewise. * solib-dsbt.c (get_dsbt_info): Likewise. * solib-spu.c (append_ocl_sos): Likewise. * solib-svr4.c (svr4_pspace_data_cleanup): Likewise. (get_svr4_info): Likewise. (library_list_start_library): Likewise. (svr4_library_list_start_list): Likewise. (hash_probe_and_action): Likewise. (equal_probe_and_action): Likewise. (svr4_update_solib_event_breakpoint): Likewise. (set_solib_svr4_fetch_link_map_offsets): Likewise. (svr4_fetch_link_map_offsets): Likewise. (svr4_have_link_map_offsets): Likewise. * solib-target.c (library_list_start_segment): Likewise. (library_list_start_section): Likewise. (library_list_start_library): Likewise. (library_list_end_library): Likewise. (library_list_start_list): Likewise. (solib_target_free_library_list): Likewise. * solib.c (solib_ops): Likewise. (set_solib_ops): Likewise. * sparc-sol2-tdep.c (sparc32_sol2_sigtramp_frame_cache): Likewise. * sparc-tdep.c (sparc_frame_cache): Likewise. (sparc32_frame_cache): Likewise. (sparc32_supply_gregset): Likewise. (sparc32_collect_gregset): Likewise. (sparc32_supply_fpregset): Likewise. (sparc32_collect_fpregset): Likewise. * sparc64-sol2-tdep.c (sparc64_sol2_sigtramp_frame_cache): Likewise. * sparc64-tdep.c (sparc64_supply_gregset): Likewise. (sparc64_collect_gregset): Likewise. (sparc64_supply_fpregset): Likewise. (sparc64_collect_fpregset): Likewise. * sparc64fbsd-tdep.c (sparc64fbsd_sigtramp_frame_cache): Likewise. * sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_frame_cache): Likewise. * sparc64obsd-tdep.c (sparc64obsd_frame_cache): Likewise. (sparc64obsd_trapframe_cache): Likewise. * sparcnbsd-tdep.c (sparc32nbsd_sigcontext_frame_cache): Likewise. * sparcobsd-tdep.c (sparc32obsd_sigtramp_frame_cache): Likewise. * spu-multiarch.c (spu_gdbarch): Likewise. * spu-tdep.c (spu_frame_unwind_cache): Likewise. (spu2ppu_prev_arch): Likewise. (spu2ppu_this_id): Likewise. (spu2ppu_prev_register): Likewise. (spu2ppu_dealloc_cache): Likewise. (spu_dis_asm_print_address): Likewise. (gdb_print_insn_spu): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (rs6000_builtin_type): Likewise. * stack.c (do_print_variable_and_value): Likewise. * stap-probe.c (get_stap_base_address_1): Likewise. * symfile-debug.c (debug_qf_has_symbols): Likewise. (debug_qf_find_last_source_symtab): Likewise. (debug_qf_forget_cached_source_info): Likewise. (debug_qf_map_symtabs_matching_filename): Likewise. (debug_qf_lookup_symbol): Likewise. (debug_qf_print_stats): Likewise. (debug_qf_dump): Likewise. (debug_qf_relocate): Likewise. (debug_qf_expand_symtabs_for_function): Likewise. (debug_qf_expand_all_symtabs): Likewise. (debug_qf_expand_symtabs_with_fullname): Likewise. (debug_qf_map_matching_symbols): Likewise. (debug_qf_expand_symtabs_matching): Likewise. (debug_qf_find_pc_sect_compunit_symtab): Likewise. (debug_qf_map_symbol_filenames): Likewise. (debug_sym_get_probes): Likewise. (debug_sym_new_init): Likewise. (debug_sym_init): Likewise. (debug_sym_read): Likewise. (debug_sym_read_psymbols): Likewise. (debug_sym_finish): Likewise. (debug_sym_offsets): Likewise. (debug_sym_read_linetable): Likewise. (debug_sym_relocate): Likewise. (uninstall_symfile_debug_logging): Likewise. * symfile-mem.c (symbol_file_add_from_memory_wrapper): Likewise. * symfile.c (place_section): Likewise. (add_section_size_callback): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (clear_memory_write_data): Likewise. (allocate_symtab): Likewise. * symmisc.c (maintenance_expand_file_matcher): Likewise. * symtab.c (lookup_symtab_callback): Likewise. (hash_demangled_name_entry): Likewise. (eq_demangled_name_entry): Likewise. (get_symbol_cache): Likewise. (symbol_cache_cleanup): Likewise. (set_symbol_cache_size): Likewise. (symbol_cache_flush): Likewise. (maintenance_print_symbol_cache): Likewise. (maintenance_print_symbol_cache_statistics): Likewise. (delete_filename_seen_cache): Likewise. (output_partial_symbol_filename): Likewise. (search_symbols_file_matches): Likewise. (search_symbols_name_matches): Likewise. (do_free_completion_list): Likewise. (maybe_add_partial_symtab_filename): Likewise. (get_main_info): Likewise. (main_info_cleanup): Likewise. * target-dcache.c (target_dcache_cleanup): Likewise. (target_dcache_init_p): Likewise. (target_dcache_invalidate): Likewise. (target_dcache_get): Likewise. (target_dcache_get_or_init): Likewise. * target-descriptions.c (target_find_description): Likewise. (tdesc_find_type): Likewise. (tdesc_data_cleanup): Likewise. (tdesc_find_arch_register): Likewise. (tdesc_register_name): Likewise. (tdesc_register_type): Likewise. (tdesc_register_reggroup_p): Likewise. (set_tdesc_pseudo_register_name): Likewise. (set_tdesc_pseudo_register_type): Likewise. (set_tdesc_pseudo_register_reggroup_p): Likewise. (tdesc_use_registers): Likewise. (free_target_description): Likewise. * target-memory.c (compare_block_starting_address): Likewise. (cleanup_request_data): Likewise. (cleanup_write_requests_vector): Likewise. * target.c (open_target): Likewise. (cleanup_restore_target_terminal): Likewise. (free_memory_read_result_vector): Likewise. * thread.c (disable_thread_stack_temporaries): Likewise. (finish_thread_state_cleanup): Likewise. (do_restore_current_thread_cleanup): Likewise. (restore_current_thread_cleanup_dtor): Likewise. (set_thread_refcount): Likewise. (tp_array_compar): Likewise. (do_captured_thread_select): Likewise. * tic6x-tdep.c (tic6x_frame_unwind_cache): Likewise. (tic6x_stub_this_id): Likewise. * tilegx-tdep.c (tilegx_frame_cache): Likewise. * top.c (do_restore_instream_cleanup): Likewise. (gdb_readline_wrapper_cleanup): Likewise. (kill_or_detach): Likewise. (print_inferior_quit_action): Likewise. * tracefile-tfile.c (match_blocktype): Likewise. (build_traceframe_info): Likewise. * tracefile.c (trace_file_writer_xfree): Likewise. * tracepoint.c (memrange_cmp): Likewise. (do_collect_symbol): Likewise. (do_clear_collection_list): Likewise. (do_restore_current_traceframe_cleanup): Likewise. (restore_current_traceframe_cleanup_dtor): Likewise. (free_current_marker): Likewise. (traceframe_info_start_memory): Likewise. (traceframe_info_start_tvar): Likewise. (free_result): Likewise. * tramp-frame.c (tramp_frame_cache): Likewise. * tui/tui-file.c (tui_file_delete): Likewise. (tui_fileopen): Likewise. (tui_sfileopen): Likewise. (tui_file_isatty): Likewise. (tui_file_rewind): Likewise. (tui_file_put): Likewise. (tui_file_fputs): Likewise. (tui_file_get_strbuf): Likewise. (tui_file_adjust_strbuf): Likewise. (tui_file_flush): Likewise. * tui/tui-layout.c (make_command_window): Likewise. (make_data_window): Likewise. (show_source_disasm_command): Likewise. (show_data): Likewise. (make_source_or_disasm_window): Likewise. (show_source_or_disasm_and_command): Likewise. * tui/tui-out.c (tui_field_int): Likewise. (tui_field_string): Likewise. (tui_field_fmt): Likewise. (tui_text): Likewise. * typeprint.c (hash_typedef_field): Likewise. (eq_typedef_field): Likewise. (do_free_typedef_hash): Likewise. (copy_typedef_hash_element): Likewise. (do_free_global_table): Likewise. (find_global_typedef): Likewise. (find_typedef_in_hash): Likewise. * ui-file.c (ui_file_write_for_put): Likewise. (do_ui_file_xstrdup): Likewise. (mem_file_delete): Likewise. (mem_file_rewind): Likewise. (mem_file_put): Likewise. (mem_file_write): Likewise. (stdio_file_delete): Likewise. (stdio_file_flush): Likewise. (stdio_file_read): Likewise. (stdio_file_write): Likewise. (stdio_file_write_async_safe): Likewise. (stdio_file_fputs): Likewise. (stdio_file_isatty): Likewise. (stdio_file_fseek): Likewise. (tee_file_delete): Likewise. (tee_file_flush): Likewise. (tee_file_write): Likewise. (tee_file_fputs): Likewise. (tee_file_isatty): Likewise. * ui-out.c (do_cleanup_table_end): Likewise. (do_cleanup_end): Likewise. * user-regs.c (user_reg_add): Likewise. (user_reg_map_name_to_regnum): Likewise. (usernum_to_user_reg): Likewise. (maintenance_print_user_registers): Likewise. * utils.c (do_bfd_close_cleanup): Likewise. (do_fclose_cleanup): Likewise. (do_obstack_free): Likewise. (do_ui_file_delete): Likewise. (do_ui_out_redirect_pop): Likewise. (do_free_section_addr_info): Likewise. (restore_integer): Likewise. (do_unpush_target): Likewise. (do_htab_delete_cleanup): Likewise. (do_restore_ui_file): Likewise. (do_value_free): Likewise. (do_free_so): Likewise. (free_current_contents): Likewise. (do_regfree_cleanup): Likewise. (core_addr_hash): Likewise. (core_addr_eq): Likewise. (do_free_char_ptr_vec): Likewise. * v850-tdep.c (v850_frame_cache): Likewise. * varobj.c (do_free_variable_cleanup): Likewise. * vax-tdep.c (vax_supply_gregset): Likewise. (vax_frame_cache): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_frame_cache): Likewise. * xml-support.c (gdb_xml_body_text): Likewise. (gdb_xml_values_cleanup): Likewise. (gdb_xml_start_element): Likewise. (gdb_xml_start_element_wrapper): Likewise. (gdb_xml_end_element): Likewise. (gdb_xml_end_element_wrapper): Likewise. (gdb_xml_cleanup): Likewise. (gdb_xml_fetch_external_entity): Likewise. (gdb_xml_parse_attr_enum): Likewise. (xinclude_start_include): Likewise. (xinclude_end_include): Likewise. (xml_xinclude_default): Likewise. (xml_xinclude_start_doctype): Likewise. (xml_xinclude_end_doctype): Likewise. (xml_xinclude_cleanup): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (free_syscalls_info): Likewise. (syscall_start_syscall): Likewise. * xml-tdesc.c (tdesc_end_arch): Likewise. (tdesc_end_osabi): Likewise. (tdesc_end_compatible): Likewise. (tdesc_start_target): Likewise. (tdesc_start_feature): Likewise. (tdesc_start_reg): Likewise. (tdesc_start_union): Likewise. (tdesc_start_struct): Likewise. (tdesc_start_flags): Likewise. (tdesc_start_field): Likewise. (tdesc_start_vector): Likewise. (fetch_available_features_from_target): Likewise. * xstormy16-tdep.c (xstormy16_frame_cache): Likewise. * xtensa-tdep.c (xtensa_supply_gregset): Likewise. (xtensa_frame_cache): Likewise. (xtensa_frame_prev_register): Likewise. (xtensa_extract_return_value): Likewise.
2015-09-25 20:08:07 +02:00
const struct target_so_ops **ops
= (const struct target_so_ops **) gdbarch_data (gdbarch, solib_data);
*ops = new_ops;
}
2000-10-24 22:05:36 +02:00
/* external data declarations */
/* FIXME: gdbarch needs to control this variable, or else every
configuration needs to call set_solib_ops. */
2000-10-24 22:05:36 +02:00
struct target_so_ops *current_target_so_ops;
/* Local function prototypes */
/* If non-empty, this is a search path for loading non-absolute shared library
symbol files. This takes precedence over the environment variables PATH
and LD_LIBRARY_PATH. */
static char *solib_search_path = NULL;
2005-02-24 Andrew Cagney <cagney@gnu.org> Add show_VARIABLE functions, update add_setshow call. * varobj.c (_initialize_varobj, show_varobjdebug): Add and update. * valprint.c (_initialize_valprint, show_print_max) (show_stop_print_at_null, show_repeat_count_threshold) (show_prettyprint_structs, show_unionprint) (show_prettyprint_arrays, show_addressprint, show_input_radix) (show_output_radix): Ditto. * valops.c (_initialize_valops, show_overload_resolution): Ditto. * utils.c (initialize_utils, show_chars_per_line) (show_lines_per_page, show_demangle, show_pagination_enabled) (show_sevenbit_strings, show_asm_demangle): Ditto * tui/tui-win.c (_initialize_tui_win, show_tui_border_kind) (show_tui_border_mode, show_tui_active_border_mode): Ditto. * top.c (init_main, show_new_async_prompt) (show_async_command_editing_p, show_write_history_p) (show_history_size, show_history_filename, show_caution) (show_annotation_level, init_main): Ditto. * target.c (initialize_targets, show_targetdebug) (show_trust_readonly): Ditto. * symfile.c (_initialize_symfile, show_symbol_reloading) (show_ext_args, show_download_write_size) (show_debug_file_directory): Ditto. * source.c (_initialize_source, show_lines_to_list): Ditto. * solib.c (_initialize_solib, show_auto_solib_add) (show_solib_search_path): Ditto. * p-valprint.c (_initialize_pascal_valprint) (show_pascal_static_field_print): Ditto. * printcmd.c (_initialize_printcmd, show_max_symbolic_offset) (show_print_symbol_filename): Add and update. * parse.c (_initialize_parse, show_expressiondebug): Dito. * observer.c (_initialize_observer, show_observer_debug): Dito. * maint.c (_initialize_maint_cmds, show_watchdog) (show_maintenance_profile_p): Dito. * linux-nat.c (_initialize_linux_nat, show_debug_linux_nat): Dito. * infrun.c (_initialize_infrun, show_debug_infrun) (show_stop_on_solib_events, show_follow_fork_mode_string) (show_scheduler_mode, show_step_stop_if_no_debug): Ditto. * infcall.c (_initialize_infcall, show_coerce_float_to_double_p) (show_unwind_on_signal_p): Ditto. * gdbtypes.c (build_gdbtypes, show_opaque_type_resolution) (_initialize_gdbtypes, show_overload_debug): Ditto. * gdb-events.c, gdb-events.sh (_initialize_gdb_events) (show_gdb_events_debug): Ditto. * gdbarch.c, gdbarch.sh (show_gdbarch_debug) (_initialize_gdbarch): Ditto. * frame.c (_initialize_frame, show_backtrace_past_main) (show_backtrace_past_entry, show_backtrace_limit) (show_frame_debug): Ditto. * exec.c (_initialize_exec, show_write_files): Ditto. * dwarf2read.c (_initialize_dwarf2_read) (show_dwarf2_max_cache_age): Ditto. * demangle.c (_initialize_demangler) (show_demangling_style_names): Ditto. * dcache.c (_initialize_dcache, show_dcache_enabled_p): Ditto. * cp-valprint.c (show_static_field_print) (_initialize_cp_valprint, show_vtblprint, show_objectprint): Ditto. * corefile.c (_initialize_core, show_gnutarget_string): Ditto. * cli/cli-logging.c (_initialize_cli_logging) (show_logging_overwrite, show_logging_redirect) (show_logging_filename): Ditto. * cli/cli-cmds.c (show_info_verbose, show_history_expansion_p) (init_cli_cmds, show_baud_rate, show_remote_debug) (show_remote_timeout, show_max_user_call_depth): Ditto. * charset.c (show_host_charset_name, show_target_charset_name) (initialize_charset): Ditto. * breakpoint.c (show_can_use_hw_watchpoints) (show_pending_break_support, _initialize_breakpoint): Ditto.
2005-02-24 14:51:36 +01:00
static void
show_solib_search_path (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
fprintf_filtered (file, _("The search path for loading non-absolute "
"shared library symbol files is %s.\n"),
2005-02-24 Andrew Cagney <cagney@gnu.org> Add show_VARIABLE functions, update add_setshow call. * varobj.c (_initialize_varobj, show_varobjdebug): Add and update. * valprint.c (_initialize_valprint, show_print_max) (show_stop_print_at_null, show_repeat_count_threshold) (show_prettyprint_structs, show_unionprint) (show_prettyprint_arrays, show_addressprint, show_input_radix) (show_output_radix): Ditto. * valops.c (_initialize_valops, show_overload_resolution): Ditto. * utils.c (initialize_utils, show_chars_per_line) (show_lines_per_page, show_demangle, show_pagination_enabled) (show_sevenbit_strings, show_asm_demangle): Ditto * tui/tui-win.c (_initialize_tui_win, show_tui_border_kind) (show_tui_border_mode, show_tui_active_border_mode): Ditto. * top.c (init_main, show_new_async_prompt) (show_async_command_editing_p, show_write_history_p) (show_history_size, show_history_filename, show_caution) (show_annotation_level, init_main): Ditto. * target.c (initialize_targets, show_targetdebug) (show_trust_readonly): Ditto. * symfile.c (_initialize_symfile, show_symbol_reloading) (show_ext_args, show_download_write_size) (show_debug_file_directory): Ditto. * source.c (_initialize_source, show_lines_to_list): Ditto. * solib.c (_initialize_solib, show_auto_solib_add) (show_solib_search_path): Ditto. * p-valprint.c (_initialize_pascal_valprint) (show_pascal_static_field_print): Ditto. * printcmd.c (_initialize_printcmd, show_max_symbolic_offset) (show_print_symbol_filename): Add and update. * parse.c (_initialize_parse, show_expressiondebug): Dito. * observer.c (_initialize_observer, show_observer_debug): Dito. * maint.c (_initialize_maint_cmds, show_watchdog) (show_maintenance_profile_p): Dito. * linux-nat.c (_initialize_linux_nat, show_debug_linux_nat): Dito. * infrun.c (_initialize_infrun, show_debug_infrun) (show_stop_on_solib_events, show_follow_fork_mode_string) (show_scheduler_mode, show_step_stop_if_no_debug): Ditto. * infcall.c (_initialize_infcall, show_coerce_float_to_double_p) (show_unwind_on_signal_p): Ditto. * gdbtypes.c (build_gdbtypes, show_opaque_type_resolution) (_initialize_gdbtypes, show_overload_debug): Ditto. * gdb-events.c, gdb-events.sh (_initialize_gdb_events) (show_gdb_events_debug): Ditto. * gdbarch.c, gdbarch.sh (show_gdbarch_debug) (_initialize_gdbarch): Ditto. * frame.c (_initialize_frame, show_backtrace_past_main) (show_backtrace_past_entry, show_backtrace_limit) (show_frame_debug): Ditto. * exec.c (_initialize_exec, show_write_files): Ditto. * dwarf2read.c (_initialize_dwarf2_read) (show_dwarf2_max_cache_age): Ditto. * demangle.c (_initialize_demangler) (show_demangling_style_names): Ditto. * dcache.c (_initialize_dcache, show_dcache_enabled_p): Ditto. * cp-valprint.c (show_static_field_print) (_initialize_cp_valprint, show_vtblprint, show_objectprint): Ditto. * corefile.c (_initialize_core, show_gnutarget_string): Ditto. * cli/cli-logging.c (_initialize_cli_logging) (show_logging_overwrite, show_logging_redirect) (show_logging_filename): Ditto. * cli/cli-cmds.c (show_info_verbose, show_history_expansion_p) (init_cli_cmds, show_baud_rate, show_remote_debug) (show_remote_timeout, show_max_user_call_depth): Ditto. * charset.c (show_host_charset_name, show_target_charset_name) (initialize_charset): Ditto. * breakpoint.c (show_can_use_hw_watchpoints) (show_pending_break_support, _initialize_breakpoint): Ditto.
2005-02-24 14:51:36 +01:00
value);
}
/* Same as HAVE_DOS_BASED_FILE_SYSTEM, but useable as an rvalue. */
#if (HAVE_DOS_BASED_FILE_SYSTEM)
# define DOS_BASED_FILE_SYSTEM 1
#else
# define DOS_BASED_FILE_SYSTEM 0
#endif
/* Return the full pathname of a binary file (the main executable or a
shared library file), or NULL if not found. If FD is non-NULL, *FD
is set to either -1 or an open file handle for the binary file.
Global variable GDB_SYSROOT is used as a prefix directory
to search for binary files if they have an absolute path.
If GDB_SYSROOT starts with "target:" and target filesystem
is the local filesystem then the "target:" prefix will be
stripped before the search starts. This ensures that the
same search algorithm is used for local files regardless of
whether a "target:" prefix was used.
Global variable SOLIB_SEARCH_PATH is used as a prefix directory
(or set of directories, as in LD_LIBRARY_PATH) to search for all
shared libraries if not found in either the sysroot (if set) or
the local filesystem. SOLIB_SEARCH_PATH is not used when searching
for the main executable.
Search algorithm:
* If a sysroot is set and path is absolute:
* Search for sysroot/path.
* else
* Look for it literally (unmodified).
* If IS_SOLIB is non-zero:
* Look in SOLIB_SEARCH_PATH.
* If available, use target defined search function.
* If NO sysroot is set, perform the following two searches:
* Look in inferior's $PATH.
* If IS_SOLIB is non-zero:
* Look in inferior's $LD_LIBRARY_PATH.
*
[gdb] Fix more typos in comments Fix typos in comments. NFC. Tested on x86_64-linux. gdb/ChangeLog: 2019-10-18 Tom de Vries <tdevries@suse.de> * aarch64-tdep.c: Fix typos in comments. * ada-lang.c: Same. * ada-tasks.c: Same. * alpha-tdep.c: Same. * alpha-tdep.h: Same. * amd64-nat.c: Same. * amd64-windows-tdep.c: Same. * arc-tdep.c: Same. * arc-tdep.h: Same. * arch-utils.c: Same. * arm-nbsd-tdep.c: Same. * arm-tdep.c: Same. * ax-gdb.c: Same. * blockframe.c: Same. * btrace.c: Same. * c-varobj.c: Same. * coff-pe-read.c: Same. * coffread.c: Same. * cris-tdep.c: Same. * darwin-nat.c: Same. * dbxread.c: Same. * dcache.c: Same. * disasm.c: Same. * dtrace-probe.c: Same. * dwarf-index-write.c: Same. * dwarf2-frame-tailcall.c: Same. * dwarf2-frame.c: Same. * dwarf2read.c: Same. * eval.c: Same. * exceptions.c: Same. * fbsd-tdep.c: Same. * findvar.c: Same. * frame.c: Same. * frv-tdep.c: Same. * gnu-v3-abi.c: Same. * go32-nat.c: Same. * h8300-tdep.c: Same. * hppa-tdep.c: Same. * i386-linux-tdep.c: Same. * i386-tdep.c: Same. * ia64-libunwind-tdep.c: Same. * ia64-tdep.c: Same. * infcmd.c: Same. * infrun.c: Same. * linespec.c: Same. * linux-nat.c: Same. * linux-thread-db.c: Same. * machoread.c: Same. * mdebugread.c: Same. * mep-tdep.c: Same. * mn10300-tdep.c: Same. * namespace.c: Same. * objfiles.c: Same. * opencl-lang.c: Same. * or1k-tdep.c: Same. * osabi.c: Same. * ppc-linux-nat.c: Same. * ppc-linux-tdep.c: Same. * ppc-sysv-tdep.c: Same. * printcmd.c: Same. * procfs.c: Same. * record-btrace.c: Same. * record-full.c: Same. * remote-fileio.c: Same. * remote.c: Same. * rs6000-tdep.c: Same. * s12z-tdep.c: Same. * score-tdep.c: Same. * ser-base.c: Same. * ser-go32.c: Same. * skip.c: Same. * sol-thread.c: Same. * solib-svr4.c: Same. * solib.c: Same. * source.c: Same. * sparc-nat.c: Same. * sparc-sol2-tdep.c: Same. * sparc-tdep.c: Same. * sparc64-tdep.c: Same. * stabsread.c: Same. * stack.c: Same. * symfile.c: Same. * symtab.c: Same. * target-descriptions.c: Same. * target-float.c: Same. * thread.c: Same. * utils.c: Same. * valops.c: Same. * valprint.c: Same. * value.c: Same. * varobj.c: Same. * windows-nat.c: Same. * xcoffread.c: Same. * xstormy16-tdep.c: Same. * xtensa-tdep.c: Same. Change-Id: I5175f1b107bfa4e1cdd4a3361ccb4739e53c75c4
2019-10-18 02:48:08 +02:00
* The last check avoids doing this search when targeting remote
* machines since a sysroot will almost always be set.
*/
static gdb::unique_xmalloc_ptr<char>
solib_find_1 (const char *in_pathname, int *fd, bool is_solib)
{
const struct target_so_ops *ops = solib_ops (target_gdbarch ());
int found_file = -1;
gdb::unique_xmalloc_ptr<char> temp_pathname;
const char *fskind = effective_target_file_system_kind ();
const char *sysroot = gdb_sysroot;
int prefix_len, orig_prefix_len;
/* If the absolute prefix starts with "target:" but the filesystem
accessed by the target_fileio_* methods is the local filesystem
then we strip the "target:" prefix now and work with the local
filesystem. This ensures that the same search algorithm is used
for all local files regardless of whether a "target:" prefix was
used. */
if (is_target_filename (sysroot) && target_filesystem_is_local ())
sysroot += strlen (TARGET_SYSROOT_PREFIX);
/* Strip any trailing slashes from the absolute prefix. */
prefix_len = orig_prefix_len = strlen (sysroot);
while (prefix_len > 0 && IS_DIR_SEPARATOR (sysroot[prefix_len - 1]))
prefix_len--;
std::string sysroot_holder;
if (prefix_len == 0)
sysroot = NULL;
else if (prefix_len != orig_prefix_len)
{
sysroot_holder = std::string (sysroot, prefix_len);
sysroot = sysroot_holder.c_str ();
}
/* If we're on a non-DOS-based system, backslashes won't be
understood as directory separator, so, convert them to forward
slashes, iff we're supposed to handle DOS-based file system
semantics for target paths. */
if (!DOS_BASED_FILE_SYSTEM && fskind == file_system_kind_dos_based)
{
char *p;
/* Avoid clobbering our input. */
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
p = (char *) alloca (strlen (in_pathname) + 1);
strcpy (p, in_pathname);
in_pathname = p;
for (; *p; p++)
{
if (*p == '\\')
*p = '/';
}
}
/* Note, we're interested in IS_TARGET_ABSOLUTE_PATH, not
IS_ABSOLUTE_PATH. The latter is for host paths only, while
IN_PATHNAME is a target path. For example, if we're supposed to
be handling DOS-like semantics we want to consider a
'c:/foo/bar.dll' path as an absolute path, even on a Unix box.
With such a path, before giving up on the sysroot, we'll try:
1st attempt, c:/foo/bar.dll ==> /sysroot/c:/foo/bar.dll
2nd attempt, c:/foo/bar.dll ==> /sysroot/c/foo/bar.dll
3rd attempt, c:/foo/bar.dll ==> /sysroot/foo/bar.dll
*/
if (!IS_TARGET_ABSOLUTE_PATH (fskind, in_pathname) || sysroot == NULL)
temp_pathname.reset (xstrdup (in_pathname));
else
{
bool need_dir_separator;
Fix regular /path/to/directory sysroots and target reported dll paths with drive specs. I tried debugging a remote Windows program on Linux host, and pointed the sysroot to "/some/path/" rather than "remote:", and I found GDB couldn't find the dlls in the sysroot. If the dll name is "C:/Windows/system32/ntdll.dll", I end up with the sysroot+in_pathname concatenated this way: (top-gdb) p temp_pathname $1 = 0x228b690 "/some/pathC:/Windows/system32/ntdll.dll" ^^ That is, a directory separator is missing. This is a regression. The problem is that solib_find decides that since the target path has a drive spec, a separator is not necessary, which is clearly wrong in this case. That check was added in <https://sourceware.org/ml/gdb-patches/2013-06/msg00028.html>, to handle the case of sysroot being "remote:". This patch fixes that original issue in a different way. Instead of checking whether the path has a drive spec, check whether the sysroot is "remote:". The patch adds a table that helps visualize the cases that need a separator. I also confirmed the original issue is still handled as expected. That is, that "set sysroot remote:" still does the right thing. remote_filename_p returns true if the filename is prefixed with "remote:". In this case, we need to check whether the filename is exactly "remote:". I thought of different ways or either changing remote_filename_p or adding another convenience function to remote.c to avoid exposing the "remote:" prefix out of remote.c. But all attempts turned out adding lot of over needless complication. So the patch just exposes the prefix behind a new macro, which allows using a straighforward strcmp. gdb/ 2013-09-27 Pedro Alves <palves@redhat.com> * remote.h (REMOTE_SYSROOT_PREFIX): New define. (remote_filename_p): Add comment. * remote.c (remote_filename_p): Adjust to use REMOTE_SYSROOT_PREFIX. * solib.c (solib_find): When deciding whether we need to add a directory separator, check whether the sysroot is "remote:" instead of checking whether the patch has a drive spec. Add comments.
2013-09-27 17:29:06 +02:00
/* Concatenate the sysroot and the target reported filename. We
may need to glue them with a directory separator. Cases to
consider:
| sysroot | separator | in_pathname |
|-----------------+-----------+----------------|
| /some/dir | / | c:/foo/bar.dll |
| /some/dir | | /foo/bar.dll |
Convert "remote:" sysroots to "target:" and remove "remote:" The functionality of "target:" sysroots is a superset of the functionality of "remote:" sysroots. This commit causes the "set sysroot" command to rewrite "remote:" sysroots as "target:" sysroots and replaces "remote:" specific code with "target:" specific code where still necessary. gdb/ChangeLog: * remote.h (REMOTE_SYSROOT_PREFIX): Remove definition. (remote_filename_p): Remove declaration. (remote_bfd_open): Likewise. * remote.c (remote_bfd_iovec_open): Remove function. (remote_bfd_iovec_close): Likewise. (remote_bfd_iovec_pread): Likewise. (remote_bfd_iovec_stat): Likewise. (remote_filename_p): Likewise. (remote_bfd_open): Likewise. * symfile.h (gdb_bfd_open_maybe_remote): Remove declaration. * symfile.c (separate_debug_file_exists): Use gdb_bfd_open. (gdb_bfd_open_maybe_remote): Remove function. (symfile_bfd_open): Replace remote filename check with target filename check. (reread_symbols): Use gdb_bfd_open. * build-id.c (gdbcore.h): New include. (build_id_to_debug_bfd): Use gdb_bfd_open. * infcmd.c (attach_command_post_wait): Remove remote filename check. * solib.c (solib_find): Replace remote-specific handling with target-specific handling. Update comments where necessary. (solib_bfd_open): Replace remote-specific handling with target-specific handling. (gdb_sysroot_changed): New function. (_initialize_solib): Call the above when gdb_sysroot changes. * windows-tdep.c (gdbcore.h): New include. (windows_xfer_shared_library): Use gdb_bfd_open.
2015-04-02 14:38:29 +02:00
| target: | | c:/foo/bar.dll |
| target: | | /foo/bar.dll |
| target:some/dir | / | c:/foo/bar.dll |
| target:some/dir | | /foo/bar.dll |
Fix regular /path/to/directory sysroots and target reported dll paths with drive specs. I tried debugging a remote Windows program on Linux host, and pointed the sysroot to "/some/path/" rather than "remote:", and I found GDB couldn't find the dlls in the sysroot. If the dll name is "C:/Windows/system32/ntdll.dll", I end up with the sysroot+in_pathname concatenated this way: (top-gdb) p temp_pathname $1 = 0x228b690 "/some/pathC:/Windows/system32/ntdll.dll" ^^ That is, a directory separator is missing. This is a regression. The problem is that solib_find decides that since the target path has a drive spec, a separator is not necessary, which is clearly wrong in this case. That check was added in <https://sourceware.org/ml/gdb-patches/2013-06/msg00028.html>, to handle the case of sysroot being "remote:". This patch fixes that original issue in a different way. Instead of checking whether the path has a drive spec, check whether the sysroot is "remote:". The patch adds a table that helps visualize the cases that need a separator. I also confirmed the original issue is still handled as expected. That is, that "set sysroot remote:" still does the right thing. remote_filename_p returns true if the filename is prefixed with "remote:". In this case, we need to check whether the filename is exactly "remote:". I thought of different ways or either changing remote_filename_p or adding another convenience function to remote.c to avoid exposing the "remote:" prefix out of remote.c. But all attempts turned out adding lot of over needless complication. So the patch just exposes the prefix behind a new macro, which allows using a straighforward strcmp. gdb/ 2013-09-27 Pedro Alves <palves@redhat.com> * remote.h (REMOTE_SYSROOT_PREFIX): New define. (remote_filename_p): Add comment. * remote.c (remote_filename_p): Adjust to use REMOTE_SYSROOT_PREFIX. * solib.c (solib_find): When deciding whether we need to add a directory separator, check whether the sysroot is "remote:" instead of checking whether the patch has a drive spec. Add comments.
2013-09-27 17:29:06 +02:00
IOW, we don't need to add a separator if IN_PATHNAME already
has one, or when the sysroot is exactly "target:".
Fix regular /path/to/directory sysroots and target reported dll paths with drive specs. I tried debugging a remote Windows program on Linux host, and pointed the sysroot to "/some/path/" rather than "remote:", and I found GDB couldn't find the dlls in the sysroot. If the dll name is "C:/Windows/system32/ntdll.dll", I end up with the sysroot+in_pathname concatenated this way: (top-gdb) p temp_pathname $1 = 0x228b690 "/some/pathC:/Windows/system32/ntdll.dll" ^^ That is, a directory separator is missing. This is a regression. The problem is that solib_find decides that since the target path has a drive spec, a separator is not necessary, which is clearly wrong in this case. That check was added in <https://sourceware.org/ml/gdb-patches/2013-06/msg00028.html>, to handle the case of sysroot being "remote:". This patch fixes that original issue in a different way. Instead of checking whether the path has a drive spec, check whether the sysroot is "remote:". The patch adds a table that helps visualize the cases that need a separator. I also confirmed the original issue is still handled as expected. That is, that "set sysroot remote:" still does the right thing. remote_filename_p returns true if the filename is prefixed with "remote:". In this case, we need to check whether the filename is exactly "remote:". I thought of different ways or either changing remote_filename_p or adding another convenience function to remote.c to avoid exposing the "remote:" prefix out of remote.c. But all attempts turned out adding lot of over needless complication. So the patch just exposes the prefix behind a new macro, which allows using a straighforward strcmp. gdb/ 2013-09-27 Pedro Alves <palves@redhat.com> * remote.h (REMOTE_SYSROOT_PREFIX): New define. (remote_filename_p): Add comment. * remote.c (remote_filename_p): Adjust to use REMOTE_SYSROOT_PREFIX. * solib.c (solib_find): When deciding whether we need to add a directory separator, check whether the sysroot is "remote:" instead of checking whether the patch has a drive spec. Add comments.
2013-09-27 17:29:06 +02:00
There's no need to check for drive spec explicitly, as we only
get here if IN_PATHNAME is considered an absolute path. */
need_dir_separator = !(IS_DIR_SEPARATOR (in_pathname[0])
Convert "remote:" sysroots to "target:" and remove "remote:" The functionality of "target:" sysroots is a superset of the functionality of "remote:" sysroots. This commit causes the "set sysroot" command to rewrite "remote:" sysroots as "target:" sysroots and replaces "remote:" specific code with "target:" specific code where still necessary. gdb/ChangeLog: * remote.h (REMOTE_SYSROOT_PREFIX): Remove definition. (remote_filename_p): Remove declaration. (remote_bfd_open): Likewise. * remote.c (remote_bfd_iovec_open): Remove function. (remote_bfd_iovec_close): Likewise. (remote_bfd_iovec_pread): Likewise. (remote_bfd_iovec_stat): Likewise. (remote_filename_p): Likewise. (remote_bfd_open): Likewise. * symfile.h (gdb_bfd_open_maybe_remote): Remove declaration. * symfile.c (separate_debug_file_exists): Use gdb_bfd_open. (gdb_bfd_open_maybe_remote): Remove function. (symfile_bfd_open): Replace remote filename check with target filename check. (reread_symbols): Use gdb_bfd_open. * build-id.c (gdbcore.h): New include. (build_id_to_debug_bfd): Use gdb_bfd_open. * infcmd.c (attach_command_post_wait): Remove remote filename check. * solib.c (solib_find): Replace remote-specific handling with target-specific handling. Update comments where necessary. (solib_bfd_open): Replace remote-specific handling with target-specific handling. (gdb_sysroot_changed): New function. (_initialize_solib): Call the above when gdb_sysroot changes. * windows-tdep.c (gdbcore.h): New include. (windows_xfer_shared_library): Use gdb_bfd_open.
2015-04-02 14:38:29 +02:00
|| strcmp (TARGET_SYSROOT_PREFIX, sysroot) == 0);
/* Cat the prefixed pathname together. */
temp_pathname.reset (concat (sysroot,
need_dir_separator ? SLASH_STRING : "",
in_pathname, (char *) NULL));
}
Convert "remote:" sysroots to "target:" and remove "remote:" The functionality of "target:" sysroots is a superset of the functionality of "remote:" sysroots. This commit causes the "set sysroot" command to rewrite "remote:" sysroots as "target:" sysroots and replaces "remote:" specific code with "target:" specific code where still necessary. gdb/ChangeLog: * remote.h (REMOTE_SYSROOT_PREFIX): Remove definition. (remote_filename_p): Remove declaration. (remote_bfd_open): Likewise. * remote.c (remote_bfd_iovec_open): Remove function. (remote_bfd_iovec_close): Likewise. (remote_bfd_iovec_pread): Likewise. (remote_bfd_iovec_stat): Likewise. (remote_filename_p): Likewise. (remote_bfd_open): Likewise. * symfile.h (gdb_bfd_open_maybe_remote): Remove declaration. * symfile.c (separate_debug_file_exists): Use gdb_bfd_open. (gdb_bfd_open_maybe_remote): Remove function. (symfile_bfd_open): Replace remote filename check with target filename check. (reread_symbols): Use gdb_bfd_open. * build-id.c (gdbcore.h): New include. (build_id_to_debug_bfd): Use gdb_bfd_open. * infcmd.c (attach_command_post_wait): Remove remote filename check. * solib.c (solib_find): Replace remote-specific handling with target-specific handling. Update comments where necessary. (solib_bfd_open): Replace remote-specific handling with target-specific handling. (gdb_sysroot_changed): New function. (_initialize_solib): Call the above when gdb_sysroot changes. * windows-tdep.c (gdbcore.h): New include. (windows_xfer_shared_library): Use gdb_bfd_open.
2015-04-02 14:38:29 +02:00
/* Handle files to be accessed via the target. */
if (is_target_filename (temp_pathname.get ()))
{
if (fd != NULL)
*fd = -1;
return temp_pathname;
}
/* Now see if we can open it. */
found_file = gdb_open_cloexec (temp_pathname.get (), O_RDONLY | O_BINARY, 0);
/* If the search in gdb_sysroot failed, and the path name has a
drive spec (e.g, c:/foo), try stripping ':' from the drive spec,
and retrying in the sysroot:
c:/foo/bar.dll ==> /sysroot/c/foo/bar.dll. */
if (found_file < 0
&& sysroot != NULL
&& HAS_TARGET_DRIVE_SPEC (fskind, in_pathname))
{
bool need_dir_separator = !IS_DIR_SEPARATOR (in_pathname[2]);
char drive[2] = { in_pathname[0], '\0' };
temp_pathname.reset (concat (sysroot,
SLASH_STRING,
drive,
need_dir_separator ? SLASH_STRING : "",
in_pathname + 2, (char *) NULL));
found_file = gdb_open_cloexec (temp_pathname.get (),
O_RDONLY | O_BINARY, 0);
if (found_file < 0)
{
/* If the search in gdb_sysroot still failed, try fully
stripping the drive spec, and trying once more in the
sysroot before giving up.
c:/foo/bar.dll ==> /sysroot/foo/bar.dll. */
temp_pathname.reset (concat (sysroot,
need_dir_separator ? SLASH_STRING : "",
in_pathname + 2, (char *) NULL));
found_file = gdb_open_cloexec (temp_pathname.get (),
O_RDONLY | O_BINARY, 0);
}
}
/* We try to find the library in various ways. After each attempt,
either found_file >= 0 and temp_pathname is a malloc'd string, or
found_file < 0 and temp_pathname does not point to storage that
needs to be freed. */
if (found_file < 0)
temp_pathname.reset (NULL);
/* If the search in gdb_sysroot failed, and the path name is
absolute at this point, make it relative. (openp will try and open the
file according to its absolute path otherwise, which is not what we want.)
Affects subsequent searches for this solib. */
if (found_file < 0 && IS_TARGET_ABSOLUTE_PATH (fskind, in_pathname))
{
/* First, get rid of any drive letters etc. */
while (!IS_TARGET_DIR_SEPARATOR (fskind, *in_pathname))
in_pathname++;
/* Next, get rid of all leading dir separators. */
while (IS_TARGET_DIR_SEPARATOR (fskind, *in_pathname))
in_pathname++;
}
/* If not found, and we're looking for a solib, search the
solib_search_path (if any). */
if (is_solib && found_file < 0 && solib_search_path != NULL)
found_file = openp (solib_search_path,
OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH,
in_pathname, O_RDONLY | O_BINARY, &temp_pathname);
/* If not found, and we're looking for a solib, next search the
solib_search_path (if any) for the basename only (ignoring the
path). This is to allow reading solibs from a path that differs
from the opened path. */
if (is_solib && found_file < 0 && solib_search_path != NULL)
found_file = openp (solib_search_path,
OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH,
target_lbasename (fskind, in_pathname),
O_RDONLY | O_BINARY, &temp_pathname);
/* If not found, and we're looking for a solib, try to use target
supplied solib search method. */
if (is_solib && found_file < 0 && ops->find_and_open_solib)
found_file = ops->find_and_open_solib (in_pathname, O_RDONLY | O_BINARY,
&temp_pathname);
2003-02-24 20:11:04 +01:00
/* If not found, next search the inferior's $PATH environment variable. */
if (found_file < 0 && sysroot == NULL)
C++ify gdb/common/environ.c As part of the preparation necessary for my upcoming task, I'd like to propose that we turn gdb_environ into a class. The approach taken here is simple: the class gdb_environ contains everything that is needed to manipulate the environment variables. These variables are stored in an std::vector<char *>, which can be converted to a 'char **' and passed as argument to functions that need it. The usage has not changed much. As per Pedro's suggestion, this class uses a static factory method initialization. This means that when an instance is created, it is initially empty. When needed, it has to be initialized using the static method 'from_host_environ'. As mentioned before, this is a preparation for an upcoming work that I will be posting in the next few weeks or so. For that work, I'll probably create another data structure that will contain all the environment variables that were set by the user using the 'set environment' command, because I'll need access to them. This will be much easier with the class-ification of gdb_environ. As noted, this has been regression-tested with the new version of environ.exp and no regressions were found. gdb/ChangeLog: 2017-06-20 Sergio Durigan Junior <sergiodj@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/environ-selftests.c'. (SUBDIR_UNITTESTS_OBS): Add 'environ-selftests.o'. * charset.c (find_charset_names): Declare object 'iconv_env'. Update code to use 'iconv_env' object. Remove call to 'free_environ'. * common/environ.c: Include <utility>. (make_environ): Delete function. (free_environ): Delete function. (gdb_environ::clear): New function. (gdb_environ::operator=): New function. (gdb_environ::get): Likewise. (environ_vector): Delete function. (set_in_environ): Delete function. (gdb_environ::set): New function. (unset_in_environ): Delete function. (gdb_environ::unset): New function. (gdb_environ::envp): Likewise. * common/environ.h: Include <vector>. (struct gdb_environ): Delete; transform into... (class gdb_environ): ... this class. (free_environ): Delete prototype. (init_environ, get_in_environ, set_in_environ, unset_in_environ, environ_vector): Likewise. * infcmd.c (run_command_1): Update code to call 'envp' from 'gdb_environ' class. (environment_info): Update code to call methods from 'gdb_environ' class. (unset_environment_command): Likewise. (path_info): Likewise. (path_command): Likewise. * inferior.c (inferior::~inferior): Delete call to 'free_environ'. (inferior::inferior): Initialize 'environment' using the host's information. * inferior.h: Remove forward declaration of 'struct gdb_environ'. Include "environ.h". (class inferior) <environment>: Change type from 'struct gdb_environ' to 'gdb_environ'. * mi/mi-cmd-env.c (mi_cmd_env_path): Update code to call methods from 'gdb_environ' class. * solib.c (solib_find_1): Likewise * unittests/environ-selftests.c: New file. gdb/gdbserver/ChangeLog: 2017-06-20 Sergio Durigan Junior <sergiodj@redhat.com> * linux-low.c (linux_create_inferior): Adjust code to access the environment information via 'gdb_environ' class. * lynx-low.c (lynx_create_inferior): Likewise. * server.c (our_environ): Make it an instance of 'gdb_environ'. (get_environ): Return a pointer to 'our_environ'. (captured_main): Initialize 'our_environ'. * server.h (get_environ): Adjust prototype. * spu-low.c (spu_create_inferior): Adjust code to access the environment information via 'gdb_environ' class.
2017-02-11 03:19:44 +01:00
found_file = openp (current_inferior ()->environment.get ("PATH"),
OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname,
O_RDONLY | O_BINARY, &temp_pathname);
/* If not found, and we're looking for a solib, next search the
inferior's $LD_LIBRARY_PATH environment variable. */
if (is_solib && found_file < 0 && sysroot == NULL)
C++ify gdb/common/environ.c As part of the preparation necessary for my upcoming task, I'd like to propose that we turn gdb_environ into a class. The approach taken here is simple: the class gdb_environ contains everything that is needed to manipulate the environment variables. These variables are stored in an std::vector<char *>, which can be converted to a 'char **' and passed as argument to functions that need it. The usage has not changed much. As per Pedro's suggestion, this class uses a static factory method initialization. This means that when an instance is created, it is initially empty. When needed, it has to be initialized using the static method 'from_host_environ'. As mentioned before, this is a preparation for an upcoming work that I will be posting in the next few weeks or so. For that work, I'll probably create another data structure that will contain all the environment variables that were set by the user using the 'set environment' command, because I'll need access to them. This will be much easier with the class-ification of gdb_environ. As noted, this has been regression-tested with the new version of environ.exp and no regressions were found. gdb/ChangeLog: 2017-06-20 Sergio Durigan Junior <sergiodj@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/environ-selftests.c'. (SUBDIR_UNITTESTS_OBS): Add 'environ-selftests.o'. * charset.c (find_charset_names): Declare object 'iconv_env'. Update code to use 'iconv_env' object. Remove call to 'free_environ'. * common/environ.c: Include <utility>. (make_environ): Delete function. (free_environ): Delete function. (gdb_environ::clear): New function. (gdb_environ::operator=): New function. (gdb_environ::get): Likewise. (environ_vector): Delete function. (set_in_environ): Delete function. (gdb_environ::set): New function. (unset_in_environ): Delete function. (gdb_environ::unset): New function. (gdb_environ::envp): Likewise. * common/environ.h: Include <vector>. (struct gdb_environ): Delete; transform into... (class gdb_environ): ... this class. (free_environ): Delete prototype. (init_environ, get_in_environ, set_in_environ, unset_in_environ, environ_vector): Likewise. * infcmd.c (run_command_1): Update code to call 'envp' from 'gdb_environ' class. (environment_info): Update code to call methods from 'gdb_environ' class. (unset_environment_command): Likewise. (path_info): Likewise. (path_command): Likewise. * inferior.c (inferior::~inferior): Delete call to 'free_environ'. (inferior::inferior): Initialize 'environment' using the host's information. * inferior.h: Remove forward declaration of 'struct gdb_environ'. Include "environ.h". (class inferior) <environment>: Change type from 'struct gdb_environ' to 'gdb_environ'. * mi/mi-cmd-env.c (mi_cmd_env_path): Update code to call methods from 'gdb_environ' class. * solib.c (solib_find_1): Likewise * unittests/environ-selftests.c: New file. gdb/gdbserver/ChangeLog: 2017-06-20 Sergio Durigan Junior <sergiodj@redhat.com> * linux-low.c (linux_create_inferior): Adjust code to access the environment information via 'gdb_environ' class. * lynx-low.c (lynx_create_inferior): Likewise. * server.c (our_environ): Make it an instance of 'gdb_environ'. (get_environ): Return a pointer to 'our_environ'. (captured_main): Initialize 'our_environ'. * server.h (get_environ): Adjust prototype. * spu-low.c (spu_create_inferior): Adjust code to access the environment information via 'gdb_environ' class.
2017-02-11 03:19:44 +01:00
found_file = openp (current_inferior ()->environment.get
("LD_LIBRARY_PATH"),
OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname,
O_RDONLY | O_BINARY, &temp_pathname);
if (fd == NULL)
{
if (found_file >= 0)
close (found_file);
}
else
*fd = found_file;
return temp_pathname;
}
/* Return the full pathname of the main executable, or NULL if not
found. If FD is non-NULL, *FD is set to either -1 or an open file
handle for the main executable. */
gdb::unique_xmalloc_ptr<char>
exec_file_find (const char *in_pathname, int *fd)
{
gdb::unique_xmalloc_ptr<char> result;
PR 20569, segv in follow_exec The following testcases make GDB crash whenever an invalid sysroot is provided, when GDB is unable to find a valid path to the symbol file: gdb.base/catch-syscall.exp gdb.base/execl-update-breakpoints.exp gdb.base/foll-exec-mode.exp gdb.base/foll-exec.exp gdb.base/foll-vfork.exp gdb.base/pie-execl.exp gdb.multi/bkpt-multi-exec.exp gdb.python/py-finish-breakpoint.exp gdb.threads/execl.exp gdb.threads/non-ldr-exc-1.exp gdb.threads/non-ldr-exc-2.exp gdb.threads/non-ldr-exc-3.exp gdb.threads/non-ldr-exc-4.exp gdb.threads/thread-execl.exp The immediate cause of the segv is that follow_exec is passing a NULL argument (the result of exec_file_find) to strlen. However, the problem is deeper than that: follow_exec simply isn't prepared for the case where sysroot translation fails to locate the new executable. Actually all callers of exec_file_find have bugs due to confusion between host and target pathnames. This commit attempts to fix all that. In terms of the testcases that were formerly segv'ing, GDB now prints a warning but continues execution of the new program, so that the tests now mostly FAIL instead. You could argue the FAILs are due to a legitimate problem with the test environment setting up the sysroot translation incorrectly. A new representative test is added which exercises the ne wwarning code path even with native testing. Tested on x86_64 Fedora 23, native and gdbserver. gdb/ChangeLog: 2016-10-25 Sandra Loosemore <sandra@codesourcery.com> Luis Machado <lgustavo@codesourcery.com> Pedro Alves <palves@redhat.com> PR gdb/20569 * exceptions.c (exception_print_same): Moved here from exec.c. * exceptions.h (exception_print_same): Declare. * exec.h: Include "symfile-add-flags.h". (try_open_exec_file): New declaration. * exec.c (exception_print_same): Moved to exceptions.c. (try_open_exec_file): New function. (exec_file_locate_attach): Rename exec_file and full_exec_path variables to avoid confusion between target and host pathnames. Move pathname processing logic to exec_file_find. Do not return early if pathname lookup fails; Call try_open_exec_file. * infrun.c (follow_exec): Split and rename execd_pathname variable to avoid confusion between target and host pathnames. Warn if pathname lookup fails. Pass target pathname to target_follow_exec, not hostpathname. Call try_open_exec_file. * main.c (symbol_file_add_main_adapter): New function. (captured_main_1): Use it. * solib-svr4.c (open_symbol_file_object): Adjust to pass symfile_add_flags to symbol_file_add_main. * solib.c (exec_file_find): Incorporate fallback logic for relative pathnames formerly in exec_file_locate_attach. * symfile.c (symbol_file_add_main, symbol_file_add_main_1): Replace 'from_tty' parameter with a symfile_add_file. (symbol_file_command): Adjust to pass symfile_add_flags to symbol_file_add_main. * symfile.h (symbol_file_add_main): Replace 'from_tty' parameter with a symfile_add_file. gdb/testsuite/ChangeLog: 2016-10-25 Luis Machado <lgustavo@codesourcery.com> * gdb.base/exec-invalid-sysroot.exp: New file.
2016-10-26 19:12:01 +02:00
const char *fskind = effective_target_file_system_kind ();
if (in_pathname == NULL)
return NULL;
PR 20569, segv in follow_exec The following testcases make GDB crash whenever an invalid sysroot is provided, when GDB is unable to find a valid path to the symbol file: gdb.base/catch-syscall.exp gdb.base/execl-update-breakpoints.exp gdb.base/foll-exec-mode.exp gdb.base/foll-exec.exp gdb.base/foll-vfork.exp gdb.base/pie-execl.exp gdb.multi/bkpt-multi-exec.exp gdb.python/py-finish-breakpoint.exp gdb.threads/execl.exp gdb.threads/non-ldr-exc-1.exp gdb.threads/non-ldr-exc-2.exp gdb.threads/non-ldr-exc-3.exp gdb.threads/non-ldr-exc-4.exp gdb.threads/thread-execl.exp The immediate cause of the segv is that follow_exec is passing a NULL argument (the result of exec_file_find) to strlen. However, the problem is deeper than that: follow_exec simply isn't prepared for the case where sysroot translation fails to locate the new executable. Actually all callers of exec_file_find have bugs due to confusion between host and target pathnames. This commit attempts to fix all that. In terms of the testcases that were formerly segv'ing, GDB now prints a warning but continues execution of the new program, so that the tests now mostly FAIL instead. You could argue the FAILs are due to a legitimate problem with the test environment setting up the sysroot translation incorrectly. A new representative test is added which exercises the ne wwarning code path even with native testing. Tested on x86_64 Fedora 23, native and gdbserver. gdb/ChangeLog: 2016-10-25 Sandra Loosemore <sandra@codesourcery.com> Luis Machado <lgustavo@codesourcery.com> Pedro Alves <palves@redhat.com> PR gdb/20569 * exceptions.c (exception_print_same): Moved here from exec.c. * exceptions.h (exception_print_same): Declare. * exec.h: Include "symfile-add-flags.h". (try_open_exec_file): New declaration. * exec.c (exception_print_same): Moved to exceptions.c. (try_open_exec_file): New function. (exec_file_locate_attach): Rename exec_file and full_exec_path variables to avoid confusion between target and host pathnames. Move pathname processing logic to exec_file_find. Do not return early if pathname lookup fails; Call try_open_exec_file. * infrun.c (follow_exec): Split and rename execd_pathname variable to avoid confusion between target and host pathnames. Warn if pathname lookup fails. Pass target pathname to target_follow_exec, not hostpathname. Call try_open_exec_file. * main.c (symbol_file_add_main_adapter): New function. (captured_main_1): Use it. * solib-svr4.c (open_symbol_file_object): Adjust to pass symfile_add_flags to symbol_file_add_main. * solib.c (exec_file_find): Incorporate fallback logic for relative pathnames formerly in exec_file_locate_attach. * symfile.c (symbol_file_add_main, symbol_file_add_main_1): Replace 'from_tty' parameter with a symfile_add_file. (symbol_file_command): Adjust to pass symfile_add_flags to symbol_file_add_main. * symfile.h (symbol_file_add_main): Replace 'from_tty' parameter with a symfile_add_file. gdb/testsuite/ChangeLog: 2016-10-25 Luis Machado <lgustavo@codesourcery.com> * gdb.base/exec-invalid-sysroot.exp: New file.
2016-10-26 19:12:01 +02:00
if (*gdb_sysroot != '\0' && IS_TARGET_ABSOLUTE_PATH (fskind, in_pathname))
{
result = solib_find_1 (in_pathname, fd, false);
PR 20569, segv in follow_exec The following testcases make GDB crash whenever an invalid sysroot is provided, when GDB is unable to find a valid path to the symbol file: gdb.base/catch-syscall.exp gdb.base/execl-update-breakpoints.exp gdb.base/foll-exec-mode.exp gdb.base/foll-exec.exp gdb.base/foll-vfork.exp gdb.base/pie-execl.exp gdb.multi/bkpt-multi-exec.exp gdb.python/py-finish-breakpoint.exp gdb.threads/execl.exp gdb.threads/non-ldr-exc-1.exp gdb.threads/non-ldr-exc-2.exp gdb.threads/non-ldr-exc-3.exp gdb.threads/non-ldr-exc-4.exp gdb.threads/thread-execl.exp The immediate cause of the segv is that follow_exec is passing a NULL argument (the result of exec_file_find) to strlen. However, the problem is deeper than that: follow_exec simply isn't prepared for the case where sysroot translation fails to locate the new executable. Actually all callers of exec_file_find have bugs due to confusion between host and target pathnames. This commit attempts to fix all that. In terms of the testcases that were formerly segv'ing, GDB now prints a warning but continues execution of the new program, so that the tests now mostly FAIL instead. You could argue the FAILs are due to a legitimate problem with the test environment setting up the sysroot translation incorrectly. A new representative test is added which exercises the ne wwarning code path even with native testing. Tested on x86_64 Fedora 23, native and gdbserver. gdb/ChangeLog: 2016-10-25 Sandra Loosemore <sandra@codesourcery.com> Luis Machado <lgustavo@codesourcery.com> Pedro Alves <palves@redhat.com> PR gdb/20569 * exceptions.c (exception_print_same): Moved here from exec.c. * exceptions.h (exception_print_same): Declare. * exec.h: Include "symfile-add-flags.h". (try_open_exec_file): New declaration. * exec.c (exception_print_same): Moved to exceptions.c. (try_open_exec_file): New function. (exec_file_locate_attach): Rename exec_file and full_exec_path variables to avoid confusion between target and host pathnames. Move pathname processing logic to exec_file_find. Do not return early if pathname lookup fails; Call try_open_exec_file. * infrun.c (follow_exec): Split and rename execd_pathname variable to avoid confusion between target and host pathnames. Warn if pathname lookup fails. Pass target pathname to target_follow_exec, not hostpathname. Call try_open_exec_file. * main.c (symbol_file_add_main_adapter): New function. (captured_main_1): Use it. * solib-svr4.c (open_symbol_file_object): Adjust to pass symfile_add_flags to symbol_file_add_main. * solib.c (exec_file_find): Incorporate fallback logic for relative pathnames formerly in exec_file_locate_attach. * symfile.c (symbol_file_add_main, symbol_file_add_main_1): Replace 'from_tty' parameter with a symfile_add_file. (symbol_file_command): Adjust to pass symfile_add_flags to symbol_file_add_main. * symfile.h (symbol_file_add_main): Replace 'from_tty' parameter with a symfile_add_file. gdb/testsuite/ChangeLog: 2016-10-25 Luis Machado <lgustavo@codesourcery.com> * gdb.base/exec-invalid-sysroot.exp: New file.
2016-10-26 19:12:01 +02:00
if (result == NULL && fskind == file_system_kind_dos_based)
{
char *new_pathname;
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
new_pathname = (char *) alloca (strlen (in_pathname) + 5);
strcpy (new_pathname, in_pathname);
strcat (new_pathname, ".exe");
result = solib_find_1 (new_pathname, fd, false);
}
}
PR 20569, segv in follow_exec The following testcases make GDB crash whenever an invalid sysroot is provided, when GDB is unable to find a valid path to the symbol file: gdb.base/catch-syscall.exp gdb.base/execl-update-breakpoints.exp gdb.base/foll-exec-mode.exp gdb.base/foll-exec.exp gdb.base/foll-vfork.exp gdb.base/pie-execl.exp gdb.multi/bkpt-multi-exec.exp gdb.python/py-finish-breakpoint.exp gdb.threads/execl.exp gdb.threads/non-ldr-exc-1.exp gdb.threads/non-ldr-exc-2.exp gdb.threads/non-ldr-exc-3.exp gdb.threads/non-ldr-exc-4.exp gdb.threads/thread-execl.exp The immediate cause of the segv is that follow_exec is passing a NULL argument (the result of exec_file_find) to strlen. However, the problem is deeper than that: follow_exec simply isn't prepared for the case where sysroot translation fails to locate the new executable. Actually all callers of exec_file_find have bugs due to confusion between host and target pathnames. This commit attempts to fix all that. In terms of the testcases that were formerly segv'ing, GDB now prints a warning but continues execution of the new program, so that the tests now mostly FAIL instead. You could argue the FAILs are due to a legitimate problem with the test environment setting up the sysroot translation incorrectly. A new representative test is added which exercises the ne wwarning code path even with native testing. Tested on x86_64 Fedora 23, native and gdbserver. gdb/ChangeLog: 2016-10-25 Sandra Loosemore <sandra@codesourcery.com> Luis Machado <lgustavo@codesourcery.com> Pedro Alves <palves@redhat.com> PR gdb/20569 * exceptions.c (exception_print_same): Moved here from exec.c. * exceptions.h (exception_print_same): Declare. * exec.h: Include "symfile-add-flags.h". (try_open_exec_file): New declaration. * exec.c (exception_print_same): Moved to exceptions.c. (try_open_exec_file): New function. (exec_file_locate_attach): Rename exec_file and full_exec_path variables to avoid confusion between target and host pathnames. Move pathname processing logic to exec_file_find. Do not return early if pathname lookup fails; Call try_open_exec_file. * infrun.c (follow_exec): Split and rename execd_pathname variable to avoid confusion between target and host pathnames. Warn if pathname lookup fails. Pass target pathname to target_follow_exec, not hostpathname. Call try_open_exec_file. * main.c (symbol_file_add_main_adapter): New function. (captured_main_1): Use it. * solib-svr4.c (open_symbol_file_object): Adjust to pass symfile_add_flags to symbol_file_add_main. * solib.c (exec_file_find): Incorporate fallback logic for relative pathnames formerly in exec_file_locate_attach. * symfile.c (symbol_file_add_main, symbol_file_add_main_1): Replace 'from_tty' parameter with a symfile_add_file. (symbol_file_command): Adjust to pass symfile_add_flags to symbol_file_add_main. * symfile.h (symbol_file_add_main): Replace 'from_tty' parameter with a symfile_add_file. gdb/testsuite/ChangeLog: 2016-10-25 Luis Machado <lgustavo@codesourcery.com> * gdb.base/exec-invalid-sysroot.exp: New file.
2016-10-26 19:12:01 +02:00
else
{
/* It's possible we don't have a full path, but rather just a
filename. Some targets, such as HP-UX, don't provide the
full path, sigh.
Attempt to qualify the filename against the source path.
(If that fails, we'll just fall back on the original
filename. Not much more we can do...) */
if (!source_full_path_of (in_pathname, &result))
result.reset (xstrdup (in_pathname));
PR 20569, segv in follow_exec The following testcases make GDB crash whenever an invalid sysroot is provided, when GDB is unable to find a valid path to the symbol file: gdb.base/catch-syscall.exp gdb.base/execl-update-breakpoints.exp gdb.base/foll-exec-mode.exp gdb.base/foll-exec.exp gdb.base/foll-vfork.exp gdb.base/pie-execl.exp gdb.multi/bkpt-multi-exec.exp gdb.python/py-finish-breakpoint.exp gdb.threads/execl.exp gdb.threads/non-ldr-exc-1.exp gdb.threads/non-ldr-exc-2.exp gdb.threads/non-ldr-exc-3.exp gdb.threads/non-ldr-exc-4.exp gdb.threads/thread-execl.exp The immediate cause of the segv is that follow_exec is passing a NULL argument (the result of exec_file_find) to strlen. However, the problem is deeper than that: follow_exec simply isn't prepared for the case where sysroot translation fails to locate the new executable. Actually all callers of exec_file_find have bugs due to confusion between host and target pathnames. This commit attempts to fix all that. In terms of the testcases that were formerly segv'ing, GDB now prints a warning but continues execution of the new program, so that the tests now mostly FAIL instead. You could argue the FAILs are due to a legitimate problem with the test environment setting up the sysroot translation incorrectly. A new representative test is added which exercises the ne wwarning code path even with native testing. Tested on x86_64 Fedora 23, native and gdbserver. gdb/ChangeLog: 2016-10-25 Sandra Loosemore <sandra@codesourcery.com> Luis Machado <lgustavo@codesourcery.com> Pedro Alves <palves@redhat.com> PR gdb/20569 * exceptions.c (exception_print_same): Moved here from exec.c. * exceptions.h (exception_print_same): Declare. * exec.h: Include "symfile-add-flags.h". (try_open_exec_file): New declaration. * exec.c (exception_print_same): Moved to exceptions.c. (try_open_exec_file): New function. (exec_file_locate_attach): Rename exec_file and full_exec_path variables to avoid confusion between target and host pathnames. Move pathname processing logic to exec_file_find. Do not return early if pathname lookup fails; Call try_open_exec_file. * infrun.c (follow_exec): Split and rename execd_pathname variable to avoid confusion between target and host pathnames. Warn if pathname lookup fails. Pass target pathname to target_follow_exec, not hostpathname. Call try_open_exec_file. * main.c (symbol_file_add_main_adapter): New function. (captured_main_1): Use it. * solib-svr4.c (open_symbol_file_object): Adjust to pass symfile_add_flags to symbol_file_add_main. * solib.c (exec_file_find): Incorporate fallback logic for relative pathnames formerly in exec_file_locate_attach. * symfile.c (symbol_file_add_main, symbol_file_add_main_1): Replace 'from_tty' parameter with a symfile_add_file. (symbol_file_command): Adjust to pass symfile_add_flags to symbol_file_add_main. * symfile.h (symbol_file_add_main): Replace 'from_tty' parameter with a symfile_add_file. gdb/testsuite/ChangeLog: 2016-10-25 Luis Machado <lgustavo@codesourcery.com> * gdb.base/exec-invalid-sysroot.exp: New file.
2016-10-26 19:12:01 +02:00
if (fd != NULL)
*fd = -1;
}
return result;
}
/* Return the full pathname of a shared library file, or NULL if not
found. If FD is non-NULL, *FD is set to either -1 or an open file
handle for the shared library.
The search algorithm used is described in solib_find_1's comment
above. */
gdb::unique_xmalloc_ptr<char>
solib_find (const char *in_pathname, int *fd)
{
const char *solib_symbols_extension
= gdbarch_solib_symbols_extension (target_gdbarch ());
/* If solib_symbols_extension is set, replace the file's
extension. */
if (solib_symbols_extension != NULL)
{
const char *p = in_pathname + strlen (in_pathname);
while (p > in_pathname && *p != '.')
p--;
if (*p == '.')
{
char *new_pathname;
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
new_pathname
= (char *) alloca (p - in_pathname + 1
+ strlen (solib_symbols_extension) + 1);
memcpy (new_pathname, in_pathname, p - in_pathname + 1);
strcpy (new_pathname + (p - in_pathname) + 1,
solib_symbols_extension);
in_pathname = new_pathname;
}
}
return solib_find_1 (in_pathname, fd, true);
}
/* Open and return a BFD for the shared library PATHNAME. If FD is not -1,
it is used as file handle to open the file. Throws an error if the file
could not be opened. Handles both local and remote file access.
If unsuccessful, the FD will be closed (unless FD was -1). */
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
gdb_bfd_ref_ptr
solib_bfd_fopen (const char *pathname, int fd)
{
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
gdb_bfd_ref_ptr abfd (gdb_bfd_open (pathname, gnutarget, fd));
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
if (abfd != NULL && !gdb_bfd_has_target_filename (abfd.get ()))
bfd_set_cacheable (abfd.get (), 1);
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
if (abfd == NULL)
{
/* Arrange to free PATHNAME when the error is thrown. */
error (_("Could not open `%s' as an executable file: %s"),
pathname, bfd_errmsg (bfd_get_error ()));
}
return abfd;
}
/* Find shared library PATHNAME and open a BFD for it. */
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
gdb_bfd_ref_ptr
solib_bfd_open (const char *pathname)
{
int found_file;
const struct bfd_arch_info *b;
/* Search for shared library file. */
gdb::unique_xmalloc_ptr<char> found_pathname
= solib_find (pathname, &found_file);
if (found_pathname == NULL)
{
/* Return failure if the file could not be found, so that we can
accumulate messages about missing libraries. */
if (errno == ENOENT)
return NULL;
perror_with_name (pathname);
}
/* Open bfd for shared library. */
gdb_bfd_ref_ptr abfd (solib_bfd_fopen (found_pathname.get (), found_file));
/* Check bfd format. */
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
if (!bfd_check_format (abfd.get (), bfd_object))
error (_("`%s': not in executable format: %s"),
bfd macro conversion to inline functions This converts some of the macros that access struct bfd fields to inline functions. bfd/ * archive.c (bfd_generic_archive_p): Use bfd_set_thin_archive. * bfd-in.h (bfd_get_filename, bfd_get_cacheable, bfd_get_format), (bfd_get_target, bfd_get_flavour, bfd_family_coff, bfd_big_endian), (bfd_little_endian, bfd_header_big_endian, bfd_header_little_endian), (bfd_get_file_flags, bfd_applicable_file_flags), (bfd_applicable_section_flags, bfd_has_map, bfd_is_thin_archive), (bfd_valid_reloc_types, bfd_usrdata, bfd_get_start_address), (bfd_get_symcount, bfd_get_outsymbols, bfd_count_sections), (bfd_get_dynamic_symcount, bfd_get_symbol_leading_char): Delete. * bfd/bfd.c (bfd_get_filename, bfd_get_cacheable, bfd_get_format), (bfd_get_file_flags, bfd_get_start_address, bfd_get_symcount), (bfd_get_dynamic_symcount, bfd_get_outsymbols, bfd_count_sections), (bfd_has_map, bfd_is_thin_archive, bfd_set_thin_archive), (bfd_usrdata, bfd_set_usrdata): New inline functions. * targets.c (bfd_get_target, bfd_get_flavour), (bfd_applicable_file_flags, bfd_family_coff, bfd_big_endian), (bfd_little_endian, bfd_header_big_endian), (bfd_header_little_endian, bfd_applicable_section_flags), (bfd_get_symbol_leading_char): New inline functions. * bfd-in2.h: Regenerate. binutils/ * ar.c (write_archive): Use bfd_set_thin_archive. gdb/ * gdb_bfd.c (gdb_bfd_ref, gdb_bfd_unref): Use bfd_set_usrdata. * dwarf2read.c (dwarf2_read_gdb_index, dwarf2_read_debug_names), (read_indirect_string_from_dwz): Use bfd accessor. * dwarf2read.h (struct dwz_file <filename>): Likewise. * machoread.c (macho_symfile_read_all_oso): Likewise. * solib.c (solib_bfd_open): Likewise. ld/ * ldelf.c (ldelf_after_open, ldelf_place_orphan * ldlang.c (walk_wild_file, lang_process): Use bfd_usrdata. (load_symbols, ldlang_add_file): Use bfd_set_usrdata. * ldmain.c (add_archive_element): Use bfd_usrdata. * ldlang.h (bfd_input_just_syms): New inline function. * emultempl/aarch64elf.em (build_section_lists): Use it. * emultempl/mmo.em (mmo_place_orphan): Likewise. * emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Likewise. * emultempl/pep.em (gld_${EMULATION_NAME}_place_orphan): Likewise. * emultempl/ppc64elf.em (build_section_lists): Likewise. sim/ * ppc/emul_generic.c (emul_add_tree_options): Delete old bfd code.
2019-09-19 04:21:04 +02:00
bfd_get_filename (abfd.get ()), bfd_errmsg (bfd_get_error ()));
/* Check bfd arch. */
b = gdbarch_bfd_arch_info (target_gdbarch ());
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
if (!b->compatible (b, bfd_get_arch_info (abfd.get ())))
warning (_("`%s': Shared library architecture %s is not compatible "
bfd macro conversion to inline functions This converts some of the macros that access struct bfd fields to inline functions. bfd/ * archive.c (bfd_generic_archive_p): Use bfd_set_thin_archive. * bfd-in.h (bfd_get_filename, bfd_get_cacheable, bfd_get_format), (bfd_get_target, bfd_get_flavour, bfd_family_coff, bfd_big_endian), (bfd_little_endian, bfd_header_big_endian, bfd_header_little_endian), (bfd_get_file_flags, bfd_applicable_file_flags), (bfd_applicable_section_flags, bfd_has_map, bfd_is_thin_archive), (bfd_valid_reloc_types, bfd_usrdata, bfd_get_start_address), (bfd_get_symcount, bfd_get_outsymbols, bfd_count_sections), (bfd_get_dynamic_symcount, bfd_get_symbol_leading_char): Delete. * bfd/bfd.c (bfd_get_filename, bfd_get_cacheable, bfd_get_format), (bfd_get_file_flags, bfd_get_start_address, bfd_get_symcount), (bfd_get_dynamic_symcount, bfd_get_outsymbols, bfd_count_sections), (bfd_has_map, bfd_is_thin_archive, bfd_set_thin_archive), (bfd_usrdata, bfd_set_usrdata): New inline functions. * targets.c (bfd_get_target, bfd_get_flavour), (bfd_applicable_file_flags, bfd_family_coff, bfd_big_endian), (bfd_little_endian, bfd_header_big_endian), (bfd_header_little_endian, bfd_applicable_section_flags), (bfd_get_symbol_leading_char): New inline functions. * bfd-in2.h: Regenerate. binutils/ * ar.c (write_archive): Use bfd_set_thin_archive. gdb/ * gdb_bfd.c (gdb_bfd_ref, gdb_bfd_unref): Use bfd_set_usrdata. * dwarf2read.c (dwarf2_read_gdb_index, dwarf2_read_debug_names), (read_indirect_string_from_dwz): Use bfd accessor. * dwarf2read.h (struct dwz_file <filename>): Likewise. * machoread.c (macho_symfile_read_all_oso): Likewise. * solib.c (solib_bfd_open): Likewise. ld/ * ldelf.c (ldelf_after_open, ldelf_place_orphan * ldlang.c (walk_wild_file, lang_process): Use bfd_usrdata. (load_symbols, ldlang_add_file): Use bfd_set_usrdata. * ldmain.c (add_archive_element): Use bfd_usrdata. * ldlang.h (bfd_input_just_syms): New inline function. * emultempl/aarch64elf.em (build_section_lists): Use it. * emultempl/mmo.em (mmo_place_orphan): Likewise. * emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Likewise. * emultempl/pep.em (gld_${EMULATION_NAME}_place_orphan): Likewise. * emultempl/ppc64elf.em (build_section_lists): Likewise. sim/ * ppc/emul_generic.c (emul_add_tree_options): Delete old bfd code.
2019-09-19 04:21:04 +02:00
"with target architecture %s."), bfd_get_filename (abfd.get ()),
bfd_get_arch_info (abfd.get ())->printable_name,
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
b->printable_name);
return abfd;
}
/* Given a pointer to one of the shared objects in our list of mapped
objects, use the recorded name to open a bfd descriptor for the
object, build a section table, relocate all the section addresses
by the base address at which the shared object was mapped, and then
add the sections to the target's section table.
FIXME: In most (all?) cases the shared object file name recorded in
the dynamic linkage tables will be a fully qualified pathname. For
1999-07-07 22:19:36 +02:00
cases where it isn't, do we really mimic the systems search
mechanism correctly in the below code (particularly the tilde
expansion stuff?). */
static int
solib_map_sections (struct so_list *so)
{
const struct target_so_ops *ops = solib_ops (target_gdbarch ());
struct target_section *p;
1999-07-07 22:19:36 +02:00
gdb::unique_xmalloc_ptr<char> filename (tilde_expand (so->so_name));
gdb_bfd_ref_ptr abfd (ops->bfd_open (filename.get ()));
if (abfd == NULL)
return 0;
2000-10-24 22:05:36 +02:00
/* Leave bfd open, core_xfer_memory and "info files" need it. */
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
so->abfd = abfd.release ();
/* Copy the full path name into so_name, allowing symbol_file_add
to find it later. This also affects the =library-loaded GDB/MI
event, and in particular the part of that notification providing
the library's host-side path. If we let the target dictate
that objfile's path, and the target is different from the host,
GDB/MI will not provide the correct host-side path. */
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
if (strlen (bfd_get_filename (so->abfd)) >= SO_NAME_MAX_PATH_SIZE)
error (_("Shared library file name is too long."));
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
strcpy (so->so_name, bfd_get_filename (so->abfd));
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
if (build_section_table (so->abfd, &so->sections, &so->sections_end))
{
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 (_("Can't find the file sections in `%s': %s"),
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
bfd_get_filename (so->abfd), bfd_errmsg (bfd_get_error ()));
}
1999-08-31 03:14:27 +02:00
2000-10-24 22:05:36 +02:00
for (p = so->sections; p < so->sections_end; p++)
1999-08-31 03:14:27 +02:00
{
2000-10-24 22:05:36 +02:00
/* Relocate the section binding addresses as recorded in the shared
object's file by the base address to which the object was actually
mapped. */
ops->relocate_section_addresses (so, p);
/* If the target didn't provide information about the address
range of the shared object, assume we want the location of
the .text section. */
if (so->addr_low == 0 && so->addr_high == 0
&& strcmp (p->the_bfd_section->name, ".text") == 0)
2000-10-24 22:05:36 +02:00
{
so->addr_low = p->addr;
so->addr_high = p->endaddr;
2000-10-24 22:05:36 +02:00
}
1999-08-31 03:14:27 +02:00
}
/* Add the shared object's sections to the current set of file
section tables. Do this immediately after mapping the object so
that later nodes in the list can query this object, as is needed
in solib-osf.c. */
add_target_sections (so, so->sections, so->sections_end);
return 1;
1999-08-31 03:14:27 +02:00
}
/* Free symbol-file related contents of SO and reset for possible reloading
of SO. If we have opened a BFD for SO, close it. If we have placed SO's
sections in some target's section table, the caller is responsible for
removing them.
This function doesn't mess with objfiles at all. If there is an
objfile associated with SO that needs to be removed, the caller is
responsible for taking care of that. */
static void
clear_so (struct so_list *so)
{
const struct target_so_ops *ops = solib_ops (target_gdbarch ());
if (so->sections)
{
xfree (so->sections);
so->sections = so->sections_end = NULL;
}
gdb_bfd_unref (so->abfd);
so->abfd = NULL;
/* Our caller closed the objfile, possibly via objfile_purge_solibs. */
so->symbols_loaded = 0;
so->objfile = NULL;
so->addr_low = so->addr_high = 0;
/* Restore the target-supplied file name. SO_NAME may be the path
of the symbol file. */
strcpy (so->so_name, so->so_original_name);
/* Do the same for target-specific data. */
if (ops->clear_so != NULL)
ops->clear_so (so);
}
/* Free the storage associated with the `struct so_list' object SO.
If we have opened a BFD for SO, close it.
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
The caller is responsible for removing SO from whatever list it is
a member of. If we have placed SO's sections in some target's
section table, the caller is responsible for removing them.
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
This function doesn't mess with objfiles at all. If there is an
objfile associated with SO that needs to be removed, the caller is
responsible for taking care of that. */
2000-10-24 22:05:36 +02:00
void
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
free_so (struct so_list *so)
{
const struct target_so_ops *ops = solib_ops (target_gdbarch ());
1999-07-07 22:19:36 +02:00
clear_so (so);
ops->free_so (so);
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
2000-12-15 02:01:51 +01:00
xfree (so);
}
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
/* Read in symbols for shared object SO. If SYMFILE_VERBOSE is set in FLAGS,
be chatty about it. Return true if any symbols were actually loaded. */
bool
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
solib_read_symbols (struct so_list *so, symfile_add_flags flags)
{
if (so->symbols_loaded)
{
/* If needed, we've already warned in our caller. */
}
else if (so->abfd == NULL)
{
/* We've already warned about this library, when trying to open
it. */
}
else
{
flags |= current_inferior ()->symfile_flags;
Rewrite TRY/CATCH This rewrites gdb's TRY/CATCH to plain C++ try/catch. The patch was largely written by script, though one change (to a comment in common-exceptions.h) was reverted by hand. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * xml-support.c: Use C++ exception handling. * x86-linux-nat.c: Use C++ exception handling. * windows-nat.c: Use C++ exception handling. * varobj.c: Use C++ exception handling. * value.c: Use C++ exception handling. * valprint.c: Use C++ exception handling. * valops.c: Use C++ exception handling. * unittests/parse-connection-spec-selftests.c: Use C++ exception handling. * unittests/cli-utils-selftests.c: Use C++ exception handling. * typeprint.c: Use C++ exception handling. * tui/tui.c: Use C++ exception handling. * tracefile-tfile.c: Use C++ exception handling. * top.c: Use C++ exception handling. * thread.c: Use C++ exception handling. * target.c: Use C++ exception handling. * symmisc.c: Use C++ exception handling. * symfile-mem.c: Use C++ exception handling. * stack.c: Use C++ exception handling. * sparc64-linux-tdep.c: Use C++ exception handling. * solib.c: Use C++ exception handling. * solib-svr4.c: Use C++ exception handling. * solib-spu.c: Use C++ exception handling. * solib-frv.c: Use C++ exception handling. * solib-dsbt.c: Use C++ exception handling. * selftest-arch.c: Use C++ exception handling. * s390-tdep.c: Use C++ exception handling. * rust-lang.c: Use C++ exception handling. * rust-exp.y: Use C++ exception handling. * rs6000-tdep.c: Use C++ exception handling. * rs6000-aix-tdep.c: Use C++ exception handling. * riscv-tdep.c: Use C++ exception handling. * remote.c: Use C++ exception handling. * remote-fileio.c: Use C++ exception handling. * record-full.c: Use C++ exception handling. * record-btrace.c: Use C++ exception handling. * python/python.c: Use C++ exception handling. * python/py-value.c: Use C++ exception handling. * python/py-utils.c: Use C++ exception handling. * python/py-unwind.c: Use C++ exception handling. * python/py-type.c: Use C++ exception handling. * python/py-symbol.c: Use C++ exception handling. * python/py-record.c: Use C++ exception handling. * python/py-record-btrace.c: Use C++ exception handling. * python/py-progspace.c: Use C++ exception handling. * python/py-prettyprint.c: Use C++ exception handling. * python/py-param.c: Use C++ exception handling. * python/py-objfile.c: Use C++ exception handling. * python/py-linetable.c: Use C++ exception handling. * python/py-lazy-string.c: Use C++ exception handling. * python/py-infthread.c: Use C++ exception handling. * python/py-inferior.c: Use C++ exception handling. * python/py-gdb-readline.c: Use C++ exception handling. * python/py-framefilter.c: Use C++ exception handling. * python/py-frame.c: Use C++ exception handling. * python/py-finishbreakpoint.c: Use C++ exception handling. * python/py-cmd.c: Use C++ exception handling. * python/py-breakpoint.c: Use C++ exception handling. * python/py-arch.c: Use C++ exception handling. * printcmd.c: Use C++ exception handling. * ppc-linux-tdep.c: Use C++ exception handling. * parse.c: Use C++ exception handling. * p-valprint.c: Use C++ exception handling. * objc-lang.c: Use C++ exception handling. * mi/mi-main.c: Use C++ exception handling. * mi/mi-interp.c: Use C++ exception handling. * mi/mi-cmd-stack.c: Use C++ exception handling. * mi/mi-cmd-break.c: Use C++ exception handling. * main.c: Use C++ exception handling. * linux-thread-db.c: Use C++ exception handling. * linux-tdep.c: Use C++ exception handling. * linux-nat.c: Use C++ exception handling. * linux-fork.c: Use C++ exception handling. * linespec.c: Use C++ exception handling. * language.c: Use C++ exception handling. * jit.c: Use C++ exception handling. * infrun.c: Use C++ exception handling. * infcmd.c: Use C++ exception handling. * infcall.c: Use C++ exception handling. * inf-loop.c: Use C++ exception handling. * i386-tdep.c: Use C++ exception handling. * i386-linux-tdep.c: Use C++ exception handling. * guile/scm-value.c: Use C++ exception handling. * guile/scm-type.c: Use C++ exception handling. * guile/scm-symtab.c: Use C++ exception handling. * guile/scm-symbol.c: Use C++ exception handling. * guile/scm-pretty-print.c: Use C++ exception handling. * guile/scm-ports.c: Use C++ exception handling. * guile/scm-param.c: Use C++ exception handling. * guile/scm-math.c: Use C++ exception handling. * guile/scm-lazy-string.c: Use C++ exception handling. * guile/scm-frame.c: Use C++ exception handling. * guile/scm-disasm.c: Use C++ exception handling. * guile/scm-cmd.c: Use C++ exception handling. * guile/scm-breakpoint.c: Use C++ exception handling. * guile/scm-block.c: Use C++ exception handling. * guile/guile-internal.h: Use C++ exception handling. * gnu-v3-abi.c: Use C++ exception handling. * gdbtypes.c: Use C++ exception handling. * frame.c: Use C++ exception handling. * frame-unwind.c: Use C++ exception handling. * fbsd-tdep.c: Use C++ exception handling. * f-valprint.c: Use C++ exception handling. * exec.c: Use C++ exception handling. * event-top.c: Use C++ exception handling. * event-loop.c: Use C++ exception handling. * eval.c: Use C++ exception handling. * dwarf2read.c: Use C++ exception handling. * dwarf2loc.c: Use C++ exception handling. * dwarf2-frame.c: Use C++ exception handling. * dwarf2-frame-tailcall.c: Use C++ exception handling. * dwarf-index-write.c: Use C++ exception handling. * dwarf-index-cache.c: Use C++ exception handling. * dtrace-probe.c: Use C++ exception handling. * disasm-selftests.c: Use C++ exception handling. * darwin-nat.c: Use C++ exception handling. * cp-valprint.c: Use C++ exception handling. * cp-support.c: Use C++ exception handling. * cp-abi.c: Use C++ exception handling. * corelow.c: Use C++ exception handling. * completer.c: Use C++ exception handling. * compile/compile-object-run.c: Use C++ exception handling. * compile/compile-object-load.c: Use C++ exception handling. * compile/compile-cplus-symbols.c: Use C++ exception handling. * compile/compile-c-symbols.c: Use C++ exception handling. * common/selftest.c: Use C++ exception handling. * common/new-op.c: Use C++ exception handling. * cli/cli-script.c: Use C++ exception handling. * cli/cli-interp.c: Use C++ exception handling. * cli/cli-cmds.c: Use C++ exception handling. * c-varobj.c: Use C++ exception handling. * btrace.c: Use C++ exception handling. * breakpoint.c: Use C++ exception handling. * break-catch-throw.c: Use C++ exception handling. * arch-utils.c: Use C++ exception handling. * amd64-tdep.c: Use C++ exception handling. * ada-valprint.c: Use C++ exception handling. * ada-typeprint.c: Use C++ exception handling. * ada-lang.c: Use C++ exception handling. * aarch64-tdep.c: Use C++ exception handling. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * server.c: Use C++ exception handling. * linux-low.c: Use C++ exception handling. * gdbreplay.c: Use C++ exception handling.
2019-04-04 00:02:42 +02:00
try
{
/* Have we already loaded this shared object? */
Remove most uses of ALL_OBJFILES This removes most uses of ALL_OBJFILES, replacing them with ranged for loops. The remaining uses are all in macros, and will be removed in subsequent patches. gdb/ChangeLog 2019-01-09 Tom Tromey <tom@tromey.com> * symtab.c (iterate_over_symtabs, matching_obj_sections) (expand_symtab_containing_pc, lookup_static_symbol) (basic_lookup_transparent_type, find_pc_sect_compunit_symtab) (find_symbol_at_address, find_line_symtab, find_main_name): Use all_objfiles. * probe.c (find_probe_by_pc, collect_probes): Use all_objfiles. * breakpoint.c (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Use all_objfiles. * linux-thread-db.c (try_thread_db_load_from_pdir) (has_libpthread): Use all_objfiles. * ada-lang.c (add_nonlocal_symbols): Use all_objfiles. * linespec.c (iterate_over_all_matching_symtabs) (search_minsyms_for_name): Use all_objfiles. * maint.c (maintenance_info_sections): Use all_objfiles. * main.c (captured_main_1): Use all_objfiles. * spu-tdep.c (spu_objfile_from_frame): Use all_objfiles. * guile/scm-objfile.c (gdbscm_objfiles): Use all_objfiles. * guile/scm-pretty-print.c (ppscm_find_pretty_printer_from_objfiles): Use all_objfiles. * solib-spu.c (append_ocl_sos): Use all_objfiles. * symmisc.c (maintenance_print_symbols): Use all_objfiles. (maintenance_print_msymbols): Use all_objfiles. * source.c (select_source_symtab): Use all_objfiles. * jit.c (jit_find_objf_with_entry_addr): Use all_objfiles. * symfile.c (remove_symbol_file_command) (expand_symtabs_matching, map_symbol_filenames): Use all_objfiles. * ppc-linux-tdep.c (ppc_linux_spe_context_inferior_created): Use all_objfiles. * dwarf2-frame.c (dwarf2_frame_find_fde): Use all_objfiles. * objc-lang.c (find_methods): Use all_objfiles. * objfiles.c (have_partial_symbols, have_full_symbols) (have_minimal_symbols, qsort_cmp) (default_iterate_over_objfiles_in_search_order): Use all_objfiles. * hppa-tdep.c (find_unwind_entry): Use all_objfiles. * psymtab.c (maintenance_print_psymbols): Use all_objfiles. (maintenance_check_psymtabs): Use all_objfiles. (ALL_PSYMTABS): Remove. * compile/compile-object-run.c (do_module_cleanup): Use all_objfiles. * blockframe.c (find_pc_partial_function): Use all_objfiles. * cp-support.c (add_symbol_overload_list_qualified): Use all_objfiles. * windows-tdep.c (windows_iterate_over_objfiles_in_search_order): Use all_objfiles. * dwarf-index-write.c (save_gdb_index_command): Use all_objfiles. * python/py-xmethods.c (gdbpy_get_matching_xmethod_workers): Use all_objfiles. * python/py-objfile.c (objfpy_lookup_objfile_by_name) (objfpy_lookup_objfile_by_build_id): Use all_objfiles. * python/py-prettyprint.c (find_pretty_printer_from_objfiles): Uses all_objfiles. * solib.c (solib_read_symbols): Use all_objfiles
2018-11-23 20:20:05 +01:00
so->objfile = nullptr;
Change all_objfiles adapter to be a method on program_space This changes the all_objfiles range adapter to be a method on the program space, and fixes up all the users. gdb/ChangeLog 2019-01-17 Tom Tromey <tom@tromey.com> * progspace.h (program_space) <objfiles_range>: New typedef. <objfiles>: New method. <objfiles_head>: Rename from objfiles. (object_files): Update. * guile/scm-progspace.c (gdbscm_progspace_objfiles): Update. * guile/scm-pretty-print.c (ppscm_find_pretty_printer_from_objfiles): Update. * guile/scm-objfile.c (gdbscm_objfiles): Update. * python/py-xmethods.c (gdbpy_get_matching_xmethod_workers): Update. * python/py-progspace.c (pspy_get_objfiles): Update. * python/py-prettyprint.c (find_pretty_printer_from_objfiles): Update. * python/py-objfile.c (objfpy_lookup_objfile_by_name) (objfpy_lookup_objfile_by_build_id): Update. * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update. * windows-tdep.c (windows_iterate_over_objfiles_in_search_order): Update. * symtab.c (iterate_over_symtabs, matching_obj_sections) (expand_symtab_containing_pc, lookup_objfile_from_block) (lookup_static_symbol, basic_lookup_transparent_type) (find_pc_sect_compunit_symtab, find_symbol_at_address) (find_line_symtab, info_sources_command) (default_collect_symbol_completion_matches_break_on) (make_source_files_completion_list, find_main_name): Update. * symmisc.c (print_symbol_bcache_statistics) (print_objfile_statistics, maintenance_print_symbols) (maintenance_print_msymbols, maintenance_print_objfiles) (maintenance_info_symtabs, maintenance_check_symtabs) (maintenance_expand_symtabs, maintenance_info_line_tables): Update. * symfile.c (remove_symbol_file_command, overlay_invalidate_all) (find_pc_overlay, find_pc_mapped_section, list_overlays_command) (map_overlay_command, unmap_overlay_command) (simple_overlay_update, expand_symtabs_matching) (map_symbol_filenames): Update. * symfile-debug.c (set_debug_symfile): Update. * spu-tdep.c (spu_overlay_update, spu_objfile_from_frame): Update. * source.c (select_source_symtab, forget_cached_source_info): Update. * solib.c (solib_read_symbols): Update. * solib-spu.c (append_ocl_sos): Update. * psymtab.c (maintenance_print_psymbols) (maintenance_info_psymtabs, maintenance_check_psymtabs): Update. * probe.c (parse_probes_in_pspace, find_probe_by_pc): Update. * printcmd.c (info_symbol_command): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_inferior_created): Update. * objfiles.h (class all_objfiles): Remove. * objfiles.c (have_partial_symbols, have_full_symbols) (have_minimal_symbols, qsort_cmp, update_section_map) (shared_objfile_contains_address_p) (default_iterate_over_objfiles_in_search_order): Update. * objc-lang.c (info_selectors_command, info_classes_command) (find_methods): Update. * minsyms.c (find_solib_trampoline_target): Update. * maint.c (maintenance_info_sections) (maintenance_translate_address, count_symtabs_and_blocks): Update. * main.c (captured_main_1): Update. * linux-thread-db.c (try_thread_db_load_from_pdir) (has_libpthread): Update. * linespec.c (iterate_over_all_matching_symtabs) (search_minsyms_for_name): Update. * jit.c (jit_find_objf_with_entry_addr): Update. * hppa-tdep.c (find_unwind_entry) (hppa_lookup_stub_minimal_symbol): Update. * gcore.c (gcore_create_callback, objfile_find_memory_regions): Update. * elfread.c (elf_gnu_ifunc_resolve_by_cache) (elf_gnu_ifunc_resolve_by_got): Update. * dwarf2-frame.c (dwarf2_frame_find_fde): Update. * dwarf-index-write.c (save_gdb_index_command): Update. * cp-support.c (add_symbol_overload_list_qualified): Update. * breakpoint.c (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * blockframe.c (find_pc_partial_function): Update. * ada-lang.c (ada_lookup_simple_minsym, add_nonlocal_symbols) (ada_collect_symbol_completion_matches) (ada_add_global_exceptions): Update.
2019-01-16 00:55:05 +01:00
for (objfile *objfile : current_program_space->objfiles ())
{
Remove most uses of ALL_OBJFILES This removes most uses of ALL_OBJFILES, replacing them with ranged for loops. The remaining uses are all in macros, and will be removed in subsequent patches. gdb/ChangeLog 2019-01-09 Tom Tromey <tom@tromey.com> * symtab.c (iterate_over_symtabs, matching_obj_sections) (expand_symtab_containing_pc, lookup_static_symbol) (basic_lookup_transparent_type, find_pc_sect_compunit_symtab) (find_symbol_at_address, find_line_symtab, find_main_name): Use all_objfiles. * probe.c (find_probe_by_pc, collect_probes): Use all_objfiles. * breakpoint.c (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Use all_objfiles. * linux-thread-db.c (try_thread_db_load_from_pdir) (has_libpthread): Use all_objfiles. * ada-lang.c (add_nonlocal_symbols): Use all_objfiles. * linespec.c (iterate_over_all_matching_symtabs) (search_minsyms_for_name): Use all_objfiles. * maint.c (maintenance_info_sections): Use all_objfiles. * main.c (captured_main_1): Use all_objfiles. * spu-tdep.c (spu_objfile_from_frame): Use all_objfiles. * guile/scm-objfile.c (gdbscm_objfiles): Use all_objfiles. * guile/scm-pretty-print.c (ppscm_find_pretty_printer_from_objfiles): Use all_objfiles. * solib-spu.c (append_ocl_sos): Use all_objfiles. * symmisc.c (maintenance_print_symbols): Use all_objfiles. (maintenance_print_msymbols): Use all_objfiles. * source.c (select_source_symtab): Use all_objfiles. * jit.c (jit_find_objf_with_entry_addr): Use all_objfiles. * symfile.c (remove_symbol_file_command) (expand_symtabs_matching, map_symbol_filenames): Use all_objfiles. * ppc-linux-tdep.c (ppc_linux_spe_context_inferior_created): Use all_objfiles. * dwarf2-frame.c (dwarf2_frame_find_fde): Use all_objfiles. * objc-lang.c (find_methods): Use all_objfiles. * objfiles.c (have_partial_symbols, have_full_symbols) (have_minimal_symbols, qsort_cmp) (default_iterate_over_objfiles_in_search_order): Use all_objfiles. * hppa-tdep.c (find_unwind_entry): Use all_objfiles. * psymtab.c (maintenance_print_psymbols): Use all_objfiles. (maintenance_check_psymtabs): Use all_objfiles. (ALL_PSYMTABS): Remove. * compile/compile-object-run.c (do_module_cleanup): Use all_objfiles. * blockframe.c (find_pc_partial_function): Use all_objfiles. * cp-support.c (add_symbol_overload_list_qualified): Use all_objfiles. * windows-tdep.c (windows_iterate_over_objfiles_in_search_order): Use all_objfiles. * dwarf-index-write.c (save_gdb_index_command): Use all_objfiles. * python/py-xmethods.c (gdbpy_get_matching_xmethod_workers): Use all_objfiles. * python/py-objfile.c (objfpy_lookup_objfile_by_name) (objfpy_lookup_objfile_by_build_id): Use all_objfiles. * python/py-prettyprint.c (find_pretty_printer_from_objfiles): Uses all_objfiles. * solib.c (solib_read_symbols): Use all_objfiles
2018-11-23 20:20:05 +01:00
if (filename_cmp (objfile_name (objfile), so->so_name) == 0
&& objfile->addr_low == so->addr_low)
{
so->objfile = objfile;
break;
}
}
if (so->objfile == NULL)
{
Remove make_cleanup_free_section_addr_info This removes make_cleanup_free_section_addr_info. Instead -- per Simon's suggestion -- this changes section_addr_info to be a std::vector. Regression tested by the buildbot. gdb/ChangeLog 2018-03-16 Tom Tromey <tom@tromey.com> * xcoffread.c (xcoff_symfile_offsets): Change type of "addrs". * utils.h (make_cleanup_free_section_addr_info): Don't declare. * utils.c (do_free_section_addr_info) (make_cleanup_free_section_addr_info): Remove. * symfile.h (struct other_sections): Add constructor. (struct section_addr_info): Remove. (section_addr_info): New typedef. (struct sym_fns) <sym_offsets>: Change type of parameter. (build_section_addr_info_from_objfile) (relative_addr_info_to_section_offsets, addr_info_make_relative) (default_symfile_offsets, symbol_file_add) (symbol_file_add_from_bfd) (build_section_addr_info_from_section_table): Update. (alloc_section_addr_info, free_section_addr_info): Don't declare. * symfile.c (alloc_section_addr_info): Remove. (build_section_addr_info_from_section_table): Change return type. Update. (build_section_addr_info_from_bfd) (build_section_addr_info_from_objfile): Likewise. (free_section_addr_info): Remove. (relative_addr_info_to_section_offsets): Change type of "addrs". (addrs_section_compar): Now a std::sort comparator. (addrs_section_sort): Change return type. (addr_info_make_relative): Change type of "addrs". Update. (default_symfile_offsets, syms_from_objfile_1) (syms_from_objfile, symbol_file_add_with_addrs): Likewise. (symbol_file_add_separate): Update. (symbol_file_add): Change type of "addrs". Update. (add_symbol_file_command): Update. Remove cleanups. * symfile-mem.c (symbol_file_add_from_memory): Update. Remove cleanups. * symfile-debug.c (debug_sym_offsets): Change type of "info". * solib.c (solib_read_symbols): Update. * objfiles.c (objfile_relocate): Update. Remove cleanups. * machoread.c (macho_symfile_offsets): Update. * jit.c (jit_bfd_try_read_symtab): Update.
2018-03-13 04:50:33 +01:00
section_addr_info sap
= build_section_addr_info_from_section_table (so->sections,
so->sections_end);
so->objfile = symbol_file_add_from_bfd (so->abfd, so->so_name,
Remove make_cleanup_free_section_addr_info This removes make_cleanup_free_section_addr_info. Instead -- per Simon's suggestion -- this changes section_addr_info to be a std::vector. Regression tested by the buildbot. gdb/ChangeLog 2018-03-16 Tom Tromey <tom@tromey.com> * xcoffread.c (xcoff_symfile_offsets): Change type of "addrs". * utils.h (make_cleanup_free_section_addr_info): Don't declare. * utils.c (do_free_section_addr_info) (make_cleanup_free_section_addr_info): Remove. * symfile.h (struct other_sections): Add constructor. (struct section_addr_info): Remove. (section_addr_info): New typedef. (struct sym_fns) <sym_offsets>: Change type of parameter. (build_section_addr_info_from_objfile) (relative_addr_info_to_section_offsets, addr_info_make_relative) (default_symfile_offsets, symbol_file_add) (symbol_file_add_from_bfd) (build_section_addr_info_from_section_table): Update. (alloc_section_addr_info, free_section_addr_info): Don't declare. * symfile.c (alloc_section_addr_info): Remove. (build_section_addr_info_from_section_table): Change return type. Update. (build_section_addr_info_from_bfd) (build_section_addr_info_from_objfile): Likewise. (free_section_addr_info): Remove. (relative_addr_info_to_section_offsets): Change type of "addrs". (addrs_section_compar): Now a std::sort comparator. (addrs_section_sort): Change return type. (addr_info_make_relative): Change type of "addrs". Update. (default_symfile_offsets, syms_from_objfile_1) (syms_from_objfile, symbol_file_add_with_addrs): Likewise. (symbol_file_add_separate): Update. (symbol_file_add): Change type of "addrs". Update. (add_symbol_file_command): Update. Remove cleanups. * symfile-mem.c (symbol_file_add_from_memory): Update. Remove cleanups. * symfile-debug.c (debug_sym_offsets): Change type of "info". * solib.c (solib_read_symbols): Update. * objfiles.c (objfile_relocate): Update. Remove cleanups. * machoread.c (macho_symfile_offsets): Update. * jit.c (jit_bfd_try_read_symtab): Update.
2018-03-13 04:50:33 +01:00
flags, &sap,
OBJF_SHARED, NULL);
so->objfile->addr_low = so->addr_low;
}
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
so->symbols_loaded = 1;
}
Rename gdb exception types This renames the gdb exception types. The old types were only needed due to the macros in common-exception.h that are now gone. The intermediate layer of gdb_exception_RETURN_MASK_ALL did not seem needed, so this patch removes it entirely. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * common/common-exceptions.h (gdb_exception_RETURN_MASK_ALL): Remove. (gdb_exception_error): Rename from gdb_exception_RETURN_MASK_ERROR. (gdb_exception_quit): Rename from gdb_exception_RETURN_MASK_QUIT. (gdb_quit_bad_alloc): Update. * aarch64-tdep.c: Update. * ada-lang.c: Update. * ada-typeprint.c: Update. * ada-valprint.c: Update. * amd64-tdep.c: Update. * arch-utils.c: Update. * break-catch-throw.c: Update. * breakpoint.c: Update. * btrace.c: Update. * c-varobj.c: Update. * cli/cli-cmds.c: Update. * cli/cli-interp.c: Update. * cli/cli-script.c: Update. * common/common-exceptions.c: Update. * common/new-op.c: Update. * common/selftest.c: Update. * compile/compile-c-symbols.c: Update. * compile/compile-cplus-symbols.c: Update. * compile/compile-object-load.c: Update. * compile/compile-object-run.c: Update. * completer.c: Update. * corelow.c: Update. * cp-abi.c: Update. * cp-support.c: Update. * cp-valprint.c: Update. * darwin-nat.c: Update. * disasm-selftests.c: Update. * dtrace-probe.c: Update. * dwarf-index-cache.c: Update. * dwarf-index-write.c: Update. * dwarf2-frame-tailcall.c: Update. * dwarf2-frame.c: Update. * dwarf2loc.c: Update. * dwarf2read.c: Update. * eval.c: Update. * event-loop.c: Update. * event-top.c: Update. * exec.c: Update. * f-valprint.c: Update. * fbsd-tdep.c: Update. * frame-unwind.c: Update. * frame.c: Update. * gdbtypes.c: Update. * gnu-v3-abi.c: Update. * guile/guile-internal.h: Update. * guile/scm-block.c: Update. * guile/scm-breakpoint.c: Update. * guile/scm-cmd.c: Update. * guile/scm-disasm.c: Update. * guile/scm-frame.c: Update. * guile/scm-lazy-string.c: Update. * guile/scm-math.c: Update. * guile/scm-param.c: Update. * guile/scm-ports.c: Update. * guile/scm-pretty-print.c: Update. * guile/scm-symbol.c: Update. * guile/scm-symtab.c: Update. * guile/scm-type.c: Update. * guile/scm-value.c: Update. * i386-linux-tdep.c: Update. * i386-tdep.c: Update. * inf-loop.c: Update. * infcall.c: Update. * infcmd.c: Update. * infrun.c: Update. * jit.c: Update. * language.c: Update. * linespec.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * main.c: Update. * mi/mi-cmd-break.c: Update. * mi/mi-cmd-stack.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * objc-lang.c: Update. * p-valprint.c: Update. * parse.c: Update. * ppc-linux-tdep.c: Update. * printcmd.c: Update. * python/py-arch.c: Update. * python/py-breakpoint.c: Update. * python/py-cmd.c: Update. * python/py-finishbreakpoint.c: Update. * python/py-frame.c: Update. * python/py-framefilter.c: Update. * python/py-gdb-readline.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * python/py-lazy-string.c: Update. * python/py-linetable.c: Update. * python/py-objfile.c: Update. * python/py-param.c: Update. * python/py-prettyprint.c: Update. * python/py-progspace.c: Update. * python/py-record-btrace.c: Update. * python/py-record.c: Update. * python/py-symbol.c: Update. * python/py-type.c: Update. * python/py-unwind.c: Update. * python/py-utils.c: Update. * python/py-value.c: Update. * python/python.c: Update. * record-btrace.c: Update. * record-full.c: Update. * remote-fileio.c: Update. * remote.c: Update. * riscv-tdep.c: Update. * rs6000-aix-tdep.c: Update. * rs6000-tdep.c: Update. * rust-exp.y: Update. * rust-lang.c: Update. * s390-tdep.c: Update. * selftest-arch.c: Update. * solib-dsbt.c: Update. * solib-frv.c: Update. * solib-spu.c: Update. * solib-svr4.c: Update. * solib.c: Update. * sparc64-linux-tdep.c: Update. * stack.c: Update. * symfile-mem.c: Update. * symmisc.c: Update. * target.c: Update. * thread.c: Update. * top.c: Update. * tracefile-tfile.c: Update. * tui/tui.c: Update. * typeprint.c: Update. * unittests/cli-utils-selftests.c: Update. * unittests/parse-connection-spec-selftests.c: Update. * valops.c: Update. * valprint.c: Update. * value.c: Update. * varobj.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * xml-support.c: Update. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * gdbreplay.c: Update. * linux-low.c: Update. * server.c: Update.
2019-04-03 23:59:07 +02:00
catch (const gdb_exception_error &e)
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
{
exception_fprintf (gdb_stderr, e, _("Error while reading shared"
" library symbols for %s:\n"),
so->so_name);
}
return true;
}
return false;
}
/* Return true if KNOWN->objfile is used by any other so_list object
in the list of shared libraries. Return false otherwise. */
static bool
solib_used (const struct so_list *const known)
{
for (const struct so_list *pivot : current_program_space->solibs ())
if (pivot != known && pivot->objfile == known->objfile)
return true;
return false;
}
/* See solib.h. */
void
update_solib_list (int from_tty)
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
{
const struct target_so_ops *ops = solib_ops (target_gdbarch ());
struct so_list *inferior = ops->current_sos();
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
struct so_list *gdb, **gdb_link;
Remove the attach_flag global, and make it per-inferior. * inferior.h (attach_flag): Delete. (inferior_process): Declare. * solib.c (update_solib_list): Adjust. * gnu-nat.c (gnu_create_inferior, gnu_attach): Adjust. * inf-ptrace.c (inf_ptrace_detach): Adjust. (inf_ptrace_files_info): Get it from the current inferior. * inf-ttrace.c (inf_ttrace_attach): Adjust. (inf_ttrace_files_info): Get it from the current inferior. * inflow.c (terminal_inferior, terminal_ours_1, set_sigint_trap) (clear_sigint_trap): Get it from the current process. * remote.c (extended_remote_attach_1) (extended_remote_create_inferior_1): Adjust. * top.c (quit_confirm, quit_target): Get it from the current inferior. * procfs.c (do_detach): Adjust. (procfs_wait): Get it from the event inferior. (procfs_files_info): Get it from the current inferior. * nto-procfs.c (procfs_files_info): Likewise. (procfs_attach): Adjust. Set the attach_flag here. (do_attach): Don't set it here. (procfs_detach): Don't clear it. (procfs_mourn_inferior): Don't clear it. * solib-osf.c (osf_solib_create_inferior_hook): Adjust. * target.c (attach_flag): Delete. (generic_mourn_inferior): Don't clear it. * win32-nat.c (get_win32_debug_event): Get it from the event process. (do_initial_win32_stuff): Add attaching argument. Set attach_flag in the inferior accordingly. (win32_attach): Don't set the attach_flag here. Pass 1 to do_intial_win32_stuff. (win32_files_info): Get it from the current inferior. (win32_create_inferior): Dont clear attach_flag here. Pass 0 to do_intial_win32_stuff.
2008-09-22 17:21:30 +02:00
/* We can reach here due to changing solib-search-path or the
sysroot, before having any inferior. */
2018-06-11 22:45:22 +02:00
if (target_has_execution && inferior_ptid != null_ptid)
Remove the attach_flag global, and make it per-inferior. * inferior.h (attach_flag): Delete. (inferior_process): Declare. * solib.c (update_solib_list): Adjust. * gnu-nat.c (gnu_create_inferior, gnu_attach): Adjust. * inf-ptrace.c (inf_ptrace_detach): Adjust. (inf_ptrace_files_info): Get it from the current inferior. * inf-ttrace.c (inf_ttrace_attach): Adjust. (inf_ttrace_files_info): Get it from the current inferior. * inflow.c (terminal_inferior, terminal_ours_1, set_sigint_trap) (clear_sigint_trap): Get it from the current process. * remote.c (extended_remote_attach_1) (extended_remote_create_inferior_1): Adjust. * top.c (quit_confirm, quit_target): Get it from the current inferior. * procfs.c (do_detach): Adjust. (procfs_wait): Get it from the event inferior. (procfs_files_info): Get it from the current inferior. * nto-procfs.c (procfs_files_info): Likewise. (procfs_attach): Adjust. Set the attach_flag here. (do_attach): Don't set it here. (procfs_detach): Don't clear it. (procfs_mourn_inferior): Don't clear it. * solib-osf.c (osf_solib_create_inferior_hook): Adjust. * target.c (attach_flag): Delete. (generic_mourn_inferior): Don't clear it. * win32-nat.c (get_win32_debug_event): Get it from the event process. (do_initial_win32_stuff): Add attaching argument. Set attach_flag in the inferior accordingly. (win32_attach): Don't set the attach_flag here. Pass 1 to do_intial_win32_stuff. (win32_files_info): Get it from the current inferior. (win32_create_inferior): Dont clear attach_flag here. Pass 0 to do_intial_win32_stuff.
2008-09-22 17:21:30 +02:00
{
struct inferior *inf = current_inferior ();
/* If we are attaching to a running process for which we
have not opened a symbol file, we may be able to get its
symbols now! */
if (inf->attach_flag && symfile_objfile == NULL)
Eliminate catch_errors If you want to use catch_errors with a function with parameters, then currently you have to manually write a "capture" struct wrapping the arguments and marshall/unmarshall that. https://sourceware.org/ml/gdb-patches/2017-09/msg00834.html proposed adjusting catch_errors to use gdb::function_view, which would allow passing lambdas with automatic captures. However, it seems like using TRY/CATCH directly instead ends up producing clearer and easier to debug code. This is what this commit does. Note that removing catch_errors exposes further cleanup opportunities around no longer having to follow catch_errors callback type, and also removes a few cleanups. I didn't do anything to save/restore current_uiout because I think that should be the responsibility of the code that changes current_uiout in the first place. (Another approach could be to make catch_errors a variadic template like: template<typename Function, typename... Args> int catch_errors (const char *errstring, return_mask mask, Function &&func, Args... args); and then with: extern void function_with_args (int, int); extern void function_with_no_args (); calls to the above functions would be wrapped like this: catch_errors ("some error happened", RETURN_MASK_ERROR, function_with_args, arg1, arg2); catch_errors ("some error happened", RETURN_MASK_ERROR, function_with_no_args); but I'm thinking that that doesn't improve much if at all either.) gdb/ChangeLog 2017-10-10 Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> * breakpoint.c (breakpoint_cond_eval): Change return type to bool and reverse logic. (WP_DELETED, WP_VALUE_CHANGED, WP_VALUE_NOT_CHANGED, WP_IGNORE): No longer macros. Instead ... (enum wp_check_result): They're now values of this new enumeration. (watchpoint_check): Change return type to wp_check_result and parameter type to bpstat. (bpstat_check_watchpoint): Use TRY/CATCH instead of catch_errors. (bpstat_check_breakpoint_conditions): Use TRY/CATCH instead of catch_errors. Reverse logic of watchpoint_check call. (breakpoint_re_set_one): Now returns void and takes a breakpoint pointer as parameter. (breakpoint_re_set): Use TRY/CATCH instead of catch_errors. * common/common-exceptions.c (throw_exception_sjlj): Update comments to avoid mentioning catch_errors. * exceptions.c (catch_errors): Delete. * exceptions.h: Update comments to avoid mentioning catch_errors. (catch_errors_ftype, catch_errors): Delete. * infrun.c (normal_stop): Use TRY/CATCH instead of catch_errors. (hook_stop_stub): Delete. (restore_selected_frame): Change return type to void, and parameter type to const frame_id &. (restore_infcall_control_state): Use TRY/CATCH instead of catch_errors. * main.c (captured_command_loop): Return void and remove parameter. Remove references to catch_errors. (captured_main): Use TRY/CATCH instead of catch_errors. * objc-lang.c (objc_submethod_helper_data) (find_objc_msgcall_submethod_helper): Delete. (find_objc_msgcall_submethod): Use TRY/CATCH instead of catch_errors. * record-full.c (record_full_message): Return void. (record_full_message_args, record_full_message_wrapper): Delete. (record_full_message_wrapper_safe): Return bool and use TRY/CATCH instead of catch_errors. * solib-aix.c (solib_aix_open_symbol_file_object): Change parameter type to int. * solib-darwin.c (open_symbol_file_object): Ditto. * solib-dsbt.c (open_symbol_file_object): Ditto. * solib-frv.c (open_symbol_file_object): Ditto. * solib-svr4.c (open_symbol_file_object): Ditto. * solib-target.c (solib_target_open_symbol_file_object): Ditto. * solib.c (update_solib_list): Use TRY/CATCH instead of catch_errors. * solist.h (struct target_so_ops) <open_symbol_file_object>: Change type. * symmisc.c (struct print_symbol_args): Remove. (dump_symtab_1): Use TRY/CATCH instead of catch_errors. (print_symbol): Change type. * windows-nat.c (handle_load_dll, handle_unload_dll): Return void and remove parameters. (catch_errors): New. (get_windows_debug_event): Adjust. gdb/testsuite/ChangeLog: 2017-10-10 Pedro Alves <palves@redhat.com> * lib/selftest-support.exp (selftest_setup): Update for captured_command_loop's prototype change.
2017-10-10 17:45:50 +02:00
{
Rewrite TRY/CATCH This rewrites gdb's TRY/CATCH to plain C++ try/catch. The patch was largely written by script, though one change (to a comment in common-exceptions.h) was reverted by hand. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * xml-support.c: Use C++ exception handling. * x86-linux-nat.c: Use C++ exception handling. * windows-nat.c: Use C++ exception handling. * varobj.c: Use C++ exception handling. * value.c: Use C++ exception handling. * valprint.c: Use C++ exception handling. * valops.c: Use C++ exception handling. * unittests/parse-connection-spec-selftests.c: Use C++ exception handling. * unittests/cli-utils-selftests.c: Use C++ exception handling. * typeprint.c: Use C++ exception handling. * tui/tui.c: Use C++ exception handling. * tracefile-tfile.c: Use C++ exception handling. * top.c: Use C++ exception handling. * thread.c: Use C++ exception handling. * target.c: Use C++ exception handling. * symmisc.c: Use C++ exception handling. * symfile-mem.c: Use C++ exception handling. * stack.c: Use C++ exception handling. * sparc64-linux-tdep.c: Use C++ exception handling. * solib.c: Use C++ exception handling. * solib-svr4.c: Use C++ exception handling. * solib-spu.c: Use C++ exception handling. * solib-frv.c: Use C++ exception handling. * solib-dsbt.c: Use C++ exception handling. * selftest-arch.c: Use C++ exception handling. * s390-tdep.c: Use C++ exception handling. * rust-lang.c: Use C++ exception handling. * rust-exp.y: Use C++ exception handling. * rs6000-tdep.c: Use C++ exception handling. * rs6000-aix-tdep.c: Use C++ exception handling. * riscv-tdep.c: Use C++ exception handling. * remote.c: Use C++ exception handling. * remote-fileio.c: Use C++ exception handling. * record-full.c: Use C++ exception handling. * record-btrace.c: Use C++ exception handling. * python/python.c: Use C++ exception handling. * python/py-value.c: Use C++ exception handling. * python/py-utils.c: Use C++ exception handling. * python/py-unwind.c: Use C++ exception handling. * python/py-type.c: Use C++ exception handling. * python/py-symbol.c: Use C++ exception handling. * python/py-record.c: Use C++ exception handling. * python/py-record-btrace.c: Use C++ exception handling. * python/py-progspace.c: Use C++ exception handling. * python/py-prettyprint.c: Use C++ exception handling. * python/py-param.c: Use C++ exception handling. * python/py-objfile.c: Use C++ exception handling. * python/py-linetable.c: Use C++ exception handling. * python/py-lazy-string.c: Use C++ exception handling. * python/py-infthread.c: Use C++ exception handling. * python/py-inferior.c: Use C++ exception handling. * python/py-gdb-readline.c: Use C++ exception handling. * python/py-framefilter.c: Use C++ exception handling. * python/py-frame.c: Use C++ exception handling. * python/py-finishbreakpoint.c: Use C++ exception handling. * python/py-cmd.c: Use C++ exception handling. * python/py-breakpoint.c: Use C++ exception handling. * python/py-arch.c: Use C++ exception handling. * printcmd.c: Use C++ exception handling. * ppc-linux-tdep.c: Use C++ exception handling. * parse.c: Use C++ exception handling. * p-valprint.c: Use C++ exception handling. * objc-lang.c: Use C++ exception handling. * mi/mi-main.c: Use C++ exception handling. * mi/mi-interp.c: Use C++ exception handling. * mi/mi-cmd-stack.c: Use C++ exception handling. * mi/mi-cmd-break.c: Use C++ exception handling. * main.c: Use C++ exception handling. * linux-thread-db.c: Use C++ exception handling. * linux-tdep.c: Use C++ exception handling. * linux-nat.c: Use C++ exception handling. * linux-fork.c: Use C++ exception handling. * linespec.c: Use C++ exception handling. * language.c: Use C++ exception handling. * jit.c: Use C++ exception handling. * infrun.c: Use C++ exception handling. * infcmd.c: Use C++ exception handling. * infcall.c: Use C++ exception handling. * inf-loop.c: Use C++ exception handling. * i386-tdep.c: Use C++ exception handling. * i386-linux-tdep.c: Use C++ exception handling. * guile/scm-value.c: Use C++ exception handling. * guile/scm-type.c: Use C++ exception handling. * guile/scm-symtab.c: Use C++ exception handling. * guile/scm-symbol.c: Use C++ exception handling. * guile/scm-pretty-print.c: Use C++ exception handling. * guile/scm-ports.c: Use C++ exception handling. * guile/scm-param.c: Use C++ exception handling. * guile/scm-math.c: Use C++ exception handling. * guile/scm-lazy-string.c: Use C++ exception handling. * guile/scm-frame.c: Use C++ exception handling. * guile/scm-disasm.c: Use C++ exception handling. * guile/scm-cmd.c: Use C++ exception handling. * guile/scm-breakpoint.c: Use C++ exception handling. * guile/scm-block.c: Use C++ exception handling. * guile/guile-internal.h: Use C++ exception handling. * gnu-v3-abi.c: Use C++ exception handling. * gdbtypes.c: Use C++ exception handling. * frame.c: Use C++ exception handling. * frame-unwind.c: Use C++ exception handling. * fbsd-tdep.c: Use C++ exception handling. * f-valprint.c: Use C++ exception handling. * exec.c: Use C++ exception handling. * event-top.c: Use C++ exception handling. * event-loop.c: Use C++ exception handling. * eval.c: Use C++ exception handling. * dwarf2read.c: Use C++ exception handling. * dwarf2loc.c: Use C++ exception handling. * dwarf2-frame.c: Use C++ exception handling. * dwarf2-frame-tailcall.c: Use C++ exception handling. * dwarf-index-write.c: Use C++ exception handling. * dwarf-index-cache.c: Use C++ exception handling. * dtrace-probe.c: Use C++ exception handling. * disasm-selftests.c: Use C++ exception handling. * darwin-nat.c: Use C++ exception handling. * cp-valprint.c: Use C++ exception handling. * cp-support.c: Use C++ exception handling. * cp-abi.c: Use C++ exception handling. * corelow.c: Use C++ exception handling. * completer.c: Use C++ exception handling. * compile/compile-object-run.c: Use C++ exception handling. * compile/compile-object-load.c: Use C++ exception handling. * compile/compile-cplus-symbols.c: Use C++ exception handling. * compile/compile-c-symbols.c: Use C++ exception handling. * common/selftest.c: Use C++ exception handling. * common/new-op.c: Use C++ exception handling. * cli/cli-script.c: Use C++ exception handling. * cli/cli-interp.c: Use C++ exception handling. * cli/cli-cmds.c: Use C++ exception handling. * c-varobj.c: Use C++ exception handling. * btrace.c: Use C++ exception handling. * breakpoint.c: Use C++ exception handling. * break-catch-throw.c: Use C++ exception handling. * arch-utils.c: Use C++ exception handling. * amd64-tdep.c: Use C++ exception handling. * ada-valprint.c: Use C++ exception handling. * ada-typeprint.c: Use C++ exception handling. * ada-lang.c: Use C++ exception handling. * aarch64-tdep.c: Use C++ exception handling. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * server.c: Use C++ exception handling. * linux-low.c: Use C++ exception handling. * gdbreplay.c: Use C++ exception handling.
2019-04-04 00:02:42 +02:00
try
Eliminate catch_errors If you want to use catch_errors with a function with parameters, then currently you have to manually write a "capture" struct wrapping the arguments and marshall/unmarshall that. https://sourceware.org/ml/gdb-patches/2017-09/msg00834.html proposed adjusting catch_errors to use gdb::function_view, which would allow passing lambdas with automatic captures. However, it seems like using TRY/CATCH directly instead ends up producing clearer and easier to debug code. This is what this commit does. Note that removing catch_errors exposes further cleanup opportunities around no longer having to follow catch_errors callback type, and also removes a few cleanups. I didn't do anything to save/restore current_uiout because I think that should be the responsibility of the code that changes current_uiout in the first place. (Another approach could be to make catch_errors a variadic template like: template<typename Function, typename... Args> int catch_errors (const char *errstring, return_mask mask, Function &&func, Args... args); and then with: extern void function_with_args (int, int); extern void function_with_no_args (); calls to the above functions would be wrapped like this: catch_errors ("some error happened", RETURN_MASK_ERROR, function_with_args, arg1, arg2); catch_errors ("some error happened", RETURN_MASK_ERROR, function_with_no_args); but I'm thinking that that doesn't improve much if at all either.) gdb/ChangeLog 2017-10-10 Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> * breakpoint.c (breakpoint_cond_eval): Change return type to bool and reverse logic. (WP_DELETED, WP_VALUE_CHANGED, WP_VALUE_NOT_CHANGED, WP_IGNORE): No longer macros. Instead ... (enum wp_check_result): They're now values of this new enumeration. (watchpoint_check): Change return type to wp_check_result and parameter type to bpstat. (bpstat_check_watchpoint): Use TRY/CATCH instead of catch_errors. (bpstat_check_breakpoint_conditions): Use TRY/CATCH instead of catch_errors. Reverse logic of watchpoint_check call. (breakpoint_re_set_one): Now returns void and takes a breakpoint pointer as parameter. (breakpoint_re_set): Use TRY/CATCH instead of catch_errors. * common/common-exceptions.c (throw_exception_sjlj): Update comments to avoid mentioning catch_errors. * exceptions.c (catch_errors): Delete. * exceptions.h: Update comments to avoid mentioning catch_errors. (catch_errors_ftype, catch_errors): Delete. * infrun.c (normal_stop): Use TRY/CATCH instead of catch_errors. (hook_stop_stub): Delete. (restore_selected_frame): Change return type to void, and parameter type to const frame_id &. (restore_infcall_control_state): Use TRY/CATCH instead of catch_errors. * main.c (captured_command_loop): Return void and remove parameter. Remove references to catch_errors. (captured_main): Use TRY/CATCH instead of catch_errors. * objc-lang.c (objc_submethod_helper_data) (find_objc_msgcall_submethod_helper): Delete. (find_objc_msgcall_submethod): Use TRY/CATCH instead of catch_errors. * record-full.c (record_full_message): Return void. (record_full_message_args, record_full_message_wrapper): Delete. (record_full_message_wrapper_safe): Return bool and use TRY/CATCH instead of catch_errors. * solib-aix.c (solib_aix_open_symbol_file_object): Change parameter type to int. * solib-darwin.c (open_symbol_file_object): Ditto. * solib-dsbt.c (open_symbol_file_object): Ditto. * solib-frv.c (open_symbol_file_object): Ditto. * solib-svr4.c (open_symbol_file_object): Ditto. * solib-target.c (solib_target_open_symbol_file_object): Ditto. * solib.c (update_solib_list): Use TRY/CATCH instead of catch_errors. * solist.h (struct target_so_ops) <open_symbol_file_object>: Change type. * symmisc.c (struct print_symbol_args): Remove. (dump_symtab_1): Use TRY/CATCH instead of catch_errors. (print_symbol): Change type. * windows-nat.c (handle_load_dll, handle_unload_dll): Return void and remove parameters. (catch_errors): New. (get_windows_debug_event): Adjust. gdb/testsuite/ChangeLog: 2017-10-10 Pedro Alves <palves@redhat.com> * lib/selftest-support.exp (selftest_setup): Update for captured_command_loop's prototype change.
2017-10-10 17:45:50 +02:00
{
ops->open_symbol_file_object (from_tty);
}
Rename gdb exception types This renames the gdb exception types. The old types were only needed due to the macros in common-exception.h that are now gone. The intermediate layer of gdb_exception_RETURN_MASK_ALL did not seem needed, so this patch removes it entirely. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * common/common-exceptions.h (gdb_exception_RETURN_MASK_ALL): Remove. (gdb_exception_error): Rename from gdb_exception_RETURN_MASK_ERROR. (gdb_exception_quit): Rename from gdb_exception_RETURN_MASK_QUIT. (gdb_quit_bad_alloc): Update. * aarch64-tdep.c: Update. * ada-lang.c: Update. * ada-typeprint.c: Update. * ada-valprint.c: Update. * amd64-tdep.c: Update. * arch-utils.c: Update. * break-catch-throw.c: Update. * breakpoint.c: Update. * btrace.c: Update. * c-varobj.c: Update. * cli/cli-cmds.c: Update. * cli/cli-interp.c: Update. * cli/cli-script.c: Update. * common/common-exceptions.c: Update. * common/new-op.c: Update. * common/selftest.c: Update. * compile/compile-c-symbols.c: Update. * compile/compile-cplus-symbols.c: Update. * compile/compile-object-load.c: Update. * compile/compile-object-run.c: Update. * completer.c: Update. * corelow.c: Update. * cp-abi.c: Update. * cp-support.c: Update. * cp-valprint.c: Update. * darwin-nat.c: Update. * disasm-selftests.c: Update. * dtrace-probe.c: Update. * dwarf-index-cache.c: Update. * dwarf-index-write.c: Update. * dwarf2-frame-tailcall.c: Update. * dwarf2-frame.c: Update. * dwarf2loc.c: Update. * dwarf2read.c: Update. * eval.c: Update. * event-loop.c: Update. * event-top.c: Update. * exec.c: Update. * f-valprint.c: Update. * fbsd-tdep.c: Update. * frame-unwind.c: Update. * frame.c: Update. * gdbtypes.c: Update. * gnu-v3-abi.c: Update. * guile/guile-internal.h: Update. * guile/scm-block.c: Update. * guile/scm-breakpoint.c: Update. * guile/scm-cmd.c: Update. * guile/scm-disasm.c: Update. * guile/scm-frame.c: Update. * guile/scm-lazy-string.c: Update. * guile/scm-math.c: Update. * guile/scm-param.c: Update. * guile/scm-ports.c: Update. * guile/scm-pretty-print.c: Update. * guile/scm-symbol.c: Update. * guile/scm-symtab.c: Update. * guile/scm-type.c: Update. * guile/scm-value.c: Update. * i386-linux-tdep.c: Update. * i386-tdep.c: Update. * inf-loop.c: Update. * infcall.c: Update. * infcmd.c: Update. * infrun.c: Update. * jit.c: Update. * language.c: Update. * linespec.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * main.c: Update. * mi/mi-cmd-break.c: Update. * mi/mi-cmd-stack.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * objc-lang.c: Update. * p-valprint.c: Update. * parse.c: Update. * ppc-linux-tdep.c: Update. * printcmd.c: Update. * python/py-arch.c: Update. * python/py-breakpoint.c: Update. * python/py-cmd.c: Update. * python/py-finishbreakpoint.c: Update. * python/py-frame.c: Update. * python/py-framefilter.c: Update. * python/py-gdb-readline.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * python/py-lazy-string.c: Update. * python/py-linetable.c: Update. * python/py-objfile.c: Update. * python/py-param.c: Update. * python/py-prettyprint.c: Update. * python/py-progspace.c: Update. * python/py-record-btrace.c: Update. * python/py-record.c: Update. * python/py-symbol.c: Update. * python/py-type.c: Update. * python/py-unwind.c: Update. * python/py-utils.c: Update. * python/py-value.c: Update. * python/python.c: Update. * record-btrace.c: Update. * record-full.c: Update. * remote-fileio.c: Update. * remote.c: Update. * riscv-tdep.c: Update. * rs6000-aix-tdep.c: Update. * rs6000-tdep.c: Update. * rust-exp.y: Update. * rust-lang.c: Update. * s390-tdep.c: Update. * selftest-arch.c: Update. * solib-dsbt.c: Update. * solib-frv.c: Update. * solib-spu.c: Update. * solib-svr4.c: Update. * solib.c: Update. * sparc64-linux-tdep.c: Update. * stack.c: Update. * symfile-mem.c: Update. * symmisc.c: Update. * target.c: Update. * thread.c: Update. * top.c: Update. * tracefile-tfile.c: Update. * tui/tui.c: Update. * typeprint.c: Update. * unittests/cli-utils-selftests.c: Update. * unittests/parse-connection-spec-selftests.c: Update. * valops.c: Update. * valprint.c: Update. * value.c: Update. * varobj.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * xml-support.c: Update. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * gdbreplay.c: Update. * linux-low.c: Update. * server.c: Update.
2019-04-03 23:59:07 +02:00
catch (const gdb_exception &ex)
Eliminate catch_errors If you want to use catch_errors with a function with parameters, then currently you have to manually write a "capture" struct wrapping the arguments and marshall/unmarshall that. https://sourceware.org/ml/gdb-patches/2017-09/msg00834.html proposed adjusting catch_errors to use gdb::function_view, which would allow passing lambdas with automatic captures. However, it seems like using TRY/CATCH directly instead ends up producing clearer and easier to debug code. This is what this commit does. Note that removing catch_errors exposes further cleanup opportunities around no longer having to follow catch_errors callback type, and also removes a few cleanups. I didn't do anything to save/restore current_uiout because I think that should be the responsibility of the code that changes current_uiout in the first place. (Another approach could be to make catch_errors a variadic template like: template<typename Function, typename... Args> int catch_errors (const char *errstring, return_mask mask, Function &&func, Args... args); and then with: extern void function_with_args (int, int); extern void function_with_no_args (); calls to the above functions would be wrapped like this: catch_errors ("some error happened", RETURN_MASK_ERROR, function_with_args, arg1, arg2); catch_errors ("some error happened", RETURN_MASK_ERROR, function_with_no_args); but I'm thinking that that doesn't improve much if at all either.) gdb/ChangeLog 2017-10-10 Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> * breakpoint.c (breakpoint_cond_eval): Change return type to bool and reverse logic. (WP_DELETED, WP_VALUE_CHANGED, WP_VALUE_NOT_CHANGED, WP_IGNORE): No longer macros. Instead ... (enum wp_check_result): They're now values of this new enumeration. (watchpoint_check): Change return type to wp_check_result and parameter type to bpstat. (bpstat_check_watchpoint): Use TRY/CATCH instead of catch_errors. (bpstat_check_breakpoint_conditions): Use TRY/CATCH instead of catch_errors. Reverse logic of watchpoint_check call. (breakpoint_re_set_one): Now returns void and takes a breakpoint pointer as parameter. (breakpoint_re_set): Use TRY/CATCH instead of catch_errors. * common/common-exceptions.c (throw_exception_sjlj): Update comments to avoid mentioning catch_errors. * exceptions.c (catch_errors): Delete. * exceptions.h: Update comments to avoid mentioning catch_errors. (catch_errors_ftype, catch_errors): Delete. * infrun.c (normal_stop): Use TRY/CATCH instead of catch_errors. (hook_stop_stub): Delete. (restore_selected_frame): Change return type to void, and parameter type to const frame_id &. (restore_infcall_control_state): Use TRY/CATCH instead of catch_errors. * main.c (captured_command_loop): Return void and remove parameter. Remove references to catch_errors. (captured_main): Use TRY/CATCH instead of catch_errors. * objc-lang.c (objc_submethod_helper_data) (find_objc_msgcall_submethod_helper): Delete. (find_objc_msgcall_submethod): Use TRY/CATCH instead of catch_errors. * record-full.c (record_full_message): Return void. (record_full_message_args, record_full_message_wrapper): Delete. (record_full_message_wrapper_safe): Return bool and use TRY/CATCH instead of catch_errors. * solib-aix.c (solib_aix_open_symbol_file_object): Change parameter type to int. * solib-darwin.c (open_symbol_file_object): Ditto. * solib-dsbt.c (open_symbol_file_object): Ditto. * solib-frv.c (open_symbol_file_object): Ditto. * solib-svr4.c (open_symbol_file_object): Ditto. * solib-target.c (solib_target_open_symbol_file_object): Ditto. * solib.c (update_solib_list): Use TRY/CATCH instead of catch_errors. * solist.h (struct target_so_ops) <open_symbol_file_object>: Change type. * symmisc.c (struct print_symbol_args): Remove. (dump_symtab_1): Use TRY/CATCH instead of catch_errors. (print_symbol): Change type. * windows-nat.c (handle_load_dll, handle_unload_dll): Return void and remove parameters. (catch_errors): New. (get_windows_debug_event): Adjust. gdb/testsuite/ChangeLog: 2017-10-10 Pedro Alves <palves@redhat.com> * lib/selftest-support.exp (selftest_setup): Update for captured_command_loop's prototype change.
2017-10-10 17:45:50 +02:00
{
exception_fprintf (gdb_stderr, ex,
"Error reading attached "
"process's symbol file.\n");
}
}
Remove the attach_flag global, and make it per-inferior. * inferior.h (attach_flag): Delete. (inferior_process): Declare. * solib.c (update_solib_list): Adjust. * gnu-nat.c (gnu_create_inferior, gnu_attach): Adjust. * inf-ptrace.c (inf_ptrace_detach): Adjust. (inf_ptrace_files_info): Get it from the current inferior. * inf-ttrace.c (inf_ttrace_attach): Adjust. (inf_ttrace_files_info): Get it from the current inferior. * inflow.c (terminal_inferior, terminal_ours_1, set_sigint_trap) (clear_sigint_trap): Get it from the current process. * remote.c (extended_remote_attach_1) (extended_remote_create_inferior_1): Adjust. * top.c (quit_confirm, quit_target): Get it from the current inferior. * procfs.c (do_detach): Adjust. (procfs_wait): Get it from the event inferior. (procfs_files_info): Get it from the current inferior. * nto-procfs.c (procfs_files_info): Likewise. (procfs_attach): Adjust. Set the attach_flag here. (do_attach): Don't set it here. (procfs_detach): Don't clear it. (procfs_mourn_inferior): Don't clear it. * solib-osf.c (osf_solib_create_inferior_hook): Adjust. * target.c (attach_flag): Delete. (generic_mourn_inferior): Don't clear it. * win32-nat.c (get_win32_debug_event): Get it from the event process. (do_initial_win32_stuff): Add attaching argument. Set attach_flag in the inferior accordingly. (win32_attach): Don't set the attach_flag here. Pass 1 to do_intial_win32_stuff. (win32_files_info): Get it from the current inferior. (win32_create_inferior): Dont clear attach_flag here. Pass 0 to do_intial_win32_stuff.
2008-09-22 17:21:30 +02:00
}
1999-08-31 03:14:27 +02:00
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
/* GDB and the inferior's dynamic linker each maintain their own
list of currently loaded shared objects; we want to bring the
former in sync with the latter. Scan both lists, seeing which
shared objects appear where. There are three cases:
- A shared object appears on both lists. This means that GDB
knows about it already, and it's still loaded in the inferior.
Nothing needs to happen.
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
- A shared object appears only on GDB's list. This means that
the inferior has unloaded it. We should remove the shared
object from GDB's tables.
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
- A shared object appears only on the inferior's list. This
means that it's just been loaded. We should add it to GDB's
tables.
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
So we walk GDB's list, checking each entry to see if it appears
in the inferior's list too. If it does, no action is needed, and
we remove it from the inferior's list. If it doesn't, the
inferior has unloaded it, and we remove it from GDB's list. By
the time we're done walking GDB's list, the inferior's list
contains only the new shared objects, which we then add. */
gdb = current_program_space->so_list;
gdb_link = &current_program_space->so_list;
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
while (gdb)
{
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
struct so_list *i = inferior;
struct so_list **i_link = &inferior;
/* Check to see whether the shared object *gdb also appears in
the inferior's current list. */
while (i)
{
if (ops->same)
{
if (ops->same (gdb, i))
break;
}
else
{
2011-03-23 Kai Tietz <ktietz@redhat.com> * breakpoint.c (clear_command): Use filename_cmp instead of strcmp for comparison. * buildsym.c (watch_main_source_file_lossage): Likewise. (patch_subfile_names): Use IS_DIR_SEPARATOR instead of checking just for slash. * dbxread.c (read_dbx_symtab): Use lbasename instead of strrchr and filename_cmp instead of strcmp for filenames. (add_old_header_file): Use filename_cmp instead of strcmp for comparison. * exec.c (exec_set_section_address): Likewise. * macrotab.c (macro_lookup_inclusion): Likewise. (macro_lookup_inclusion): Likewise. * elfread.c (_initialize_elfread): Likewise. (elfstab_offset_sections): Likewise. (elfstab_offset_sections): Use lbasename instead of strrchr. * mdebugread.c (parse_partial_symbols): Likewise. (arse_partial_symbols): Use filename_(n)cmp instead of str(n)cmp for comparison. * minsyms.c (lookup_minimal_symbol): Likewise. * psymtab.c (read_psymtabs_with_filename): Likewise. * solib.c (solib_read_symbols): Likewise. (reload_shared_libraries_1): Likewise. * symmisc.c (maintenance_print_symbols): Likewise. * symfile.c (separate_debug_file_exists): Likewise. (reread_symbols): Likewise. (find_separate_debug_file_by_debuglink): Likewise. * remote-fileio.c (remote_fileio_func_rename): Likewise. * source.c (add_path): Likewise. * symtab.c (filename_seen): Likewise. (file_matches): Likewise. (print_symbol_info): Likewise. (maybe_add_partial_symtab_filename): Likewise. (make_source_files_completion_list): Likewise. * xml-syscall.c (init_sysinfo): Likewise. * windows-nat.c (_initialize_check_for_gdb_ini): Use IS_DIR_SEPARATOR for checking for trailing path separator.
2011-03-23 19:23:56 +01:00
if (! filename_cmp (gdb->so_original_name, i->so_original_name))
break;
}
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
i_link = &i->next;
i = *i_link;
}
1999-07-07 22:19:36 +02:00
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
/* If the shared object appears on the inferior's list too, then
it's still loaded, so we don't need to do anything. Delete
it from the inferior's list, and leave it on GDB's list. */
if (i)
{
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
*i_link = i->next;
free_so (i);
gdb_link = &gdb->next;
gdb = *gdb_link;
}
/* If it's not on the inferior's list, remove it from GDB's tables. */
else
{
/* Notify any observer that the shared object has been
unloaded before we remove it from GDB's tables. */
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::solib_unloaded.notify (gdb);
current_program_space->deleted_solibs.push_back (gdb->so_name);
PR symtab/12406: * solib.c (update_solib_list): Update the program space's added_solibs and deleted_solibs fields. * progspace.h (struct program_space) <added_solibs, deleted_solibs>: New fields. (clear_program_space_solib_cache): Declare. * progspace.c (release_program_space): Call clear_program_space_solib_cache. (clear_program_space_solib_cache): New function. * infrun.c (handle_inferior_event) <TARGET_WAITKIND_LOADED>: Call bpstat_stop_status. Use handle_solib_event. * breakpoint.c: Include gdb_regex.h. (print_solib_event): New function. (bpstat_print): Use print_solib_event. (bpstat_stop_status): Add special case for bp_shlib_event. (handle_solib_event): New function. (bpstat_what): Use handle_solib_event. (struct solib_catchpoint): New. (dtor_catch_solib, insert_catch_solib, remove_catch_solib) (breakpoint_hit_catch_solib, check_status_catch_solib) (print_it_catch_solib, print_one_catch_solib) (print_mention_catch_solib, print_recreate_catch_solib): New functions. (catch_solib_breakpoint_ops): New global. (catch_load_or_unload, catch_load_command_1) (catch_unload_command_1): New functions. (internal_bkpt_check_status): Add special case for bp_shlib_event. (internal_bkpt_print_it): Use print_solib_event. (initialize_breakpoint_ops): Initialize catch_solib_breakpoint_ops. (_initialize_breakpoint): Register "catch load" and "catch unload". * breakpoint.h (handle_solib_event): Declare. * NEWS: Add entry for "catch load" and "catch unload". gdb/doc * gdb.texinfo (Set Catchpoints): Document "catch load" and "catch unload". (Files): Mention new catch commands. (GDB/MI Async Records): Likewise. gdb/testsuite * lib/mi-support.exp (mi_expect_stop): Add special case for solib-event. * gdb.base/catch-load-so.c: New file. * gdb.base/catch-load.exp: New file. * gdb.base/catch-load.c: New file. * gdb.base/break-interp.exp (reach_1): Update regexp.
2012-01-24 22:39:18 +01:00
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
*gdb_link = gdb->next;
/* Unless the user loaded it explicitly, free SO's objfile. */
if (gdb->objfile && ! (gdb->objfile->flags & OBJF_USERLOADED)
&& !solib_used (gdb))
gdb->objfile->unlink ();
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
/* Some targets' section tables might be referring to
sections from so->abfd; remove them. */
remove_target_sections (gdb);
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
free_so (gdb);
gdb = *gdb_link;
}
}
1999-07-07 22:19:36 +02:00
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
/* Now the inferior's list contains only shared objects that don't
appear in GDB's list --- those that are newly loaded. Add them
to GDB's shared object list. */
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
if (inferior)
{
int not_found = 0;
const char *not_found_filename = NULL;
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
struct so_list *i;
/* Add the new shared objects to GDB's list. */
*gdb_link = inferior;
/* Fill in the rest of each of the `struct so_list' nodes. */
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
for (i = inferior; i; i = i->next)
{
2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> Add base multi-executable/process support to GDB. gdb/ * Makefile.in (SFILES): Add progspace.c. (COMMON_OBS): Add progspace.o. * progspace.h: New. * progspace.c: New. * breakpoint.h (struct bp_target_info) <placed_address_space>: New field. (struct bp_location) <pspace>: New field. (struct breakpoint) <pspace>: New field. (bpstat_stop_status, breakpoint_here_p) (moribund_breakpoint_here_p, breakpoint_inserted_here_p) (regular_breakpoint_inserted_here_p) (software_breakpoint_inserted_here_p, breakpoint_thread_match) (set_default_breakpoint): Adjust prototypes. (remove_breakpoints_pid, breakpoint_program_space_exit): Declare. (insert_single_step_breakpoint, deprecated_insert_raw_breakpoint): Adjust prototypes. * breakpoint.c (executing_startup): Delete. (default_breakpoint_sspace): New. (breakpoint_restore_shadows): Skip if the address space doesn't match. (update_watchpoint): Record the frame's program space in the breakpoint location. (insert_bp_location): Record the address space in target_info. Adjust to pass the symbol space to solib_name_from_address. (breakpoint_program_space_exit): New. (insert_breakpoint_locations): Switch the symbol space and thread when inserting breakpoints. Don't insert breakpoints in a vfork parent waiting for vfork done if we're not attached to the vfork child. (remove_breakpoints_pid): New. (reattach_breakpoints): Switch to a thread of PID. Ignore breakpoints of other symbol spaces. (create_internal_breakpoint): Store the symbol space in the sal. (create_longjmp_master_breakpoint): Iterate over all symbol spaces. (update_breakpoints_after_exec): Ignore breakpoints for other symbol spaces. (remove_breakpoint): Rename to ... (remove_breakpoint_1): ... this. Pass the breakpoints symbol space to solib_name_from_address. (remove_breakpoint): New. (mark_breakpoints_out): Ignore breakpoints from other symbol spaces. (breakpoint_init_inferior): Ditto. (breakpoint_here_p): Add an address space argument and adjust to use breakpoint_address_match. (moribund_breakpoint_here_p): Ditto. (regular_breakpoint_inserted_here_p): Ditto. (breakpoint_inserted_here_p): Ditto. (software_breakpoint_inserted_here_p): Ditto. (breakpoint_thread_match): Ditto. (bpstat_check_location): Ditto. (bpstat_stop_status): Ditto. (print_breakpoint_location): If there's a location to print, switch the current symbol space. (print_one_breakpoint_location): Add `allflag' argument. (print_one_breakpoint): Ditto. Adjust. (do_captured_breakpoint_query): Adjust. (breakpoint_1): Adjust. (breakpoint_has_pc): Also match the symbol space. (describe_other_breakpoints): Add a symbol space argument and adjust. (set_default_breakpoint): Add a symbol space argument. Set default_breakpoint_sspace. (breakpoint_address_match): New. (check_duplicates_for): Add an address space argument, and adjust. (set_raw_breakpoint): Record the symbol space in the location and in the breakpoint. (set_longjmp_breakpoint): Skip longjmp master breakpoints from other symbol spaces. (remove_thread_event_breakpoints, remove_solib_event_breakpoints) (disable_breakpoints_in_shlibs): Skip breakpoints from other symbol spaces. (disable_breakpoints_in_unloaded_shlib): Match symbol spaces. (create_catchpoint): Set the symbol space in the sal. (disable_breakpoints_before_startup): Skip breakpoints from other symbol spaces. Set executing_startup in the current symbol space. (enable_breakpoints_after_startup): Clear executing_startup in the current symbol space. Skip breakpoints from other symbol spaces. (clone_momentary_breakpoint): Also copy the symbol space. (add_location_to_breakpoint): Set the location's symbol space. (bp_loc_is_permanent): Switch thread and symbol space. (create_breakpoint): Adjust. (expand_line_sal_maybe): Expand comment to mention symbol spaces. Switch thread and symbol space when reading memory. (parse_breakpoint_sals): Set the symbol space in the sal. (break_command_really): Ditto. (skip_prologue_sal): Switch and space. (resolve_sal_pc): Ditto. (watch_command_1): Record the symbol space in the sal. (create_ada_exception_breakpoint): Adjust. (clear_command): Adjust. Match symbol spaces. (update_global_location_list): Use breakpoint_address_match. (breakpoint_re_set_one): Switch thread and space. (breakpoint_re_set): Save symbol space. (breakpoint_re_set_thread): Also reset the symbol space. (deprecated_insert_raw_breakpoint): Add an address space argument. Adjust. (insert_single_step_breakpoint): Ditto. (single_step_breakpoint_inserted_here_p): Ditto. (clear_syscall_counts): New. (_initialize_breakpoint): Install it as inferior_exit observer. * exec.h: Include "progspace.h". (exec_bfd, exec_bfd_mtime): New defines. (exec_close): Declare. * exec.c: Include "gdbthread.h" and "progspace.h". (exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete. (using_exec_ops): New. (exec_close_1): Rename to exec_close, and make public. (exec_close): Rename to exec_close_1, and adjust all callers. Add description. Remove target sections and close executables from all program spaces. (exec_file_attach): Add comment. (add_target_sections): Check on `using_exec_ops' to check if the target should be pushed. (remove_target_sections): Only unpush the target if there are no more target sections in any symbol space. * gdbcore.h: Include "exec.h". (exec_bfd, exec_bfd_mtime): Remove declarations. * frame.h (get_frame_program_space, get_frame_address_space) (frame_unwind_program_space): Declare. * frame.c (struct frame_info) <pspace, aspace>: New fields. (create_sentinel_frame): Add program space argument. Set the pspace and aspace fields of the frame object. (get_current_frame, create_new_frame): Adjust. (get_frame_program_space): New. (frame_unwind_program_space): New. (get_frame_address_space): New. * stack.c (print_frame_info): Adjust. (print_frame): Use the frame's program space. * gdbthread.h (any_live_thread_of_process): Declare. * thread.c (any_live_thread_of_process): New. (switch_to_thread): Switch the program space as well. (restore_selected_frame): Don't warn if trying to restore frame level 0. * inferior.h: Include "progspace.h". (detach_fork): Declare. (struct inferior) <removable, aspace, pspace> <vfork_parent, vfork_child, pending_detach> <waiting_for_vfork_done>: New fields. <terminal_info>: Remove field. <data, num_data>: New fields. (register_inferior_data, register_inferior_data_with_cleanup) (clear_inferior_data, set_inferior_data, inferior_data): Declare. (exit_inferior, exit_inferior_silent, exit_inferior_num_silent) (inferior_appeared): Declare. (find_inferior_pid): Typo. (find_inferior_id, find_inferior_for_program_space): Declare. (set_current_inferior, save_current_inferior, prune_inferiors) (number_of_inferiors): Declare. (inferior_list): Declare. * inferior.c: Include "gdbcore.h" and "symfile.h". (inferior_list): Make public. (delete_inferior_1): Always delete thread silently. (find_inferior_id): Make public. (current_inferior_): New. (current_inferior): Use it. (set_current_inferior): New. (restore_inferior): New. (save_current_inferior): New. (free_inferior): Free the per-inferior data. (add_inferior_silent): Allocate per-inferior data. Call inferior_appeared. (delete_threads_of_inferior): New. (delete_inferior_1): Adjust interface to take an inferior pointer. (delete_inferior): Adjust. (delete_inferior_silent): Adjust. (exit_inferior_1): New. (exit_inferior): New. (exit_inferior_silent): New. (exit_inferior_num_silent): New. (detach_inferior): Adjust. (inferior_appeared): New. (discard_all_inferiors): Adjust. (find_inferior_id): Make public. Assert pid is not zero. (find_inferior_for_program_space): New. (have_inferiors): Check if we have any inferior with pid not zero. (have_live_inferiors): Go over all pushed targets looking for process_stratum. (prune_inferiors): New. (number_of_inferiors): New. (print_inferior): Add executable column. Print vfork parent/child relationships. (inferior_command): Adjust to cope with not running inferiors. (remove_inferior_command): New. (add_inferior_command): New. (clone_inferior_command): New. (struct inferior_data): New. (struct inferior_data_registration): New. (struct inferior_data_registry): New. (inferior_data_registry): New. (register_inferior_data_with_cleanup): New. (register_inferior_data): New. (inferior_alloc_data): New. (inferior_free_data): New. (clear_inferior_data): New. (set_inferior_data): New. (inferior_data): New. (initialize_inferiors): New. (_initialize_inferiors): Register "add-inferior", "remove-inferior" and "clone-inferior" commands. * objfiles.h: Include "progspace.h". (struct objfile) <pspace>: New field. (symfile_objfile, object_files): Don't declare. (ALL_PSPACE_OBJFILES): New. (ALL_PSPACE_OBJFILES_SAFE): New. (ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust. (ALL_PSPACE_SYMTABS): New. (ALL_PRIMARY_SYMTABS): Adjust. (ALL_PSPACE_PRIMARY_SYMTABS): New. (ALL_PSYMTABS): Adjust. (ALL_PSPACE_PSYMTABS): New. * objfiles.c (object_files, symfile_objfile): Delete. (struct objfile_sspace_info): New. (objfiles_pspace_data): New. (objfiles_pspace_data_cleanup): New. (get_objfile_pspace_data): New. (objfiles_changed_p): Delete. (allocate_objfile): Set the objfile's program space. Adjust to reference objfiles_changed_p in pspace data. (free_objfile): Adjust to reference objfiles_changed_p in pspace data. (objfile_relocate): Ditto. (update_section_map): Add pspace argument. Adjust to iterate over objfiles in the passed in pspace. (find_pc_section): Delete sections and num_sections statics. Adjust to refer to program space's objfiles_changed_p. Adjust to refer to sections and num_sections store in the objfile's pspace data. (objfiles_changed): Adjust to reference objfiles_changed_p in pspace data. (_initialize_objfiles): New. * linespec.c (decode_all_digits, decode_dollar): Set the sal's program space. * source.c (current_source_pspace): New. (get_current_source_symtab_and_line): Set the sal's program space. (set_current_source_symtab_and_line): Set current_source_pspace. (select_source_symtab): Ditto. Use ALL_OBJFILES. (forget_cached_source_info): Iterate over all program spaces. * symfile.c (clear_symtab_users): Adjust. * symmisc.c (print_symbol_bcache_statistics): Iterate over all program spaces. (print_objfile_statistics): Ditto. (maintenance_print_msymbols): Ditto. (maintenance_print_objfiles): Ditto. (maintenance_info_symtabs): Ditto. (maintenance_info_psymtabs): Ditto. * symtab.h (SYMTAB_PSPACE): New. (struct symtab_and_line) <pspace>: New field. * symtab.c (init_sal): Clear the sal's program space. (find_pc_sect_symtab): Set the sal's program space. Switch thread and space. (append_expanded_sal): Add program space argument. Iterate over all program spaces. (expand_line_sal): Iterate over all program spaces. Switch program space. * target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New. (struct target_ops) <to_thread_address_space>: New field. (target_thread_address_space): Define. * target.c (target_detach): Only remove breakpoints from the inferior we're detaching. (target_thread_address_space): New. * defs.h (initialize_progspace): Declare. * top.c (gdb_init): Call it. * solist.h (struct so_list) <sspace>: New field. * solib.h (struct program_space): Forward declare. (solib_name_from_address): Adjust prototype. * solib.c (so_list_head): Replace with a macro referencing the program space. (update_solib_list): Set the so's program space. (solib_name_from_address): Add a program space argument and adjust. * solib-svr4.c (struct svr4_info) <pid>: Delete field. <interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low> <interp_plt_sect_high>: New fields. (svr4_info_p, svr4_info): Delete. (solib_svr4_sspace_data): New. (get_svr4_info): Rewrite. (svr4_sspace_data_cleanup): New. (open_symbol_file_object): Adjust. (svr4_default_sos): Adjust. (svr4_fetch_objfile_link_map): Adjust. (interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low) (interp_plt_sect_high): Delete. (svr4_in_dynsym_resolve_code): Adjust. (enable_break): Adjust. (svr4_clear_solib): Revert bit that removed the svr4_info here, and reinstate clearing debug_base, debug_loader_offset_p, debug_loader_offset and debug_loader_name. (_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't install an inferior_exit observer anymore. * printcmd.c (struct display) <pspace>: New field. (display_command): Set the display's sspace. (do_one_display): Match the display's sspace. (display_uses_solib_p): Ditto. * linux-fork.c (detach_fork): Moved to infrun.c. (_initialize_linux_fork): Moved "detach-on-fork" command to infrun.c. * infrun.c (detach_fork): Moved from linux-fork.c. (proceed_after_vfork_done): New. (handle_vfork_child_exec_or_exit): New. (follow_exec_mode_replace, follow_exec_mode_keep) (follow_exec_mode_names, follow_exec_mode_string) (show_follow_exec_mode_string): New. (follow_exec): New. Reinstate the mark_breakpoints_out call. Remove shared libraries before attaching new executable. If user wants to keep the inferior, keep it. (displaced_step_fixup): Adjust to pass an address space to the breakpoints module. (resume): Ditto. (clear_proceed_status): In all-stop mode, always clear the proceed status of all threads. (prepare_to_proceed): Adjust to pass an address space to the breakpoints module. (proceed): Ditto. (adjust_pc_after_break): Ditto. (handle_inferior_event): When handling a process exit, switch the program space to the inferior's that had exited. Call handle_vfork_child_exec_or_exit. Adjust to pass an address space to the breakpoints module. In non-stop mode, when following a fork and detach-fork is off, also resume the other branch. Handle TARGET_WAITKIND_VFORK_DONE. Set the program space in sals. (normal_stop): Prune inferiors. (_initialize_infrun): Install the new "follow-exec-mode" command. "detach-on-fork" moved here. * regcache.h (get_regcache_aspace): Declare. * regcache.c (struct regcache) <aspace>: New field. (regcache_xmalloc): Clear the aspace. (get_regcache_aspace): New. (regcache_cpy): Copy the aspace field. (regcache_cpy_no_passthrough): Ditto. (get_thread_regcache): Fetch the thread's address space from the target, and store it in the regcache. * infcall.c (call_function_by_hand): Set the sal's pspace. * arch-utils.c (default_has_shared_address_space): New. * arch-utils.h (default_has_shared_address_space): Declare. * gdbarch.sh (has_shared_address_space): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.c: Include auxv.h, target.h, elf/common.h. (linux_has_shared_address_space): New. (_initialize_linux_tdep): Declare. * arm-tdep.c (arm_software_single_step): Pass the frame's address space to insert_single_step_breakpoint. * arm-linux-tdep.c (arm_linux_software_single_step): Pass the frame's pspace to breakpoint functions. * cris-tdep.c (crisv32_single_step_through_delay): Ditto. (cris_software_single_step): Ditto. * mips-tdep.c (deal_with_atomic_sequence): Add frame argument. Pass the frame's pspace to breakpoint functions. (mips_software_single_step): Adjust. (mips_single_step_through_delay): Adjust. * rs6000-aix-tdep.c (rs6000_software_single_step): Adjust. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust. * solib-irix.c (enable_break): Adjust to pass the current frame's address space to breakpoint functions. * sparc-tdep.c (sparc_software_single_step): Ditto. * spu-tdep.c (spu_software_single_step): Ditto. * alpha-tdep.c (alpha_software_single_step): Ditto. * record.c (record_wait): Adjust to pass an address space to the breakpoints module. * fork-child.c (fork_inferior): Set the new inferior's program and address spaces. * inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program and address spaces. (inf_ptrace_attach): Set the inferior's program and address spaces. * linux-nat.c: Include "solib.h". (linux_child_follow_fork): Manage parent and child's program and address spaces. Clone the parent's program space if necessary. Don't wait for the vfork to be done here. Refuse to resume if following the vfork parent while leaving the child stopped. (resume_callback): Don't resume a vfork parent. (linux_nat_resume): Also check for pending events in the lp->waitstatus field. (linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE events to the core. (stop_wait_callback): Don't wait for SIGSTOP on vfork parents. (cancel_breakpoint): Adjust. * linux-thread-db.c (thread_db_wait): Don't remove thread event breakpoints here. (thread_db_mourn_inferior): Don't mark breakpoints out here. Remove thread event breakpoints after mourning. * corelow.c: Include progspace.h. (core_open): Set the inferior's program and address spaces. * remote.c (remote_add_inferior): Set the new inferior's program and address spaces. (remote_start_remote): Update address spaces. (extended_remote_create_inferior_1): Don't init the thread list if we already debugging other inferiors. * darwin-nat.c (darwin_attach): Set the new inferior's program and address spaces. * gnu-nat.c (gnu_attach): Ditto. * go32-nat.c (go32_create_inferior): Ditto. * inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto. * monitor.c (monitor_open): Ditto. * nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto. * procfs.c (do_attach): Ditto. * windows-nat.c (do_initial_windows_stuff): Ditto. * inflow.c (inferior_process_group) (terminal_init_inferior_with_pgrp, terminal_inferior, (terminal_ours_1, inflow_inferior_exit, copy_terminal_info) (child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust to use per-inferior data instead of inferior->terminal_info. (inflow_inferior_data): New. (inflow_new_inferior): Delete. (inflow_inferior_data_cleanup): New. (get_inflow_inferior_data): New. * mi/mi-interp.c (mi_new_inferior): Rename to... (mi_inferior_appeared): ... this. (mi_interpreter_init): Adjust. * tui/tui-disasm.c: Include "progspace.h". (tui_set_disassem_content): Pass an address space to breakpoint_here_p. * NEWS: Mention multi-program debugging support. Mention new commands "add-inferior", "clone-inferior", "remove-inferior", "maint info program-spaces", and new option "set follow-exec-mode". 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * observer.texi (new_inferior): Rename to... (inferior_appeared): ... this. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/testsuite/ * gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork". * gdb.base/foll-exec.exp: Adjust to expect a process id before "Executing new program". * gdb.base/foll-fork.exp: Adjust to spell out "follow-fork". * gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being left listed after having been killed. * gdb.base/attach.exp: Adjust to spell out "symbol-file". * gdb.base/maint.exp: Adjust test. * Makefile.in (ALL_SUBDIRS): Add gdb.multi. * gdb.multi/Makefile.in: New. * gdb.multi/base.exp: New. * gdb.multi/goodbye.c: New. * gdb.multi/hangout.c: New. * gdb.multi/hello.c: New. * gdb.multi/bkpt-multi-exec.c: New. * gdb.multi/bkpt-multi-exec.exp: New. * gdb.multi/crashme.c: New. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * gdb.texinfo (Inferiors): Rename node to ... (Inferiors and Programs): ... this. Mention running multiple programs in the same debug session. <info inferiors>: Mention the new 'Executable' column if "info inferiors". Update examples. Document the "add-inferior", "clone-inferior", "remove-inferior" and "maint info program-spaces" commands. (Process): Rename node to... (Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
i->pspace = current_program_space;
current_program_space->added_solibs.push_back (i);
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
Rewrite TRY/CATCH This rewrites gdb's TRY/CATCH to plain C++ try/catch. The patch was largely written by script, though one change (to a comment in common-exceptions.h) was reverted by hand. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * xml-support.c: Use C++ exception handling. * x86-linux-nat.c: Use C++ exception handling. * windows-nat.c: Use C++ exception handling. * varobj.c: Use C++ exception handling. * value.c: Use C++ exception handling. * valprint.c: Use C++ exception handling. * valops.c: Use C++ exception handling. * unittests/parse-connection-spec-selftests.c: Use C++ exception handling. * unittests/cli-utils-selftests.c: Use C++ exception handling. * typeprint.c: Use C++ exception handling. * tui/tui.c: Use C++ exception handling. * tracefile-tfile.c: Use C++ exception handling. * top.c: Use C++ exception handling. * thread.c: Use C++ exception handling. * target.c: Use C++ exception handling. * symmisc.c: Use C++ exception handling. * symfile-mem.c: Use C++ exception handling. * stack.c: Use C++ exception handling. * sparc64-linux-tdep.c: Use C++ exception handling. * solib.c: Use C++ exception handling. * solib-svr4.c: Use C++ exception handling. * solib-spu.c: Use C++ exception handling. * solib-frv.c: Use C++ exception handling. * solib-dsbt.c: Use C++ exception handling. * selftest-arch.c: Use C++ exception handling. * s390-tdep.c: Use C++ exception handling. * rust-lang.c: Use C++ exception handling. * rust-exp.y: Use C++ exception handling. * rs6000-tdep.c: Use C++ exception handling. * rs6000-aix-tdep.c: Use C++ exception handling. * riscv-tdep.c: Use C++ exception handling. * remote.c: Use C++ exception handling. * remote-fileio.c: Use C++ exception handling. * record-full.c: Use C++ exception handling. * record-btrace.c: Use C++ exception handling. * python/python.c: Use C++ exception handling. * python/py-value.c: Use C++ exception handling. * python/py-utils.c: Use C++ exception handling. * python/py-unwind.c: Use C++ exception handling. * python/py-type.c: Use C++ exception handling. * python/py-symbol.c: Use C++ exception handling. * python/py-record.c: Use C++ exception handling. * python/py-record-btrace.c: Use C++ exception handling. * python/py-progspace.c: Use C++ exception handling. * python/py-prettyprint.c: Use C++ exception handling. * python/py-param.c: Use C++ exception handling. * python/py-objfile.c: Use C++ exception handling. * python/py-linetable.c: Use C++ exception handling. * python/py-lazy-string.c: Use C++ exception handling. * python/py-infthread.c: Use C++ exception handling. * python/py-inferior.c: Use C++ exception handling. * python/py-gdb-readline.c: Use C++ exception handling. * python/py-framefilter.c: Use C++ exception handling. * python/py-frame.c: Use C++ exception handling. * python/py-finishbreakpoint.c: Use C++ exception handling. * python/py-cmd.c: Use C++ exception handling. * python/py-breakpoint.c: Use C++ exception handling. * python/py-arch.c: Use C++ exception handling. * printcmd.c: Use C++ exception handling. * ppc-linux-tdep.c: Use C++ exception handling. * parse.c: Use C++ exception handling. * p-valprint.c: Use C++ exception handling. * objc-lang.c: Use C++ exception handling. * mi/mi-main.c: Use C++ exception handling. * mi/mi-interp.c: Use C++ exception handling. * mi/mi-cmd-stack.c: Use C++ exception handling. * mi/mi-cmd-break.c: Use C++ exception handling. * main.c: Use C++ exception handling. * linux-thread-db.c: Use C++ exception handling. * linux-tdep.c: Use C++ exception handling. * linux-nat.c: Use C++ exception handling. * linux-fork.c: Use C++ exception handling. * linespec.c: Use C++ exception handling. * language.c: Use C++ exception handling. * jit.c: Use C++ exception handling. * infrun.c: Use C++ exception handling. * infcmd.c: Use C++ exception handling. * infcall.c: Use C++ exception handling. * inf-loop.c: Use C++ exception handling. * i386-tdep.c: Use C++ exception handling. * i386-linux-tdep.c: Use C++ exception handling. * guile/scm-value.c: Use C++ exception handling. * guile/scm-type.c: Use C++ exception handling. * guile/scm-symtab.c: Use C++ exception handling. * guile/scm-symbol.c: Use C++ exception handling. * guile/scm-pretty-print.c: Use C++ exception handling. * guile/scm-ports.c: Use C++ exception handling. * guile/scm-param.c: Use C++ exception handling. * guile/scm-math.c: Use C++ exception handling. * guile/scm-lazy-string.c: Use C++ exception handling. * guile/scm-frame.c: Use C++ exception handling. * guile/scm-disasm.c: Use C++ exception handling. * guile/scm-cmd.c: Use C++ exception handling. * guile/scm-breakpoint.c: Use C++ exception handling. * guile/scm-block.c: Use C++ exception handling. * guile/guile-internal.h: Use C++ exception handling. * gnu-v3-abi.c: Use C++ exception handling. * gdbtypes.c: Use C++ exception handling. * frame.c: Use C++ exception handling. * frame-unwind.c: Use C++ exception handling. * fbsd-tdep.c: Use C++ exception handling. * f-valprint.c: Use C++ exception handling. * exec.c: Use C++ exception handling. * event-top.c: Use C++ exception handling. * event-loop.c: Use C++ exception handling. * eval.c: Use C++ exception handling. * dwarf2read.c: Use C++ exception handling. * dwarf2loc.c: Use C++ exception handling. * dwarf2-frame.c: Use C++ exception handling. * dwarf2-frame-tailcall.c: Use C++ exception handling. * dwarf-index-write.c: Use C++ exception handling. * dwarf-index-cache.c: Use C++ exception handling. * dtrace-probe.c: Use C++ exception handling. * disasm-selftests.c: Use C++ exception handling. * darwin-nat.c: Use C++ exception handling. * cp-valprint.c: Use C++ exception handling. * cp-support.c: Use C++ exception handling. * cp-abi.c: Use C++ exception handling. * corelow.c: Use C++ exception handling. * completer.c: Use C++ exception handling. * compile/compile-object-run.c: Use C++ exception handling. * compile/compile-object-load.c: Use C++ exception handling. * compile/compile-cplus-symbols.c: Use C++ exception handling. * compile/compile-c-symbols.c: Use C++ exception handling. * common/selftest.c: Use C++ exception handling. * common/new-op.c: Use C++ exception handling. * cli/cli-script.c: Use C++ exception handling. * cli/cli-interp.c: Use C++ exception handling. * cli/cli-cmds.c: Use C++ exception handling. * c-varobj.c: Use C++ exception handling. * btrace.c: Use C++ exception handling. * breakpoint.c: Use C++ exception handling. * break-catch-throw.c: Use C++ exception handling. * arch-utils.c: Use C++ exception handling. * amd64-tdep.c: Use C++ exception handling. * ada-valprint.c: Use C++ exception handling. * ada-typeprint.c: Use C++ exception handling. * ada-lang.c: Use C++ exception handling. * aarch64-tdep.c: Use C++ exception handling. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * server.c: Use C++ exception handling. * linux-low.c: Use C++ exception handling. * gdbreplay.c: Use C++ exception handling.
2019-04-04 00:02:42 +02:00
try
{
/* Fill in the rest of the `struct so_list' node. */
if (!solib_map_sections (i))
{
not_found++;
if (not_found_filename == NULL)
not_found_filename = i->so_original_name;
}
}
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
Rename gdb exception types This renames the gdb exception types. The old types were only needed due to the macros in common-exception.h that are now gone. The intermediate layer of gdb_exception_RETURN_MASK_ALL did not seem needed, so this patch removes it entirely. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * common/common-exceptions.h (gdb_exception_RETURN_MASK_ALL): Remove. (gdb_exception_error): Rename from gdb_exception_RETURN_MASK_ERROR. (gdb_exception_quit): Rename from gdb_exception_RETURN_MASK_QUIT. (gdb_quit_bad_alloc): Update. * aarch64-tdep.c: Update. * ada-lang.c: Update. * ada-typeprint.c: Update. * ada-valprint.c: Update. * amd64-tdep.c: Update. * arch-utils.c: Update. * break-catch-throw.c: Update. * breakpoint.c: Update. * btrace.c: Update. * c-varobj.c: Update. * cli/cli-cmds.c: Update. * cli/cli-interp.c: Update. * cli/cli-script.c: Update. * common/common-exceptions.c: Update. * common/new-op.c: Update. * common/selftest.c: Update. * compile/compile-c-symbols.c: Update. * compile/compile-cplus-symbols.c: Update. * compile/compile-object-load.c: Update. * compile/compile-object-run.c: Update. * completer.c: Update. * corelow.c: Update. * cp-abi.c: Update. * cp-support.c: Update. * cp-valprint.c: Update. * darwin-nat.c: Update. * disasm-selftests.c: Update. * dtrace-probe.c: Update. * dwarf-index-cache.c: Update. * dwarf-index-write.c: Update. * dwarf2-frame-tailcall.c: Update. * dwarf2-frame.c: Update. * dwarf2loc.c: Update. * dwarf2read.c: Update. * eval.c: Update. * event-loop.c: Update. * event-top.c: Update. * exec.c: Update. * f-valprint.c: Update. * fbsd-tdep.c: Update. * frame-unwind.c: Update. * frame.c: Update. * gdbtypes.c: Update. * gnu-v3-abi.c: Update. * guile/guile-internal.h: Update. * guile/scm-block.c: Update. * guile/scm-breakpoint.c: Update. * guile/scm-cmd.c: Update. * guile/scm-disasm.c: Update. * guile/scm-frame.c: Update. * guile/scm-lazy-string.c: Update. * guile/scm-math.c: Update. * guile/scm-param.c: Update. * guile/scm-ports.c: Update. * guile/scm-pretty-print.c: Update. * guile/scm-symbol.c: Update. * guile/scm-symtab.c: Update. * guile/scm-type.c: Update. * guile/scm-value.c: Update. * i386-linux-tdep.c: Update. * i386-tdep.c: Update. * inf-loop.c: Update. * infcall.c: Update. * infcmd.c: Update. * infrun.c: Update. * jit.c: Update. * language.c: Update. * linespec.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * main.c: Update. * mi/mi-cmd-break.c: Update. * mi/mi-cmd-stack.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * objc-lang.c: Update. * p-valprint.c: Update. * parse.c: Update. * ppc-linux-tdep.c: Update. * printcmd.c: Update. * python/py-arch.c: Update. * python/py-breakpoint.c: Update. * python/py-cmd.c: Update. * python/py-finishbreakpoint.c: Update. * python/py-frame.c: Update. * python/py-framefilter.c: Update. * python/py-gdb-readline.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * python/py-lazy-string.c: Update. * python/py-linetable.c: Update. * python/py-objfile.c: Update. * python/py-param.c: Update. * python/py-prettyprint.c: Update. * python/py-progspace.c: Update. * python/py-record-btrace.c: Update. * python/py-record.c: Update. * python/py-symbol.c: Update. * python/py-type.c: Update. * python/py-unwind.c: Update. * python/py-utils.c: Update. * python/py-value.c: Update. * python/python.c: Update. * record-btrace.c: Update. * record-full.c: Update. * remote-fileio.c: Update. * remote.c: Update. * riscv-tdep.c: Update. * rs6000-aix-tdep.c: Update. * rs6000-tdep.c: Update. * rust-exp.y: Update. * rust-lang.c: Update. * s390-tdep.c: Update. * selftest-arch.c: Update. * solib-dsbt.c: Update. * solib-frv.c: Update. * solib-spu.c: Update. * solib-svr4.c: Update. * solib.c: Update. * sparc64-linux-tdep.c: Update. * stack.c: Update. * symfile-mem.c: Update. * symmisc.c: Update. * target.c: Update. * thread.c: Update. * top.c: Update. * tracefile-tfile.c: Update. * tui/tui.c: Update. * typeprint.c: Update. * unittests/cli-utils-selftests.c: Update. * unittests/parse-connection-spec-selftests.c: Update. * valops.c: Update. * valprint.c: Update. * value.c: Update. * varobj.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * xml-support.c: Update. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * gdbreplay.c: Update. * linux-low.c: Update. * server.c: Update.
2019-04-03 23:59:07 +02:00
catch (const gdb_exception_error &e)
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
{
exception_fprintf (gdb_stderr, e,
_("Error while mapping shared "
"library sections:\n"));
}
/* Notify any observer that the shared object has been
loaded now that we've added it to GDB's tables. */
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::solib_loaded.notify (i);
}
/* If a library was not found, issue an appropriate warning
message. We have to use a single call to warning in case the
front end does something special with warnings, e.g., pop up
a dialog box. It Would Be Nice if we could get a "warning: "
prefix on each line in the CLI front end, though - it doesn't
stand out well. */
if (not_found == 1)
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
warning (_("Could not load shared library symbols for %s.\n"
"Do you need \"set solib-search-path\" "
"or \"set sysroot\"?"),
not_found_filename);
else if (not_found > 1)
warning (_("\
Could not load shared library symbols for %d libraries, e.g. %s.\n\
Use the \"info sharedlibrary\" command to see the complete listing.\n\
Do you need \"set solib-search-path\" or \"set sysroot\"?"),
not_found, not_found_filename);
}
}
/* Return non-zero if NAME is the libpthread shared library.
Uses a fairly simplistic heuristic approach where we check
the file name against "/libpthread". This can lead to false
positives, but this should be good enough in practice. */
bool
libpthread_name_p (const char *name)
{
return (strstr (name, "/libpthread") != NULL);
}
/* Return non-zero if SO is the libpthread shared library. */
static bool
libpthread_solib_p (struct so_list *so)
{
return libpthread_name_p (so->so_name);
}
/* Read in symbolic information for any shared objects whose names
match PATTERN. (If we've already read a shared object's symbol
info, leave it alone.) If PATTERN is zero, read them all.
Approved by kev@cygnus.com ChangeLog entry: 2001-11-01 Fred Fish <fnf@redhat.com> * coff-solib.c (coff_solib_add): Add new readsyms arg. * irix5-nat.c (solib_add): Ditto. * osfsolib.c (solib_add): Ditto. * pa64solib.c (pa64_solib_add): Ditto. * pa64solib.c (add_to_solist): Ditto. * pa64solib.c (read_dld_descriptor): Ditto. * solib.c (solib_add): Ditto. * somsolib.c (som_solib_add): Ditto. * win32-nat.c (child_solib_add): Ditto. * xcoffsolib.c (solib_add): Ditto. * coff-solib.h (coff_solib_add): Add new readsyms arg to prototype. * pa64solib.c (add_to_solist): Ditto. * pa64solib.c (read_dld_descriptor): Ditto. * pa64solib.h (pa64_solib_add): Ditto. * solib.h (solib_add): Ditto. * somsolib.h (som_solib_add): Ditto. * config/i386/tm-cygwin.h (child_solib_add): Ditto. * coff-solib.c (coff_solib_add): If readsyms is zero don't read symbols but do any other needed work for shared libs. * irix5-nat.c: Ditto. * osfsolib.c (solib_add): Ditto. * solib.c (solib_add): Ditto. * win32-nat.c (child_solib_add): Ditto. * xcoffsolib.c (solib_add): Ditto. * irix5-nat.c (sharedlibrary_command): Pass 1 as readsyms to solib_add to force reading of shared library symbols. * osfsolib.c (sharedlibrary_command;): Ditto. * pa64solib.c (pa64_solib_sharedlibrary_command): Ditto. * solib.c (sharedlibrary_command): Ditto. * somsolib.c (som_solib_sharedlibrary_command): Ditto. * xcoffsolib.c (sharedlibrary_command): Ditto. * coff-solib.c (coff_solib_create_inferior_hook): Call solib_add unconditionally with auto_solib_add. * irix5-nat.c (solib_create_inferior_hook): Ditto. * osfsolib.c (solib_create_inferior_hook): Ditto. * solib.c (solib_create_inferior_hook): Ditto. * solib-osf.c (osf_solib_create_inferior_hook): Ditto. * solib-svr4.c (enable_break): Ditto. * solib-sunos.c (sunos_solib_create_inferior_hook): Ditto. * corelow.c (solib_add_stub): Add auto_solib_add to args passed via SOLIB_ADD. * sol-thread.c (sol_thread_attach): Ditto. * config/rs6000/nm-rs6000.h (SOLIB_ADD): Ditto. * infcmd.c (attach_command): Remove auto_solib_add decl. Call SOLIB_ADD directly with auto_solib_add. * infrun.c (handle_inferior_event): Ditto. * coff-solib.h (SOLIB_ADD): Add readsyms arg. * pa64solib.h (SOLIB_ADD): Ditto. * solib.h (SOLIB_ADD): Ditto. * somsolib.h (SOLIB_ADD): Ditto. * config/i386/tm-cygwin.h (SOLIB_ADD): Ditto. * fork-child.c (clone_and_follow_inferior): Remove unused auto_solib_add decl. * pa64solib.c (pa64_solib_add): Call add_to_solist with readsyms. (read_dld_descriptor): Ditto. (pa64_solib_add): Call read_dld_descriptor with readsyms. (pa64_solib_in_dynamic_linker): Ditto. * corelow.c (symfile.h): Need this for auto_solib_add declaration. * sol-thread.c (symfile.h): Ditto. Approved by eliz@is.elta.co.il doc/ChangeLog entry: 2001-11-01 Fred Fish <fnf@redhat.com> * gdbint.texinfo (SOLIB_ADD): Document additional new "readsyms" arg.
2001-11-01 17:17:08 +01:00
If READSYMS is 0, defer reading symbolic information until later
but still do any needed low level processing.
FROM_TTY is described for update_solib_list, above. */
void
solib_add (const char *pattern, int from_tty, int readsyms)
{
if (print_symbol_loading_p (from_tty, 0, 0))
{
if (pattern != NULL)
{
printf_unfiltered (_("Loading symbols for shared libraries: %s\n"),
pattern);
}
else
printf_unfiltered (_("Loading symbols for shared libraries.\n"));
}
current_program_space->solib_add_generation++;
if (pattern)
{
char *re_err = re_comp (pattern);
if (re_err)
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 (_("Invalid regexp: %s"), re_err);
}
update_solib_list (from_tty);
/* Walk the list of currently loaded shared libraries, and read
symbols for any that match the pattern --- or any whose symbols
aren't already loaded, if no pattern was given. */
{
bool any_matches = false;
bool loaded_any_symbols = false;
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 = SYMFILE_DEFER_BP_RESET;
if (from_tty)
add_flags |= SYMFILE_VERBOSE;
for (struct so_list *gdb : current_program_space->solibs ())
if (! pattern || re_exec (gdb->so_name))
{
/* Normally, we would read the symbols from that library
only if READSYMS is set. However, we're making a small
exception for the pthread library, because we sometimes
need the library symbols to be loaded in order to provide
thread support (x86-linux for instance). */
const int add_this_solib =
(readsyms || libpthread_solib_p (gdb));
any_matches = true;
if (add_this_solib)
{
if (gdb->symbols_loaded)
{
/* If no pattern was given, be quiet for shared
libraries we have already loaded. */
if (pattern && (from_tty || info_verbose))
printf_unfiltered (_("Symbols already loaded for %s\n"),
gdb->so_name);
}
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
else if (solib_read_symbols (gdb, add_flags))
loaded_any_symbols = true;
}
}
if (loaded_any_symbols)
breakpoint_re_set ();
if (from_tty && pattern && ! any_matches)
printf_unfiltered
("No loaded shared libraries match the pattern `%s'.\n", pattern);
if (loaded_any_symbols)
{
/* Getting new symbols may change our opinion about what is
frameless. */
reinit_frame_cache ();
}
}
}
/* Implement the "info sharedlibrary" command. Walk through the
shared library list and print information about each attached
library matching PATTERN. If PATTERN is elided, print them
all. */
static void
Constify add_info This patch constifies add_info and updates all the info commands. The bulk of this patch was written using a script; and then I did a manual pass to fix up the remaining compilation errors. I could not compile every changed file; in particular nto-procfs.c, gnu-nat.c, and darwin-nat-info.c; but I at least tried to check the correctness by inspection. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * frame.h (info_locals_command, info_args_command): Constify. * auto-load.h (auto_load_info_scripts): Constify. * inferior.h (registers_info): Constify. * copying.c: Rebuild. * copying.awk: Constify generated commands. * auto-load.c (auto_load_info_scripts) (info_auto_load_gdb_scripts): Constify. * cli/cli-decode.c (struct cmd_list_element): Take a cmd_const_cfunc_ftype. * command.h (add_info): Take a cmd_const_cfunc_ftype. * tui/tui-win.c (tui_all_windows_info): Constify. * python/py-auto-load.c (info_auto_load_python_scripts): Constify. * cli/cli-cmds.c (show_command): Remove non-const overload. * tracepoint.c (info_tvariables_command, info_scope_command): Constify. (info_static_tracepoint_markers_command): Constify. * thread.c (info_threads_command): Constify. (print_thread_info_1): Constify. * target.c (info_target_command): Constify. * symtab.c (info_sources_command, info_functions_command) (info_types_command): Constify. (info_variables_command): Remove non-const overload. * symfile.c (info_ext_lang_command): Constify. * stack.c (info_frame_command, info_locals_command) (info_args_command): Constify. (backtrace_command): Remove non-const overload. * source.c (info_source_command, info_line_command): Constify. * solib.c (info_sharedlibrary_command): Constify. * skip.c (info_skip_command): Constify. * ser-go32.c (info_serial_command): Constify. * reverse.c (info_bookmarks_command): Constify. * printcmd.c (info_symbol_command, info_address_command) (info_display_command): Constify. * osdata.c (info_osdata_command): Constify. * objc-lang.c (info_selectors_command, info_classes_command): Constify. * nto-procfs.c (procfs_pidlist, procfs_meminfo): Constify. * memattr.c (info_mem_command): Constify. * macrocmd.c (info_macro_command, info_macros_command): Constify. * linux-fork.c (info_checkpoints_command): Constify. * infrun.c (info_signals_command): Constify. * inflow.c (info_terminal_command): Constify. * inferior.c (info_inferiors_command): Constify. (print_inferior): Constify. * infcmd.c (info_program_command, info_all_registers_command) (info_registers_command, info_vector_command) (info_float_command): Constify. (registers_info): Constify. * gnu-nat.c (info_send_rights_cmd, info_recv_rights_cmd) (info_port_sets_cmd, info_dead_names_cmd, info_port_rights_cmd): Constify. * f-valprint.c (info_common_command): Constify. * dcache.c (info_dcache_command): Constify. (dcache_info_1): Constify. * darwin-nat-info.c (info_mach_tasks_command) (info_mach_task_command, info_mach_ports_command) (info_mach_port_command, info_mach_threads_command) (info_mach_thread_command, info_mach_regions_command) (info_mach_regions_recurse_command, info_mach_region_command) (info_mach_exceptions_command): Constify. (get_task_from_args): Constify. * cp-support.c (info_vtbl_command): Constify. * breakpoint.c (info_watchpoints_command) (info_tracepoints_command): Constify. (info_breakpoints_command): Remove non-const overload. * avr-tdep.c (avr_io_reg_read_command): Constify. * auxv.c (info_auxv_command): Constify. * ada-tasks.c (info_tasks_command): Constify. (info_task): Constify. * ada-lang.c (info_exceptions_command): Constify.
2017-10-14 06:07:26 +02:00
info_sharedlibrary_command (const char *pattern, int from_tty)
{
bool so_missing_debug_info = false;
int addr_width;
int nr_libs;
struct gdbarch *gdbarch = target_gdbarch ();
2011-08-04 Pedro Alves <pedro@codesourcery.com> * ui-out.h (uiout): Rename to ... (current_uiout): ... this. * ui-out.c (uiout): Rename to ... (current_uiout): ... this. * ada-lang.c (print_it_exception, print_one_exception) (print_mention_exception): Adjust. * breakpoint.c (watchpoint_check): Adjust. (print_breakpoint_location, print_one_breakpoint, breakpoint_1) (default_collect_info, watchpoints_info, print_one_catch_fork) (print_one_catch_vfork, print_one_catch_syscall) (print_one_catch_exec, mention, print_it_ranged_breakpoint) (print_one_ranged_breakpoint, print_mention_ranged_breakpoint) (print_it_watchpoint, print_mention_watchpoint) (print_it_masked_watchpoint, print_mention_masked_watchpoint) (print_it_exception_catchpoint, print_one_exception_catchpoint) (print_mention_exception_catchpoint, say_where, bkpt_print_it) (bkpt_print_mention, momentary_bkpt_print_it) (tracepoint_print_mention, update_static_tracepoint) (tracepoints_info, save_breakpoints): Adjust. * cli-out.c (field_separator): Adjust. * cp-abi.c (list_cp_abis, show_cp_abi_cmd): Adjust. * exceptions.c (catch_exceptions_with_msg, catch_errors): Adjust. * frame.c (get_current_frame): Adjust. * infcmd.c (run_command_1, print_return_value): Adjust. * inferior.c (inferior_command, info_inferiors_command): Adjust. * infrun.c (print_end_stepping_range_reason): Adjust. (print_signal_exited_reason, print_exited_reason): Adjust. (print_signal_received_reason, print_no_history_reason): Adjust. * interps.c (interp_set): Adjust. * osdata.c (info_osdata_command): Adjust. * progspace.c (maintenance_info_program_spaces_command): Adjust. * remote-fileio.c (remote_fileio_request): Adjust. * remote.c (show_remote_cmd): Adjust. * solib.c (info_sharedlibrary_command): Adjust. * source.c (print_source_lines_base): Adjust. * stack.c (print_stack_frame): Adjust. (do_gdb_disassembly, print_frame_info, print_frame): Adjust. * symfile-mem.c (add_vsyscall_page): Adjust. * symfile.c (load_progress, generic_load) (print_transfer_performance): Adjust. * thread.c (info_threads_command, restore_selected_frame) (thread_command): Adjust. * top.c (make_cleanup_restore_ui_file): Adjust. * tracepoint.c (tvariables_info_1, trace_status_mi, tfind_1) (print_one_static_tracepoint_marker): Adjust. * cli/cli-cmds.c (print_disassembly): Adjust. * cli/cli-decode.c (print_doc_line): Adjust. * cli/cli-interp.c (safe_execute_command): Adjust. * cli/cli-logging.c (set_logging_redirect, pop_output_files) (handle_redirections): Adjust. * cli/cli-script.c (show_user_1): Adjust. * cli/cli-setshow.c (do_setshow_command, cmd_show_list): Adjust. * mi/mi-cmd-break.c (breakpoint_notify): Adjust. * mi/mi-cmd-disas.c (mi_cmd_disassemble): Adjust. * mi/mi-cmd-env.c (mi_cmd_env_pwd, mi_cmd_env_path) (mi_cmd_env_dir): Adjust. * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file) (print_partial_file_name, mi_cmd_file_list_exec_source_files): Adjust. * mi/mi-cmd-stack.c (mi_cmd_stack_list_frames) (mi_cmd_stack_info_depth, mi_cmd_stack_list_args) (list_args_or_locals): Adjust. * mi/mi-cmd-var.c (print_varobj, mi_cmd_var_create) (mi_cmd_var_delete, mi_cmd_var_set_format, mi_cmd_var_set_frozen) (mi_cmd_var_show_format, mi_cmd_var_info_num_children) (mi_cmd_var_list_children, mi_cmd_var_info_type) (mi_cmd_var_info_path_expression, mi_cmd_var_info_expression) (mi_cmd_var_show_attributes, mi_cmd_var_evaluate_expression) (mi_cmd_var_assign, mi_cmd_var_update, varobj_update_one): Adjust. * mi/mi-interp.c (mi_on_normal_stop): Adjust. * mi/mi-main.c (mi_cmd_gdb_exit, mi_cmd_thread_select) (mi_cmd_thread_list_ids, mi_cmd_thread_info, print_one_inferior) (list_available_thread_groups, mi_cmd_list_thread_groups) (mi_cmd_data_list_register_names) (mi_cmd_data_list_changed_registers) (mi_cmd_data_list_register_values, get_register) (mi_cmd_data_evaluate_expression, mi_cmd_data_read_memory) (mi_cmd_data_read_memory_bytes, mi_cmd_list_features) (mi_cmd_list_target_features, mi_cmd_add_inferior) (mi_execute_command, mi_load_progress): Adjust. * mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Adjust. * python/py-auto-load.c (print_script, info_auto_load_scripts): Adjust. * python/py-breakpoint.c (bppy_get_commands): Adjust. * tui/tui-interp.c (tui_command_loop): Adjust. * tui/tui-io.c (tui_setup_io, tui_initialize_io): Adjust.
2011-08-04 21:10:14 +02:00
struct ui_out *uiout = current_uiout;
if (pattern)
{
char *re_err = re_comp (pattern);
if (re_err)
error (_("Invalid regexp: %s"), re_err);
}
/* "0x", a little whitespace, and two hex digits per byte of pointers. */
addr_width = 4 + (gdbarch_ptr_bit (gdbarch) / 4);
update_solib_list (from_tty);
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
/* ui_out_emit_table table_emitter needs to know the number of rows,
so we need to make two passes over the libs. */
nr_libs = 0;
for (struct so_list *so : current_program_space->solibs ())
{
1999-07-07 22:19:36 +02:00
if (so->so_name[0])
{
if (pattern && ! re_exec (so->so_name))
continue;
++nr_libs;
}
}
{
ui_out_emit_table table_emitter (uiout, 4, nr_libs, "SharedLibraryTable");
/* The "- 1" is because ui_out adds one space between columns. */
uiout->table_header (addr_width - 1, ui_left, "from", "From");
uiout->table_header (addr_width - 1, ui_left, "to", "To");
uiout->table_header (12 - 1, ui_left, "syms-read", "Syms Read");
uiout->table_header (0, ui_noalign, "name", "Shared Object Library");
uiout->table_body ();
for (struct so_list *so : current_program_space->solibs ())
{
if (! so->so_name[0])
continue;
if (pattern && ! re_exec (so->so_name))
continue;
ui_out_emit_tuple tuple_emitter (uiout, "lib");
if (so->addr_high != 0)
{
uiout->field_core_addr ("from", gdbarch, so->addr_low);
uiout->field_core_addr ("to", gdbarch, so->addr_high);
}
else
{
uiout->field_skip ("from");
uiout->field_skip ("to");
}
if (! top_level_interpreter ()->interp_ui_out ()->is_mi_like_p ()
&& so->symbols_loaded
&& !objfile_has_symbols (so->objfile))
{
so_missing_debug_info = true;
uiout->field_string ("syms-read", "Yes (*)");
}
else
uiout->field_string ("syms-read", so->symbols_loaded ? "Yes" : "No");
Remove the ui_out_style_kind enum This removes the ui_out_style_kind enum, in favor of simply using ui_file_style references. This simplifies the code somewhat. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * ui-out.h (enum class ui_out_style_kind): Remove. (class ui_out) <field_string, field_stsream, do_field_string>: Change type of "style". * ui-out.c (ui_out::field_core_addr, ui_out::field_stream) (ui_out::field_string): Update. * tui/tui-out.h (class tui_ui_out) <do_field_string>: Change type of "style". * tui/tui-out.c (tui_ui_out::do_field_string): Update. * tracepoint.c (print_one_static_tracepoint_marker): Update. * stack.c (print_frame_arg, print_frame_info, print_frame): Update. * source.c (print_source_lines_base): Update. * solib.c (info_sharedlibrary_command): Update. * skip.c (info_skip_command): Update. * record-btrace.c (btrace_call_history_src_line) (btrace_call_history): Update. * python/py-framefilter.c (py_print_frame): Update. * mi/mi-out.h (class mi_ui_out) <do_field_string>: Change type of "style". * mi/mi-out.c (mi_ui_out::do_table_header) (mi_ui_out::do_field_signed, mi_ui_out::do_field_unsigned) (mi_ui_out::do_field_string): Update. * disasm.c (gdb_pretty_print_disassembler::pretty_print_insn): Update. * cli-out.h (class cli_ui_out) <do_field_string>: Change type of "style". * cli-out.c (cli_ui_out::do_table_header) (cli_ui_out::do_field_signed, cli_ui_out::do_field_unsigned) (cli_ui_out::do_field_skip, cli_ui_out::do_field_string) (cli_ui_out::do_field_fmt): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update.
2019-06-06 00:21:24 +02:00
uiout->field_string ("name", so->so_name, file_name_style.style ());
uiout->text ("\n");
}
}
if (nr_libs == 0)
{
if (pattern)
Class-ify ui_out This patch finalizes the C++ conversion of the ui-out subsystem, by turning the ui_out and ui_out_impl structures into a single class hierarchy. ui_out functions are turned into virtual methods of that new class, so as a result there are a lot of call sites to update. In the previous version of the patchset, there were separate ui_out and ui_out_impl classes, but it wasn't really useful and added boilerplate. In this version there is simply an ui_out base class that is extended for CLI, TUI and MI. It's a bit hard to maintain a ChangeLog for such a big patch, I did my best but I'm sure there are some missing or outdated info in there... gdb/ChangeLog: * ui-out.h (ui_out_begin, ui_out_end, ui_out_table_header, ui_out_table_body, ui_out_field_int, ui_out_field_fmt_int, ui_out_field_core_addr, ui_out_field_string, ui_out_field_stream, ui_out_field_fmt, ui_out_field_skip, ui_out_spaces, ui_out_text, ui_out_message, ui_out_wrap_hint, ui_out_flush, ui_out_test_flags, ui_out_query_field, ui_out_is_mi_like_p, ui_out_redirect): Remove, replace with a method in class ui_out. (table_begin_ftype): Remove, replace with pure virtual method in class ui_out. (table_body_ftype): Likewise. (table_end_ftype): Likewise. (table_header_ftype): Likewise. (ui_out_begin_ftype): Likewise. (ui_out_end_ftype): Likewise. (field_int_ftype): Likewise. (field_skip_ftype): Likewise. (field_string_ftype): Likewise. (field_fmt_ftype): Likewise. (spaces_ftype): Likewise. (text_ftype): Likewise. (message_ftype): Likewise. (wrap_hint_ftype): Likewise. (flush_ftype): Likewise. (redirect_ftype): Likewise. (data_destroy_ftype): Likewise. (struct ui_out_impl): Remove, replace with class ui_out. (ui_out_new): Remove. (class ui_out): New class. * ui-out.c (struct ui_out): Remove, replaced with class ui_out. (current_level): Remove, replace with ui_out method. (push_level): Likewise. (pop_level): Likewise. (uo_table_begin, uo_table_body, uo_table_end, uo_table_header, uo_begin, uo_end, uo_field_int, uo_field_skip, uo_field_fmt, uo_spaces, uo_text, uo_message, uo_wrap_hint, uo_flush, uo_redirect, uo_field_string): Remove. (ui_out_table_begin): Replace with ... (ui_out::table_begin): ... this. (ui_out_table_body): Replace with ... (ui_out::table_body): ... this. (ui_out_table_end): Replace with ... (ui_out::table_end): ... this. (ui_out_table_header): Replace with ... (ui_out::table_header): ... this. (ui_out_begin): Replace with ... (ui_out::begin): ... this. (ui_out_end): Replace with ... (ui_out::end): ... this. (ui_out_field_int): Replace with ... (ui_out::field_int): ... this. (ui_out_field_fmt_int): Replace with ... (ui_out::field_fmt_int): ... this. (ui_out_field_core_addr): Replace with ... (ui_out::field_core_addr): ... this. (ui_out_field_stream): Replace with ... (ui_out::field_stream): ... this. (ui_out_field_skip): Replace with ... (ui_out::field_skip): ... this. (ui_out_field_string): Replace with ... (ui_out::field_string): ... this. (ui_out_field_fmt): Replace with ... (ui_out::field_fmt): ... this. (ui_out_spaces): Replace with ... (ui_out::spaces): ... this. (ui_out_text): Replace with ... (ui_out::text): ... this. (ui_out_message): Replace with ... (ui_out::message): ... this. (ui_out_wrap_hint): Replace with ... (ui_out::wrap_hint): ... this. (ui_out_flush): Replace with ... (ui_out::flush): ... this. (ui_out_redirect): Replace with ... (ui_out::redirect): ... this. (ui_out_test_flags): Replace with ... (ui_out::test_flags): ... this. (ui_out_is_mi_like_p): Replace with ... (ui_out::is_mi_like_p): ... this. (verify_field): Replace with ... (ui_out::verify_field): ... this. (ui_out_query_field): Replace with ... (ui_out::query_table_field): ... this. (ui_out_data): Remove. (ui_out_new): Remove, replace with ... (ui_out::ui_out): ... this constructor. (do_cleanup_table_end, make_cleanup_ui_out_tuple_begin_end, do_cleanup_end, make_cleanup_ui_out_tuple_begin_end, make_cleanup_ui_out_list_begin_end): Update fallouts of struct ui_out -> class ui_out change. * cli-out.c (cli_out_data): Remove. (cli_uiout_dtor): Remove. (cli_table_begin): Replace with ... (cli_ui_out::do_table_begin): ... this new method. (cli_table_body): Replace with ... (cli_ui_out::do_table_body): ... this new method. (cli_table_end): Replace with ... (cli_ui_out::do_table_end): ... this new method. (cli_table_header): Replace with ... (cli_ui_out::do_table_header): ... this new method. (cli_begin): Replace with ... (cli_ui_out::do_begin): ... this new method. (cli_end): Replace with ... (cli_ui_out::do_end): ... this new method. (cli_field_int): Replace with ... (cli_ui_out::do_field_int): ... this new method. (cli_field_skip): Replace with ... (cli_ui_out::do_field_skip): ... this new method. (cli_field_string): Replace with ... (cli_ui_out::do_field_string): ... this new method. (cli_field_fmt): Replace with ... (cli_ui_out::do_field_fmt): ... this new method. (cli_spaces): Replace with ... (cli_ui_out::do_spaces): ... this new method. (cli_text): Replace with ... (cli_ui_out::do_text): ... this new method. (cli_message): Replace with ... (cli_ui_out::do_message): ... this new method. (cli_wrap_hint): Replace with ... (cli_ui_out::do_wrap_hint): ... this new method. (cli_flush): Replace with ... (cli_ui_out::do_flush): ... this new method. (cli_redirect): Replace with ... (cli_ui_out::do_redirect): ... this new method. (out_field_fmt): Replace with ... (cli_ui_out::out_field_fmt): ... this new method. (field_separator): Replace with ... (cli_ui_out::field_separator): ... this new method. (cli_out_set_stream): Replace with ... (cli_ui_out::set_stream): ... this new method. (cli_ui_out_impl): Remove. (cli_out_data_ctor): Remove. (cli_ui_out_impl::cli_ui_out_impl): New constructor. (cli_ui_out_impl::~cli_ui_out_impl): New destructor. (cli_out_new): Change return type to cli_ui_out *, instantiate a cli_ui_out. * cli-out.h (cli_ui_out_data): Remove, replace with class cli_ui_out. (class cli_ui_out): New class. (cli_ui_out_impl): Remove. (cli_out_data_ctor): Remove. (cli_out_new): Change return type to cli_ui_out*. (cli_out_set_stream): Remove. * cli/cli-interp.c (struct cli_interp) <cli_uiout>: Change type to cli_ui_out*. (cli_interpreter_resume): Adapt. (cli_interpreter_exec): Adapt. * mi/mi-out.c (mi_ui_out_data, mi_out_data): Remove. (mi_ui_out_impl): Remove. (mi_table_begin): Replace with ... (mi_ui_out::do_table_begin): ... this. (mi_table_body): Replace with ... (mi_ui_out::do_table_body): ... this. (mi_table_end): Replace with ... (mi_ui_out::do_table_end): ... this. (mi_table_header): Replace with ... (mi_ui_out::do_table_header): ... this. (mi_begin): Replace with ... (mi_ui_out::do_begin): ... this. (mi_end): Replace with ... (mi_ui_out::do_end): ... this. (mi_field_int): Replace with ... (mi_ui_out::do_field_int): ... this. (mi_field_skip): Replace with ... (mi_ui_out::do_field_skip): ... this. (mi_field_string): Replace with ... (mi_ui_out::do_field_string): ... this. (mi_field_fmt): Replace with ... (mi_ui_out::do_field_fmt): ... this. (mi_spaces): Replace with ... (mi_ui_out::do_spaces): ... this. (mi_text): Replace with ... (mi_ui_out::do_text): ... this. (mi_message): Replace with ... (mi_ui_out::do_message): ... this. (mi_wrap_hint): Replace with ... (mi_ui_out::do_wrap_hint): ... this. (mi_flush): Replace with ... (mi_ui_out::do_flush): ... this. (mi_redirect): Replace with ... (mi_ui_out::do_redirect): (field_separator): Replace with ... (mi_ui_out::field_separator): (mi_open): Replace with ... (mi_ui_out::open): ... this. (mi_close): Replace with ... (mi_ui_out::close): ... this. (mi_out_rewind): Replace with ... (mi_ui_out::rewind): ... this. (mi_out_put): Replace with ... (mi_ui_out::put): ... this. (mi_version): Replace with ... (mi_ui_out::version): ... this. (mi_out_data_ctor): Replace with ... (mi_ui_out::mi_ui_out): ... this. (mi_out_data_dtor): Replace with ... (mi_ui_out::~mi_ui_out): ... this. (mi_out_new): Change return type to mi_ui_out*, instantiate an mi_ui_out object. (as_mi_ui_out): New function. (mi_version): Update fallouts of struct ui_out to class ui_out transition. (mi_out_put): Likewise. (mi_out_rewind): Likewise. * mi/mi-out.h (mi_out_new): Change return type to mi_ui_out*. * tui/tui-out.c (tui_ui_out_data, tui_out_data, tui_ui_out_impl): Remove. (tui_field_int): Replace with ... (tui_ui_out::do_field_int): ... this. (tui_field_string): Replace with ... (tui_ui_out::do_field_string): ... this. (tui_field_fmt): Replace with ... (tui_ui_out::do_field_fmt): ... this. (tui_text): Replace with ... (tui_ui_out::do_text): ... this. (tui_out_new): Change return type to tui_ui_out*, instantiate tui_ui_out object. (tui_ui_out::tui_ui_out): New. * tui/tui-out.h: New file. * tui/tui.h (tui_out_new): Move declaration to tui/tui-out.h. * tui/tui-io.c: Include tui/tui-out.h. (tui_old_uiout): Change type to cli_ui_out*. (tui_setup_io): Use dynamic_cast. * tui/tui-io.h (tui_old_uiout): Change type to cli_ui_out*. * tui/tui-interp.c (tui_resume): Adapt. * ada-lang.c (print_it_exception): Update fallouts of struct ui_out to class ui_out transition. (print_one_exception): Likewise. (print_mention_exception): Likewise. * ada-tasks.c (print_ada_task_info): Likewise. (info_task): Likewise. (task_command): Likewise. * auto-load.c (print_script): Likewise. (auto_load_info_scripts): Likewise. (info_auto_load_cmd): Likewise. * break-catch-sig.c (signal_catchpoint_print_one): Likewise. * break-catch-syscall.c (print_it_catch_syscall): Likewise. (print_one_catch_syscall): Likewise. * break-catch-throw.c (print_it_exception_catchpoint): Likewise. (print_one_exception_catchpoint): Likewise. (print_one_detail_exception_catchpoint): Likewise. (print_mention_exception_catchpoint): Likewise. * breakpoint.c (maybe_print_thread_hit_breakpoint): Likewise. (print_solib_event): Likewise. (watchpoint_check): Likewise. (wrap_indent_at_field): Likewise. (print_breakpoint_location): Likewise. (output_thread_groups): Likewise. (print_one_breakpoint_location): Likewise. (breakpoint_1): Likewise. (default_collect_info): Likewise. (watchpoints_info): Likewise. (print_it_catch_fork): Likewise. (print_one_catch_fork): Likewise. (print_it_catch_vfork): Likewise. (print_one_catch_vfork): Likewise. (print_it_catch_solib): Likewise. (print_one_catch_solib): Likewise. (print_it_catch_exec): Likewise. (print_one_catch_exec): Likewise. (mention): Likewise. (print_it_ranged_breakpoint): Likewise. (print_one_ranged_breakpoint): Likewise. (print_one_detail_ranged_breakpoint): Likewise. (print_mention_ranged_breakpoint): Likewise. (print_it_watchpoint): Likewise. (print_mention_watchpoint): Likewise. (print_it_masked_watchpoint): Likewise. (print_one_detail_masked_watchpoint): Likewise. (print_mention_masked_watchpoint): Likewise. (bkpt_print_it): Likewise. (tracepoint_print_one_detail): Likewise. (tracepoint_print_mention): Likewise. (update_static_tracepoint): Likewise. (tracepoints_info): Likewise. (save_breakpoints): Likewise. * cli/cli-cmds.c (complete_command): Likewise. * cli/cli-logging.c (set_logging_redirect): Likewise. (pop_output_files): Likewise. (handle_redirections): Likewise. * cli/cli-script.c (print_command_lines): Likewise. * cli/cli-setshow.c (do_show_command): Likewise. (cmd_show_list): Likewise. * cp-abi.c (list_cp_abis): Likewise. (show_cp_abi_cmd): Likewise. * darwin-nat-info.c (darwin_debug_regions_recurse): Likewise. * disasm.c (gdb_pretty_print_insn): Likewise. (do_mixed_source_and_assembly_deprecated): Likewise. (do_mixed_source_and_assembly): Likewise. * gdb_bfd.c (print_one_bfd): Likewise. (maintenance_info_bfds): Likewise. * guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Likewise. * guile/scm-ports.c (ioscm_with_output_to_port_worker): Likewise. * i386-linux-tdep.c (i386_linux_handle_segmentation_fault): Likewise. * i386-tdep.c (i386_mpx_print_bounds): Likewise. * infcmd.c (run_command_1): Likewise. (print_return_value_1): Likewise. * inferior.c (print_selected_inferior): Likewise. (print_inferior): Likewise. * infrun.c (print_end_stepping_range_reason): Likewise. (print_signal_exited_reason): Likewise. (print_exited_reason): Likewise. (print_signal_received_reason): Likewise. (print_no_history_reason): Likewise. * interps.c (interp_set): Likewise. * linespec.c (decode_line_full): Likewise. * linux-thread-db.c (info_auto_load_libthread_db): Likewise. * mi/mi-cmd-env.c (mi_cmd_env_pwd): Likewise. (mi_cmd_env_path): Likewise. (mi_cmd_env_dir): Likewise. (mi_cmd_inferior_tty_show): Likewise. * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file): Likewise. (print_partial_file_name): Likewise. (mi_cmd_file_list_exec_source_files): Likewise. * mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions): Likewise. (mi_cmd_info_gdb_mi_command): Likewise. * mi/mi-cmd-stack.c (mi_cmd_stack_info_depth): Likewise. (mi_cmd_stack_list_args): Likewise. (list_arg_or_local): Likewise. * mi/mi-cmd-var.c (print_varobj): Likewise. (mi_cmd_var_create): Likewise. (mi_cmd_var_delete): Likewise. (mi_cmd_var_set_format): Likewise. (mi_cmd_var_show_format): Likewise. (mi_cmd_var_info_num_children): Likewise. (mi_cmd_var_list_children): Likewise. (mi_cmd_var_info_type): Likewise. (mi_cmd_var_info_path_expression): Likewise. (mi_cmd_var_info_expression): Likewise. (mi_cmd_var_show_attributes): Likewise. (mi_cmd_var_evaluate_expression): Likewise. (mi_cmd_var_assign): Likewise. (varobj_update_one): Likewise. * mi/mi-interp.c (as_mi_interp): Likewise. (mi_on_normal_stop_1): Likewise. (mi_tsv_modified): Likewise. (mi_breakpoint_created): Likewise. (mi_breakpoint_modified): Likewise. (mi_solib_loaded): Likewise. (mi_solib_unloaded): Likewise. (mi_command_param_changed): Likewise. (mi_memory_changed): Likewise. (mi_user_selected_context_changed): Likewise. * mi/mi-main.c (print_one_inferior): Likewise. (output_cores): Likewise. (list_available_thread_groups): Likewise. (mi_cmd_data_list_register_names): Likewise. (mi_cmd_data_list_changed_registers): Likewise. (output_register): Likewise. (mi_cmd_data_evaluate_expression): Likewise. (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_list_features): Likewise. (mi_cmd_list_target_features): Likewise. (mi_cmd_add_inferior): Likewise. (mi_execute_command): Likewise. (mi_load_progress): Likewise. (print_variable_or_computed): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Likewise. * osdata.c (info_osdata_command): Likewise. * probe.c (gen_ui_out_table_header_info): Likewise. (print_ui_out_not_applicables): Likewise. (print_ui_out_info): Likewise. (info_probes_for_ops): Likewise. (enable_probes_command): Likewise. (disable_probes_command): Likewise. * progspace.c (print_program_space): Likewise. * python/py-breakpoint.c (bppy_get_commands): Likewise. * python/py-framefilter.c (py_print_type): Likewise. (py_print_value): Likewise. (py_print_single_arg): Likewise. (enumerate_args): Likewise. (enumerate_locals): Likewise. (py_print_args): Likewise. (py_print_frame): Likewise. * record-btrace.c (btrace_ui_out_decode_error): Likewise. (btrace_call_history_insn_range): Likewise. (btrace_call_history_src_line): Likewise. (btrace_call_history): Likewise. * remote.c (show_remote_cmd): Likewise. * skip.c (skip_info): Likewise. * solib.c (info_sharedlibrary_command): Likewise. * source.c (print_source_lines_base): Likewise. * spu-tdep.c (info_spu_event_command): Likewise. (info_spu_signal_command): Likewise. (info_spu_mailbox_list): Likewise. (info_spu_dma_cmdlist): Likewise. (info_spu_dma_command): Likewise. (info_spu_proxydma_command): Likewise. * stack.c (print_stack_frame): Likewise. (print_frame_arg): Likewise. (read_frame_arg): Likewise. (print_frame_args): Likewise. (print_frame_info): Likewise. (print_frame): Likewise. * symfile.c (load_progress): Likewise. (generic_load): Likewise. (print_transfer_performance): Likewise. * thread.c (do_captured_list_thread_ids): Likewise. (print_thread_info_1): Likewise. (restore_selected_frame): Likewise. (do_captured_thread_select): Likewise. (print_selected_thread_frame): Likewise. * top.c (execute_command_to_string): Likewise. * tracepoint.c (tvariables_info_1): Likewise. (trace_status_mi): Likewise. (tfind_1): Likewise. (print_one_static_tracepoint_marker): Likewise. (info_static_tracepoint_markers_command): Likewise. * utils.c (do_ui_out_redirect_pop): Likewise. (fputs_maybe_filtered): Likewise.
2016-12-22 22:17:31 +01:00
uiout->message (_("No shared libraries matched.\n"));
else
Class-ify ui_out This patch finalizes the C++ conversion of the ui-out subsystem, by turning the ui_out and ui_out_impl structures into a single class hierarchy. ui_out functions are turned into virtual methods of that new class, so as a result there are a lot of call sites to update. In the previous version of the patchset, there were separate ui_out and ui_out_impl classes, but it wasn't really useful and added boilerplate. In this version there is simply an ui_out base class that is extended for CLI, TUI and MI. It's a bit hard to maintain a ChangeLog for such a big patch, I did my best but I'm sure there are some missing or outdated info in there... gdb/ChangeLog: * ui-out.h (ui_out_begin, ui_out_end, ui_out_table_header, ui_out_table_body, ui_out_field_int, ui_out_field_fmt_int, ui_out_field_core_addr, ui_out_field_string, ui_out_field_stream, ui_out_field_fmt, ui_out_field_skip, ui_out_spaces, ui_out_text, ui_out_message, ui_out_wrap_hint, ui_out_flush, ui_out_test_flags, ui_out_query_field, ui_out_is_mi_like_p, ui_out_redirect): Remove, replace with a method in class ui_out. (table_begin_ftype): Remove, replace with pure virtual method in class ui_out. (table_body_ftype): Likewise. (table_end_ftype): Likewise. (table_header_ftype): Likewise. (ui_out_begin_ftype): Likewise. (ui_out_end_ftype): Likewise. (field_int_ftype): Likewise. (field_skip_ftype): Likewise. (field_string_ftype): Likewise. (field_fmt_ftype): Likewise. (spaces_ftype): Likewise. (text_ftype): Likewise. (message_ftype): Likewise. (wrap_hint_ftype): Likewise. (flush_ftype): Likewise. (redirect_ftype): Likewise. (data_destroy_ftype): Likewise. (struct ui_out_impl): Remove, replace with class ui_out. (ui_out_new): Remove. (class ui_out): New class. * ui-out.c (struct ui_out): Remove, replaced with class ui_out. (current_level): Remove, replace with ui_out method. (push_level): Likewise. (pop_level): Likewise. (uo_table_begin, uo_table_body, uo_table_end, uo_table_header, uo_begin, uo_end, uo_field_int, uo_field_skip, uo_field_fmt, uo_spaces, uo_text, uo_message, uo_wrap_hint, uo_flush, uo_redirect, uo_field_string): Remove. (ui_out_table_begin): Replace with ... (ui_out::table_begin): ... this. (ui_out_table_body): Replace with ... (ui_out::table_body): ... this. (ui_out_table_end): Replace with ... (ui_out::table_end): ... this. (ui_out_table_header): Replace with ... (ui_out::table_header): ... this. (ui_out_begin): Replace with ... (ui_out::begin): ... this. (ui_out_end): Replace with ... (ui_out::end): ... this. (ui_out_field_int): Replace with ... (ui_out::field_int): ... this. (ui_out_field_fmt_int): Replace with ... (ui_out::field_fmt_int): ... this. (ui_out_field_core_addr): Replace with ... (ui_out::field_core_addr): ... this. (ui_out_field_stream): Replace with ... (ui_out::field_stream): ... this. (ui_out_field_skip): Replace with ... (ui_out::field_skip): ... this. (ui_out_field_string): Replace with ... (ui_out::field_string): ... this. (ui_out_field_fmt): Replace with ... (ui_out::field_fmt): ... this. (ui_out_spaces): Replace with ... (ui_out::spaces): ... this. (ui_out_text): Replace with ... (ui_out::text): ... this. (ui_out_message): Replace with ... (ui_out::message): ... this. (ui_out_wrap_hint): Replace with ... (ui_out::wrap_hint): ... this. (ui_out_flush): Replace with ... (ui_out::flush): ... this. (ui_out_redirect): Replace with ... (ui_out::redirect): ... this. (ui_out_test_flags): Replace with ... (ui_out::test_flags): ... this. (ui_out_is_mi_like_p): Replace with ... (ui_out::is_mi_like_p): ... this. (verify_field): Replace with ... (ui_out::verify_field): ... this. (ui_out_query_field): Replace with ... (ui_out::query_table_field): ... this. (ui_out_data): Remove. (ui_out_new): Remove, replace with ... (ui_out::ui_out): ... this constructor. (do_cleanup_table_end, make_cleanup_ui_out_tuple_begin_end, do_cleanup_end, make_cleanup_ui_out_tuple_begin_end, make_cleanup_ui_out_list_begin_end): Update fallouts of struct ui_out -> class ui_out change. * cli-out.c (cli_out_data): Remove. (cli_uiout_dtor): Remove. (cli_table_begin): Replace with ... (cli_ui_out::do_table_begin): ... this new method. (cli_table_body): Replace with ... (cli_ui_out::do_table_body): ... this new method. (cli_table_end): Replace with ... (cli_ui_out::do_table_end): ... this new method. (cli_table_header): Replace with ... (cli_ui_out::do_table_header): ... this new method. (cli_begin): Replace with ... (cli_ui_out::do_begin): ... this new method. (cli_end): Replace with ... (cli_ui_out::do_end): ... this new method. (cli_field_int): Replace with ... (cli_ui_out::do_field_int): ... this new method. (cli_field_skip): Replace with ... (cli_ui_out::do_field_skip): ... this new method. (cli_field_string): Replace with ... (cli_ui_out::do_field_string): ... this new method. (cli_field_fmt): Replace with ... (cli_ui_out::do_field_fmt): ... this new method. (cli_spaces): Replace with ... (cli_ui_out::do_spaces): ... this new method. (cli_text): Replace with ... (cli_ui_out::do_text): ... this new method. (cli_message): Replace with ... (cli_ui_out::do_message): ... this new method. (cli_wrap_hint): Replace with ... (cli_ui_out::do_wrap_hint): ... this new method. (cli_flush): Replace with ... (cli_ui_out::do_flush): ... this new method. (cli_redirect): Replace with ... (cli_ui_out::do_redirect): ... this new method. (out_field_fmt): Replace with ... (cli_ui_out::out_field_fmt): ... this new method. (field_separator): Replace with ... (cli_ui_out::field_separator): ... this new method. (cli_out_set_stream): Replace with ... (cli_ui_out::set_stream): ... this new method. (cli_ui_out_impl): Remove. (cli_out_data_ctor): Remove. (cli_ui_out_impl::cli_ui_out_impl): New constructor. (cli_ui_out_impl::~cli_ui_out_impl): New destructor. (cli_out_new): Change return type to cli_ui_out *, instantiate a cli_ui_out. * cli-out.h (cli_ui_out_data): Remove, replace with class cli_ui_out. (class cli_ui_out): New class. (cli_ui_out_impl): Remove. (cli_out_data_ctor): Remove. (cli_out_new): Change return type to cli_ui_out*. (cli_out_set_stream): Remove. * cli/cli-interp.c (struct cli_interp) <cli_uiout>: Change type to cli_ui_out*. (cli_interpreter_resume): Adapt. (cli_interpreter_exec): Adapt. * mi/mi-out.c (mi_ui_out_data, mi_out_data): Remove. (mi_ui_out_impl): Remove. (mi_table_begin): Replace with ... (mi_ui_out::do_table_begin): ... this. (mi_table_body): Replace with ... (mi_ui_out::do_table_body): ... this. (mi_table_end): Replace with ... (mi_ui_out::do_table_end): ... this. (mi_table_header): Replace with ... (mi_ui_out::do_table_header): ... this. (mi_begin): Replace with ... (mi_ui_out::do_begin): ... this. (mi_end): Replace with ... (mi_ui_out::do_end): ... this. (mi_field_int): Replace with ... (mi_ui_out::do_field_int): ... this. (mi_field_skip): Replace with ... (mi_ui_out::do_field_skip): ... this. (mi_field_string): Replace with ... (mi_ui_out::do_field_string): ... this. (mi_field_fmt): Replace with ... (mi_ui_out::do_field_fmt): ... this. (mi_spaces): Replace with ... (mi_ui_out::do_spaces): ... this. (mi_text): Replace with ... (mi_ui_out::do_text): ... this. (mi_message): Replace with ... (mi_ui_out::do_message): ... this. (mi_wrap_hint): Replace with ... (mi_ui_out::do_wrap_hint): ... this. (mi_flush): Replace with ... (mi_ui_out::do_flush): ... this. (mi_redirect): Replace with ... (mi_ui_out::do_redirect): (field_separator): Replace with ... (mi_ui_out::field_separator): (mi_open): Replace with ... (mi_ui_out::open): ... this. (mi_close): Replace with ... (mi_ui_out::close): ... this. (mi_out_rewind): Replace with ... (mi_ui_out::rewind): ... this. (mi_out_put): Replace with ... (mi_ui_out::put): ... this. (mi_version): Replace with ... (mi_ui_out::version): ... this. (mi_out_data_ctor): Replace with ... (mi_ui_out::mi_ui_out): ... this. (mi_out_data_dtor): Replace with ... (mi_ui_out::~mi_ui_out): ... this. (mi_out_new): Change return type to mi_ui_out*, instantiate an mi_ui_out object. (as_mi_ui_out): New function. (mi_version): Update fallouts of struct ui_out to class ui_out transition. (mi_out_put): Likewise. (mi_out_rewind): Likewise. * mi/mi-out.h (mi_out_new): Change return type to mi_ui_out*. * tui/tui-out.c (tui_ui_out_data, tui_out_data, tui_ui_out_impl): Remove. (tui_field_int): Replace with ... (tui_ui_out::do_field_int): ... this. (tui_field_string): Replace with ... (tui_ui_out::do_field_string): ... this. (tui_field_fmt): Replace with ... (tui_ui_out::do_field_fmt): ... this. (tui_text): Replace with ... (tui_ui_out::do_text): ... this. (tui_out_new): Change return type to tui_ui_out*, instantiate tui_ui_out object. (tui_ui_out::tui_ui_out): New. * tui/tui-out.h: New file. * tui/tui.h (tui_out_new): Move declaration to tui/tui-out.h. * tui/tui-io.c: Include tui/tui-out.h. (tui_old_uiout): Change type to cli_ui_out*. (tui_setup_io): Use dynamic_cast. * tui/tui-io.h (tui_old_uiout): Change type to cli_ui_out*. * tui/tui-interp.c (tui_resume): Adapt. * ada-lang.c (print_it_exception): Update fallouts of struct ui_out to class ui_out transition. (print_one_exception): Likewise. (print_mention_exception): Likewise. * ada-tasks.c (print_ada_task_info): Likewise. (info_task): Likewise. (task_command): Likewise. * auto-load.c (print_script): Likewise. (auto_load_info_scripts): Likewise. (info_auto_load_cmd): Likewise. * break-catch-sig.c (signal_catchpoint_print_one): Likewise. * break-catch-syscall.c (print_it_catch_syscall): Likewise. (print_one_catch_syscall): Likewise. * break-catch-throw.c (print_it_exception_catchpoint): Likewise. (print_one_exception_catchpoint): Likewise. (print_one_detail_exception_catchpoint): Likewise. (print_mention_exception_catchpoint): Likewise. * breakpoint.c (maybe_print_thread_hit_breakpoint): Likewise. (print_solib_event): Likewise. (watchpoint_check): Likewise. (wrap_indent_at_field): Likewise. (print_breakpoint_location): Likewise. (output_thread_groups): Likewise. (print_one_breakpoint_location): Likewise. (breakpoint_1): Likewise. (default_collect_info): Likewise. (watchpoints_info): Likewise. (print_it_catch_fork): Likewise. (print_one_catch_fork): Likewise. (print_it_catch_vfork): Likewise. (print_one_catch_vfork): Likewise. (print_it_catch_solib): Likewise. (print_one_catch_solib): Likewise. (print_it_catch_exec): Likewise. (print_one_catch_exec): Likewise. (mention): Likewise. (print_it_ranged_breakpoint): Likewise. (print_one_ranged_breakpoint): Likewise. (print_one_detail_ranged_breakpoint): Likewise. (print_mention_ranged_breakpoint): Likewise. (print_it_watchpoint): Likewise. (print_mention_watchpoint): Likewise. (print_it_masked_watchpoint): Likewise. (print_one_detail_masked_watchpoint): Likewise. (print_mention_masked_watchpoint): Likewise. (bkpt_print_it): Likewise. (tracepoint_print_one_detail): Likewise. (tracepoint_print_mention): Likewise. (update_static_tracepoint): Likewise. (tracepoints_info): Likewise. (save_breakpoints): Likewise. * cli/cli-cmds.c (complete_command): Likewise. * cli/cli-logging.c (set_logging_redirect): Likewise. (pop_output_files): Likewise. (handle_redirections): Likewise. * cli/cli-script.c (print_command_lines): Likewise. * cli/cli-setshow.c (do_show_command): Likewise. (cmd_show_list): Likewise. * cp-abi.c (list_cp_abis): Likewise. (show_cp_abi_cmd): Likewise. * darwin-nat-info.c (darwin_debug_regions_recurse): Likewise. * disasm.c (gdb_pretty_print_insn): Likewise. (do_mixed_source_and_assembly_deprecated): Likewise. (do_mixed_source_and_assembly): Likewise. * gdb_bfd.c (print_one_bfd): Likewise. (maintenance_info_bfds): Likewise. * guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Likewise. * guile/scm-ports.c (ioscm_with_output_to_port_worker): Likewise. * i386-linux-tdep.c (i386_linux_handle_segmentation_fault): Likewise. * i386-tdep.c (i386_mpx_print_bounds): Likewise. * infcmd.c (run_command_1): Likewise. (print_return_value_1): Likewise. * inferior.c (print_selected_inferior): Likewise. (print_inferior): Likewise. * infrun.c (print_end_stepping_range_reason): Likewise. (print_signal_exited_reason): Likewise. (print_exited_reason): Likewise. (print_signal_received_reason): Likewise. (print_no_history_reason): Likewise. * interps.c (interp_set): Likewise. * linespec.c (decode_line_full): Likewise. * linux-thread-db.c (info_auto_load_libthread_db): Likewise. * mi/mi-cmd-env.c (mi_cmd_env_pwd): Likewise. (mi_cmd_env_path): Likewise. (mi_cmd_env_dir): Likewise. (mi_cmd_inferior_tty_show): Likewise. * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file): Likewise. (print_partial_file_name): Likewise. (mi_cmd_file_list_exec_source_files): Likewise. * mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions): Likewise. (mi_cmd_info_gdb_mi_command): Likewise. * mi/mi-cmd-stack.c (mi_cmd_stack_info_depth): Likewise. (mi_cmd_stack_list_args): Likewise. (list_arg_or_local): Likewise. * mi/mi-cmd-var.c (print_varobj): Likewise. (mi_cmd_var_create): Likewise. (mi_cmd_var_delete): Likewise. (mi_cmd_var_set_format): Likewise. (mi_cmd_var_show_format): Likewise. (mi_cmd_var_info_num_children): Likewise. (mi_cmd_var_list_children): Likewise. (mi_cmd_var_info_type): Likewise. (mi_cmd_var_info_path_expression): Likewise. (mi_cmd_var_info_expression): Likewise. (mi_cmd_var_show_attributes): Likewise. (mi_cmd_var_evaluate_expression): Likewise. (mi_cmd_var_assign): Likewise. (varobj_update_one): Likewise. * mi/mi-interp.c (as_mi_interp): Likewise. (mi_on_normal_stop_1): Likewise. (mi_tsv_modified): Likewise. (mi_breakpoint_created): Likewise. (mi_breakpoint_modified): Likewise. (mi_solib_loaded): Likewise. (mi_solib_unloaded): Likewise. (mi_command_param_changed): Likewise. (mi_memory_changed): Likewise. (mi_user_selected_context_changed): Likewise. * mi/mi-main.c (print_one_inferior): Likewise. (output_cores): Likewise. (list_available_thread_groups): Likewise. (mi_cmd_data_list_register_names): Likewise. (mi_cmd_data_list_changed_registers): Likewise. (output_register): Likewise. (mi_cmd_data_evaluate_expression): Likewise. (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_list_features): Likewise. (mi_cmd_list_target_features): Likewise. (mi_cmd_add_inferior): Likewise. (mi_execute_command): Likewise. (mi_load_progress): Likewise. (print_variable_or_computed): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Likewise. * osdata.c (info_osdata_command): Likewise. * probe.c (gen_ui_out_table_header_info): Likewise. (print_ui_out_not_applicables): Likewise. (print_ui_out_info): Likewise. (info_probes_for_ops): Likewise. (enable_probes_command): Likewise. (disable_probes_command): Likewise. * progspace.c (print_program_space): Likewise. * python/py-breakpoint.c (bppy_get_commands): Likewise. * python/py-framefilter.c (py_print_type): Likewise. (py_print_value): Likewise. (py_print_single_arg): Likewise. (enumerate_args): Likewise. (enumerate_locals): Likewise. (py_print_args): Likewise. (py_print_frame): Likewise. * record-btrace.c (btrace_ui_out_decode_error): Likewise. (btrace_call_history_insn_range): Likewise. (btrace_call_history_src_line): Likewise. (btrace_call_history): Likewise. * remote.c (show_remote_cmd): Likewise. * skip.c (skip_info): Likewise. * solib.c (info_sharedlibrary_command): Likewise. * source.c (print_source_lines_base): Likewise. * spu-tdep.c (info_spu_event_command): Likewise. (info_spu_signal_command): Likewise. (info_spu_mailbox_list): Likewise. (info_spu_dma_cmdlist): Likewise. (info_spu_dma_command): Likewise. (info_spu_proxydma_command): Likewise. * stack.c (print_stack_frame): Likewise. (print_frame_arg): Likewise. (read_frame_arg): Likewise. (print_frame_args): Likewise. (print_frame_info): Likewise. (print_frame): Likewise. * symfile.c (load_progress): Likewise. (generic_load): Likewise. (print_transfer_performance): Likewise. * thread.c (do_captured_list_thread_ids): Likewise. (print_thread_info_1): Likewise. (restore_selected_frame): Likewise. (do_captured_thread_select): Likewise. (print_selected_thread_frame): Likewise. * top.c (execute_command_to_string): Likewise. * tracepoint.c (tvariables_info_1): Likewise. (trace_status_mi): Likewise. (tfind_1): Likewise. (print_one_static_tracepoint_marker): Likewise. (info_static_tracepoint_markers_command): Likewise. * utils.c (do_ui_out_redirect_pop): Likewise. (fputs_maybe_filtered): Likewise.
2016-12-22 22:17:31 +01:00
uiout->message (_("No shared libraries loaded at this time.\n"));
}
else
{
if (so_missing_debug_info)
Class-ify ui_out This patch finalizes the C++ conversion of the ui-out subsystem, by turning the ui_out and ui_out_impl structures into a single class hierarchy. ui_out functions are turned into virtual methods of that new class, so as a result there are a lot of call sites to update. In the previous version of the patchset, there were separate ui_out and ui_out_impl classes, but it wasn't really useful and added boilerplate. In this version there is simply an ui_out base class that is extended for CLI, TUI and MI. It's a bit hard to maintain a ChangeLog for such a big patch, I did my best but I'm sure there are some missing or outdated info in there... gdb/ChangeLog: * ui-out.h (ui_out_begin, ui_out_end, ui_out_table_header, ui_out_table_body, ui_out_field_int, ui_out_field_fmt_int, ui_out_field_core_addr, ui_out_field_string, ui_out_field_stream, ui_out_field_fmt, ui_out_field_skip, ui_out_spaces, ui_out_text, ui_out_message, ui_out_wrap_hint, ui_out_flush, ui_out_test_flags, ui_out_query_field, ui_out_is_mi_like_p, ui_out_redirect): Remove, replace with a method in class ui_out. (table_begin_ftype): Remove, replace with pure virtual method in class ui_out. (table_body_ftype): Likewise. (table_end_ftype): Likewise. (table_header_ftype): Likewise. (ui_out_begin_ftype): Likewise. (ui_out_end_ftype): Likewise. (field_int_ftype): Likewise. (field_skip_ftype): Likewise. (field_string_ftype): Likewise. (field_fmt_ftype): Likewise. (spaces_ftype): Likewise. (text_ftype): Likewise. (message_ftype): Likewise. (wrap_hint_ftype): Likewise. (flush_ftype): Likewise. (redirect_ftype): Likewise. (data_destroy_ftype): Likewise. (struct ui_out_impl): Remove, replace with class ui_out. (ui_out_new): Remove. (class ui_out): New class. * ui-out.c (struct ui_out): Remove, replaced with class ui_out. (current_level): Remove, replace with ui_out method. (push_level): Likewise. (pop_level): Likewise. (uo_table_begin, uo_table_body, uo_table_end, uo_table_header, uo_begin, uo_end, uo_field_int, uo_field_skip, uo_field_fmt, uo_spaces, uo_text, uo_message, uo_wrap_hint, uo_flush, uo_redirect, uo_field_string): Remove. (ui_out_table_begin): Replace with ... (ui_out::table_begin): ... this. (ui_out_table_body): Replace with ... (ui_out::table_body): ... this. (ui_out_table_end): Replace with ... (ui_out::table_end): ... this. (ui_out_table_header): Replace with ... (ui_out::table_header): ... this. (ui_out_begin): Replace with ... (ui_out::begin): ... this. (ui_out_end): Replace with ... (ui_out::end): ... this. (ui_out_field_int): Replace with ... (ui_out::field_int): ... this. (ui_out_field_fmt_int): Replace with ... (ui_out::field_fmt_int): ... this. (ui_out_field_core_addr): Replace with ... (ui_out::field_core_addr): ... this. (ui_out_field_stream): Replace with ... (ui_out::field_stream): ... this. (ui_out_field_skip): Replace with ... (ui_out::field_skip): ... this. (ui_out_field_string): Replace with ... (ui_out::field_string): ... this. (ui_out_field_fmt): Replace with ... (ui_out::field_fmt): ... this. (ui_out_spaces): Replace with ... (ui_out::spaces): ... this. (ui_out_text): Replace with ... (ui_out::text): ... this. (ui_out_message): Replace with ... (ui_out::message): ... this. (ui_out_wrap_hint): Replace with ... (ui_out::wrap_hint): ... this. (ui_out_flush): Replace with ... (ui_out::flush): ... this. (ui_out_redirect): Replace with ... (ui_out::redirect): ... this. (ui_out_test_flags): Replace with ... (ui_out::test_flags): ... this. (ui_out_is_mi_like_p): Replace with ... (ui_out::is_mi_like_p): ... this. (verify_field): Replace with ... (ui_out::verify_field): ... this. (ui_out_query_field): Replace with ... (ui_out::query_table_field): ... this. (ui_out_data): Remove. (ui_out_new): Remove, replace with ... (ui_out::ui_out): ... this constructor. (do_cleanup_table_end, make_cleanup_ui_out_tuple_begin_end, do_cleanup_end, make_cleanup_ui_out_tuple_begin_end, make_cleanup_ui_out_list_begin_end): Update fallouts of struct ui_out -> class ui_out change. * cli-out.c (cli_out_data): Remove. (cli_uiout_dtor): Remove. (cli_table_begin): Replace with ... (cli_ui_out::do_table_begin): ... this new method. (cli_table_body): Replace with ... (cli_ui_out::do_table_body): ... this new method. (cli_table_end): Replace with ... (cli_ui_out::do_table_end): ... this new method. (cli_table_header): Replace with ... (cli_ui_out::do_table_header): ... this new method. (cli_begin): Replace with ... (cli_ui_out::do_begin): ... this new method. (cli_end): Replace with ... (cli_ui_out::do_end): ... this new method. (cli_field_int): Replace with ... (cli_ui_out::do_field_int): ... this new method. (cli_field_skip): Replace with ... (cli_ui_out::do_field_skip): ... this new method. (cli_field_string): Replace with ... (cli_ui_out::do_field_string): ... this new method. (cli_field_fmt): Replace with ... (cli_ui_out::do_field_fmt): ... this new method. (cli_spaces): Replace with ... (cli_ui_out::do_spaces): ... this new method. (cli_text): Replace with ... (cli_ui_out::do_text): ... this new method. (cli_message): Replace with ... (cli_ui_out::do_message): ... this new method. (cli_wrap_hint): Replace with ... (cli_ui_out::do_wrap_hint): ... this new method. (cli_flush): Replace with ... (cli_ui_out::do_flush): ... this new method. (cli_redirect): Replace with ... (cli_ui_out::do_redirect): ... this new method. (out_field_fmt): Replace with ... (cli_ui_out::out_field_fmt): ... this new method. (field_separator): Replace with ... (cli_ui_out::field_separator): ... this new method. (cli_out_set_stream): Replace with ... (cli_ui_out::set_stream): ... this new method. (cli_ui_out_impl): Remove. (cli_out_data_ctor): Remove. (cli_ui_out_impl::cli_ui_out_impl): New constructor. (cli_ui_out_impl::~cli_ui_out_impl): New destructor. (cli_out_new): Change return type to cli_ui_out *, instantiate a cli_ui_out. * cli-out.h (cli_ui_out_data): Remove, replace with class cli_ui_out. (class cli_ui_out): New class. (cli_ui_out_impl): Remove. (cli_out_data_ctor): Remove. (cli_out_new): Change return type to cli_ui_out*. (cli_out_set_stream): Remove. * cli/cli-interp.c (struct cli_interp) <cli_uiout>: Change type to cli_ui_out*. (cli_interpreter_resume): Adapt. (cli_interpreter_exec): Adapt. * mi/mi-out.c (mi_ui_out_data, mi_out_data): Remove. (mi_ui_out_impl): Remove. (mi_table_begin): Replace with ... (mi_ui_out::do_table_begin): ... this. (mi_table_body): Replace with ... (mi_ui_out::do_table_body): ... this. (mi_table_end): Replace with ... (mi_ui_out::do_table_end): ... this. (mi_table_header): Replace with ... (mi_ui_out::do_table_header): ... this. (mi_begin): Replace with ... (mi_ui_out::do_begin): ... this. (mi_end): Replace with ... (mi_ui_out::do_end): ... this. (mi_field_int): Replace with ... (mi_ui_out::do_field_int): ... this. (mi_field_skip): Replace with ... (mi_ui_out::do_field_skip): ... this. (mi_field_string): Replace with ... (mi_ui_out::do_field_string): ... this. (mi_field_fmt): Replace with ... (mi_ui_out::do_field_fmt): ... this. (mi_spaces): Replace with ... (mi_ui_out::do_spaces): ... this. (mi_text): Replace with ... (mi_ui_out::do_text): ... this. (mi_message): Replace with ... (mi_ui_out::do_message): ... this. (mi_wrap_hint): Replace with ... (mi_ui_out::do_wrap_hint): ... this. (mi_flush): Replace with ... (mi_ui_out::do_flush): ... this. (mi_redirect): Replace with ... (mi_ui_out::do_redirect): (field_separator): Replace with ... (mi_ui_out::field_separator): (mi_open): Replace with ... (mi_ui_out::open): ... this. (mi_close): Replace with ... (mi_ui_out::close): ... this. (mi_out_rewind): Replace with ... (mi_ui_out::rewind): ... this. (mi_out_put): Replace with ... (mi_ui_out::put): ... this. (mi_version): Replace with ... (mi_ui_out::version): ... this. (mi_out_data_ctor): Replace with ... (mi_ui_out::mi_ui_out): ... this. (mi_out_data_dtor): Replace with ... (mi_ui_out::~mi_ui_out): ... this. (mi_out_new): Change return type to mi_ui_out*, instantiate an mi_ui_out object. (as_mi_ui_out): New function. (mi_version): Update fallouts of struct ui_out to class ui_out transition. (mi_out_put): Likewise. (mi_out_rewind): Likewise. * mi/mi-out.h (mi_out_new): Change return type to mi_ui_out*. * tui/tui-out.c (tui_ui_out_data, tui_out_data, tui_ui_out_impl): Remove. (tui_field_int): Replace with ... (tui_ui_out::do_field_int): ... this. (tui_field_string): Replace with ... (tui_ui_out::do_field_string): ... this. (tui_field_fmt): Replace with ... (tui_ui_out::do_field_fmt): ... this. (tui_text): Replace with ... (tui_ui_out::do_text): ... this. (tui_out_new): Change return type to tui_ui_out*, instantiate tui_ui_out object. (tui_ui_out::tui_ui_out): New. * tui/tui-out.h: New file. * tui/tui.h (tui_out_new): Move declaration to tui/tui-out.h. * tui/tui-io.c: Include tui/tui-out.h. (tui_old_uiout): Change type to cli_ui_out*. (tui_setup_io): Use dynamic_cast. * tui/tui-io.h (tui_old_uiout): Change type to cli_ui_out*. * tui/tui-interp.c (tui_resume): Adapt. * ada-lang.c (print_it_exception): Update fallouts of struct ui_out to class ui_out transition. (print_one_exception): Likewise. (print_mention_exception): Likewise. * ada-tasks.c (print_ada_task_info): Likewise. (info_task): Likewise. (task_command): Likewise. * auto-load.c (print_script): Likewise. (auto_load_info_scripts): Likewise. (info_auto_load_cmd): Likewise. * break-catch-sig.c (signal_catchpoint_print_one): Likewise. * break-catch-syscall.c (print_it_catch_syscall): Likewise. (print_one_catch_syscall): Likewise. * break-catch-throw.c (print_it_exception_catchpoint): Likewise. (print_one_exception_catchpoint): Likewise. (print_one_detail_exception_catchpoint): Likewise. (print_mention_exception_catchpoint): Likewise. * breakpoint.c (maybe_print_thread_hit_breakpoint): Likewise. (print_solib_event): Likewise. (watchpoint_check): Likewise. (wrap_indent_at_field): Likewise. (print_breakpoint_location): Likewise. (output_thread_groups): Likewise. (print_one_breakpoint_location): Likewise. (breakpoint_1): Likewise. (default_collect_info): Likewise. (watchpoints_info): Likewise. (print_it_catch_fork): Likewise. (print_one_catch_fork): Likewise. (print_it_catch_vfork): Likewise. (print_one_catch_vfork): Likewise. (print_it_catch_solib): Likewise. (print_one_catch_solib): Likewise. (print_it_catch_exec): Likewise. (print_one_catch_exec): Likewise. (mention): Likewise. (print_it_ranged_breakpoint): Likewise. (print_one_ranged_breakpoint): Likewise. (print_one_detail_ranged_breakpoint): Likewise. (print_mention_ranged_breakpoint): Likewise. (print_it_watchpoint): Likewise. (print_mention_watchpoint): Likewise. (print_it_masked_watchpoint): Likewise. (print_one_detail_masked_watchpoint): Likewise. (print_mention_masked_watchpoint): Likewise. (bkpt_print_it): Likewise. (tracepoint_print_one_detail): Likewise. (tracepoint_print_mention): Likewise. (update_static_tracepoint): Likewise. (tracepoints_info): Likewise. (save_breakpoints): Likewise. * cli/cli-cmds.c (complete_command): Likewise. * cli/cli-logging.c (set_logging_redirect): Likewise. (pop_output_files): Likewise. (handle_redirections): Likewise. * cli/cli-script.c (print_command_lines): Likewise. * cli/cli-setshow.c (do_show_command): Likewise. (cmd_show_list): Likewise. * cp-abi.c (list_cp_abis): Likewise. (show_cp_abi_cmd): Likewise. * darwin-nat-info.c (darwin_debug_regions_recurse): Likewise. * disasm.c (gdb_pretty_print_insn): Likewise. (do_mixed_source_and_assembly_deprecated): Likewise. (do_mixed_source_and_assembly): Likewise. * gdb_bfd.c (print_one_bfd): Likewise. (maintenance_info_bfds): Likewise. * guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Likewise. * guile/scm-ports.c (ioscm_with_output_to_port_worker): Likewise. * i386-linux-tdep.c (i386_linux_handle_segmentation_fault): Likewise. * i386-tdep.c (i386_mpx_print_bounds): Likewise. * infcmd.c (run_command_1): Likewise. (print_return_value_1): Likewise. * inferior.c (print_selected_inferior): Likewise. (print_inferior): Likewise. * infrun.c (print_end_stepping_range_reason): Likewise. (print_signal_exited_reason): Likewise. (print_exited_reason): Likewise. (print_signal_received_reason): Likewise. (print_no_history_reason): Likewise. * interps.c (interp_set): Likewise. * linespec.c (decode_line_full): Likewise. * linux-thread-db.c (info_auto_load_libthread_db): Likewise. * mi/mi-cmd-env.c (mi_cmd_env_pwd): Likewise. (mi_cmd_env_path): Likewise. (mi_cmd_env_dir): Likewise. (mi_cmd_inferior_tty_show): Likewise. * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file): Likewise. (print_partial_file_name): Likewise. (mi_cmd_file_list_exec_source_files): Likewise. * mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions): Likewise. (mi_cmd_info_gdb_mi_command): Likewise. * mi/mi-cmd-stack.c (mi_cmd_stack_info_depth): Likewise. (mi_cmd_stack_list_args): Likewise. (list_arg_or_local): Likewise. * mi/mi-cmd-var.c (print_varobj): Likewise. (mi_cmd_var_create): Likewise. (mi_cmd_var_delete): Likewise. (mi_cmd_var_set_format): Likewise. (mi_cmd_var_show_format): Likewise. (mi_cmd_var_info_num_children): Likewise. (mi_cmd_var_list_children): Likewise. (mi_cmd_var_info_type): Likewise. (mi_cmd_var_info_path_expression): Likewise. (mi_cmd_var_info_expression): Likewise. (mi_cmd_var_show_attributes): Likewise. (mi_cmd_var_evaluate_expression): Likewise. (mi_cmd_var_assign): Likewise. (varobj_update_one): Likewise. * mi/mi-interp.c (as_mi_interp): Likewise. (mi_on_normal_stop_1): Likewise. (mi_tsv_modified): Likewise. (mi_breakpoint_created): Likewise. (mi_breakpoint_modified): Likewise. (mi_solib_loaded): Likewise. (mi_solib_unloaded): Likewise. (mi_command_param_changed): Likewise. (mi_memory_changed): Likewise. (mi_user_selected_context_changed): Likewise. * mi/mi-main.c (print_one_inferior): Likewise. (output_cores): Likewise. (list_available_thread_groups): Likewise. (mi_cmd_data_list_register_names): Likewise. (mi_cmd_data_list_changed_registers): Likewise. (output_register): Likewise. (mi_cmd_data_evaluate_expression): Likewise. (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_list_features): Likewise. (mi_cmd_list_target_features): Likewise. (mi_cmd_add_inferior): Likewise. (mi_execute_command): Likewise. (mi_load_progress): Likewise. (print_variable_or_computed): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Likewise. * osdata.c (info_osdata_command): Likewise. * probe.c (gen_ui_out_table_header_info): Likewise. (print_ui_out_not_applicables): Likewise. (print_ui_out_info): Likewise. (info_probes_for_ops): Likewise. (enable_probes_command): Likewise. (disable_probes_command): Likewise. * progspace.c (print_program_space): Likewise. * python/py-breakpoint.c (bppy_get_commands): Likewise. * python/py-framefilter.c (py_print_type): Likewise. (py_print_value): Likewise. (py_print_single_arg): Likewise. (enumerate_args): Likewise. (enumerate_locals): Likewise. (py_print_args): Likewise. (py_print_frame): Likewise. * record-btrace.c (btrace_ui_out_decode_error): Likewise. (btrace_call_history_insn_range): Likewise. (btrace_call_history_src_line): Likewise. (btrace_call_history): Likewise. * remote.c (show_remote_cmd): Likewise. * skip.c (skip_info): Likewise. * solib.c (info_sharedlibrary_command): Likewise. * source.c (print_source_lines_base): Likewise. * spu-tdep.c (info_spu_event_command): Likewise. (info_spu_signal_command): Likewise. (info_spu_mailbox_list): Likewise. (info_spu_dma_cmdlist): Likewise. (info_spu_dma_command): Likewise. (info_spu_proxydma_command): Likewise. * stack.c (print_stack_frame): Likewise. (print_frame_arg): Likewise. (read_frame_arg): Likewise. (print_frame_args): Likewise. (print_frame_info): Likewise. (print_frame): Likewise. * symfile.c (load_progress): Likewise. (generic_load): Likewise. (print_transfer_performance): Likewise. * thread.c (do_captured_list_thread_ids): Likewise. (print_thread_info_1): Likewise. (restore_selected_frame): Likewise. (do_captured_thread_select): Likewise. (print_selected_thread_frame): Likewise. * top.c (execute_command_to_string): Likewise. * tracepoint.c (tvariables_info_1): Likewise. (trace_status_mi): Likewise. (tfind_1): Likewise. (print_one_static_tracepoint_marker): Likewise. (info_static_tracepoint_markers_command): Likewise. * utils.c (do_ui_out_redirect_pop): Likewise. (fputs_maybe_filtered): Likewise.
2016-12-22 22:17:31 +01:00
uiout->message (_("(*): Shared library is missing "
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
"debugging information.\n"));
}
}
/* See solib.h. */
bool
solib_contains_address_p (const struct so_list *const solib,
CORE_ADDR address)
{
struct target_section *p;
for (p = solib->sections; p < solib->sections_end; p++)
if (p->addr <= address && address < p->endaddr)
return true;
return false;
}
/* If ADDRESS is in a shared lib in program space PSPACE, return its
name.
Provides a hook for other gdb routines to discover whether or not a
particular address is within the mapped address space of a shared
library.
1999-07-07 22:19:36 +02:00
For example, this routine is called at one point to disable
breakpoints which are in shared libraries that are not currently
mapped in. */
char *
2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> Add base multi-executable/process support to GDB. gdb/ * Makefile.in (SFILES): Add progspace.c. (COMMON_OBS): Add progspace.o. * progspace.h: New. * progspace.c: New. * breakpoint.h (struct bp_target_info) <placed_address_space>: New field. (struct bp_location) <pspace>: New field. (struct breakpoint) <pspace>: New field. (bpstat_stop_status, breakpoint_here_p) (moribund_breakpoint_here_p, breakpoint_inserted_here_p) (regular_breakpoint_inserted_here_p) (software_breakpoint_inserted_here_p, breakpoint_thread_match) (set_default_breakpoint): Adjust prototypes. (remove_breakpoints_pid, breakpoint_program_space_exit): Declare. (insert_single_step_breakpoint, deprecated_insert_raw_breakpoint): Adjust prototypes. * breakpoint.c (executing_startup): Delete. (default_breakpoint_sspace): New. (breakpoint_restore_shadows): Skip if the address space doesn't match. (update_watchpoint): Record the frame's program space in the breakpoint location. (insert_bp_location): Record the address space in target_info. Adjust to pass the symbol space to solib_name_from_address. (breakpoint_program_space_exit): New. (insert_breakpoint_locations): Switch the symbol space and thread when inserting breakpoints. Don't insert breakpoints in a vfork parent waiting for vfork done if we're not attached to the vfork child. (remove_breakpoints_pid): New. (reattach_breakpoints): Switch to a thread of PID. Ignore breakpoints of other symbol spaces. (create_internal_breakpoint): Store the symbol space in the sal. (create_longjmp_master_breakpoint): Iterate over all symbol spaces. (update_breakpoints_after_exec): Ignore breakpoints for other symbol spaces. (remove_breakpoint): Rename to ... (remove_breakpoint_1): ... this. Pass the breakpoints symbol space to solib_name_from_address. (remove_breakpoint): New. (mark_breakpoints_out): Ignore breakpoints from other symbol spaces. (breakpoint_init_inferior): Ditto. (breakpoint_here_p): Add an address space argument and adjust to use breakpoint_address_match. (moribund_breakpoint_here_p): Ditto. (regular_breakpoint_inserted_here_p): Ditto. (breakpoint_inserted_here_p): Ditto. (software_breakpoint_inserted_here_p): Ditto. (breakpoint_thread_match): Ditto. (bpstat_check_location): Ditto. (bpstat_stop_status): Ditto. (print_breakpoint_location): If there's a location to print, switch the current symbol space. (print_one_breakpoint_location): Add `allflag' argument. (print_one_breakpoint): Ditto. Adjust. (do_captured_breakpoint_query): Adjust. (breakpoint_1): Adjust. (breakpoint_has_pc): Also match the symbol space. (describe_other_breakpoints): Add a symbol space argument and adjust. (set_default_breakpoint): Add a symbol space argument. Set default_breakpoint_sspace. (breakpoint_address_match): New. (check_duplicates_for): Add an address space argument, and adjust. (set_raw_breakpoint): Record the symbol space in the location and in the breakpoint. (set_longjmp_breakpoint): Skip longjmp master breakpoints from other symbol spaces. (remove_thread_event_breakpoints, remove_solib_event_breakpoints) (disable_breakpoints_in_shlibs): Skip breakpoints from other symbol spaces. (disable_breakpoints_in_unloaded_shlib): Match symbol spaces. (create_catchpoint): Set the symbol space in the sal. (disable_breakpoints_before_startup): Skip breakpoints from other symbol spaces. Set executing_startup in the current symbol space. (enable_breakpoints_after_startup): Clear executing_startup in the current symbol space. Skip breakpoints from other symbol spaces. (clone_momentary_breakpoint): Also copy the symbol space. (add_location_to_breakpoint): Set the location's symbol space. (bp_loc_is_permanent): Switch thread and symbol space. (create_breakpoint): Adjust. (expand_line_sal_maybe): Expand comment to mention symbol spaces. Switch thread and symbol space when reading memory. (parse_breakpoint_sals): Set the symbol space in the sal. (break_command_really): Ditto. (skip_prologue_sal): Switch and space. (resolve_sal_pc): Ditto. (watch_command_1): Record the symbol space in the sal. (create_ada_exception_breakpoint): Adjust. (clear_command): Adjust. Match symbol spaces. (update_global_location_list): Use breakpoint_address_match. (breakpoint_re_set_one): Switch thread and space. (breakpoint_re_set): Save symbol space. (breakpoint_re_set_thread): Also reset the symbol space. (deprecated_insert_raw_breakpoint): Add an address space argument. Adjust. (insert_single_step_breakpoint): Ditto. (single_step_breakpoint_inserted_here_p): Ditto. (clear_syscall_counts): New. (_initialize_breakpoint): Install it as inferior_exit observer. * exec.h: Include "progspace.h". (exec_bfd, exec_bfd_mtime): New defines. (exec_close): Declare. * exec.c: Include "gdbthread.h" and "progspace.h". (exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete. (using_exec_ops): New. (exec_close_1): Rename to exec_close, and make public. (exec_close): Rename to exec_close_1, and adjust all callers. Add description. Remove target sections and close executables from all program spaces. (exec_file_attach): Add comment. (add_target_sections): Check on `using_exec_ops' to check if the target should be pushed. (remove_target_sections): Only unpush the target if there are no more target sections in any symbol space. * gdbcore.h: Include "exec.h". (exec_bfd, exec_bfd_mtime): Remove declarations. * frame.h (get_frame_program_space, get_frame_address_space) (frame_unwind_program_space): Declare. * frame.c (struct frame_info) <pspace, aspace>: New fields. (create_sentinel_frame): Add program space argument. Set the pspace and aspace fields of the frame object. (get_current_frame, create_new_frame): Adjust. (get_frame_program_space): New. (frame_unwind_program_space): New. (get_frame_address_space): New. * stack.c (print_frame_info): Adjust. (print_frame): Use the frame's program space. * gdbthread.h (any_live_thread_of_process): Declare. * thread.c (any_live_thread_of_process): New. (switch_to_thread): Switch the program space as well. (restore_selected_frame): Don't warn if trying to restore frame level 0. * inferior.h: Include "progspace.h". (detach_fork): Declare. (struct inferior) <removable, aspace, pspace> <vfork_parent, vfork_child, pending_detach> <waiting_for_vfork_done>: New fields. <terminal_info>: Remove field. <data, num_data>: New fields. (register_inferior_data, register_inferior_data_with_cleanup) (clear_inferior_data, set_inferior_data, inferior_data): Declare. (exit_inferior, exit_inferior_silent, exit_inferior_num_silent) (inferior_appeared): Declare. (find_inferior_pid): Typo. (find_inferior_id, find_inferior_for_program_space): Declare. (set_current_inferior, save_current_inferior, prune_inferiors) (number_of_inferiors): Declare. (inferior_list): Declare. * inferior.c: Include "gdbcore.h" and "symfile.h". (inferior_list): Make public. (delete_inferior_1): Always delete thread silently. (find_inferior_id): Make public. (current_inferior_): New. (current_inferior): Use it. (set_current_inferior): New. (restore_inferior): New. (save_current_inferior): New. (free_inferior): Free the per-inferior data. (add_inferior_silent): Allocate per-inferior data. Call inferior_appeared. (delete_threads_of_inferior): New. (delete_inferior_1): Adjust interface to take an inferior pointer. (delete_inferior): Adjust. (delete_inferior_silent): Adjust. (exit_inferior_1): New. (exit_inferior): New. (exit_inferior_silent): New. (exit_inferior_num_silent): New. (detach_inferior): Adjust. (inferior_appeared): New. (discard_all_inferiors): Adjust. (find_inferior_id): Make public. Assert pid is not zero. (find_inferior_for_program_space): New. (have_inferiors): Check if we have any inferior with pid not zero. (have_live_inferiors): Go over all pushed targets looking for process_stratum. (prune_inferiors): New. (number_of_inferiors): New. (print_inferior): Add executable column. Print vfork parent/child relationships. (inferior_command): Adjust to cope with not running inferiors. (remove_inferior_command): New. (add_inferior_command): New. (clone_inferior_command): New. (struct inferior_data): New. (struct inferior_data_registration): New. (struct inferior_data_registry): New. (inferior_data_registry): New. (register_inferior_data_with_cleanup): New. (register_inferior_data): New. (inferior_alloc_data): New. (inferior_free_data): New. (clear_inferior_data): New. (set_inferior_data): New. (inferior_data): New. (initialize_inferiors): New. (_initialize_inferiors): Register "add-inferior", "remove-inferior" and "clone-inferior" commands. * objfiles.h: Include "progspace.h". (struct objfile) <pspace>: New field. (symfile_objfile, object_files): Don't declare. (ALL_PSPACE_OBJFILES): New. (ALL_PSPACE_OBJFILES_SAFE): New. (ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust. (ALL_PSPACE_SYMTABS): New. (ALL_PRIMARY_SYMTABS): Adjust. (ALL_PSPACE_PRIMARY_SYMTABS): New. (ALL_PSYMTABS): Adjust. (ALL_PSPACE_PSYMTABS): New. * objfiles.c (object_files, symfile_objfile): Delete. (struct objfile_sspace_info): New. (objfiles_pspace_data): New. (objfiles_pspace_data_cleanup): New. (get_objfile_pspace_data): New. (objfiles_changed_p): Delete. (allocate_objfile): Set the objfile's program space. Adjust to reference objfiles_changed_p in pspace data. (free_objfile): Adjust to reference objfiles_changed_p in pspace data. (objfile_relocate): Ditto. (update_section_map): Add pspace argument. Adjust to iterate over objfiles in the passed in pspace. (find_pc_section): Delete sections and num_sections statics. Adjust to refer to program space's objfiles_changed_p. Adjust to refer to sections and num_sections store in the objfile's pspace data. (objfiles_changed): Adjust to reference objfiles_changed_p in pspace data. (_initialize_objfiles): New. * linespec.c (decode_all_digits, decode_dollar): Set the sal's program space. * source.c (current_source_pspace): New. (get_current_source_symtab_and_line): Set the sal's program space. (set_current_source_symtab_and_line): Set current_source_pspace. (select_source_symtab): Ditto. Use ALL_OBJFILES. (forget_cached_source_info): Iterate over all program spaces. * symfile.c (clear_symtab_users): Adjust. * symmisc.c (print_symbol_bcache_statistics): Iterate over all program spaces. (print_objfile_statistics): Ditto. (maintenance_print_msymbols): Ditto. (maintenance_print_objfiles): Ditto. (maintenance_info_symtabs): Ditto. (maintenance_info_psymtabs): Ditto. * symtab.h (SYMTAB_PSPACE): New. (struct symtab_and_line) <pspace>: New field. * symtab.c (init_sal): Clear the sal's program space. (find_pc_sect_symtab): Set the sal's program space. Switch thread and space. (append_expanded_sal): Add program space argument. Iterate over all program spaces. (expand_line_sal): Iterate over all program spaces. Switch program space. * target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New. (struct target_ops) <to_thread_address_space>: New field. (target_thread_address_space): Define. * target.c (target_detach): Only remove breakpoints from the inferior we're detaching. (target_thread_address_space): New. * defs.h (initialize_progspace): Declare. * top.c (gdb_init): Call it. * solist.h (struct so_list) <sspace>: New field. * solib.h (struct program_space): Forward declare. (solib_name_from_address): Adjust prototype. * solib.c (so_list_head): Replace with a macro referencing the program space. (update_solib_list): Set the so's program space. (solib_name_from_address): Add a program space argument and adjust. * solib-svr4.c (struct svr4_info) <pid>: Delete field. <interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low> <interp_plt_sect_high>: New fields. (svr4_info_p, svr4_info): Delete. (solib_svr4_sspace_data): New. (get_svr4_info): Rewrite. (svr4_sspace_data_cleanup): New. (open_symbol_file_object): Adjust. (svr4_default_sos): Adjust. (svr4_fetch_objfile_link_map): Adjust. (interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low) (interp_plt_sect_high): Delete. (svr4_in_dynsym_resolve_code): Adjust. (enable_break): Adjust. (svr4_clear_solib): Revert bit that removed the svr4_info here, and reinstate clearing debug_base, debug_loader_offset_p, debug_loader_offset and debug_loader_name. (_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't install an inferior_exit observer anymore. * printcmd.c (struct display) <pspace>: New field. (display_command): Set the display's sspace. (do_one_display): Match the display's sspace. (display_uses_solib_p): Ditto. * linux-fork.c (detach_fork): Moved to infrun.c. (_initialize_linux_fork): Moved "detach-on-fork" command to infrun.c. * infrun.c (detach_fork): Moved from linux-fork.c. (proceed_after_vfork_done): New. (handle_vfork_child_exec_or_exit): New. (follow_exec_mode_replace, follow_exec_mode_keep) (follow_exec_mode_names, follow_exec_mode_string) (show_follow_exec_mode_string): New. (follow_exec): New. Reinstate the mark_breakpoints_out call. Remove shared libraries before attaching new executable. If user wants to keep the inferior, keep it. (displaced_step_fixup): Adjust to pass an address space to the breakpoints module. (resume): Ditto. (clear_proceed_status): In all-stop mode, always clear the proceed status of all threads. (prepare_to_proceed): Adjust to pass an address space to the breakpoints module. (proceed): Ditto. (adjust_pc_after_break): Ditto. (handle_inferior_event): When handling a process exit, switch the program space to the inferior's that had exited. Call handle_vfork_child_exec_or_exit. Adjust to pass an address space to the breakpoints module. In non-stop mode, when following a fork and detach-fork is off, also resume the other branch. Handle TARGET_WAITKIND_VFORK_DONE. Set the program space in sals. (normal_stop): Prune inferiors. (_initialize_infrun): Install the new "follow-exec-mode" command. "detach-on-fork" moved here. * regcache.h (get_regcache_aspace): Declare. * regcache.c (struct regcache) <aspace>: New field. (regcache_xmalloc): Clear the aspace. (get_regcache_aspace): New. (regcache_cpy): Copy the aspace field. (regcache_cpy_no_passthrough): Ditto. (get_thread_regcache): Fetch the thread's address space from the target, and store it in the regcache. * infcall.c (call_function_by_hand): Set the sal's pspace. * arch-utils.c (default_has_shared_address_space): New. * arch-utils.h (default_has_shared_address_space): Declare. * gdbarch.sh (has_shared_address_space): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.c: Include auxv.h, target.h, elf/common.h. (linux_has_shared_address_space): New. (_initialize_linux_tdep): Declare. * arm-tdep.c (arm_software_single_step): Pass the frame's address space to insert_single_step_breakpoint. * arm-linux-tdep.c (arm_linux_software_single_step): Pass the frame's pspace to breakpoint functions. * cris-tdep.c (crisv32_single_step_through_delay): Ditto. (cris_software_single_step): Ditto. * mips-tdep.c (deal_with_atomic_sequence): Add frame argument. Pass the frame's pspace to breakpoint functions. (mips_software_single_step): Adjust. (mips_single_step_through_delay): Adjust. * rs6000-aix-tdep.c (rs6000_software_single_step): Adjust. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust. * solib-irix.c (enable_break): Adjust to pass the current frame's address space to breakpoint functions. * sparc-tdep.c (sparc_software_single_step): Ditto. * spu-tdep.c (spu_software_single_step): Ditto. * alpha-tdep.c (alpha_software_single_step): Ditto. * record.c (record_wait): Adjust to pass an address space to the breakpoints module. * fork-child.c (fork_inferior): Set the new inferior's program and address spaces. * inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program and address spaces. (inf_ptrace_attach): Set the inferior's program and address spaces. * linux-nat.c: Include "solib.h". (linux_child_follow_fork): Manage parent and child's program and address spaces. Clone the parent's program space if necessary. Don't wait for the vfork to be done here. Refuse to resume if following the vfork parent while leaving the child stopped. (resume_callback): Don't resume a vfork parent. (linux_nat_resume): Also check for pending events in the lp->waitstatus field. (linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE events to the core. (stop_wait_callback): Don't wait for SIGSTOP on vfork parents. (cancel_breakpoint): Adjust. * linux-thread-db.c (thread_db_wait): Don't remove thread event breakpoints here. (thread_db_mourn_inferior): Don't mark breakpoints out here. Remove thread event breakpoints after mourning. * corelow.c: Include progspace.h. (core_open): Set the inferior's program and address spaces. * remote.c (remote_add_inferior): Set the new inferior's program and address spaces. (remote_start_remote): Update address spaces. (extended_remote_create_inferior_1): Don't init the thread list if we already debugging other inferiors. * darwin-nat.c (darwin_attach): Set the new inferior's program and address spaces. * gnu-nat.c (gnu_attach): Ditto. * go32-nat.c (go32_create_inferior): Ditto. * inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto. * monitor.c (monitor_open): Ditto. * nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto. * procfs.c (do_attach): Ditto. * windows-nat.c (do_initial_windows_stuff): Ditto. * inflow.c (inferior_process_group) (terminal_init_inferior_with_pgrp, terminal_inferior, (terminal_ours_1, inflow_inferior_exit, copy_terminal_info) (child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust to use per-inferior data instead of inferior->terminal_info. (inflow_inferior_data): New. (inflow_new_inferior): Delete. (inflow_inferior_data_cleanup): New. (get_inflow_inferior_data): New. * mi/mi-interp.c (mi_new_inferior): Rename to... (mi_inferior_appeared): ... this. (mi_interpreter_init): Adjust. * tui/tui-disasm.c: Include "progspace.h". (tui_set_disassem_content): Pass an address space to breakpoint_here_p. * NEWS: Mention multi-program debugging support. Mention new commands "add-inferior", "clone-inferior", "remove-inferior", "maint info program-spaces", and new option "set follow-exec-mode". 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * observer.texi (new_inferior): Rename to... (inferior_appeared): ... this. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/testsuite/ * gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork". * gdb.base/foll-exec.exp: Adjust to expect a process id before "Executing new program". * gdb.base/foll-fork.exp: Adjust to spell out "follow-fork". * gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being left listed after having been killed. * gdb.base/attach.exp: Adjust to spell out "symbol-file". * gdb.base/maint.exp: Adjust test. * Makefile.in (ALL_SUBDIRS): Add gdb.multi. * gdb.multi/Makefile.in: New. * gdb.multi/base.exp: New. * gdb.multi/goodbye.c: New. * gdb.multi/hangout.c: New. * gdb.multi/hello.c: New. * gdb.multi/bkpt-multi-exec.c: New. * gdb.multi/bkpt-multi-exec.exp: New. * gdb.multi/crashme.c: New. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * gdb.texinfo (Inferiors): Rename node to ... (Inferiors and Programs): ... this. Mention running multiple programs in the same debug session. <info inferiors>: Mention the new 'Executable' column if "info inferiors". Update examples. Document the "add-inferior", "clone-inferior", "remove-inferior" and "maint info program-spaces" commands. (Process): Rename node to... (Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
solib_name_from_address (struct program_space *pspace, CORE_ADDR address)
{
2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> Add base multi-executable/process support to GDB. gdb/ * Makefile.in (SFILES): Add progspace.c. (COMMON_OBS): Add progspace.o. * progspace.h: New. * progspace.c: New. * breakpoint.h (struct bp_target_info) <placed_address_space>: New field. (struct bp_location) <pspace>: New field. (struct breakpoint) <pspace>: New field. (bpstat_stop_status, breakpoint_here_p) (moribund_breakpoint_here_p, breakpoint_inserted_here_p) (regular_breakpoint_inserted_here_p) (software_breakpoint_inserted_here_p, breakpoint_thread_match) (set_default_breakpoint): Adjust prototypes. (remove_breakpoints_pid, breakpoint_program_space_exit): Declare. (insert_single_step_breakpoint, deprecated_insert_raw_breakpoint): Adjust prototypes. * breakpoint.c (executing_startup): Delete. (default_breakpoint_sspace): New. (breakpoint_restore_shadows): Skip if the address space doesn't match. (update_watchpoint): Record the frame's program space in the breakpoint location. (insert_bp_location): Record the address space in target_info. Adjust to pass the symbol space to solib_name_from_address. (breakpoint_program_space_exit): New. (insert_breakpoint_locations): Switch the symbol space and thread when inserting breakpoints. Don't insert breakpoints in a vfork parent waiting for vfork done if we're not attached to the vfork child. (remove_breakpoints_pid): New. (reattach_breakpoints): Switch to a thread of PID. Ignore breakpoints of other symbol spaces. (create_internal_breakpoint): Store the symbol space in the sal. (create_longjmp_master_breakpoint): Iterate over all symbol spaces. (update_breakpoints_after_exec): Ignore breakpoints for other symbol spaces. (remove_breakpoint): Rename to ... (remove_breakpoint_1): ... this. Pass the breakpoints symbol space to solib_name_from_address. (remove_breakpoint): New. (mark_breakpoints_out): Ignore breakpoints from other symbol spaces. (breakpoint_init_inferior): Ditto. (breakpoint_here_p): Add an address space argument and adjust to use breakpoint_address_match. (moribund_breakpoint_here_p): Ditto. (regular_breakpoint_inserted_here_p): Ditto. (breakpoint_inserted_here_p): Ditto. (software_breakpoint_inserted_here_p): Ditto. (breakpoint_thread_match): Ditto. (bpstat_check_location): Ditto. (bpstat_stop_status): Ditto. (print_breakpoint_location): If there's a location to print, switch the current symbol space. (print_one_breakpoint_location): Add `allflag' argument. (print_one_breakpoint): Ditto. Adjust. (do_captured_breakpoint_query): Adjust. (breakpoint_1): Adjust. (breakpoint_has_pc): Also match the symbol space. (describe_other_breakpoints): Add a symbol space argument and adjust. (set_default_breakpoint): Add a symbol space argument. Set default_breakpoint_sspace. (breakpoint_address_match): New. (check_duplicates_for): Add an address space argument, and adjust. (set_raw_breakpoint): Record the symbol space in the location and in the breakpoint. (set_longjmp_breakpoint): Skip longjmp master breakpoints from other symbol spaces. (remove_thread_event_breakpoints, remove_solib_event_breakpoints) (disable_breakpoints_in_shlibs): Skip breakpoints from other symbol spaces. (disable_breakpoints_in_unloaded_shlib): Match symbol spaces. (create_catchpoint): Set the symbol space in the sal. (disable_breakpoints_before_startup): Skip breakpoints from other symbol spaces. Set executing_startup in the current symbol space. (enable_breakpoints_after_startup): Clear executing_startup in the current symbol space. Skip breakpoints from other symbol spaces. (clone_momentary_breakpoint): Also copy the symbol space. (add_location_to_breakpoint): Set the location's symbol space. (bp_loc_is_permanent): Switch thread and symbol space. (create_breakpoint): Adjust. (expand_line_sal_maybe): Expand comment to mention symbol spaces. Switch thread and symbol space when reading memory. (parse_breakpoint_sals): Set the symbol space in the sal. (break_command_really): Ditto. (skip_prologue_sal): Switch and space. (resolve_sal_pc): Ditto. (watch_command_1): Record the symbol space in the sal. (create_ada_exception_breakpoint): Adjust. (clear_command): Adjust. Match symbol spaces. (update_global_location_list): Use breakpoint_address_match. (breakpoint_re_set_one): Switch thread and space. (breakpoint_re_set): Save symbol space. (breakpoint_re_set_thread): Also reset the symbol space. (deprecated_insert_raw_breakpoint): Add an address space argument. Adjust. (insert_single_step_breakpoint): Ditto. (single_step_breakpoint_inserted_here_p): Ditto. (clear_syscall_counts): New. (_initialize_breakpoint): Install it as inferior_exit observer. * exec.h: Include "progspace.h". (exec_bfd, exec_bfd_mtime): New defines. (exec_close): Declare. * exec.c: Include "gdbthread.h" and "progspace.h". (exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete. (using_exec_ops): New. (exec_close_1): Rename to exec_close, and make public. (exec_close): Rename to exec_close_1, and adjust all callers. Add description. Remove target sections and close executables from all program spaces. (exec_file_attach): Add comment. (add_target_sections): Check on `using_exec_ops' to check if the target should be pushed. (remove_target_sections): Only unpush the target if there are no more target sections in any symbol space. * gdbcore.h: Include "exec.h". (exec_bfd, exec_bfd_mtime): Remove declarations. * frame.h (get_frame_program_space, get_frame_address_space) (frame_unwind_program_space): Declare. * frame.c (struct frame_info) <pspace, aspace>: New fields. (create_sentinel_frame): Add program space argument. Set the pspace and aspace fields of the frame object. (get_current_frame, create_new_frame): Adjust. (get_frame_program_space): New. (frame_unwind_program_space): New. (get_frame_address_space): New. * stack.c (print_frame_info): Adjust. (print_frame): Use the frame's program space. * gdbthread.h (any_live_thread_of_process): Declare. * thread.c (any_live_thread_of_process): New. (switch_to_thread): Switch the program space as well. (restore_selected_frame): Don't warn if trying to restore frame level 0. * inferior.h: Include "progspace.h". (detach_fork): Declare. (struct inferior) <removable, aspace, pspace> <vfork_parent, vfork_child, pending_detach> <waiting_for_vfork_done>: New fields. <terminal_info>: Remove field. <data, num_data>: New fields. (register_inferior_data, register_inferior_data_with_cleanup) (clear_inferior_data, set_inferior_data, inferior_data): Declare. (exit_inferior, exit_inferior_silent, exit_inferior_num_silent) (inferior_appeared): Declare. (find_inferior_pid): Typo. (find_inferior_id, find_inferior_for_program_space): Declare. (set_current_inferior, save_current_inferior, prune_inferiors) (number_of_inferiors): Declare. (inferior_list): Declare. * inferior.c: Include "gdbcore.h" and "symfile.h". (inferior_list): Make public. (delete_inferior_1): Always delete thread silently. (find_inferior_id): Make public. (current_inferior_): New. (current_inferior): Use it. (set_current_inferior): New. (restore_inferior): New. (save_current_inferior): New. (free_inferior): Free the per-inferior data. (add_inferior_silent): Allocate per-inferior data. Call inferior_appeared. (delete_threads_of_inferior): New. (delete_inferior_1): Adjust interface to take an inferior pointer. (delete_inferior): Adjust. (delete_inferior_silent): Adjust. (exit_inferior_1): New. (exit_inferior): New. (exit_inferior_silent): New. (exit_inferior_num_silent): New. (detach_inferior): Adjust. (inferior_appeared): New. (discard_all_inferiors): Adjust. (find_inferior_id): Make public. Assert pid is not zero. (find_inferior_for_program_space): New. (have_inferiors): Check if we have any inferior with pid not zero. (have_live_inferiors): Go over all pushed targets looking for process_stratum. (prune_inferiors): New. (number_of_inferiors): New. (print_inferior): Add executable column. Print vfork parent/child relationships. (inferior_command): Adjust to cope with not running inferiors. (remove_inferior_command): New. (add_inferior_command): New. (clone_inferior_command): New. (struct inferior_data): New. (struct inferior_data_registration): New. (struct inferior_data_registry): New. (inferior_data_registry): New. (register_inferior_data_with_cleanup): New. (register_inferior_data): New. (inferior_alloc_data): New. (inferior_free_data): New. (clear_inferior_data): New. (set_inferior_data): New. (inferior_data): New. (initialize_inferiors): New. (_initialize_inferiors): Register "add-inferior", "remove-inferior" and "clone-inferior" commands. * objfiles.h: Include "progspace.h". (struct objfile) <pspace>: New field. (symfile_objfile, object_files): Don't declare. (ALL_PSPACE_OBJFILES): New. (ALL_PSPACE_OBJFILES_SAFE): New. (ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust. (ALL_PSPACE_SYMTABS): New. (ALL_PRIMARY_SYMTABS): Adjust. (ALL_PSPACE_PRIMARY_SYMTABS): New. (ALL_PSYMTABS): Adjust. (ALL_PSPACE_PSYMTABS): New. * objfiles.c (object_files, symfile_objfile): Delete. (struct objfile_sspace_info): New. (objfiles_pspace_data): New. (objfiles_pspace_data_cleanup): New. (get_objfile_pspace_data): New. (objfiles_changed_p): Delete. (allocate_objfile): Set the objfile's program space. Adjust to reference objfiles_changed_p in pspace data. (free_objfile): Adjust to reference objfiles_changed_p in pspace data. (objfile_relocate): Ditto. (update_section_map): Add pspace argument. Adjust to iterate over objfiles in the passed in pspace. (find_pc_section): Delete sections and num_sections statics. Adjust to refer to program space's objfiles_changed_p. Adjust to refer to sections and num_sections store in the objfile's pspace data. (objfiles_changed): Adjust to reference objfiles_changed_p in pspace data. (_initialize_objfiles): New. * linespec.c (decode_all_digits, decode_dollar): Set the sal's program space. * source.c (current_source_pspace): New. (get_current_source_symtab_and_line): Set the sal's program space. (set_current_source_symtab_and_line): Set current_source_pspace. (select_source_symtab): Ditto. Use ALL_OBJFILES. (forget_cached_source_info): Iterate over all program spaces. * symfile.c (clear_symtab_users): Adjust. * symmisc.c (print_symbol_bcache_statistics): Iterate over all program spaces. (print_objfile_statistics): Ditto. (maintenance_print_msymbols): Ditto. (maintenance_print_objfiles): Ditto. (maintenance_info_symtabs): Ditto. (maintenance_info_psymtabs): Ditto. * symtab.h (SYMTAB_PSPACE): New. (struct symtab_and_line) <pspace>: New field. * symtab.c (init_sal): Clear the sal's program space. (find_pc_sect_symtab): Set the sal's program space. Switch thread and space. (append_expanded_sal): Add program space argument. Iterate over all program spaces. (expand_line_sal): Iterate over all program spaces. Switch program space. * target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New. (struct target_ops) <to_thread_address_space>: New field. (target_thread_address_space): Define. * target.c (target_detach): Only remove breakpoints from the inferior we're detaching. (target_thread_address_space): New. * defs.h (initialize_progspace): Declare. * top.c (gdb_init): Call it. * solist.h (struct so_list) <sspace>: New field. * solib.h (struct program_space): Forward declare. (solib_name_from_address): Adjust prototype. * solib.c (so_list_head): Replace with a macro referencing the program space. (update_solib_list): Set the so's program space. (solib_name_from_address): Add a program space argument and adjust. * solib-svr4.c (struct svr4_info) <pid>: Delete field. <interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low> <interp_plt_sect_high>: New fields. (svr4_info_p, svr4_info): Delete. (solib_svr4_sspace_data): New. (get_svr4_info): Rewrite. (svr4_sspace_data_cleanup): New. (open_symbol_file_object): Adjust. (svr4_default_sos): Adjust. (svr4_fetch_objfile_link_map): Adjust. (interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low) (interp_plt_sect_high): Delete. (svr4_in_dynsym_resolve_code): Adjust. (enable_break): Adjust. (svr4_clear_solib): Revert bit that removed the svr4_info here, and reinstate clearing debug_base, debug_loader_offset_p, debug_loader_offset and debug_loader_name. (_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't install an inferior_exit observer anymore. * printcmd.c (struct display) <pspace>: New field. (display_command): Set the display's sspace. (do_one_display): Match the display's sspace. (display_uses_solib_p): Ditto. * linux-fork.c (detach_fork): Moved to infrun.c. (_initialize_linux_fork): Moved "detach-on-fork" command to infrun.c. * infrun.c (detach_fork): Moved from linux-fork.c. (proceed_after_vfork_done): New. (handle_vfork_child_exec_or_exit): New. (follow_exec_mode_replace, follow_exec_mode_keep) (follow_exec_mode_names, follow_exec_mode_string) (show_follow_exec_mode_string): New. (follow_exec): New. Reinstate the mark_breakpoints_out call. Remove shared libraries before attaching new executable. If user wants to keep the inferior, keep it. (displaced_step_fixup): Adjust to pass an address space to the breakpoints module. (resume): Ditto. (clear_proceed_status): In all-stop mode, always clear the proceed status of all threads. (prepare_to_proceed): Adjust to pass an address space to the breakpoints module. (proceed): Ditto. (adjust_pc_after_break): Ditto. (handle_inferior_event): When handling a process exit, switch the program space to the inferior's that had exited. Call handle_vfork_child_exec_or_exit. Adjust to pass an address space to the breakpoints module. In non-stop mode, when following a fork and detach-fork is off, also resume the other branch. Handle TARGET_WAITKIND_VFORK_DONE. Set the program space in sals. (normal_stop): Prune inferiors. (_initialize_infrun): Install the new "follow-exec-mode" command. "detach-on-fork" moved here. * regcache.h (get_regcache_aspace): Declare. * regcache.c (struct regcache) <aspace>: New field. (regcache_xmalloc): Clear the aspace. (get_regcache_aspace): New. (regcache_cpy): Copy the aspace field. (regcache_cpy_no_passthrough): Ditto. (get_thread_regcache): Fetch the thread's address space from the target, and store it in the regcache. * infcall.c (call_function_by_hand): Set the sal's pspace. * arch-utils.c (default_has_shared_address_space): New. * arch-utils.h (default_has_shared_address_space): Declare. * gdbarch.sh (has_shared_address_space): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.c: Include auxv.h, target.h, elf/common.h. (linux_has_shared_address_space): New. (_initialize_linux_tdep): Declare. * arm-tdep.c (arm_software_single_step): Pass the frame's address space to insert_single_step_breakpoint. * arm-linux-tdep.c (arm_linux_software_single_step): Pass the frame's pspace to breakpoint functions. * cris-tdep.c (crisv32_single_step_through_delay): Ditto. (cris_software_single_step): Ditto. * mips-tdep.c (deal_with_atomic_sequence): Add frame argument. Pass the frame's pspace to breakpoint functions. (mips_software_single_step): Adjust. (mips_single_step_through_delay): Adjust. * rs6000-aix-tdep.c (rs6000_software_single_step): Adjust. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust. * solib-irix.c (enable_break): Adjust to pass the current frame's address space to breakpoint functions. * sparc-tdep.c (sparc_software_single_step): Ditto. * spu-tdep.c (spu_software_single_step): Ditto. * alpha-tdep.c (alpha_software_single_step): Ditto. * record.c (record_wait): Adjust to pass an address space to the breakpoints module. * fork-child.c (fork_inferior): Set the new inferior's program and address spaces. * inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program and address spaces. (inf_ptrace_attach): Set the inferior's program and address spaces. * linux-nat.c: Include "solib.h". (linux_child_follow_fork): Manage parent and child's program and address spaces. Clone the parent's program space if necessary. Don't wait for the vfork to be done here. Refuse to resume if following the vfork parent while leaving the child stopped. (resume_callback): Don't resume a vfork parent. (linux_nat_resume): Also check for pending events in the lp->waitstatus field. (linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE events to the core. (stop_wait_callback): Don't wait for SIGSTOP on vfork parents. (cancel_breakpoint): Adjust. * linux-thread-db.c (thread_db_wait): Don't remove thread event breakpoints here. (thread_db_mourn_inferior): Don't mark breakpoints out here. Remove thread event breakpoints after mourning. * corelow.c: Include progspace.h. (core_open): Set the inferior's program and address spaces. * remote.c (remote_add_inferior): Set the new inferior's program and address spaces. (remote_start_remote): Update address spaces. (extended_remote_create_inferior_1): Don't init the thread list if we already debugging other inferiors. * darwin-nat.c (darwin_attach): Set the new inferior's program and address spaces. * gnu-nat.c (gnu_attach): Ditto. * go32-nat.c (go32_create_inferior): Ditto. * inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto. * monitor.c (monitor_open): Ditto. * nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto. * procfs.c (do_attach): Ditto. * windows-nat.c (do_initial_windows_stuff): Ditto. * inflow.c (inferior_process_group) (terminal_init_inferior_with_pgrp, terminal_inferior, (terminal_ours_1, inflow_inferior_exit, copy_terminal_info) (child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust to use per-inferior data instead of inferior->terminal_info. (inflow_inferior_data): New. (inflow_new_inferior): Delete. (inflow_inferior_data_cleanup): New. (get_inflow_inferior_data): New. * mi/mi-interp.c (mi_new_inferior): Rename to... (mi_inferior_appeared): ... this. (mi_interpreter_init): Adjust. * tui/tui-disasm.c: Include "progspace.h". (tui_set_disassem_content): Pass an address space to breakpoint_here_p. * NEWS: Mention multi-program debugging support. Mention new commands "add-inferior", "clone-inferior", "remove-inferior", "maint info program-spaces", and new option "set follow-exec-mode". 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * observer.texi (new_inferior): Rename to... (inferior_appeared): ... this. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/testsuite/ * gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork". * gdb.base/foll-exec.exp: Adjust to expect a process id before "Executing new program". * gdb.base/foll-fork.exp: Adjust to spell out "follow-fork". * gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being left listed after having been killed. * gdb.base/attach.exp: Adjust to spell out "symbol-file". * gdb.base/maint.exp: Adjust test. * Makefile.in (ALL_SUBDIRS): Add gdb.multi. * gdb.multi/Makefile.in: New. * gdb.multi/base.exp: New. * gdb.multi/goodbye.c: New. * gdb.multi/hangout.c: New. * gdb.multi/hello.c: New. * gdb.multi/bkpt-multi-exec.c: New. * gdb.multi/bkpt-multi-exec.exp: New. * gdb.multi/crashme.c: New. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * gdb.texinfo (Inferiors): Rename node to ... (Inferiors and Programs): ... this. Mention running multiple programs in the same debug session. <info inferiors>: Mention the new 'Executable' column if "info inferiors". Update examples. Document the "add-inferior", "clone-inferior", "remove-inferior" and "maint info program-spaces" commands. (Process): Rename node to... (Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
struct so_list *so = NULL;
1999-07-07 22:19:36 +02:00
2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> Add base multi-executable/process support to GDB. gdb/ * Makefile.in (SFILES): Add progspace.c. (COMMON_OBS): Add progspace.o. * progspace.h: New. * progspace.c: New. * breakpoint.h (struct bp_target_info) <placed_address_space>: New field. (struct bp_location) <pspace>: New field. (struct breakpoint) <pspace>: New field. (bpstat_stop_status, breakpoint_here_p) (moribund_breakpoint_here_p, breakpoint_inserted_here_p) (regular_breakpoint_inserted_here_p) (software_breakpoint_inserted_here_p, breakpoint_thread_match) (set_default_breakpoint): Adjust prototypes. (remove_breakpoints_pid, breakpoint_program_space_exit): Declare. (insert_single_step_breakpoint, deprecated_insert_raw_breakpoint): Adjust prototypes. * breakpoint.c (executing_startup): Delete. (default_breakpoint_sspace): New. (breakpoint_restore_shadows): Skip if the address space doesn't match. (update_watchpoint): Record the frame's program space in the breakpoint location. (insert_bp_location): Record the address space in target_info. Adjust to pass the symbol space to solib_name_from_address. (breakpoint_program_space_exit): New. (insert_breakpoint_locations): Switch the symbol space and thread when inserting breakpoints. Don't insert breakpoints in a vfork parent waiting for vfork done if we're not attached to the vfork child. (remove_breakpoints_pid): New. (reattach_breakpoints): Switch to a thread of PID. Ignore breakpoints of other symbol spaces. (create_internal_breakpoint): Store the symbol space in the sal. (create_longjmp_master_breakpoint): Iterate over all symbol spaces. (update_breakpoints_after_exec): Ignore breakpoints for other symbol spaces. (remove_breakpoint): Rename to ... (remove_breakpoint_1): ... this. Pass the breakpoints symbol space to solib_name_from_address. (remove_breakpoint): New. (mark_breakpoints_out): Ignore breakpoints from other symbol spaces. (breakpoint_init_inferior): Ditto. (breakpoint_here_p): Add an address space argument and adjust to use breakpoint_address_match. (moribund_breakpoint_here_p): Ditto. (regular_breakpoint_inserted_here_p): Ditto. (breakpoint_inserted_here_p): Ditto. (software_breakpoint_inserted_here_p): Ditto. (breakpoint_thread_match): Ditto. (bpstat_check_location): Ditto. (bpstat_stop_status): Ditto. (print_breakpoint_location): If there's a location to print, switch the current symbol space. (print_one_breakpoint_location): Add `allflag' argument. (print_one_breakpoint): Ditto. Adjust. (do_captured_breakpoint_query): Adjust. (breakpoint_1): Adjust. (breakpoint_has_pc): Also match the symbol space. (describe_other_breakpoints): Add a symbol space argument and adjust. (set_default_breakpoint): Add a symbol space argument. Set default_breakpoint_sspace. (breakpoint_address_match): New. (check_duplicates_for): Add an address space argument, and adjust. (set_raw_breakpoint): Record the symbol space in the location and in the breakpoint. (set_longjmp_breakpoint): Skip longjmp master breakpoints from other symbol spaces. (remove_thread_event_breakpoints, remove_solib_event_breakpoints) (disable_breakpoints_in_shlibs): Skip breakpoints from other symbol spaces. (disable_breakpoints_in_unloaded_shlib): Match symbol spaces. (create_catchpoint): Set the symbol space in the sal. (disable_breakpoints_before_startup): Skip breakpoints from other symbol spaces. Set executing_startup in the current symbol space. (enable_breakpoints_after_startup): Clear executing_startup in the current symbol space. Skip breakpoints from other symbol spaces. (clone_momentary_breakpoint): Also copy the symbol space. (add_location_to_breakpoint): Set the location's symbol space. (bp_loc_is_permanent): Switch thread and symbol space. (create_breakpoint): Adjust. (expand_line_sal_maybe): Expand comment to mention symbol spaces. Switch thread and symbol space when reading memory. (parse_breakpoint_sals): Set the symbol space in the sal. (break_command_really): Ditto. (skip_prologue_sal): Switch and space. (resolve_sal_pc): Ditto. (watch_command_1): Record the symbol space in the sal. (create_ada_exception_breakpoint): Adjust. (clear_command): Adjust. Match symbol spaces. (update_global_location_list): Use breakpoint_address_match. (breakpoint_re_set_one): Switch thread and space. (breakpoint_re_set): Save symbol space. (breakpoint_re_set_thread): Also reset the symbol space. (deprecated_insert_raw_breakpoint): Add an address space argument. Adjust. (insert_single_step_breakpoint): Ditto. (single_step_breakpoint_inserted_here_p): Ditto. (clear_syscall_counts): New. (_initialize_breakpoint): Install it as inferior_exit observer. * exec.h: Include "progspace.h". (exec_bfd, exec_bfd_mtime): New defines. (exec_close): Declare. * exec.c: Include "gdbthread.h" and "progspace.h". (exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete. (using_exec_ops): New. (exec_close_1): Rename to exec_close, and make public. (exec_close): Rename to exec_close_1, and adjust all callers. Add description. Remove target sections and close executables from all program spaces. (exec_file_attach): Add comment. (add_target_sections): Check on `using_exec_ops' to check if the target should be pushed. (remove_target_sections): Only unpush the target if there are no more target sections in any symbol space. * gdbcore.h: Include "exec.h". (exec_bfd, exec_bfd_mtime): Remove declarations. * frame.h (get_frame_program_space, get_frame_address_space) (frame_unwind_program_space): Declare. * frame.c (struct frame_info) <pspace, aspace>: New fields. (create_sentinel_frame): Add program space argument. Set the pspace and aspace fields of the frame object. (get_current_frame, create_new_frame): Adjust. (get_frame_program_space): New. (frame_unwind_program_space): New. (get_frame_address_space): New. * stack.c (print_frame_info): Adjust. (print_frame): Use the frame's program space. * gdbthread.h (any_live_thread_of_process): Declare. * thread.c (any_live_thread_of_process): New. (switch_to_thread): Switch the program space as well. (restore_selected_frame): Don't warn if trying to restore frame level 0. * inferior.h: Include "progspace.h". (detach_fork): Declare. (struct inferior) <removable, aspace, pspace> <vfork_parent, vfork_child, pending_detach> <waiting_for_vfork_done>: New fields. <terminal_info>: Remove field. <data, num_data>: New fields. (register_inferior_data, register_inferior_data_with_cleanup) (clear_inferior_data, set_inferior_data, inferior_data): Declare. (exit_inferior, exit_inferior_silent, exit_inferior_num_silent) (inferior_appeared): Declare. (find_inferior_pid): Typo. (find_inferior_id, find_inferior_for_program_space): Declare. (set_current_inferior, save_current_inferior, prune_inferiors) (number_of_inferiors): Declare. (inferior_list): Declare. * inferior.c: Include "gdbcore.h" and "symfile.h". (inferior_list): Make public. (delete_inferior_1): Always delete thread silently. (find_inferior_id): Make public. (current_inferior_): New. (current_inferior): Use it. (set_current_inferior): New. (restore_inferior): New. (save_current_inferior): New. (free_inferior): Free the per-inferior data. (add_inferior_silent): Allocate per-inferior data. Call inferior_appeared. (delete_threads_of_inferior): New. (delete_inferior_1): Adjust interface to take an inferior pointer. (delete_inferior): Adjust. (delete_inferior_silent): Adjust. (exit_inferior_1): New. (exit_inferior): New. (exit_inferior_silent): New. (exit_inferior_num_silent): New. (detach_inferior): Adjust. (inferior_appeared): New. (discard_all_inferiors): Adjust. (find_inferior_id): Make public. Assert pid is not zero. (find_inferior_for_program_space): New. (have_inferiors): Check if we have any inferior with pid not zero. (have_live_inferiors): Go over all pushed targets looking for process_stratum. (prune_inferiors): New. (number_of_inferiors): New. (print_inferior): Add executable column. Print vfork parent/child relationships. (inferior_command): Adjust to cope with not running inferiors. (remove_inferior_command): New. (add_inferior_command): New. (clone_inferior_command): New. (struct inferior_data): New. (struct inferior_data_registration): New. (struct inferior_data_registry): New. (inferior_data_registry): New. (register_inferior_data_with_cleanup): New. (register_inferior_data): New. (inferior_alloc_data): New. (inferior_free_data): New. (clear_inferior_data): New. (set_inferior_data): New. (inferior_data): New. (initialize_inferiors): New. (_initialize_inferiors): Register "add-inferior", "remove-inferior" and "clone-inferior" commands. * objfiles.h: Include "progspace.h". (struct objfile) <pspace>: New field. (symfile_objfile, object_files): Don't declare. (ALL_PSPACE_OBJFILES): New. (ALL_PSPACE_OBJFILES_SAFE): New. (ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust. (ALL_PSPACE_SYMTABS): New. (ALL_PRIMARY_SYMTABS): Adjust. (ALL_PSPACE_PRIMARY_SYMTABS): New. (ALL_PSYMTABS): Adjust. (ALL_PSPACE_PSYMTABS): New. * objfiles.c (object_files, symfile_objfile): Delete. (struct objfile_sspace_info): New. (objfiles_pspace_data): New. (objfiles_pspace_data_cleanup): New. (get_objfile_pspace_data): New. (objfiles_changed_p): Delete. (allocate_objfile): Set the objfile's program space. Adjust to reference objfiles_changed_p in pspace data. (free_objfile): Adjust to reference objfiles_changed_p in pspace data. (objfile_relocate): Ditto. (update_section_map): Add pspace argument. Adjust to iterate over objfiles in the passed in pspace. (find_pc_section): Delete sections and num_sections statics. Adjust to refer to program space's objfiles_changed_p. Adjust to refer to sections and num_sections store in the objfile's pspace data. (objfiles_changed): Adjust to reference objfiles_changed_p in pspace data. (_initialize_objfiles): New. * linespec.c (decode_all_digits, decode_dollar): Set the sal's program space. * source.c (current_source_pspace): New. (get_current_source_symtab_and_line): Set the sal's program space. (set_current_source_symtab_and_line): Set current_source_pspace. (select_source_symtab): Ditto. Use ALL_OBJFILES. (forget_cached_source_info): Iterate over all program spaces. * symfile.c (clear_symtab_users): Adjust. * symmisc.c (print_symbol_bcache_statistics): Iterate over all program spaces. (print_objfile_statistics): Ditto. (maintenance_print_msymbols): Ditto. (maintenance_print_objfiles): Ditto. (maintenance_info_symtabs): Ditto. (maintenance_info_psymtabs): Ditto. * symtab.h (SYMTAB_PSPACE): New. (struct symtab_and_line) <pspace>: New field. * symtab.c (init_sal): Clear the sal's program space. (find_pc_sect_symtab): Set the sal's program space. Switch thread and space. (append_expanded_sal): Add program space argument. Iterate over all program spaces. (expand_line_sal): Iterate over all program spaces. Switch program space. * target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New. (struct target_ops) <to_thread_address_space>: New field. (target_thread_address_space): Define. * target.c (target_detach): Only remove breakpoints from the inferior we're detaching. (target_thread_address_space): New. * defs.h (initialize_progspace): Declare. * top.c (gdb_init): Call it. * solist.h (struct so_list) <sspace>: New field. * solib.h (struct program_space): Forward declare. (solib_name_from_address): Adjust prototype. * solib.c (so_list_head): Replace with a macro referencing the program space. (update_solib_list): Set the so's program space. (solib_name_from_address): Add a program space argument and adjust. * solib-svr4.c (struct svr4_info) <pid>: Delete field. <interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low> <interp_plt_sect_high>: New fields. (svr4_info_p, svr4_info): Delete. (solib_svr4_sspace_data): New. (get_svr4_info): Rewrite. (svr4_sspace_data_cleanup): New. (open_symbol_file_object): Adjust. (svr4_default_sos): Adjust. (svr4_fetch_objfile_link_map): Adjust. (interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low) (interp_plt_sect_high): Delete. (svr4_in_dynsym_resolve_code): Adjust. (enable_break): Adjust. (svr4_clear_solib): Revert bit that removed the svr4_info here, and reinstate clearing debug_base, debug_loader_offset_p, debug_loader_offset and debug_loader_name. (_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't install an inferior_exit observer anymore. * printcmd.c (struct display) <pspace>: New field. (display_command): Set the display's sspace. (do_one_display): Match the display's sspace. (display_uses_solib_p): Ditto. * linux-fork.c (detach_fork): Moved to infrun.c. (_initialize_linux_fork): Moved "detach-on-fork" command to infrun.c. * infrun.c (detach_fork): Moved from linux-fork.c. (proceed_after_vfork_done): New. (handle_vfork_child_exec_or_exit): New. (follow_exec_mode_replace, follow_exec_mode_keep) (follow_exec_mode_names, follow_exec_mode_string) (show_follow_exec_mode_string): New. (follow_exec): New. Reinstate the mark_breakpoints_out call. Remove shared libraries before attaching new executable. If user wants to keep the inferior, keep it. (displaced_step_fixup): Adjust to pass an address space to the breakpoints module. (resume): Ditto. (clear_proceed_status): In all-stop mode, always clear the proceed status of all threads. (prepare_to_proceed): Adjust to pass an address space to the breakpoints module. (proceed): Ditto. (adjust_pc_after_break): Ditto. (handle_inferior_event): When handling a process exit, switch the program space to the inferior's that had exited. Call handle_vfork_child_exec_or_exit. Adjust to pass an address space to the breakpoints module. In non-stop mode, when following a fork and detach-fork is off, also resume the other branch. Handle TARGET_WAITKIND_VFORK_DONE. Set the program space in sals. (normal_stop): Prune inferiors. (_initialize_infrun): Install the new "follow-exec-mode" command. "detach-on-fork" moved here. * regcache.h (get_regcache_aspace): Declare. * regcache.c (struct regcache) <aspace>: New field. (regcache_xmalloc): Clear the aspace. (get_regcache_aspace): New. (regcache_cpy): Copy the aspace field. (regcache_cpy_no_passthrough): Ditto. (get_thread_regcache): Fetch the thread's address space from the target, and store it in the regcache. * infcall.c (call_function_by_hand): Set the sal's pspace. * arch-utils.c (default_has_shared_address_space): New. * arch-utils.h (default_has_shared_address_space): Declare. * gdbarch.sh (has_shared_address_space): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.c: Include auxv.h, target.h, elf/common.h. (linux_has_shared_address_space): New. (_initialize_linux_tdep): Declare. * arm-tdep.c (arm_software_single_step): Pass the frame's address space to insert_single_step_breakpoint. * arm-linux-tdep.c (arm_linux_software_single_step): Pass the frame's pspace to breakpoint functions. * cris-tdep.c (crisv32_single_step_through_delay): Ditto. (cris_software_single_step): Ditto. * mips-tdep.c (deal_with_atomic_sequence): Add frame argument. Pass the frame's pspace to breakpoint functions. (mips_software_single_step): Adjust. (mips_single_step_through_delay): Adjust. * rs6000-aix-tdep.c (rs6000_software_single_step): Adjust. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust. * solib-irix.c (enable_break): Adjust to pass the current frame's address space to breakpoint functions. * sparc-tdep.c (sparc_software_single_step): Ditto. * spu-tdep.c (spu_software_single_step): Ditto. * alpha-tdep.c (alpha_software_single_step): Ditto. * record.c (record_wait): Adjust to pass an address space to the breakpoints module. * fork-child.c (fork_inferior): Set the new inferior's program and address spaces. * inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program and address spaces. (inf_ptrace_attach): Set the inferior's program and address spaces. * linux-nat.c: Include "solib.h". (linux_child_follow_fork): Manage parent and child's program and address spaces. Clone the parent's program space if necessary. Don't wait for the vfork to be done here. Refuse to resume if following the vfork parent while leaving the child stopped. (resume_callback): Don't resume a vfork parent. (linux_nat_resume): Also check for pending events in the lp->waitstatus field. (linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE events to the core. (stop_wait_callback): Don't wait for SIGSTOP on vfork parents. (cancel_breakpoint): Adjust. * linux-thread-db.c (thread_db_wait): Don't remove thread event breakpoints here. (thread_db_mourn_inferior): Don't mark breakpoints out here. Remove thread event breakpoints after mourning. * corelow.c: Include progspace.h. (core_open): Set the inferior's program and address spaces. * remote.c (remote_add_inferior): Set the new inferior's program and address spaces. (remote_start_remote): Update address spaces. (extended_remote_create_inferior_1): Don't init the thread list if we already debugging other inferiors. * darwin-nat.c (darwin_attach): Set the new inferior's program and address spaces. * gnu-nat.c (gnu_attach): Ditto. * go32-nat.c (go32_create_inferior): Ditto. * inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto. * monitor.c (monitor_open): Ditto. * nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto. * procfs.c (do_attach): Ditto. * windows-nat.c (do_initial_windows_stuff): Ditto. * inflow.c (inferior_process_group) (terminal_init_inferior_with_pgrp, terminal_inferior, (terminal_ours_1, inflow_inferior_exit, copy_terminal_info) (child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust to use per-inferior data instead of inferior->terminal_info. (inflow_inferior_data): New. (inflow_new_inferior): Delete. (inflow_inferior_data_cleanup): New. (get_inflow_inferior_data): New. * mi/mi-interp.c (mi_new_inferior): Rename to... (mi_inferior_appeared): ... this. (mi_interpreter_init): Adjust. * tui/tui-disasm.c: Include "progspace.h". (tui_set_disassem_content): Pass an address space to breakpoint_here_p. * NEWS: Mention multi-program debugging support. Mention new commands "add-inferior", "clone-inferior", "remove-inferior", "maint info program-spaces", and new option "set follow-exec-mode". 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * observer.texi (new_inferior): Rename to... (inferior_appeared): ... this. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/testsuite/ * gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork". * gdb.base/foll-exec.exp: Adjust to expect a process id before "Executing new program". * gdb.base/foll-fork.exp: Adjust to spell out "follow-fork". * gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being left listed after having been killed. * gdb.base/attach.exp: Adjust to spell out "symbol-file". * gdb.base/maint.exp: Adjust test. * Makefile.in (ALL_SUBDIRS): Add gdb.multi. * gdb.multi/Makefile.in: New. * gdb.multi/base.exp: New. * gdb.multi/goodbye.c: New. * gdb.multi/hangout.c: New. * gdb.multi/hello.c: New. * gdb.multi/bkpt-multi-exec.c: New. * gdb.multi/bkpt-multi-exec.exp: New. * gdb.multi/crashme.c: New. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * gdb.texinfo (Inferiors): Rename node to ... (Inferiors and Programs): ... this. Mention running multiple programs in the same debug session. <info inferiors>: Mention the new 'Executable' column if "info inferiors". Update examples. Document the "add-inferior", "clone-inferior", "remove-inferior" and "maint info program-spaces" commands. (Process): Rename node to... (Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
for (so = pspace->so_list; so; so = so->next)
if (solib_contains_address_p (so, address))
return (so->so_name);
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
return (0);
}
/* See solib.h. */
bool
solib_keep_data_in_core (CORE_ADDR vaddr, unsigned long size)
{
const struct target_so_ops *ops = solib_ops (target_gdbarch ());
if (ops->keep_data_in_core)
return ops->keep_data_in_core (vaddr, size) != 0;
else
return false;
}
/* Called by free_all_symtabs */
1999-07-07 22:19:36 +02:00
void
2000-07-30 03:48:28 +02:00
clear_solib (void)
{
const struct target_so_ops *ops = solib_ops (target_gdbarch ());
gdb: Remove support for obsolete OSABIs and a.out gdb/ChangeLog: 2016-12-09 Pedro Alves <palves@redhat.com> * Makefile.in (ALL_TARGET_OBS): Remove vax-obsd-tdep.o. * alpha-fbsd-tdep.c (_initialize_alphafbsd_tdep): Adjust. * alpha-nbsd-tdep.c: Move comment to _initialize_alphanbsd_tdep. (alphanbsd_core_osabi_sniffer): Delete. (_initialize_alphanbsd_tdep): No longer handle a.out. * alpha-obsd-tdep.c (_initialize_alphaobsd_tdep): Adjust. * amd64-fbsd-tdep.c (_initialize_amd64fbsd_tdep): Adjust. * amd64-nbsd-tdep.c (_initialize_amd64nbsd_tdep): Adjust. * amd64-obsd-tdep.c (amd64obsd_supply_regset) (amd64obsd_combined_regset) (amd64obsd_iterate_over_regset_sections, amd64obsd_core_init_abi): Delete. (_initialize_amd64obsd_tdep): Don't handle a.out. * arm-nbsd-nat.c (struct md_core, fetch_core_registers) (arm_netbsd_core_fns): Delete. (_initialize_arm_netbsd_nat): Don't register arm_netbsd_core_fns. * arm-nbsd-tdep.c (arm_netbsd_aout_init_abi) (arm_netbsd_aout_osabi_sniffer): Delete. (_initialize_arm_netbsd_tdep): Don't handle a.out. * arm-obsd-tdep.c (armobsd_core_osabi_sniffer): Delete. (_initialize_armobsd_tdep): Don't handle a.out. * arm-tdep.c (arm_gdbarch_init): Remove bfd_target_aout_flavour case. * breakpoint.c (disable_breakpoints_in_unloaded_shlib): Remove SunOS a.out handling. * configure.tgt (vax-*-netbsd* | vax-*-knetbsd*-gnu): Remove vax-obsd-tdep.o from gdb_target_objs. (vax-*-openbsd*): Likewise. (*-*-freebsd*): Adjust default gdb_osabi. (*-*-openbsd*): Likewise. * dbxread.c (block_address_function_relative): Delete. (dbx_symfile_read): Remove reference to block_address_function_relative. (dbx_symfile_read): Don't call read_dbx_dynamic_symtab. (read_dbx_dynamic_symtab): Delete. (process_one_symbol): Remove references to block_address_function_relative. * defs.h (GDB_OSABI_FREEBSD_AOUT, GDB_OSABI_NETBSD_AOUT): Remove. (GDB_OSABI_FREEBSD_ELF): Rename to ... (GDB_OSABI_FREEBSD): ... this. (GDB_OSABI_NETBSD_ELF): Rename to ... (GDB_OSABI_NETBSD): ... this. (GDB_OSABI_OPENBSD_ELF): Rename to ... (GDB_OSABI_OPENBSD): ... this. (GDB_OSABI_HPUX_ELF, GDB_OSABI_HPUX_SOM): Remove. * fbsd-tdep.c: Adjust comment. * hppa-nbsd-tdep.c (_initialize_hppanbsd_tdep): Adjust. * hppa-obsd-tdep.c (GDB_OSABI_NETBSD_CORE): Delete. (hppaobsd_core_osabi_sniffer): Delete. (_initialize_hppabsd_tdep): Don't handle a.out. * hppa-tdep.c (hppa_stub_frame_unwind_cache): Don't handle GDB_OSABI_HPUX_SOM. (hppa_gdbarch_init): Likewise. * i386-bsd-tdep.c (i386bsd_aout_osabi_sniffer) (i386bsd_core_osabi_sniffer, _initialize_i386bsd_tdep): Delete. * i386-fbsd-tdep.c (i386fbsdaout_init_abi): Delete. Merge bits with ... (i386fbsd_init_abi): ... this. (_initialize_i386fbsd_tdep): Don't handle a.out. * i386-nbsd-tdep.c (_initialize_i386nbsd_tdep): Adjust. * i386-obsd-tdep.c (i386obsd_aout_supply_regset) (i386obsd_aout_gregset) (i386obsd_aout_iterate_over_regset_sections): Delete. (i386obsd_init_abi): Merge with i386obsd_elf_init_abi. (i386obsd_aout_init_abi): Delete. (_initialize_i386obsd_tdep): Don't handle a.out. * m68k-bsd-tdep.c (m68kobsd_sigtramp_cache_init) (m68kobsd_sigtramp): Delete. (m68kbsd_init_abi): Merge with ... (m68kbsd_elf_init_abi): ... this, and delete it. (m68kbsd_aout_init_abi): Delete. (m68kbsd_aout_osabi_sniffer, m68kbsd_core_osabi_sniffer): Delete. (_initialize_m68kbsd_tdep): Don't handle a.out. * mips-nbsd-tdep.c (_initialize_mipsnbsd_tdep): Adjust. * mips64-obsd-tdep.c (_initialize_mips64obsd_tdep): Adjust. * osabi.c (gdb_osabi_names): Remove "a.out" entries. Drop "ELF" suffixes. Remove "HP-UX" entries. (generic_elf_osabi_sniff_abi_tag_sections): Adjust. (generic_elf_osabi_sniffer): No longer handle GDB_OSABI_HPUX_ELF. Adjust. (_initialize_ppcfbsd_tdep): Adjust. * ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Adjust. * ppc-obsd-tdep.c (GDB_OSABI_NETBSD_CORE) (ppcobsd_core_osabi_sniffer): Delete. (_initialize_ppcobsd_tdep): Don't handle a.out. * rs6000-tdep.c (rs6000_gdbarch_init): Adjust. * sh-nbsd-tdep.c (GDB_OSABI_NETBSD_CORE) (shnbsd_core_osabi_sniffer): Delete. (_initialize_shnbsd_tdep): Don't handle a.out. * solib.c (clear_solib): Don't handle SunOS/a.out. * sparc-nbsd-tdep.c (sparc32nbsd_init_abi): Make extern. (sparc32nbsd_aout_init_abi): Delete. (sparc32nbsd_elf_init_abi): Merged into sparc32nbsd_init_abi. (sparcnbsd_aout_osabi_sniffer): Delete. (GDB_OSABI_NETBSD_CORE, sparcnbsd_core_osabi_sniffer): Delete. (_initialize_sparcnbsd_tdep): No longer handle a.out. * sparc-obsd-tdep.c (sparc32obsd_init_abi) (_initialize_sparc32obsd_tdep): Adjust. * sparc-tdep.h (sparc32nbsd_elf_init_abi): Rename to ... (sparc32nbsd_init_abi): ... this. * sparc64-fbsd-tdep.c (_initialize_sparc64fbsd_tdep): Adjust. * sparc64-nbsd-tdep.c (_initialize_sparc64nbsd_tdep): Adjust. * sparc64-obsd-tdep.c (_initialize_sparc64obsd_tdep): Adjust. * stabsread.c: Update comment. * symmisc.c (print_objfile_statistics): Don't mention "a.out" in output. * vax-nbsd-tdep.c (_initialize_vaxnbsd_tdep): Adjust. * vax-obsd-tdep.c: Delete file.
2016-12-09 17:08:49 +01:00
disable_breakpoints_in_shlibs ();
1999-06-28 18:06:02 +02:00
while (current_program_space->so_list)
{
struct so_list *so = current_program_space->so_list;
current_program_space->so_list = so->next;
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::solib_unloaded.notify (so);
remove_target_sections (so);
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
free_so (so);
}
Deal with the inferior unloading shared objects. * solib.c (current_sos): New function, replacing find_solib. (find_solib): Deleted. (free_so): New function. (clear_solib): Call free_so, instead of writing it out. (solib_add): Rewritten: compare the inferior's current list of shared objects with GDB's list, and do the required loads and unloads. (info_sharedlibrary_command, solib_address): Don't use find_solib to walk the list of shared libraries: call solib_add, and then walk the list at so_list_head normally. * objfiles.c (free_objfile): Don't call CLEAR_SOLIB, and don't detach the core target. These tasks are taken care of elsewhere. * target.c (remove_target_sections): New function. * target.h (remove_target_sections): New declaration. * solib.c (symbol_add_stub): Check whether we've already created an objfile for this shared object first, before doing all that work to compute section addresses, etc. * objfiles.c (unlink_objfile): Report an internal error if objfile doesn't occur in the object_files list. * solib.c (special_symbol_handling): Delete argument; it's not used. * solib.c (SOLIB_EXTRACT_ADDRESS): New macro to extract addresses from solib structures. Use it throughout solib.c, get rid of all CORE_ADDR casts. (struct so_list): Change type of lmaddr to CORE_ADDR. (first_link_map_member): Change return value type to CORE_ADDR, update callers. (solib_add_common_symbols): Change parameter type to CORE_ADDR, update callers. (open_symbol_file_object, find_solib): Change type of lm variable to CORE_ADDR.
2000-03-15 17:55:07 +01:00
ops->clear_solib ();
}
/* Shared library startup support. When GDB starts up the inferior,
it nurses it along (through the shell) until it is ready to execute
its first instruction. At this point, this function gets
called. */
1999-07-07 22:19:36 +02:00
void
gdb/ Add from_tty to solib_create_inferior_hook. * infcmd.c (post_create_inferior): Move solib_add after solib_create_inferior_hook. Pass from_tty to solib_create_inferior_hook. Call solib_add and SOLIB_ADD with 0 from_tty and comment why. * infrun.c (follow_exec): Pass from_tty solib_create_inferior_hook as 0. * linux-nat.c (linux_child_follow_fork): Likewise. * nto-procfs.c (procfs_post_attach, procfs_create_inferior): Likewise. * solib-darwin.c (darwin_solib_create_inferior_hook): New parameter from_tty. * solib-frv.c (frv_solib_create_inferior_hook): Likewise. * solib-irix.c (irix_solib_create_inferior_hook): Likewise. * solib-null.c (null_solib_create_inferior_hook): Likewise. * solib-osf.c (osf_solib_create_inferior_hook): Likewise. * solib-pa64.c (pa64_solib_create_inferior_hook): Likewise. * solib-som.c (som_solib_create_inferior_hook): Likewise. * solib-spu.c (spu_solib_create_inferior_hook): New parameter from_tty. Pass it to svr4_so_ops.solib_create_inferior_hook. * solib-sunos.c (sunos_solib_create_inferior_hook): New parameter from_tty. * solib-svr4.c (enable_break): New parameter from_tty. Pass it to solib_add. (svr4_solib_create_inferior_hook): New parameter from_tty. Pass it to enable_break. * solib-target.c (solib_target_solib_create_inferior_hook): New parameter from_tty. * solib.c (solib_create_inferior_hook): New parameter from_tty. Pass it to ops->solib_create_inferior_hook. (reload_shared_libraries): Pass from_tty to solib_create_inferior_hook. Move solib_add after solib_create_inferior_hook, call it now with from_tty as 0. New comment there. * solib.h (solib_create_inferior_hook): New parameter from_tty. * solist.h (struct target_so_ops <solib_create_inferior_hook>): Likewise.
2010-01-08 23:52:04 +01:00
solib_create_inferior_hook (int from_tty)
{
const struct target_so_ops *ops = solib_ops (target_gdbarch ());
gdb/ Add from_tty to solib_create_inferior_hook. * infcmd.c (post_create_inferior): Move solib_add after solib_create_inferior_hook. Pass from_tty to solib_create_inferior_hook. Call solib_add and SOLIB_ADD with 0 from_tty and comment why. * infrun.c (follow_exec): Pass from_tty solib_create_inferior_hook as 0. * linux-nat.c (linux_child_follow_fork): Likewise. * nto-procfs.c (procfs_post_attach, procfs_create_inferior): Likewise. * solib-darwin.c (darwin_solib_create_inferior_hook): New parameter from_tty. * solib-frv.c (frv_solib_create_inferior_hook): Likewise. * solib-irix.c (irix_solib_create_inferior_hook): Likewise. * solib-null.c (null_solib_create_inferior_hook): Likewise. * solib-osf.c (osf_solib_create_inferior_hook): Likewise. * solib-pa64.c (pa64_solib_create_inferior_hook): Likewise. * solib-som.c (som_solib_create_inferior_hook): Likewise. * solib-spu.c (spu_solib_create_inferior_hook): New parameter from_tty. Pass it to svr4_so_ops.solib_create_inferior_hook. * solib-sunos.c (sunos_solib_create_inferior_hook): New parameter from_tty. * solib-svr4.c (enable_break): New parameter from_tty. Pass it to solib_add. (svr4_solib_create_inferior_hook): New parameter from_tty. Pass it to enable_break. * solib-target.c (solib_target_solib_create_inferior_hook): New parameter from_tty. * solib.c (solib_create_inferior_hook): New parameter from_tty. Pass it to ops->solib_create_inferior_hook. (reload_shared_libraries): Pass from_tty to solib_create_inferior_hook. Move solib_add after solib_create_inferior_hook, call it now with from_tty as 0. New comment there. * solib.h (solib_create_inferior_hook): New parameter from_tty. * solist.h (struct target_so_ops <solib_create_inferior_hook>): Likewise.
2010-01-08 23:52:04 +01:00
ops->solib_create_inferior_hook (from_tty);
}
/* See solib.h. */
bool
in_solib_dynsym_resolve_code (CORE_ADDR pc)
{
const struct target_so_ops *ops = solib_ops (target_gdbarch ());
return ops->in_dynsym_resolve_code (pc) != 0;
}
/* Implements the "sharedlibrary" command. */
static void
Constify add_com This changes add_com to take a cmd_const_cfunc_ftype, and then fixes up all the command implementations. In most cases this is trivial. In a couple of places I had to again introduce a temporary non-const overload. These overloads will be removed when add_info is constified. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * solib.h (no_shared_libraries): Constify. * frame.h (return_command): Constify. * cli/cli-cmds.h (quit_command): Constify. * top.h (quit_command, execute_command): Constify. * target.h (flash_erase_command): Constify. * inferior.h (set_inferior_args, attach_command): Constify. * tracepoint.h (start_tracing, stop_tracing): Constify. * breakpoint.h (break_command, tbreak_command) (hbreak_command_wrapper, thbreak_command_wrapper) (rbreak_command_wrapper, watch_command_wrapper) (awatch_command_wrapper, rwatch_command_wrapper) (get_tracepoint_by_number): Constify. * symtab.c (info_variables_command, rbreak_command) (symtab_symbol_info): Constify. (info_variables_command): Add non-const overload. * top.c (dont_repeat_command): Constify. * breakpoint.c (ignore_command, commands_command) (condition_command, tbreak_command, hbreak_command) (thbreak_command, clear_command, break_command) (info_breakpoints_command, watch_command, rwatch_command) (awatch_command, trace_command, ftrace_command, strace_command) (trace_pass_command, break_range_command, dprintf_command) (agent_printf_command, get_tracepoint_by_number) (watch_maybe_just_location, trace_pass_command): Constify. (info_breakpoints_command): Add non-const overload. * tracefile.c (tsave_command): Constify. * infcmd.c (attach_command, disconnect_command, signal_command) (queue_signal_command, stepi_command, nexti_command) (finish_command, next_command, step_command, until_command) (advance_command, jump_command, continue_command, run_command) (start_command, starti_command, interrupt_command) (run_command_1, set_inferior_args, step_1): Constify. * inferior.c (add_inferior_command, remove_inferior_command) (clone_inferior_command): Constify. * linux-fork.c (checkpoint_command, restart_command): Constify. * windows-nat.c (signal_event_command): Constify. * guile/guile.c (guile_repl_command, guile_command): Constify. * printcmd.c (x_command, display_command, printf_command) (output_command, set_command, call_command, print_command) (eval_command): Constify. (non_const_set_command): Remove. (_initialize_printcmd): Update. * source.c (forward_search_command, reverse_search_command): Constify. * jit.c (jit_reader_load_command, jit_reader_unload_command): Constify. * infrun.c (handle_command): Constify. * memattr.c (mem_command): Constify. * stack.c (return_command, up_command, up_silently_command) (down_command, down_silently_command, frame_command) (backtrace_command, func_command, backtrace_command_1): Constify. (backtrace_command): Add non-const overload. * remote-sim.c (simulator_command): Constify. * exec.c (set_section_command): Constify. * tracepoint.c (tdump_command, trace_variable_command) (tstatus_command, tstop_command, tstart_command) (end_actions_pseudocommand, while_stepping_pseudocommand) (collect_pseudocommand, teval_pseudocommand, actions_command) (start_tracing, stop_tracing): Constify. * value.c (init_if_undefined_command): Constify. * tui/tui-stack.c (tui_update_command): Constify. * tui/tui-win.c (tui_refresh_all_command) (tui_set_tab_width_command, tui_set_win_height_command) (tui_set_focus_command, tui_scroll_forward_command) (tui_scroll_backward_command, tui_scroll_left_command) (tui_scroll_right_command, parse_scrolling_args, tui_set_focus) (tui_set_win_height): Constify. * tui/tui-layout.c (tui_layout_command): Constify. * procfs.c (proc_trace_syscalls, proc_trace_sysentry_cmd) (proc_trace_sysexit_cmd, proc_untrace_sysentry_cmd) (proc_untrace_sysexit_cmd): Constify. * remote.c (threadlist_test_cmd, threadinfo_test_cmd) (threadset_test_cmd, threadlist_update_test_cmd) (threadalive_test): Constify. * objc-lang.c (print_object_command): Constify. * command.h (add_com): Constify. * cli/cli-dump.c (restore_command): Constify. * cli/cli-cmds.c (pwd_command, echo_command, quit_command) (help_command, complete_command, shell_command, edit_command) (list_command, disassemble_command, make_command) (apropos_command, alias_command): Constify. * cli/cli-script.c (document_command, define_command) (while_command, if_command, validate_comname): Constify. * cli/cli-decode.c (struct cmd_list_element): Change type of "fun". * target.c (do_monitor_command, flash_erase_command): Constify. * regcache.c (reg_flush_command): Constify. * reverse.c (reverse_step, reverse_next, reverse_stepi) (reverse_nexti, reverse_continue, reverse_finish) (save_bookmark_command, goto_bookmark_command) (exec_reverse_once): Constify. * python/python.c (python_interactive_command, python_command): Constify. * typeprint.c (ptype_command, whatis_command, whatis_exp): Constify. * solib.c (sharedlibrary_command, no_shared_libraries): Constify. * gcore.c (gcore_command): Constify.
2017-10-11 23:43:01 +02:00
sharedlibrary_command (const char *args, int from_tty)
{
dont_repeat ();
solib_add (args, from_tty, 1);
}
/* Implements the command "nosharedlibrary", which discards symbols
that have been auto-loaded from shared libraries. Symbols from
shared libraries that were added by explicit request of the user
are not discarded. Also called from remote.c. */
void
Constify add_com This changes add_com to take a cmd_const_cfunc_ftype, and then fixes up all the command implementations. In most cases this is trivial. In a couple of places I had to again introduce a temporary non-const overload. These overloads will be removed when add_info is constified. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * solib.h (no_shared_libraries): Constify. * frame.h (return_command): Constify. * cli/cli-cmds.h (quit_command): Constify. * top.h (quit_command, execute_command): Constify. * target.h (flash_erase_command): Constify. * inferior.h (set_inferior_args, attach_command): Constify. * tracepoint.h (start_tracing, stop_tracing): Constify. * breakpoint.h (break_command, tbreak_command) (hbreak_command_wrapper, thbreak_command_wrapper) (rbreak_command_wrapper, watch_command_wrapper) (awatch_command_wrapper, rwatch_command_wrapper) (get_tracepoint_by_number): Constify. * symtab.c (info_variables_command, rbreak_command) (symtab_symbol_info): Constify. (info_variables_command): Add non-const overload. * top.c (dont_repeat_command): Constify. * breakpoint.c (ignore_command, commands_command) (condition_command, tbreak_command, hbreak_command) (thbreak_command, clear_command, break_command) (info_breakpoints_command, watch_command, rwatch_command) (awatch_command, trace_command, ftrace_command, strace_command) (trace_pass_command, break_range_command, dprintf_command) (agent_printf_command, get_tracepoint_by_number) (watch_maybe_just_location, trace_pass_command): Constify. (info_breakpoints_command): Add non-const overload. * tracefile.c (tsave_command): Constify. * infcmd.c (attach_command, disconnect_command, signal_command) (queue_signal_command, stepi_command, nexti_command) (finish_command, next_command, step_command, until_command) (advance_command, jump_command, continue_command, run_command) (start_command, starti_command, interrupt_command) (run_command_1, set_inferior_args, step_1): Constify. * inferior.c (add_inferior_command, remove_inferior_command) (clone_inferior_command): Constify. * linux-fork.c (checkpoint_command, restart_command): Constify. * windows-nat.c (signal_event_command): Constify. * guile/guile.c (guile_repl_command, guile_command): Constify. * printcmd.c (x_command, display_command, printf_command) (output_command, set_command, call_command, print_command) (eval_command): Constify. (non_const_set_command): Remove. (_initialize_printcmd): Update. * source.c (forward_search_command, reverse_search_command): Constify. * jit.c (jit_reader_load_command, jit_reader_unload_command): Constify. * infrun.c (handle_command): Constify. * memattr.c (mem_command): Constify. * stack.c (return_command, up_command, up_silently_command) (down_command, down_silently_command, frame_command) (backtrace_command, func_command, backtrace_command_1): Constify. (backtrace_command): Add non-const overload. * remote-sim.c (simulator_command): Constify. * exec.c (set_section_command): Constify. * tracepoint.c (tdump_command, trace_variable_command) (tstatus_command, tstop_command, tstart_command) (end_actions_pseudocommand, while_stepping_pseudocommand) (collect_pseudocommand, teval_pseudocommand, actions_command) (start_tracing, stop_tracing): Constify. * value.c (init_if_undefined_command): Constify. * tui/tui-stack.c (tui_update_command): Constify. * tui/tui-win.c (tui_refresh_all_command) (tui_set_tab_width_command, tui_set_win_height_command) (tui_set_focus_command, tui_scroll_forward_command) (tui_scroll_backward_command, tui_scroll_left_command) (tui_scroll_right_command, parse_scrolling_args, tui_set_focus) (tui_set_win_height): Constify. * tui/tui-layout.c (tui_layout_command): Constify. * procfs.c (proc_trace_syscalls, proc_trace_sysentry_cmd) (proc_trace_sysexit_cmd, proc_untrace_sysentry_cmd) (proc_untrace_sysexit_cmd): Constify. * remote.c (threadlist_test_cmd, threadinfo_test_cmd) (threadset_test_cmd, threadlist_update_test_cmd) (threadalive_test): Constify. * objc-lang.c (print_object_command): Constify. * command.h (add_com): Constify. * cli/cli-dump.c (restore_command): Constify. * cli/cli-cmds.c (pwd_command, echo_command, quit_command) (help_command, complete_command, shell_command, edit_command) (list_command, disassemble_command, make_command) (apropos_command, alias_command): Constify. * cli/cli-script.c (document_command, define_command) (while_command, if_command, validate_comname): Constify. * cli/cli-decode.c (struct cmd_list_element): Change type of "fun". * target.c (do_monitor_command, flash_erase_command): Constify. * regcache.c (reg_flush_command): Constify. * reverse.c (reverse_step, reverse_next, reverse_stepi) (reverse_nexti, reverse_continue, reverse_finish) (save_bookmark_command, goto_bookmark_command) (exec_reverse_once): Constify. * python/python.c (python_interactive_command, python_command): Constify. * typeprint.c (ptype_command, whatis_command, whatis_exp): Constify. * solib.c (sharedlibrary_command, no_shared_libraries): Constify. * gcore.c (gcore_command): Constify.
2017-10-11 23:43:01 +02:00
no_shared_libraries (const char *ignored, int from_tty)
{
/* The order of the two routines below is important: clear_solib notifies
the solib_unloaded observers, and some of these observers might need
access to their associated objfiles. Therefore, we can not purge the
solibs' objfiles before clear_solib has been called. */
clear_solib ();
objfile_purge_solibs ();
}
2013-06-04 Gary Benson <gbenson@redhat.com> * breakpoint.h (handle_solib_event): Moved function declaration to solib.h. * breakpoint.c (handle_solib_event): Moved function to solib.c. (bpstat_stop_status): Pass new argument to handle_solib_event. * solib.h (update_solib_breakpoints): New function declaration. (handle_solib_event): Moved function declaration from breakpoint.h. * solib.c (update_solib_breakpoints): New function. (handle_solib_event): Moved function from breakpoint.c. Updated to call solib_ops->handle_event if not NULL. * solist.h (target_so_ops): New fields "update_breakpoints" and "handle_event". * infrun.c (set_stop_on_solib_events): New function. (_initialize_infrun): Use the above for "set stop-on-solib-events". (handle_inferior_event): Pass new argument to handle_solib_event. * solib-svr4.c (probe.h): New include. (svr4_free_library_list): New forward declaration. (probe_action): New enum. (probe_info): New struct. (probe_info): New static variable. (NUM_PROBES): New definition. (svr4_info): New fields "using_xfer", "probes_table" and "solib_list". (free_probes_table): New function. (free_solib_list): New function. (svr4_pspace_data_cleanup): Free probes table and solib list. (svr4_copy_library_list): New function. (svr4_current_sos_via_xfer_libraries): New parameter "annex". (svr4_read_so_list): New parameter "prev_lm". (svr4_current_sos_direct): Renamed from "svr4_current_sos". (svr4_current_sos): New function. (probe_and_action): New struct. (hash_probe_and_action): New function. (equal_probe_and_action): Likewise. (register_solib_event_probe): Likewise. (solib_event_probe_at): Likewise. (solib_event_probe_action): Likewise. (solist_update_full): Likewise. (solist_update_incremental): Likewise. (disable_probes_interface_cleanup): Likewise. (svr4_handle_solib_event): Likewise. (svr4_update_solib_event_breakpoint): Likewise. (svr4_update_solib_event_breakpoints): Likewise. (svr4_create_solib_event_breakpoints): Likewise. (enable_break): Free probes table before creating breakpoints. Use svr4_create_solib_event_breakpoints to create breakpoints. (svr4_solib_create_inferior_hook): Free the solib list. (_initialize_svr4_solib): Initialise svr4_so_ops.handle_solib_event and svr4_so_ops.update_breakpoints.
2013-06-04 15:17:06 +02:00
/* See solib.h. */
void
update_solib_breakpoints (void)
{
const struct target_so_ops *ops = solib_ops (target_gdbarch ());
if (ops->update_breakpoints != NULL)
ops->update_breakpoints ();
}
/* See solib.h. */
void
handle_solib_event (void)
{
const struct target_so_ops *ops = solib_ops (target_gdbarch ());
if (ops->handle_event != NULL)
ops->handle_event ();
clear_program_space_solib_cache (current_inferior ()->pspace);
/* Check for any newly added shared libraries if we're supposed to
be adding them automatically. Switch terminal for any messages
produced by breakpoint_re_set. */
Remove make_cleanup_restore_target_terminal This removes make_cleanup_restore_target_terminal and generally C++-ifies target terminal handling. It changes all target_terminal_* functions to be static members of a new target_terminal class and changes the cleanup to be a scoped_* class. make_cleanup_override_quit_handler is also removed in favor of simply using scoped_restore. Note that there are some files in this patch that I could not compile. Considering that some of the rewrites were automated, and that none of these files involed cleanups, I feel that this is relatively safe. Regression tested by the buildbot. gdb/ChangeLog 2017-09-20 Tom Tromey <tom@tromey.com> * windows-nat.c (get_windows_debug_event, windows_wait) (do_initial_windows_stuff, windows_attach): Update. * utils.c (vwarning, internal_vproblem): Update. (ui_unregister_input_event_handler_cleanup) (prepare_to_handle_input): Remove. (class scoped_input_handler): New. (defaulted_query, prompt_for_continue): Update. * tui/tui-hooks.c (tui_refresh_frame_and_register_information): Update. * top.c (undo_terminal_modifications_before_exit): Update. * target/target.h (target_terminal_init, target_terminal_inferior) (target_terminal_ours): Don't declare. (class target_terminal): New. * target.h (target_terminal_is_inferior, target_terminal_is_ours) (target_terminal_ours_for_output) (make_cleanup_restore_target_terminal): Don't declare. (target_terminal_info): Remove. * target.c (enum terminal_state, terminal_state): Remove. (target_terminal::terminal_state): Define. (target_terminal::init): Rename from target_terminal_init. (target_terminal::inferior): Rename from target_terminal_inferior. (target_terminal::ours): Rename from target_terminal_ours. (target_terminal::ours_for_output): Rename from target_terminal_ours_for_output. (target_terminal::info): New method. (cleanup_restore_target_terminal) (make_cleanup_restore_target_terminal): Remove. * solib.c (handle_solib_event): Update. * remote.c (remote_serial_quit_handler): Update. (remote_terminal_inferior, remote_wait_as): Update. * record-full.c (record_full_wait_1): Update. * nto-procfs.c (procfs_create_inferior): Update. * nat/fork-inferior.c (startup_inferior): Update. * mi/mi-interp.c (mi_new_thread, mi_thread_exit) (mi_record_changed, mi_inferior_added, mi_inferior_appeared) (mi_inferior_exit, mi_inferior_removed, mi_traceframe_changed) (mi_tsv_created, mi_tsv_deleted, mi_tsv_modified) (mi_breakpoint_created, mi_breakpoint_deleted) (mi_breakpoint_modified, mi_on_resume, mi_solib_loaded) (mi_solib_unloaded, mi_command_param_changed, mi_memory_changed) (mi_user_selected_context_changed, report_initial_inferior): Update. * linux-nat.c (linux_nat_attach, linux_nat_terminal_ours) (linux_nat_terminal_inferior): Update. * infrun.c (follow_fork_inferior) (handle_vfork_child_exec_or_exit, do_target_resume) (check_curr_ui_sync_execution_done, handle_inferior_event_1) (handle_signal_stop, maybe_remove_breakpoints, normal_stop): Update. * inflow.c (child_terminal_init, info_terminal_command): Update. * infcmd.c (post_create_inferior, continue_1, prepare_one_step) (attach_command): Update. * infcall.c (call_thread_fsm_should_stop): Update. * gnu-nat.c (gnu_attach): Update. * extension.c (struct active_ext_lang_state) (restore_active_ext_lang): Update. * exceptions.c (print_flush): Update. * event-top.c (async_enable_stdin, default_quit_handler): Update. (struct quit_handler_cleanup_data, restore_quit_handler) (restore_quit_handler_dtor, make_cleanup_override_quit_handler): Remove. * cp-support.c (gdb_demangle): Update. * breakpoint.c (update_inserted_breakpoint_locations) (insert_breakpoint_locations, handle_jit_event) (disable_breakpoints_in_unloaded_shlib): Update. * annotate.c (annotate_breakpoints_invalid) (annotate_frames_invalid): Update. gdb/gdbserver/ChangeLog 2017-09-20 Tom Tromey <tom@tromey.com> * target.c (target_terminal::terminal_state): Define. (target_terminal::init): Rename from target_terminal_init. (target_terminal::inferior): Rename from target_terminal_inferior. (target_terminal::ours): Rename from target_terminal_ours. (target_terminal::ours_for_output, target_terminal::info): New.
2017-09-20 05:56:36 +02:00
target_terminal::ours_for_output ();
solib_add (NULL, 0, auto_solib_add);
Remove make_cleanup_restore_target_terminal This removes make_cleanup_restore_target_terminal and generally C++-ifies target terminal handling. It changes all target_terminal_* functions to be static members of a new target_terminal class and changes the cleanup to be a scoped_* class. make_cleanup_override_quit_handler is also removed in favor of simply using scoped_restore. Note that there are some files in this patch that I could not compile. Considering that some of the rewrites were automated, and that none of these files involed cleanups, I feel that this is relatively safe. Regression tested by the buildbot. gdb/ChangeLog 2017-09-20 Tom Tromey <tom@tromey.com> * windows-nat.c (get_windows_debug_event, windows_wait) (do_initial_windows_stuff, windows_attach): Update. * utils.c (vwarning, internal_vproblem): Update. (ui_unregister_input_event_handler_cleanup) (prepare_to_handle_input): Remove. (class scoped_input_handler): New. (defaulted_query, prompt_for_continue): Update. * tui/tui-hooks.c (tui_refresh_frame_and_register_information): Update. * top.c (undo_terminal_modifications_before_exit): Update. * target/target.h (target_terminal_init, target_terminal_inferior) (target_terminal_ours): Don't declare. (class target_terminal): New. * target.h (target_terminal_is_inferior, target_terminal_is_ours) (target_terminal_ours_for_output) (make_cleanup_restore_target_terminal): Don't declare. (target_terminal_info): Remove. * target.c (enum terminal_state, terminal_state): Remove. (target_terminal::terminal_state): Define. (target_terminal::init): Rename from target_terminal_init. (target_terminal::inferior): Rename from target_terminal_inferior. (target_terminal::ours): Rename from target_terminal_ours. (target_terminal::ours_for_output): Rename from target_terminal_ours_for_output. (target_terminal::info): New method. (cleanup_restore_target_terminal) (make_cleanup_restore_target_terminal): Remove. * solib.c (handle_solib_event): Update. * remote.c (remote_serial_quit_handler): Update. (remote_terminal_inferior, remote_wait_as): Update. * record-full.c (record_full_wait_1): Update. * nto-procfs.c (procfs_create_inferior): Update. * nat/fork-inferior.c (startup_inferior): Update. * mi/mi-interp.c (mi_new_thread, mi_thread_exit) (mi_record_changed, mi_inferior_added, mi_inferior_appeared) (mi_inferior_exit, mi_inferior_removed, mi_traceframe_changed) (mi_tsv_created, mi_tsv_deleted, mi_tsv_modified) (mi_breakpoint_created, mi_breakpoint_deleted) (mi_breakpoint_modified, mi_on_resume, mi_solib_loaded) (mi_solib_unloaded, mi_command_param_changed, mi_memory_changed) (mi_user_selected_context_changed, report_initial_inferior): Update. * linux-nat.c (linux_nat_attach, linux_nat_terminal_ours) (linux_nat_terminal_inferior): Update. * infrun.c (follow_fork_inferior) (handle_vfork_child_exec_or_exit, do_target_resume) (check_curr_ui_sync_execution_done, handle_inferior_event_1) (handle_signal_stop, maybe_remove_breakpoints, normal_stop): Update. * inflow.c (child_terminal_init, info_terminal_command): Update. * infcmd.c (post_create_inferior, continue_1, prepare_one_step) (attach_command): Update. * infcall.c (call_thread_fsm_should_stop): Update. * gnu-nat.c (gnu_attach): Update. * extension.c (struct active_ext_lang_state) (restore_active_ext_lang): Update. * exceptions.c (print_flush): Update. * event-top.c (async_enable_stdin, default_quit_handler): Update. (struct quit_handler_cleanup_data, restore_quit_handler) (restore_quit_handler_dtor, make_cleanup_override_quit_handler): Remove. * cp-support.c (gdb_demangle): Update. * breakpoint.c (update_inserted_breakpoint_locations) (insert_breakpoint_locations, handle_jit_event) (disable_breakpoints_in_unloaded_shlib): Update. * annotate.c (annotate_breakpoints_invalid) (annotate_frames_invalid): Update. gdb/gdbserver/ChangeLog 2017-09-20 Tom Tromey <tom@tromey.com> * target.c (target_terminal::terminal_state): Define. (target_terminal::init): Rename from target_terminal_init. (target_terminal::inferior): Rename from target_terminal_inferior. (target_terminal::ours): Rename from target_terminal_ours. (target_terminal::ours_for_output, target_terminal::info): New.
2017-09-20 05:56:36 +02:00
target_terminal::inferior ();
2013-06-04 Gary Benson <gbenson@redhat.com> * breakpoint.h (handle_solib_event): Moved function declaration to solib.h. * breakpoint.c (handle_solib_event): Moved function to solib.c. (bpstat_stop_status): Pass new argument to handle_solib_event. * solib.h (update_solib_breakpoints): New function declaration. (handle_solib_event): Moved function declaration from breakpoint.h. * solib.c (update_solib_breakpoints): New function. (handle_solib_event): Moved function from breakpoint.c. Updated to call solib_ops->handle_event if not NULL. * solist.h (target_so_ops): New fields "update_breakpoints" and "handle_event". * infrun.c (set_stop_on_solib_events): New function. (_initialize_infrun): Use the above for "set stop-on-solib-events". (handle_inferior_event): Pass new argument to handle_solib_event. * solib-svr4.c (probe.h): New include. (svr4_free_library_list): New forward declaration. (probe_action): New enum. (probe_info): New struct. (probe_info): New static variable. (NUM_PROBES): New definition. (svr4_info): New fields "using_xfer", "probes_table" and "solib_list". (free_probes_table): New function. (free_solib_list): New function. (svr4_pspace_data_cleanup): Free probes table and solib list. (svr4_copy_library_list): New function. (svr4_current_sos_via_xfer_libraries): New parameter "annex". (svr4_read_so_list): New parameter "prev_lm". (svr4_current_sos_direct): Renamed from "svr4_current_sos". (svr4_current_sos): New function. (probe_and_action): New struct. (hash_probe_and_action): New function. (equal_probe_and_action): Likewise. (register_solib_event_probe): Likewise. (solib_event_probe_at): Likewise. (solib_event_probe_action): Likewise. (solist_update_full): Likewise. (solist_update_incremental): Likewise. (disable_probes_interface_cleanup): Likewise. (svr4_handle_solib_event): Likewise. (svr4_update_solib_event_breakpoint): Likewise. (svr4_update_solib_event_breakpoints): Likewise. (svr4_create_solib_event_breakpoints): Likewise. (enable_break): Free probes table before creating breakpoints. Use svr4_create_solib_event_breakpoints to create breakpoints. (svr4_solib_create_inferior_hook): Free the solib list. (_initialize_svr4_solib): Initialise svr4_so_ops.handle_solib_event and svr4_so_ops.update_breakpoints.
2013-06-04 15:17:06 +02:00
}
/* Reload shared libraries, but avoid reloading the same symbol file
we already have loaded. */
static void
reload_shared_libraries_1 (int from_tty)
{
if (print_symbol_loading_p (from_tty, 0, 0))
printf_unfiltered (_("Loading symbols for shared libraries.\n"));
for (struct so_list *so : current_program_space->solibs ())
{
bfd_get_filename This macro says: /* Cast from const char * to char * so that caller can assign to a char * without a warning. */ I reckon that isn't such a good idea since it can result in char* variables where const char* is appropriate. Not very many places need the char* cast. bfd/ * aout-target.h (object_p): Formatting. * bfd-in.h (bfd_get_filename): Don't cast to char*. * corefile.c (generic_core_file_matches_executable_p): Constify variables and remove cast. * bfd-in2.h: Regenerate. binutils/ * nm.c (print_object_filename_bsd, print_object_filename_sysv), (print_object_filename_posix, print_archive_filename_bsd), (print_archive_filename_sysv, print_archive_filename_posix), (print_archive_member_bsd, print_archive_member_sysv), (print_archive_member_posix): Constify parameter. (struct output_fns <print_object_filename, print_archive_filename>), (<print_archive_member>): Likewise. * objcopy.c (copy_archive): Add cast for make_tempdir. ld/ * emultempl/elf32.em (gld${EMULATION_NAME}_search_needed): Constify variable. * emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Likewise. * emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise. gdb/ * coffread.c (coff_symfile_read): Constify filename variable. * dbxread.c (dbx_symfile_init, coffstab_build_psymtabs), (elfstab_build_psymtabs, stabsect_build_psymtabs): Likewise. * gdb_bfd.c (gdb_bfd_close_or_warn): Likewise. * solib.c (reload_shared_libraries_1): Likewise. * symfile.c (reread_symbols): Likewise. * solib-aix.c (solib_aix_bfd_open): Add cast for xfree of filename. * solib-darwin.c (darwin_bfd_open): Likewise. * symfile-mem.c (symbol_file_add_from_memory): Likewise. sim/cris/ * sim-if.c (sim_open): Constify filename variable.
2019-09-06 04:37:05 +02:00
const char *found_pathname = NULL;
bool was_loaded = so->symbols_loaded != 0;
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 = SYMFILE_DEFER_BP_RESET;
if (from_tty)
add_flags |= SYMFILE_VERBOSE;
gdb::unique_xmalloc_ptr<char> filename
(tilde_expand (so->so_original_name));
gdb_bfd_ref_ptr abfd (solib_bfd_open (filename.get ()));
if (abfd != NULL)
found_pathname = bfd_get_filename (abfd.get ());
/* If this shared library is no longer associated with its previous
symbol file, close that. */
if ((found_pathname == NULL && was_loaded)
|| (found_pathname != NULL
2011-03-23 Kai Tietz <ktietz@redhat.com> * breakpoint.c (clear_command): Use filename_cmp instead of strcmp for comparison. * buildsym.c (watch_main_source_file_lossage): Likewise. (patch_subfile_names): Use IS_DIR_SEPARATOR instead of checking just for slash. * dbxread.c (read_dbx_symtab): Use lbasename instead of strrchr and filename_cmp instead of strcmp for filenames. (add_old_header_file): Use filename_cmp instead of strcmp for comparison. * exec.c (exec_set_section_address): Likewise. * macrotab.c (macro_lookup_inclusion): Likewise. (macro_lookup_inclusion): Likewise. * elfread.c (_initialize_elfread): Likewise. (elfstab_offset_sections): Likewise. (elfstab_offset_sections): Use lbasename instead of strrchr. * mdebugread.c (parse_partial_symbols): Likewise. (arse_partial_symbols): Use filename_(n)cmp instead of str(n)cmp for comparison. * minsyms.c (lookup_minimal_symbol): Likewise. * psymtab.c (read_psymtabs_with_filename): Likewise. * solib.c (solib_read_symbols): Likewise. (reload_shared_libraries_1): Likewise. * symmisc.c (maintenance_print_symbols): Likewise. * symfile.c (separate_debug_file_exists): Likewise. (reread_symbols): Likewise. (find_separate_debug_file_by_debuglink): Likewise. * remote-fileio.c (remote_fileio_func_rename): Likewise. * source.c (add_path): Likewise. * symtab.c (filename_seen): Likewise. (file_matches): Likewise. (print_symbol_info): Likewise. (maybe_add_partial_symtab_filename): Likewise. (make_source_files_completion_list): Likewise. * xml-syscall.c (init_sysinfo): Likewise. * windows-nat.c (_initialize_check_for_gdb_ini): Use IS_DIR_SEPARATOR for checking for trailing path separator.
2011-03-23 19:23:56 +01:00
&& filename_cmp (found_pathname, so->so_name) != 0))
{
if (so->objfile && ! (so->objfile->flags & OBJF_USERLOADED)
&& !solib_used (so))
so->objfile->unlink ();
remove_target_sections (so);
clear_so (so);
}
/* If this shared library is now associated with a new symbol
file, open it. */
if (found_pathname != NULL
&& (!was_loaded
2011-03-23 Kai Tietz <ktietz@redhat.com> * breakpoint.c (clear_command): Use filename_cmp instead of strcmp for comparison. * buildsym.c (watch_main_source_file_lossage): Likewise. (patch_subfile_names): Use IS_DIR_SEPARATOR instead of checking just for slash. * dbxread.c (read_dbx_symtab): Use lbasename instead of strrchr and filename_cmp instead of strcmp for filenames. (add_old_header_file): Use filename_cmp instead of strcmp for comparison. * exec.c (exec_set_section_address): Likewise. * macrotab.c (macro_lookup_inclusion): Likewise. (macro_lookup_inclusion): Likewise. * elfread.c (_initialize_elfread): Likewise. (elfstab_offset_sections): Likewise. (elfstab_offset_sections): Use lbasename instead of strrchr. * mdebugread.c (parse_partial_symbols): Likewise. (arse_partial_symbols): Use filename_(n)cmp instead of str(n)cmp for comparison. * minsyms.c (lookup_minimal_symbol): Likewise. * psymtab.c (read_psymtabs_with_filename): Likewise. * solib.c (solib_read_symbols): Likewise. (reload_shared_libraries_1): Likewise. * symmisc.c (maintenance_print_symbols): Likewise. * symfile.c (separate_debug_file_exists): Likewise. (reread_symbols): Likewise. (find_separate_debug_file_by_debuglink): Likewise. * remote-fileio.c (remote_fileio_func_rename): Likewise. * source.c (add_path): Likewise. * symtab.c (filename_seen): Likewise. (file_matches): Likewise. (print_symbol_info): Likewise. (maybe_add_partial_symtab_filename): Likewise. (make_source_files_completion_list): Likewise. * xml-syscall.c (init_sysinfo): Likewise. * windows-nat.c (_initialize_check_for_gdb_ini): Use IS_DIR_SEPARATOR for checking for trailing path separator.
2011-03-23 19:23:56 +01:00
|| filename_cmp (found_pathname, so->so_name) != 0))
{
bool got_error = false;
Rewrite TRY/CATCH This rewrites gdb's TRY/CATCH to plain C++ try/catch. The patch was largely written by script, though one change (to a comment in common-exceptions.h) was reverted by hand. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * xml-support.c: Use C++ exception handling. * x86-linux-nat.c: Use C++ exception handling. * windows-nat.c: Use C++ exception handling. * varobj.c: Use C++ exception handling. * value.c: Use C++ exception handling. * valprint.c: Use C++ exception handling. * valops.c: Use C++ exception handling. * unittests/parse-connection-spec-selftests.c: Use C++ exception handling. * unittests/cli-utils-selftests.c: Use C++ exception handling. * typeprint.c: Use C++ exception handling. * tui/tui.c: Use C++ exception handling. * tracefile-tfile.c: Use C++ exception handling. * top.c: Use C++ exception handling. * thread.c: Use C++ exception handling. * target.c: Use C++ exception handling. * symmisc.c: Use C++ exception handling. * symfile-mem.c: Use C++ exception handling. * stack.c: Use C++ exception handling. * sparc64-linux-tdep.c: Use C++ exception handling. * solib.c: Use C++ exception handling. * solib-svr4.c: Use C++ exception handling. * solib-spu.c: Use C++ exception handling. * solib-frv.c: Use C++ exception handling. * solib-dsbt.c: Use C++ exception handling. * selftest-arch.c: Use C++ exception handling. * s390-tdep.c: Use C++ exception handling. * rust-lang.c: Use C++ exception handling. * rust-exp.y: Use C++ exception handling. * rs6000-tdep.c: Use C++ exception handling. * rs6000-aix-tdep.c: Use C++ exception handling. * riscv-tdep.c: Use C++ exception handling. * remote.c: Use C++ exception handling. * remote-fileio.c: Use C++ exception handling. * record-full.c: Use C++ exception handling. * record-btrace.c: Use C++ exception handling. * python/python.c: Use C++ exception handling. * python/py-value.c: Use C++ exception handling. * python/py-utils.c: Use C++ exception handling. * python/py-unwind.c: Use C++ exception handling. * python/py-type.c: Use C++ exception handling. * python/py-symbol.c: Use C++ exception handling. * python/py-record.c: Use C++ exception handling. * python/py-record-btrace.c: Use C++ exception handling. * python/py-progspace.c: Use C++ exception handling. * python/py-prettyprint.c: Use C++ exception handling. * python/py-param.c: Use C++ exception handling. * python/py-objfile.c: Use C++ exception handling. * python/py-linetable.c: Use C++ exception handling. * python/py-lazy-string.c: Use C++ exception handling. * python/py-infthread.c: Use C++ exception handling. * python/py-inferior.c: Use C++ exception handling. * python/py-gdb-readline.c: Use C++ exception handling. * python/py-framefilter.c: Use C++ exception handling. * python/py-frame.c: Use C++ exception handling. * python/py-finishbreakpoint.c: Use C++ exception handling. * python/py-cmd.c: Use C++ exception handling. * python/py-breakpoint.c: Use C++ exception handling. * python/py-arch.c: Use C++ exception handling. * printcmd.c: Use C++ exception handling. * ppc-linux-tdep.c: Use C++ exception handling. * parse.c: Use C++ exception handling. * p-valprint.c: Use C++ exception handling. * objc-lang.c: Use C++ exception handling. * mi/mi-main.c: Use C++ exception handling. * mi/mi-interp.c: Use C++ exception handling. * mi/mi-cmd-stack.c: Use C++ exception handling. * mi/mi-cmd-break.c: Use C++ exception handling. * main.c: Use C++ exception handling. * linux-thread-db.c: Use C++ exception handling. * linux-tdep.c: Use C++ exception handling. * linux-nat.c: Use C++ exception handling. * linux-fork.c: Use C++ exception handling. * linespec.c: Use C++ exception handling. * language.c: Use C++ exception handling. * jit.c: Use C++ exception handling. * infrun.c: Use C++ exception handling. * infcmd.c: Use C++ exception handling. * infcall.c: Use C++ exception handling. * inf-loop.c: Use C++ exception handling. * i386-tdep.c: Use C++ exception handling. * i386-linux-tdep.c: Use C++ exception handling. * guile/scm-value.c: Use C++ exception handling. * guile/scm-type.c: Use C++ exception handling. * guile/scm-symtab.c: Use C++ exception handling. * guile/scm-symbol.c: Use C++ exception handling. * guile/scm-pretty-print.c: Use C++ exception handling. * guile/scm-ports.c: Use C++ exception handling. * guile/scm-param.c: Use C++ exception handling. * guile/scm-math.c: Use C++ exception handling. * guile/scm-lazy-string.c: Use C++ exception handling. * guile/scm-frame.c: Use C++ exception handling. * guile/scm-disasm.c: Use C++ exception handling. * guile/scm-cmd.c: Use C++ exception handling. * guile/scm-breakpoint.c: Use C++ exception handling. * guile/scm-block.c: Use C++ exception handling. * guile/guile-internal.h: Use C++ exception handling. * gnu-v3-abi.c: Use C++ exception handling. * gdbtypes.c: Use C++ exception handling. * frame.c: Use C++ exception handling. * frame-unwind.c: Use C++ exception handling. * fbsd-tdep.c: Use C++ exception handling. * f-valprint.c: Use C++ exception handling. * exec.c: Use C++ exception handling. * event-top.c: Use C++ exception handling. * event-loop.c: Use C++ exception handling. * eval.c: Use C++ exception handling. * dwarf2read.c: Use C++ exception handling. * dwarf2loc.c: Use C++ exception handling. * dwarf2-frame.c: Use C++ exception handling. * dwarf2-frame-tailcall.c: Use C++ exception handling. * dwarf-index-write.c: Use C++ exception handling. * dwarf-index-cache.c: Use C++ exception handling. * dtrace-probe.c: Use C++ exception handling. * disasm-selftests.c: Use C++ exception handling. * darwin-nat.c: Use C++ exception handling. * cp-valprint.c: Use C++ exception handling. * cp-support.c: Use C++ exception handling. * cp-abi.c: Use C++ exception handling. * corelow.c: Use C++ exception handling. * completer.c: Use C++ exception handling. * compile/compile-object-run.c: Use C++ exception handling. * compile/compile-object-load.c: Use C++ exception handling. * compile/compile-cplus-symbols.c: Use C++ exception handling. * compile/compile-c-symbols.c: Use C++ exception handling. * common/selftest.c: Use C++ exception handling. * common/new-op.c: Use C++ exception handling. * cli/cli-script.c: Use C++ exception handling. * cli/cli-interp.c: Use C++ exception handling. * cli/cli-cmds.c: Use C++ exception handling. * c-varobj.c: Use C++ exception handling. * btrace.c: Use C++ exception handling. * breakpoint.c: Use C++ exception handling. * break-catch-throw.c: Use C++ exception handling. * arch-utils.c: Use C++ exception handling. * amd64-tdep.c: Use C++ exception handling. * ada-valprint.c: Use C++ exception handling. * ada-typeprint.c: Use C++ exception handling. * ada-lang.c: Use C++ exception handling. * aarch64-tdep.c: Use C++ exception handling. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * server.c: Use C++ exception handling. * linux-low.c: Use C++ exception handling. * gdbreplay.c: Use C++ exception handling.
2019-04-04 00:02:42 +02:00
try
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
{
solib_map_sections (so);
}
Rename gdb exception types This renames the gdb exception types. The old types were only needed due to the macros in common-exception.h that are now gone. The intermediate layer of gdb_exception_RETURN_MASK_ALL did not seem needed, so this patch removes it entirely. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * common/common-exceptions.h (gdb_exception_RETURN_MASK_ALL): Remove. (gdb_exception_error): Rename from gdb_exception_RETURN_MASK_ERROR. (gdb_exception_quit): Rename from gdb_exception_RETURN_MASK_QUIT. (gdb_quit_bad_alloc): Update. * aarch64-tdep.c: Update. * ada-lang.c: Update. * ada-typeprint.c: Update. * ada-valprint.c: Update. * amd64-tdep.c: Update. * arch-utils.c: Update. * break-catch-throw.c: Update. * breakpoint.c: Update. * btrace.c: Update. * c-varobj.c: Update. * cli/cli-cmds.c: Update. * cli/cli-interp.c: Update. * cli/cli-script.c: Update. * common/common-exceptions.c: Update. * common/new-op.c: Update. * common/selftest.c: Update. * compile/compile-c-symbols.c: Update. * compile/compile-cplus-symbols.c: Update. * compile/compile-object-load.c: Update. * compile/compile-object-run.c: Update. * completer.c: Update. * corelow.c: Update. * cp-abi.c: Update. * cp-support.c: Update. * cp-valprint.c: Update. * darwin-nat.c: Update. * disasm-selftests.c: Update. * dtrace-probe.c: Update. * dwarf-index-cache.c: Update. * dwarf-index-write.c: Update. * dwarf2-frame-tailcall.c: Update. * dwarf2-frame.c: Update. * dwarf2loc.c: Update. * dwarf2read.c: Update. * eval.c: Update. * event-loop.c: Update. * event-top.c: Update. * exec.c: Update. * f-valprint.c: Update. * fbsd-tdep.c: Update. * frame-unwind.c: Update. * frame.c: Update. * gdbtypes.c: Update. * gnu-v3-abi.c: Update. * guile/guile-internal.h: Update. * guile/scm-block.c: Update. * guile/scm-breakpoint.c: Update. * guile/scm-cmd.c: Update. * guile/scm-disasm.c: Update. * guile/scm-frame.c: Update. * guile/scm-lazy-string.c: Update. * guile/scm-math.c: Update. * guile/scm-param.c: Update. * guile/scm-ports.c: Update. * guile/scm-pretty-print.c: Update. * guile/scm-symbol.c: Update. * guile/scm-symtab.c: Update. * guile/scm-type.c: Update. * guile/scm-value.c: Update. * i386-linux-tdep.c: Update. * i386-tdep.c: Update. * inf-loop.c: Update. * infcall.c: Update. * infcmd.c: Update. * infrun.c: Update. * jit.c: Update. * language.c: Update. * linespec.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * main.c: Update. * mi/mi-cmd-break.c: Update. * mi/mi-cmd-stack.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * objc-lang.c: Update. * p-valprint.c: Update. * parse.c: Update. * ppc-linux-tdep.c: Update. * printcmd.c: Update. * python/py-arch.c: Update. * python/py-breakpoint.c: Update. * python/py-cmd.c: Update. * python/py-finishbreakpoint.c: Update. * python/py-frame.c: Update. * python/py-framefilter.c: Update. * python/py-gdb-readline.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * python/py-lazy-string.c: Update. * python/py-linetable.c: Update. * python/py-objfile.c: Update. * python/py-param.c: Update. * python/py-prettyprint.c: Update. * python/py-progspace.c: Update. * python/py-record-btrace.c: Update. * python/py-record.c: Update. * python/py-symbol.c: Update. * python/py-type.c: Update. * python/py-unwind.c: Update. * python/py-utils.c: Update. * python/py-value.c: Update. * python/python.c: Update. * record-btrace.c: Update. * record-full.c: Update. * remote-fileio.c: Update. * remote.c: Update. * riscv-tdep.c: Update. * rs6000-aix-tdep.c: Update. * rs6000-tdep.c: Update. * rust-exp.y: Update. * rust-lang.c: Update. * s390-tdep.c: Update. * selftest-arch.c: Update. * solib-dsbt.c: Update. * solib-frv.c: Update. * solib-spu.c: Update. * solib-svr4.c: Update. * solib.c: Update. * sparc64-linux-tdep.c: Update. * stack.c: Update. * symfile-mem.c: Update. * symmisc.c: Update. * target.c: Update. * thread.c: Update. * top.c: Update. * tracefile-tfile.c: Update. * tui/tui.c: Update. * typeprint.c: Update. * unittests/cli-utils-selftests.c: Update. * unittests/parse-connection-spec-selftests.c: Update. * valops.c: Update. * valprint.c: Update. * value.c: Update. * varobj.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * xml-support.c: Update. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * gdbreplay.c: Update. * linux-low.c: Update. * server.c: Update.
2019-04-03 23:59:07 +02:00
catch (const gdb_exception_error &e)
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
{
exception_fprintf (gdb_stderr, e,
_("Error while mapping "
"shared library sections:\n"));
got_error = true;
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
}
Split TRY_CATCH into TRY + CATCH This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-03-07 16:14:14 +01:00
if (!got_error
&& (auto_solib_add || was_loaded || libpthread_solib_p (so)))
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
solib_read_symbols (so, add_flags);
}
}
}
static void
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
reload_shared_libraries (const char *ignored, int from_tty,
struct cmd_list_element *e)
{
const struct target_so_ops *ops;
reload_shared_libraries_1 (from_tty);
ops = solib_ops (target_gdbarch ());
/* Creating inferior hooks here has two purposes. First, if we reload
shared libraries then the address of solib breakpoint we've computed
previously might be no longer valid. For example, if we forgot to set
solib-absolute-prefix and are setting it right now, then the previous
breakpoint address is plain wrong. Second, installing solib hooks
also implicitly figures were ld.so is and loads symbols for it.
Absent this call, if we've just connected to a target and set
solib-absolute-prefix or solib-search-path, we'll lose all information
about ld.so. */
if (target_has_execution)
{
/* Reset or free private data structures not associated with
so_list entries. */
ops->clear_solib ();
/* Remove any previous solib event breakpoint. This is usually
done in common code, at breakpoint_init_inferior time, but
we're not really starting up the inferior here. */
remove_solib_event_breakpoints ();
gdb/ Add from_tty to solib_create_inferior_hook. * infcmd.c (post_create_inferior): Move solib_add after solib_create_inferior_hook. Pass from_tty to solib_create_inferior_hook. Call solib_add and SOLIB_ADD with 0 from_tty and comment why. * infrun.c (follow_exec): Pass from_tty solib_create_inferior_hook as 0. * linux-nat.c (linux_child_follow_fork): Likewise. * nto-procfs.c (procfs_post_attach, procfs_create_inferior): Likewise. * solib-darwin.c (darwin_solib_create_inferior_hook): New parameter from_tty. * solib-frv.c (frv_solib_create_inferior_hook): Likewise. * solib-irix.c (irix_solib_create_inferior_hook): Likewise. * solib-null.c (null_solib_create_inferior_hook): Likewise. * solib-osf.c (osf_solib_create_inferior_hook): Likewise. * solib-pa64.c (pa64_solib_create_inferior_hook): Likewise. * solib-som.c (som_solib_create_inferior_hook): Likewise. * solib-spu.c (spu_solib_create_inferior_hook): New parameter from_tty. Pass it to svr4_so_ops.solib_create_inferior_hook. * solib-sunos.c (sunos_solib_create_inferior_hook): New parameter from_tty. * solib-svr4.c (enable_break): New parameter from_tty. Pass it to solib_add. (svr4_solib_create_inferior_hook): New parameter from_tty. Pass it to enable_break. * solib-target.c (solib_target_solib_create_inferior_hook): New parameter from_tty. * solib.c (solib_create_inferior_hook): New parameter from_tty. Pass it to ops->solib_create_inferior_hook. (reload_shared_libraries): Pass from_tty to solib_create_inferior_hook. Move solib_add after solib_create_inferior_hook, call it now with from_tty as 0. New comment there. * solib.h (solib_create_inferior_hook): New parameter from_tty. * solist.h (struct target_so_ops <solib_create_inferior_hook>): Likewise.
2010-01-08 23:52:04 +01:00
solib_create_inferior_hook (from_tty);
}
gdb/ Add from_tty to solib_create_inferior_hook. * infcmd.c (post_create_inferior): Move solib_add after solib_create_inferior_hook. Pass from_tty to solib_create_inferior_hook. Call solib_add and SOLIB_ADD with 0 from_tty and comment why. * infrun.c (follow_exec): Pass from_tty solib_create_inferior_hook as 0. * linux-nat.c (linux_child_follow_fork): Likewise. * nto-procfs.c (procfs_post_attach, procfs_create_inferior): Likewise. * solib-darwin.c (darwin_solib_create_inferior_hook): New parameter from_tty. * solib-frv.c (frv_solib_create_inferior_hook): Likewise. * solib-irix.c (irix_solib_create_inferior_hook): Likewise. * solib-null.c (null_solib_create_inferior_hook): Likewise. * solib-osf.c (osf_solib_create_inferior_hook): Likewise. * solib-pa64.c (pa64_solib_create_inferior_hook): Likewise. * solib-som.c (som_solib_create_inferior_hook): Likewise. * solib-spu.c (spu_solib_create_inferior_hook): New parameter from_tty. Pass it to svr4_so_ops.solib_create_inferior_hook. * solib-sunos.c (sunos_solib_create_inferior_hook): New parameter from_tty. * solib-svr4.c (enable_break): New parameter from_tty. Pass it to solib_add. (svr4_solib_create_inferior_hook): New parameter from_tty. Pass it to enable_break. * solib-target.c (solib_target_solib_create_inferior_hook): New parameter from_tty. * solib.c (solib_create_inferior_hook): New parameter from_tty. Pass it to ops->solib_create_inferior_hook. (reload_shared_libraries): Pass from_tty to solib_create_inferior_hook. Move solib_add after solib_create_inferior_hook, call it now with from_tty as 0. New comment there. * solib.h (solib_create_inferior_hook): New parameter from_tty. * solist.h (struct target_so_ops <solib_create_inferior_hook>): Likewise.
2010-01-08 23:52:04 +01:00
/* Sometimes the platform-specific hook loads initial shared
libraries, and sometimes it doesn't. If it doesn't FROM_TTY will be
incorrectly 0 but such solib targets should be fixed anyway. If we
made all the inferior hook methods consistent, this call could be
removed. Call it only after the solib target has been initialized by
solib_create_inferior_hook. */
solib_add (NULL, 0, auto_solib_add);
gdb/ Add from_tty to solib_create_inferior_hook. * infcmd.c (post_create_inferior): Move solib_add after solib_create_inferior_hook. Pass from_tty to solib_create_inferior_hook. Call solib_add and SOLIB_ADD with 0 from_tty and comment why. * infrun.c (follow_exec): Pass from_tty solib_create_inferior_hook as 0. * linux-nat.c (linux_child_follow_fork): Likewise. * nto-procfs.c (procfs_post_attach, procfs_create_inferior): Likewise. * solib-darwin.c (darwin_solib_create_inferior_hook): New parameter from_tty. * solib-frv.c (frv_solib_create_inferior_hook): Likewise. * solib-irix.c (irix_solib_create_inferior_hook): Likewise. * solib-null.c (null_solib_create_inferior_hook): Likewise. * solib-osf.c (osf_solib_create_inferior_hook): Likewise. * solib-pa64.c (pa64_solib_create_inferior_hook): Likewise. * solib-som.c (som_solib_create_inferior_hook): Likewise. * solib-spu.c (spu_solib_create_inferior_hook): New parameter from_tty. Pass it to svr4_so_ops.solib_create_inferior_hook. * solib-sunos.c (sunos_solib_create_inferior_hook): New parameter from_tty. * solib-svr4.c (enable_break): New parameter from_tty. Pass it to solib_add. (svr4_solib_create_inferior_hook): New parameter from_tty. Pass it to enable_break. * solib-target.c (solib_target_solib_create_inferior_hook): New parameter from_tty. * solib.c (solib_create_inferior_hook): New parameter from_tty. Pass it to ops->solib_create_inferior_hook. (reload_shared_libraries): Pass from_tty to solib_create_inferior_hook. Move solib_add after solib_create_inferior_hook, call it now with from_tty as 0. New comment there. * solib.h (solib_create_inferior_hook): New parameter from_tty. * solist.h (struct target_so_ops <solib_create_inferior_hook>): Likewise.
2010-01-08 23:52:04 +01:00
breakpoint_re_set ();
/* We may have loaded or unloaded debug info for some (or all)
shared libraries. However, frames may still reference them. For
example, a frame's unwinder might still point at DWARF FDE
structures that are now freed. Also, getting new symbols may
change our opinion about what is frameless. */
reinit_frame_cache ();
}
Convert "remote:" sysroots to "target:" and remove "remote:" The functionality of "target:" sysroots is a superset of the functionality of "remote:" sysroots. This commit causes the "set sysroot" command to rewrite "remote:" sysroots as "target:" sysroots and replaces "remote:" specific code with "target:" specific code where still necessary. gdb/ChangeLog: * remote.h (REMOTE_SYSROOT_PREFIX): Remove definition. (remote_filename_p): Remove declaration. (remote_bfd_open): Likewise. * remote.c (remote_bfd_iovec_open): Remove function. (remote_bfd_iovec_close): Likewise. (remote_bfd_iovec_pread): Likewise. (remote_bfd_iovec_stat): Likewise. (remote_filename_p): Likewise. (remote_bfd_open): Likewise. * symfile.h (gdb_bfd_open_maybe_remote): Remove declaration. * symfile.c (separate_debug_file_exists): Use gdb_bfd_open. (gdb_bfd_open_maybe_remote): Remove function. (symfile_bfd_open): Replace remote filename check with target filename check. (reread_symbols): Use gdb_bfd_open. * build-id.c (gdbcore.h): New include. (build_id_to_debug_bfd): Use gdb_bfd_open. * infcmd.c (attach_command_post_wait): Remove remote filename check. * solib.c (solib_find): Replace remote-specific handling with target-specific handling. Update comments where necessary. (solib_bfd_open): Replace remote-specific handling with target-specific handling. (gdb_sysroot_changed): New function. (_initialize_solib): Call the above when gdb_sysroot changes. * windows-tdep.c (gdbcore.h): New include. (windows_xfer_shared_library): Use gdb_bfd_open.
2015-04-02 14:38:29 +02:00
/* Wrapper for reload_shared_libraries that replaces "remote:"
at the start of gdb_sysroot with "target:". */
static void
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
gdb_sysroot_changed (const char *ignored, int from_tty,
Convert "remote:" sysroots to "target:" and remove "remote:" The functionality of "target:" sysroots is a superset of the functionality of "remote:" sysroots. This commit causes the "set sysroot" command to rewrite "remote:" sysroots as "target:" sysroots and replaces "remote:" specific code with "target:" specific code where still necessary. gdb/ChangeLog: * remote.h (REMOTE_SYSROOT_PREFIX): Remove definition. (remote_filename_p): Remove declaration. (remote_bfd_open): Likewise. * remote.c (remote_bfd_iovec_open): Remove function. (remote_bfd_iovec_close): Likewise. (remote_bfd_iovec_pread): Likewise. (remote_bfd_iovec_stat): Likewise. (remote_filename_p): Likewise. (remote_bfd_open): Likewise. * symfile.h (gdb_bfd_open_maybe_remote): Remove declaration. * symfile.c (separate_debug_file_exists): Use gdb_bfd_open. (gdb_bfd_open_maybe_remote): Remove function. (symfile_bfd_open): Replace remote filename check with target filename check. (reread_symbols): Use gdb_bfd_open. * build-id.c (gdbcore.h): New include. (build_id_to_debug_bfd): Use gdb_bfd_open. * infcmd.c (attach_command_post_wait): Remove remote filename check. * solib.c (solib_find): Replace remote-specific handling with target-specific handling. Update comments where necessary. (solib_bfd_open): Replace remote-specific handling with target-specific handling. (gdb_sysroot_changed): New function. (_initialize_solib): Call the above when gdb_sysroot changes. * windows-tdep.c (gdbcore.h): New include. (windows_xfer_shared_library): Use gdb_bfd_open.
2015-04-02 14:38:29 +02:00
struct cmd_list_element *e)
{
const char *old_prefix = "remote:";
const char *new_prefix = TARGET_SYSROOT_PREFIX;
if (startswith (gdb_sysroot, old_prefix))
{
static bool warning_issued = false;
Convert "remote:" sysroots to "target:" and remove "remote:" The functionality of "target:" sysroots is a superset of the functionality of "remote:" sysroots. This commit causes the "set sysroot" command to rewrite "remote:" sysroots as "target:" sysroots and replaces "remote:" specific code with "target:" specific code where still necessary. gdb/ChangeLog: * remote.h (REMOTE_SYSROOT_PREFIX): Remove definition. (remote_filename_p): Remove declaration. (remote_bfd_open): Likewise. * remote.c (remote_bfd_iovec_open): Remove function. (remote_bfd_iovec_close): Likewise. (remote_bfd_iovec_pread): Likewise. (remote_bfd_iovec_stat): Likewise. (remote_filename_p): Likewise. (remote_bfd_open): Likewise. * symfile.h (gdb_bfd_open_maybe_remote): Remove declaration. * symfile.c (separate_debug_file_exists): Use gdb_bfd_open. (gdb_bfd_open_maybe_remote): Remove function. (symfile_bfd_open): Replace remote filename check with target filename check. (reread_symbols): Use gdb_bfd_open. * build-id.c (gdbcore.h): New include. (build_id_to_debug_bfd): Use gdb_bfd_open. * infcmd.c (attach_command_post_wait): Remove remote filename check. * solib.c (solib_find): Replace remote-specific handling with target-specific handling. Update comments where necessary. (solib_bfd_open): Replace remote-specific handling with target-specific handling. (gdb_sysroot_changed): New function. (_initialize_solib): Call the above when gdb_sysroot changes. * windows-tdep.c (gdbcore.h): New include. (windows_xfer_shared_library): Use gdb_bfd_open.
2015-04-02 14:38:29 +02:00
gdb_assert (strlen (old_prefix) == strlen (new_prefix));
memcpy (gdb_sysroot, new_prefix, strlen (new_prefix));
if (!warning_issued)
{
warning (_("\"%s\" is deprecated, use \"%s\" instead."),
old_prefix, new_prefix);
warning (_("sysroot set to \"%s\"."), gdb_sysroot);
warning_issued = true;
Convert "remote:" sysroots to "target:" and remove "remote:" The functionality of "target:" sysroots is a superset of the functionality of "remote:" sysroots. This commit causes the "set sysroot" command to rewrite "remote:" sysroots as "target:" sysroots and replaces "remote:" specific code with "target:" specific code where still necessary. gdb/ChangeLog: * remote.h (REMOTE_SYSROOT_PREFIX): Remove definition. (remote_filename_p): Remove declaration. (remote_bfd_open): Likewise. * remote.c (remote_bfd_iovec_open): Remove function. (remote_bfd_iovec_close): Likewise. (remote_bfd_iovec_pread): Likewise. (remote_bfd_iovec_stat): Likewise. (remote_filename_p): Likewise. (remote_bfd_open): Likewise. * symfile.h (gdb_bfd_open_maybe_remote): Remove declaration. * symfile.c (separate_debug_file_exists): Use gdb_bfd_open. (gdb_bfd_open_maybe_remote): Remove function. (symfile_bfd_open): Replace remote filename check with target filename check. (reread_symbols): Use gdb_bfd_open. * build-id.c (gdbcore.h): New include. (build_id_to_debug_bfd): Use gdb_bfd_open. * infcmd.c (attach_command_post_wait): Remove remote filename check. * solib.c (solib_find): Replace remote-specific handling with target-specific handling. Update comments where necessary. (solib_bfd_open): Replace remote-specific handling with target-specific handling. (gdb_sysroot_changed): New function. (_initialize_solib): Call the above when gdb_sysroot changes. * windows-tdep.c (gdbcore.h): New include. (windows_xfer_shared_library): Use gdb_bfd_open.
2015-04-02 14:38:29 +02:00
}
}
reload_shared_libraries (ignored, from_tty, e);
}
2005-02-24 Andrew Cagney <cagney@gnu.org> Add show_VARIABLE functions, update add_setshow call. * varobj.c (_initialize_varobj, show_varobjdebug): Add and update. * valprint.c (_initialize_valprint, show_print_max) (show_stop_print_at_null, show_repeat_count_threshold) (show_prettyprint_structs, show_unionprint) (show_prettyprint_arrays, show_addressprint, show_input_radix) (show_output_radix): Ditto. * valops.c (_initialize_valops, show_overload_resolution): Ditto. * utils.c (initialize_utils, show_chars_per_line) (show_lines_per_page, show_demangle, show_pagination_enabled) (show_sevenbit_strings, show_asm_demangle): Ditto * tui/tui-win.c (_initialize_tui_win, show_tui_border_kind) (show_tui_border_mode, show_tui_active_border_mode): Ditto. * top.c (init_main, show_new_async_prompt) (show_async_command_editing_p, show_write_history_p) (show_history_size, show_history_filename, show_caution) (show_annotation_level, init_main): Ditto. * target.c (initialize_targets, show_targetdebug) (show_trust_readonly): Ditto. * symfile.c (_initialize_symfile, show_symbol_reloading) (show_ext_args, show_download_write_size) (show_debug_file_directory): Ditto. * source.c (_initialize_source, show_lines_to_list): Ditto. * solib.c (_initialize_solib, show_auto_solib_add) (show_solib_search_path): Ditto. * p-valprint.c (_initialize_pascal_valprint) (show_pascal_static_field_print): Ditto. * printcmd.c (_initialize_printcmd, show_max_symbolic_offset) (show_print_symbol_filename): Add and update. * parse.c (_initialize_parse, show_expressiondebug): Dito. * observer.c (_initialize_observer, show_observer_debug): Dito. * maint.c (_initialize_maint_cmds, show_watchdog) (show_maintenance_profile_p): Dito. * linux-nat.c (_initialize_linux_nat, show_debug_linux_nat): Dito. * infrun.c (_initialize_infrun, show_debug_infrun) (show_stop_on_solib_events, show_follow_fork_mode_string) (show_scheduler_mode, show_step_stop_if_no_debug): Ditto. * infcall.c (_initialize_infcall, show_coerce_float_to_double_p) (show_unwind_on_signal_p): Ditto. * gdbtypes.c (build_gdbtypes, show_opaque_type_resolution) (_initialize_gdbtypes, show_overload_debug): Ditto. * gdb-events.c, gdb-events.sh (_initialize_gdb_events) (show_gdb_events_debug): Ditto. * gdbarch.c, gdbarch.sh (show_gdbarch_debug) (_initialize_gdbarch): Ditto. * frame.c (_initialize_frame, show_backtrace_past_main) (show_backtrace_past_entry, show_backtrace_limit) (show_frame_debug): Ditto. * exec.c (_initialize_exec, show_write_files): Ditto. * dwarf2read.c (_initialize_dwarf2_read) (show_dwarf2_max_cache_age): Ditto. * demangle.c (_initialize_demangler) (show_demangling_style_names): Ditto. * dcache.c (_initialize_dcache, show_dcache_enabled_p): Ditto. * cp-valprint.c (show_static_field_print) (_initialize_cp_valprint, show_vtblprint, show_objectprint): Ditto. * corefile.c (_initialize_core, show_gnutarget_string): Ditto. * cli/cli-logging.c (_initialize_cli_logging) (show_logging_overwrite, show_logging_redirect) (show_logging_filename): Ditto. * cli/cli-cmds.c (show_info_verbose, show_history_expansion_p) (init_cli_cmds, show_baud_rate, show_remote_debug) (show_remote_timeout, show_max_user_call_depth): Ditto. * charset.c (show_host_charset_name, show_target_charset_name) (initialize_charset): Ditto. * breakpoint.c (show_can_use_hw_watchpoints) (show_pending_break_support, _initialize_breakpoint): Ditto.
2005-02-24 14:51:36 +01:00
static void
show_auto_solib_add (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
fprintf_filtered (file, _("Autoloading of shared library symbols is %s.\n"),
value);
}
/* Lookup the value for a specific symbol from dynamic symbol table. Look
up symbol from ABFD. MATCH_SYM is a callback function to determine
whether to pick up a symbol. DATA is the input of this callback
function. Return NULL if symbol is not found. */
CORE_ADDR
gdb_bfd_lookup_symbol_from_symtab (bfd *abfd,
int (*match_sym) (const asymbol *,
const void *),
const void *data)
{
long storage_needed = bfd_get_symtab_upper_bound (abfd);
CORE_ADDR symaddr = 0;
if (storage_needed > 0)
{
unsigned int i;
gdb::def_vector<asymbol *> storage (storage_needed / sizeof (asymbol *));
asymbol **symbol_table = storage.data ();
unsigned int number_of_symbols =
bfd_canonicalize_symtab (abfd, symbol_table);
for (i = 0; i < number_of_symbols; i++)
{
asymbol *sym = *symbol_table++;
if (match_sym (sym, data))
{
MIPS: Keep the ISA bit in compressed code addresses 1. Background information The MIPS architecture, as originally designed and implemented in mid-1980s has a uniform instruction word size that is 4 bytes, naturally aligned. As such all MIPS instructions are located at addresses that have their bits #1 and #0 set to zeroes, and any attempt to execute an instruction from an address that has any of the two bits set to one causes an address error exception. This may for example happen when a jump-register instruction is executed whose register value used as the jump target has any of these bits set. Then in mid 1990s LSI sought a way to improve code density for their TinyRISC family of MIPS cores and invented an alternatively encoded instruction set in a joint effort with MIPS Technologies (then a subsidiary of SGI). The new instruction set has been named the MIPS16 ASE (Application-Specific Extension) and uses a variable instruction word size, which is 2 bytes (as the name of the ASE suggests) for most, but there are a couple of exceptions that take 4 bytes, and then most of the 2-byte instructions can be treated with a 2-byte extension prefix to expand the range of the immediate operands used. As a result instructions are no longer 4-byte aligned, instead they are aligned to a multiple of 2. That left the bit #0 still unused for code references, be it for the standard MIPS (i.e. as originally invented) or for the MIPS16 instruction set, and based on that observation a clever trick was invented that on one hand allowed the processor to be seamlessly switched between the two instruction sets at any time at the run time while on the other avoided the introduction of any special control register to do that. So it is the bit #0 of the instruction address that was chosen as the selector and named the ISA bit. Any instruction executed at an even address is interpreted as a standard MIPS instruction (the address still has to have its bit #1 clear), any instruction executed at an odd address is interpreted as a MIPS16 instruction. To switch between modes ordinary jump instructions are used, such as used for function calls and returns, specifically the bit #0 of the source register used in jump-register instructions selects the execution (ISA) mode for the following piece of code to be interpreted in. Additionally new jump-immediate instructions were added that flipped the ISA bit to select the opposite mode upon execution. They were considered necessary to avoid the need to make register jumps in all cases as the original jump-immediate instructions provided no way to change the bit #0 at all. This was all important for cases where standard MIPS and MIPS16 code had to be mixed, either for compatibility with the existing binary code base or to access resources not reachable from MIPS16 code (the MIPS16 instruction set only provides access to general-purpose registers, and not for example floating-point unit registers or privileged coprocessor 0 registers) -- pieces of code in the opposite mode can be executed as ordinary subroutine calls. A similar approach has been more recently adopted for the MIPS16 replacement instruction set defined as the so called microMIPS ASE. This is another instruction set encoding introduced to the MIPS architecture. Just like the MIPS16 ASE, the microMIPS instruction set uses a variable-length encoding, where each instruction takes a multiple of 2 bytes. The ISA bit has been reused and for microMIPS-capable processors selects between the standard MIPS and the microMIPS mode instead. 2. Statement of the problem To put it shortly, MIPS16 and microMIPS code pointers used by GDB are different to these observed at the run time. This results in the same expressions being evaluated producing different results in GDB and in the program being debugged. Obviously it's the results obtained at the run time that are correct (they define how the program behaves) and therefore by definition the results obtained in GDB are incorrect. A bit longer description will record that obviously at the run time the ISA bit has to be set correctly (refer to background information above if unsure why so) or the program will not run as expected. This is recorded in all the executable file structures used at the run time: the dynamic symbol table (but not always the static one!), the GOT, and obviously in all the addresses embedded in code or data of the program itself, calculated by applying the appropriate relocations at the static link time. While a program is being processed by GDB, the ISA bit is stripped off from any code addresses, presumably to make them the same as the respective raw memory byte address used by the processor to access the instruction in the instruction fetch access cycle. This stripping is actually performed outside GDB proper, in BFD, specifically _bfd_mips_elf_symbol_processing (elfxx-mips.c, see the piece of code at the very bottom of that function, starting with an: "If this is an odd-valued function symbol, assume it's a MIPS16 or microMIPS one." comment). This function is also responsible for symbol table dumps made by `objdump' too, so you'll never see the ISA bit reported there by that tool, you need to use `readelf'. This is however unlike what is ever done at the run time, the ISA bit once present is never stripped off, for example a cast like this: (short *) main will not strip the ISA bit off and if the resulting pointer is intended to be used to access instructions as data, for example for software instruction decoding (like for fault recovery or emulation in a signal handler) or for self-modifying code then the bit still has to be stripped off by an explicit AND operation. This is probably best illustrated with a simple real program example. Let's consider the following simple program: $ cat foobar.c int __attribute__ ((mips16)) foo (void) { return 1; } int __attribute__ ((mips16)) bar (void) { return 2; } int __attribute__ ((nomips16)) foo32 (void) { return 3; } int (*foo32p) (void) = foo32; int (*foop) (void) = foo; int fooi = (int) foo; int main (void) { return foop (); } $ This is plain C with no odd tricks, except from the instruction mode attributes. They are not necessary to trigger this problem, I just put them here so that the program can be contained in a single source file and to make it obvious which function is MIPS16 code and which is not. Let's try it with Linux, so that everyone can repeat this experiment: $ mips-linux-gnu-gcc -mips16 -g -O2 -o foobar foobar.c $ Let's have a look at some interesting symbols: $ mips-linux-gnu-readelf -s foobar | egrep 'table|foo|bar' Symbol table '.dynsym' contains 7 entries: Symbol table '.symtab' contains 95 entries: 55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c 66: 0040068c 4 FUNC GLOBAL DEFAULT [MIPS16] 12 bar 68: 00410848 4 OBJECT GLOBAL DEFAULT 21 foo32p 70: 00410844 4 OBJECT GLOBAL DEFAULT 21 foop 78: 00400684 8 FUNC GLOBAL DEFAULT 12 foo32 80: 00400680 4 FUNC GLOBAL DEFAULT [MIPS16] 12 foo 88: 00410840 4 OBJECT GLOBAL DEFAULT 21 fooi $ Hmm, no sight of the ISA bit, but notice how foo and bar (but not foo32!) have been marked as MIPS16 functions (ELF symbol structure's `st_other' field is used for that). So let's try to run and poke at this program with GDB. I'll be using a native system for simplicity (I'll be using ellipses here and there to remove unrelated clutter): $ ./foobar $ echo $? 1 $ So far, so good. $ gdb ./foobar [...] (gdb) break main Breakpoint 1 at 0x400490: file foobar.c, line 23. (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) Yay, it worked! OK, so let's poke at it: (gdb) print main $1 = {int (void)} 0x400490 <main> (gdb) print foo32 $2 = {int (void)} 0x400684 <foo32> (gdb) print foo32p $3 = (int (*)(void)) 0x400684 <foo32> (gdb) print bar $4 = {int (void)} 0x40068c <bar> (gdb) print foo $5 = {int (void)} 0x400680 <foo> (gdb) print foop $6 = (int (*)(void)) 0x400681 <foo> (gdb) A-ha! Here's the difference and finally the ISA bit! (gdb) print /x fooi $7 = 0x400681 (gdb) p/x $pc p/x $pc $8 = 0x400491 (gdb) And here as well... (gdb) advance foo foo () at foobar.c:4 4 } (gdb) disassemble Dump of assembler code for function foo: 0x00400680 <+0>: jr ra 0x00400682 <+2>: li v0,1 End of assembler dump. (gdb) finish Run till exit from #0 foo () at foobar.c:4 main () at foobar.c:24 24 } Value returned is $9 = 1 (gdb) continue Continuing. [Inferior 1 (process 14103) exited with code 01] (gdb) So let's be a bit inquisitive... (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) Actually we do not like to run foo here at all. Let's run bar instead! (gdb) set foop = bar (gdb) print foop $10 = (int (*)(void)) 0x40068c <bar> (gdb) Hmm, no ISA bit. Is it going to work? (gdb) advance bar bar () at foobar.c:9 9 } (gdb) p/x $pc $11 = 0x40068c (gdb) disassemble Dump of assembler code for function bar: => 0x0040068c <+0>: jr ra 0x0040068e <+2>: li v0,2 End of assembler dump. (gdb) finish Run till exit from #0 bar () at foobar.c:9 Program received signal SIGILL, Illegal instruction. bar () at foobar.c:9 9 } (gdb) Oops! (gdb) p/x $pc $12 = 0x40068c (gdb) We're still there! (gdb) continue Continuing. Program terminated with signal SIGILL, Illegal instruction. The program no longer exists. (gdb) So let's try something else: (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) set foop = foo (gdb) advance foo foo () at foobar.c:4 4 } (gdb) disassemble Dump of assembler code for function foo: => 0x00400680 <+0>: jr ra 0x00400682 <+2>: li v0,1 End of assembler dump. (gdb) finish Run till exit from #0 foo () at foobar.c:4 Program received signal SIGILL, Illegal instruction. foo () at foobar.c:4 4 } (gdb) continue Continuing. Program terminated with signal SIGILL, Illegal instruction. The program no longer exists. (gdb) The same problem! (gdb) run Starting program: /net/build2-lucid-cs/scratch/macro/mips-linux-fsf-gcc/isa-bit/foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) set foop = foo32 (gdb) advance foo32 foo32 () at foobar.c:14 14 } (gdb) disassemble Dump of assembler code for function foo32: => 0x00400684 <+0>: jr ra 0x00400688 <+4>: li v0,3 End of assembler dump. (gdb) finish Run till exit from #0 foo32 () at foobar.c:14 main () at foobar.c:24 24 } Value returned is $14 = 3 (gdb) continue Continuing. [Inferior 1 (process 14113) exited with code 03] (gdb) That did work though, so it's the ISA bit only! (gdb) quit Enough! That's the tip of the iceberg only though. So let's rebuild the executable with some dynamic symbols: $ mips-linux-gnu-gcc -mips16 -Wl,--export-dynamic -g -O2 -o foobar-dyn foobar.c $ mips-linux-gnu-readelf -s foobar-dyn | egrep 'table|foo|bar' Symbol table '.dynsym' contains 32 entries: 6: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar 8: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p 9: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop 15: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32 17: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo 25: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi Symbol table '.symtab' contains 95 entries: 55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c 69: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar 71: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p 72: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop 79: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32 81: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo 89: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi $ OK, now the ISA bit is there for a change, but the MIPS16 `st_other' attribute gone, hmm... What does `objdump' do then: $ mips-linux-gnu-objdump -Tt foobar-dyn | egrep 'SYMBOL|foo|bar' foobar-dyn: file format elf32-tradbigmips SYMBOL TABLE: 00000000 l df *ABS* 00000000 foobar.c 004009cc g F .text 00000004 0xf0 bar 00410b88 g O .data 00000004 foo32p 00410b84 g O .data 00000004 foop 004009c4 g F .text 00000008 foo32 004009c0 g F .text 00000004 0xf0 foo 00410b80 g O .data 00000004 fooi DYNAMIC SYMBOL TABLE: 004009cc g DF .text 00000004 Base 0xf0 bar 00410b88 g DO .data 00000004 Base foo32p 00410b84 g DO .data 00000004 Base foop 004009c4 g DF .text 00000008 Base foo32 004009c0 g DF .text 00000004 Base 0xf0 foo 00410b80 g DO .data 00000004 Base fooi $ Hmm, the attribute (0xf0, printed raw) is back, and the ISA bit gone again. Let's have a look at some DWARF-2 records GDB uses (I'll be stripping off a lot here for brevity) -- debug info: $ mips-linux-gnu-readelf -wi foobar Contents of the .debug_info section: [...] Compilation Unit @ offset 0x88: Length: 0xbb (32-bit) Version: 4 Abbrev Offset: 62 Pointer Size: 4 <0><93>: Abbrev Number: 1 (DW_TAG_compile_unit) <94> DW_AT_producer : (indirect string, offset: 0x19e): GNU C 4.8.0 20120513 (experimental) -meb -mips16 -march=mips32r2 -mhard-float -mllsc -mplt -mno-synci -mno-shared -mabi=32 -g -O2 <98> DW_AT_language : 1 (ANSI C) <99> DW_AT_name : (indirect string, offset: 0x190): foobar.c <9d> DW_AT_comp_dir : (indirect string, offset: 0x225): [...] <a1> DW_AT_ranges : 0x0 <a5> DW_AT_low_pc : 0x0 <a9> DW_AT_stmt_list : 0x27 <1><ad>: Abbrev Number: 2 (DW_TAG_subprogram) <ae> DW_AT_external : 1 <ae> DW_AT_name : foo <b2> DW_AT_decl_file : 1 <b3> DW_AT_decl_line : 1 <b4> DW_AT_prototyped : 1 <b4> DW_AT_type : <0xc2> <b8> DW_AT_low_pc : 0x400680 <bc> DW_AT_high_pc : 0x400684 <c0> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <c2> DW_AT_GNU_all_call_sites: 1 <1><c2>: Abbrev Number: 3 (DW_TAG_base_type) <c3> DW_AT_byte_size : 4 <c4> DW_AT_encoding : 5 (signed) <c5> DW_AT_name : int <1><c9>: Abbrev Number: 4 (DW_TAG_subprogram) <ca> DW_AT_external : 1 <ca> DW_AT_name : (indirect string, offset: 0x18a): foo32 <ce> DW_AT_decl_file : 1 <cf> DW_AT_decl_line : 11 <d0> DW_AT_prototyped : 1 <d0> DW_AT_type : <0xc2> <d4> DW_AT_low_pc : 0x400684 <d8> DW_AT_high_pc : 0x40068c <dc> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <de> DW_AT_GNU_all_call_sites: 1 <1><de>: Abbrev Number: 2 (DW_TAG_subprogram) <df> DW_AT_external : 1 <df> DW_AT_name : bar <e3> DW_AT_decl_file : 1 <e4> DW_AT_decl_line : 6 <e5> DW_AT_prototyped : 1 <e5> DW_AT_type : <0xc2> <e9> DW_AT_low_pc : 0x40068c <ed> DW_AT_high_pc : 0x400690 <f1> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <f3> DW_AT_GNU_all_call_sites: 1 <1><f3>: Abbrev Number: 5 (DW_TAG_subprogram) <f4> DW_AT_external : 1 <f4> DW_AT_name : (indirect string, offset: 0x199): main <f8> DW_AT_decl_file : 1 <f9> DW_AT_decl_line : 21 <fa> DW_AT_prototyped : 1 <fa> DW_AT_type : <0xc2> <fe> DW_AT_low_pc : 0x400490 <102> DW_AT_high_pc : 0x4004a4 <106> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <108> DW_AT_GNU_all_tail_call_sites: 1 [...] $ -- no sign of the ISA bit anywhere -- frame info: $ mips-linux-gnu-readelf -wf foobar [...] Contents of the .debug_frame section: 00000000 0000000c ffffffff CIE Version: 1 Augmentation: "" Code alignment factor: 1 Data alignment factor: -4 Return address column: 31 DW_CFA_def_cfa_register: r29 DW_CFA_nop 00000010 0000000c 00000000 FDE cie=00000000 pc=00400680..00400684 00000020 0000000c 00000000 FDE cie=00000000 pc=00400684..0040068c 00000030 0000000c 00000000 FDE cie=00000000 pc=0040068c..00400690 00000040 00000018 00000000 FDE cie=00000000 pc=00400490..004004a4 DW_CFA_advance_loc: 6 to 00400496 DW_CFA_def_cfa_offset: 32 DW_CFA_offset: r31 at cfa-4 DW_CFA_advance_loc: 6 to 0040049c DW_CFA_restore: r31 DW_CFA_def_cfa_offset: 0 DW_CFA_nop DW_CFA_nop DW_CFA_nop [...] $ -- no sign of the ISA bit anywhere -- range info (GDB doesn't use arange): $ mips-linux-gnu-readelf -wR foobar Contents of the .debug_ranges section: Offset Begin End 00000000 00400680 00400690 00000000 00400490 004004a4 00000000 <End of list> $ -- no sign of the ISA bit anywhere -- line info: $ mips-linux-gnu-readelf -wl foobar Raw dump of debug contents of section .debug_line: [...] Offset: 0x27 Length: 78 DWARF Version: 2 Prologue Length: 31 Minimum Instruction Length: 1 Initial value of 'is_stmt': 1 Line Base: -5 Line Range: 14 Opcode Base: 13 Opcodes: Opcode 1 has 0 args Opcode 2 has 1 args Opcode 3 has 1 args Opcode 4 has 1 args Opcode 5 has 1 args Opcode 6 has 0 args Opcode 7 has 0 args Opcode 8 has 0 args Opcode 9 has 1 args Opcode 10 has 0 args Opcode 11 has 0 args Opcode 12 has 1 args The Directory Table is empty. The File Name Table: Entry Dir Time Size Name 1 0 0 0 foobar.c Line Number Statements: Extended opcode 2: set Address to 0x400681 Special opcode 6: advance Address by 0 to 0x400681 and Line by 1 to 2 Special opcode 7: advance Address by 0 to 0x400681 and Line by 2 to 4 Special opcode 55: advance Address by 3 to 0x400684 and Line by 8 to 12 Special opcode 7: advance Address by 0 to 0x400684 and Line by 2 to 14 Advance Line by -7 to 7 Special opcode 131: advance Address by 9 to 0x40068d and Line by 0 to 7 Special opcode 7: advance Address by 0 to 0x40068d and Line by 2 to 9 Advance PC by 3 to 0x400690 Extended opcode 1: End of Sequence Extended opcode 2: set Address to 0x400491 Advance Line by 21 to 22 Copy Special opcode 6: advance Address by 0 to 0x400491 and Line by 1 to 23 Special opcode 60: advance Address by 4 to 0x400495 and Line by -1 to 22 Special opcode 34: advance Address by 2 to 0x400497 and Line by 1 to 23 Special opcode 62: advance Address by 4 to 0x40049b and Line by 1 to 24 Special opcode 32: advance Address by 2 to 0x40049d and Line by -1 to 23 Special opcode 6: advance Address by 0 to 0x40049d and Line by 1 to 24 Advance PC by 7 to 0x4004a4 Extended opcode 1: End of Sequence [...] -- a-ha, the ISA bit is there! However it's not always right for some reason, I don't have a small test case to show it, but here's an excerpt from MIPS16 libc, a prologue of a function: 00019630 <__libc_init_first>: 19630: e8a0 jrc ra 19632: 6500 nop 00019634 <_init>: 19634: f000 6a11 li v0,17 19638: f7d8 0b08 la v1,15e00 <_DYNAMIC+0x15c54> 1963c: f400 3240 sll v0,16 19640: e269 addu v0,v1 19642: 659a move gp,v0 19644: 64f6 save 48,ra,s0-s1 19646: 671c move s0,gp 19648: d204 sw v0,16(sp) 1964a: f352 984c lw v0,-27828(s0) 1964e: 6724 move s1,a0 and the corresponding DWARF-2 line info: Line Number Statements: Extended opcode 2: set Address to 0x19631 Advance Line by 44 to 45 Copy Special opcode 8: advance Address by 0 to 0x19631 and Line by 3 to 48 Special opcode 66: advance Address by 4 to 0x19635 and Line by 5 to 53 Advance PC by constant 17 to 0x19646 Special opcode 25: advance Address by 1 to 0x19647 and Line by 6 to 59 Advance Line by -6 to 53 Special opcode 33: advance Address by 2 to 0x19649 and Line by 0 to 53 Special opcode 39: advance Address by 2 to 0x1964b and Line by 6 to 59 Advance Line by -6 to 53 Special opcode 61: advance Address by 4 to 0x1964f and Line by 0 to 53 -- see that "Advance PC by constant 17" there? It clears the ISA bit, however code at 0x19646 is not standard MIPS code at all. For some reason the constant is always 17, I've never seen DW_LNS_const_add_pc used with any other value -- is that a binutils bug or what? 3. Solution: I think we should retain the value of the ISA bit in code references, that is effectively treat them as cookies as they indeed are (although trivially calculated) rather than raw memory byte addresses. In a perfect world both the static symbol table and the respective DWARF-2 records should be fixed to include the ISA bit in all the cases. I think however that this is infeasible. All the uses of `_bfd_mips_elf_symbol_processing' can not necessarily be tracked down. This function is used by `elf_slurp_symbol_table' that in turn is used by `bfd_canonicalize_symtab' and `bfd_canonicalize_dynamic_symtab', which are public interfaces. Similarly DWARF-2 records are used outside GDB, one notable if a bit questionable is the exception unwinder (libgcc/unwind-dw2.c) -- I have identified at least bits in `execute_cfa_program' and `uw_frame_state_for', both around the calls to `_Unwind_IsSignalFrame', that would need an update as they effectively flip the ISA bit freely; see also the comment about MASK_RETURN_ADDR in gcc/config/mips/mips.h. But there may be more places. Any change in how DWARF-2 records are produced would require an update there and would cause compatibility problems with libgcc.a binaries already distributed; given that this is a static library a complex change involving function renames would likely be required. I propose therefore to accept the existing inconsistencies and deal with them entirely within GDB. I have figured out that the ISA bit lost in various places can still be recovered as long as we have symbol information -- that'll have the `st_other' attribute correctly set to one of standard MIPS/MIPS16/microMIPS encoding. Here's the resulting change. It adds a couple of new `gdbarch' hooks, one to update symbol information with the ISA bit lost in `_bfd_mips_elf_symbol_processing', and two other ones to adjust DWARF-2 records as they're processed. The ISA bit is set in each address handled according to information retrieved from the symbol table for the symbol spanning the address if any; limits are adjusted based on the address they point to related to the respective base address. Additionally minimal symbol information has to be adjusted accordingly in its gdbarch hook. With these changes in place some complications with ISA bit juggling in the PC that never fully worked can be removed from the MIPS backend. Conversely, the generic dynamic linker event special breakpoint symbol handler has to be updated to call the minimal symbol gdbarch hook to record that the symbol is a MIPS16 or microMIPS address if applicable or the breakpoint will be set at the wrong address and either fail to work or cause SIGTRAPs (this is because the symbol is handled early on and bypasses regular symbol processing). 4. Results obtained The change fixes the example above -- to repeat only the crucial steps: (gdb) break main Breakpoint 1 at 0x400491: file foobar.c, line 23. (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) print foo $1 = {int (void)} 0x400681 <foo> (gdb) set foop = bar (gdb) advance bar bar () at foobar.c:9 9 } (gdb) disassemble Dump of assembler code for function bar: => 0x0040068d <+0>: jr ra 0x0040068f <+2>: li v0,2 End of assembler dump. (gdb) finish Run till exit from #0 bar () at foobar.c:9 main () at foobar.c:24 24 } Value returned is $2 = 2 (gdb) continue Continuing. [Inferior 1 (process 14128) exited with code 02] (gdb) -- excellent! The change removes about 90 failures per MIPS16 multilib in mips-sde-elf testing too, results for MIPS16 are now similar to that for standard MIPS; microMIPS results are a bit worse because of host-I/O problems in QEMU used instead of MIPSsim for microMIPS testing only: === gdb Summary === # of expected passes 14299 # of unexpected failures 187 # of expected failures 56 # of known failures 58 # of unresolved testcases 11 # of untested testcases 52 # of unsupported tests 174 MIPS16: === gdb Summary === # of expected passes 14298 # of unexpected failures 187 # of unexpected successes 2 # of expected failures 54 # of known failures 58 # of unresolved testcases 12 # of untested testcases 52 # of unsupported tests 174 microMIPS: === gdb Summary === # of expected passes 14149 # of unexpected failures 201 # of unexpected successes 2 # of expected failures 54 # of known failures 58 # of unresolved testcases 7 # of untested testcases 53 # of unsupported tests 175 2014-12-12 Maciej W. Rozycki <macro@codesourcery.com> Maciej W. Rozycki <macro@mips.com> Pedro Alves <pedro@codesourcery.com> gdb/ * gdbarch.sh (elf_make_msymbol_special): Change type to `F', remove `predefault' and `invalid_p' initializers. (make_symbol_special): New architecture method. (adjust_dwarf2_addr, adjust_dwarf2_line): Likewise. (objfile, symbol): New declarations. * arch-utils.h (default_elf_make_msymbol_special): Remove prototype. (default_make_symbol_special): New prototype. (default_adjust_dwarf2_addr): Likewise. (default_adjust_dwarf2_line): Likewise. * mips-tdep.h (mips_unmake_compact_addr): New prototype. * arch-utils.c (default_elf_make_msymbol_special): Remove function. (default_make_symbol_special): New function. (default_adjust_dwarf2_addr): Likewise. (default_adjust_dwarf2_line): Likewise. * dwarf2-frame.c (decode_frame_entry_1): Call `gdbarch_adjust_dwarf2_addr'. * dwarf2loc.c (dwarf2_find_location_expression): Likewise. * dwarf2read.c (create_addrmap_from_index): Likewise. (process_psymtab_comp_unit_reader): Likewise. (add_partial_symbol): Likewise. (add_partial_subprogram): Likewise. (process_full_comp_unit): Likewise. (read_file_scope): Likewise. (read_func_scope): Likewise. Call `gdbarch_make_symbol_special'. (read_lexical_block_scope): Call `gdbarch_adjust_dwarf2_addr'. (read_call_site_scope): Likewise. (dwarf2_ranges_read): Likewise. (dwarf2_record_block_ranges): Likewise. (read_attribute_value): Likewise. (dwarf_decode_lines_1): Call `gdbarch_adjust_dwarf2_line'. (new_symbol_full): Call `gdbarch_adjust_dwarf2_addr'. * elfread.c (elf_symtab_read): Don't call `gdbarch_elf_make_msymbol_special' if unset. * mips-linux-tdep.c (micromips_linux_sigframe_validate): Strip the ISA bit from the PC. * mips-tdep.c (mips_unmake_compact_addr): New function. (mips_elf_make_msymbol_special): Set the ISA bit in the symbol's address appropriately. (mips_make_symbol_special): New function. (mips_pc_is_mips): Set the ISA bit before symbol lookup. (mips_pc_is_mips16): Likewise. (mips_pc_is_micromips): Likewise. (mips_pc_isa): Likewise. (mips_adjust_dwarf2_addr): New function. (mips_adjust_dwarf2_line): Likewise. (mips_read_pc, mips_unwind_pc): Keep the ISA bit. (mips_addr_bits_remove): Likewise. (mips_skip_trampoline_code): Likewise. (mips_write_pc): Don't set the ISA bit. (mips_eabi_push_dummy_call): Likewise. (mips_o64_push_dummy_call): Likewise. (mips_gdbarch_init): Install `mips_make_symbol_special', `mips_adjust_dwarf2_addr' and `mips_adjust_dwarf2_line' gdbarch handlers. * solib.c (gdb_bfd_lookup_symbol_from_symtab): Get target-specific symbol address adjustments. * gdbarch.h: Regenerate. * gdbarch.c: Regenerate. 2014-12-12 Maciej W. Rozycki <macro@codesourcery.com> gdb/testsuite/ * gdb.base/func-ptrs.c: New file. * gdb.base/func-ptrs.exp: New file.
2014-12-12 14:31:53 +01:00
struct gdbarch *gdbarch = target_gdbarch ();
symaddr = sym->value;
/* Some ELF targets fiddle with addresses of symbols they
consider special. They use minimal symbols to do that
and this is needed for correct breakpoint placement,
but we do not have full data here to build a complete
minimal symbol, so just set the address and let the
targets cope with that. */
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
&& gdbarch_elf_make_msymbol_special_p (gdbarch))
{
struct minimal_symbol msym {};
MIPS: Keep the ISA bit in compressed code addresses 1. Background information The MIPS architecture, as originally designed and implemented in mid-1980s has a uniform instruction word size that is 4 bytes, naturally aligned. As such all MIPS instructions are located at addresses that have their bits #1 and #0 set to zeroes, and any attempt to execute an instruction from an address that has any of the two bits set to one causes an address error exception. This may for example happen when a jump-register instruction is executed whose register value used as the jump target has any of these bits set. Then in mid 1990s LSI sought a way to improve code density for their TinyRISC family of MIPS cores and invented an alternatively encoded instruction set in a joint effort with MIPS Technologies (then a subsidiary of SGI). The new instruction set has been named the MIPS16 ASE (Application-Specific Extension) and uses a variable instruction word size, which is 2 bytes (as the name of the ASE suggests) for most, but there are a couple of exceptions that take 4 bytes, and then most of the 2-byte instructions can be treated with a 2-byte extension prefix to expand the range of the immediate operands used. As a result instructions are no longer 4-byte aligned, instead they are aligned to a multiple of 2. That left the bit #0 still unused for code references, be it for the standard MIPS (i.e. as originally invented) or for the MIPS16 instruction set, and based on that observation a clever trick was invented that on one hand allowed the processor to be seamlessly switched between the two instruction sets at any time at the run time while on the other avoided the introduction of any special control register to do that. So it is the bit #0 of the instruction address that was chosen as the selector and named the ISA bit. Any instruction executed at an even address is interpreted as a standard MIPS instruction (the address still has to have its bit #1 clear), any instruction executed at an odd address is interpreted as a MIPS16 instruction. To switch between modes ordinary jump instructions are used, such as used for function calls and returns, specifically the bit #0 of the source register used in jump-register instructions selects the execution (ISA) mode for the following piece of code to be interpreted in. Additionally new jump-immediate instructions were added that flipped the ISA bit to select the opposite mode upon execution. They were considered necessary to avoid the need to make register jumps in all cases as the original jump-immediate instructions provided no way to change the bit #0 at all. This was all important for cases where standard MIPS and MIPS16 code had to be mixed, either for compatibility with the existing binary code base or to access resources not reachable from MIPS16 code (the MIPS16 instruction set only provides access to general-purpose registers, and not for example floating-point unit registers or privileged coprocessor 0 registers) -- pieces of code in the opposite mode can be executed as ordinary subroutine calls. A similar approach has been more recently adopted for the MIPS16 replacement instruction set defined as the so called microMIPS ASE. This is another instruction set encoding introduced to the MIPS architecture. Just like the MIPS16 ASE, the microMIPS instruction set uses a variable-length encoding, where each instruction takes a multiple of 2 bytes. The ISA bit has been reused and for microMIPS-capable processors selects between the standard MIPS and the microMIPS mode instead. 2. Statement of the problem To put it shortly, MIPS16 and microMIPS code pointers used by GDB are different to these observed at the run time. This results in the same expressions being evaluated producing different results in GDB and in the program being debugged. Obviously it's the results obtained at the run time that are correct (they define how the program behaves) and therefore by definition the results obtained in GDB are incorrect. A bit longer description will record that obviously at the run time the ISA bit has to be set correctly (refer to background information above if unsure why so) or the program will not run as expected. This is recorded in all the executable file structures used at the run time: the dynamic symbol table (but not always the static one!), the GOT, and obviously in all the addresses embedded in code or data of the program itself, calculated by applying the appropriate relocations at the static link time. While a program is being processed by GDB, the ISA bit is stripped off from any code addresses, presumably to make them the same as the respective raw memory byte address used by the processor to access the instruction in the instruction fetch access cycle. This stripping is actually performed outside GDB proper, in BFD, specifically _bfd_mips_elf_symbol_processing (elfxx-mips.c, see the piece of code at the very bottom of that function, starting with an: "If this is an odd-valued function symbol, assume it's a MIPS16 or microMIPS one." comment). This function is also responsible for symbol table dumps made by `objdump' too, so you'll never see the ISA bit reported there by that tool, you need to use `readelf'. This is however unlike what is ever done at the run time, the ISA bit once present is never stripped off, for example a cast like this: (short *) main will not strip the ISA bit off and if the resulting pointer is intended to be used to access instructions as data, for example for software instruction decoding (like for fault recovery or emulation in a signal handler) or for self-modifying code then the bit still has to be stripped off by an explicit AND operation. This is probably best illustrated with a simple real program example. Let's consider the following simple program: $ cat foobar.c int __attribute__ ((mips16)) foo (void) { return 1; } int __attribute__ ((mips16)) bar (void) { return 2; } int __attribute__ ((nomips16)) foo32 (void) { return 3; } int (*foo32p) (void) = foo32; int (*foop) (void) = foo; int fooi = (int) foo; int main (void) { return foop (); } $ This is plain C with no odd tricks, except from the instruction mode attributes. They are not necessary to trigger this problem, I just put them here so that the program can be contained in a single source file and to make it obvious which function is MIPS16 code and which is not. Let's try it with Linux, so that everyone can repeat this experiment: $ mips-linux-gnu-gcc -mips16 -g -O2 -o foobar foobar.c $ Let's have a look at some interesting symbols: $ mips-linux-gnu-readelf -s foobar | egrep 'table|foo|bar' Symbol table '.dynsym' contains 7 entries: Symbol table '.symtab' contains 95 entries: 55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c 66: 0040068c 4 FUNC GLOBAL DEFAULT [MIPS16] 12 bar 68: 00410848 4 OBJECT GLOBAL DEFAULT 21 foo32p 70: 00410844 4 OBJECT GLOBAL DEFAULT 21 foop 78: 00400684 8 FUNC GLOBAL DEFAULT 12 foo32 80: 00400680 4 FUNC GLOBAL DEFAULT [MIPS16] 12 foo 88: 00410840 4 OBJECT GLOBAL DEFAULT 21 fooi $ Hmm, no sight of the ISA bit, but notice how foo and bar (but not foo32!) have been marked as MIPS16 functions (ELF symbol structure's `st_other' field is used for that). So let's try to run and poke at this program with GDB. I'll be using a native system for simplicity (I'll be using ellipses here and there to remove unrelated clutter): $ ./foobar $ echo $? 1 $ So far, so good. $ gdb ./foobar [...] (gdb) break main Breakpoint 1 at 0x400490: file foobar.c, line 23. (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) Yay, it worked! OK, so let's poke at it: (gdb) print main $1 = {int (void)} 0x400490 <main> (gdb) print foo32 $2 = {int (void)} 0x400684 <foo32> (gdb) print foo32p $3 = (int (*)(void)) 0x400684 <foo32> (gdb) print bar $4 = {int (void)} 0x40068c <bar> (gdb) print foo $5 = {int (void)} 0x400680 <foo> (gdb) print foop $6 = (int (*)(void)) 0x400681 <foo> (gdb) A-ha! Here's the difference and finally the ISA bit! (gdb) print /x fooi $7 = 0x400681 (gdb) p/x $pc p/x $pc $8 = 0x400491 (gdb) And here as well... (gdb) advance foo foo () at foobar.c:4 4 } (gdb) disassemble Dump of assembler code for function foo: 0x00400680 <+0>: jr ra 0x00400682 <+2>: li v0,1 End of assembler dump. (gdb) finish Run till exit from #0 foo () at foobar.c:4 main () at foobar.c:24 24 } Value returned is $9 = 1 (gdb) continue Continuing. [Inferior 1 (process 14103) exited with code 01] (gdb) So let's be a bit inquisitive... (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) Actually we do not like to run foo here at all. Let's run bar instead! (gdb) set foop = bar (gdb) print foop $10 = (int (*)(void)) 0x40068c <bar> (gdb) Hmm, no ISA bit. Is it going to work? (gdb) advance bar bar () at foobar.c:9 9 } (gdb) p/x $pc $11 = 0x40068c (gdb) disassemble Dump of assembler code for function bar: => 0x0040068c <+0>: jr ra 0x0040068e <+2>: li v0,2 End of assembler dump. (gdb) finish Run till exit from #0 bar () at foobar.c:9 Program received signal SIGILL, Illegal instruction. bar () at foobar.c:9 9 } (gdb) Oops! (gdb) p/x $pc $12 = 0x40068c (gdb) We're still there! (gdb) continue Continuing. Program terminated with signal SIGILL, Illegal instruction. The program no longer exists. (gdb) So let's try something else: (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) set foop = foo (gdb) advance foo foo () at foobar.c:4 4 } (gdb) disassemble Dump of assembler code for function foo: => 0x00400680 <+0>: jr ra 0x00400682 <+2>: li v0,1 End of assembler dump. (gdb) finish Run till exit from #0 foo () at foobar.c:4 Program received signal SIGILL, Illegal instruction. foo () at foobar.c:4 4 } (gdb) continue Continuing. Program terminated with signal SIGILL, Illegal instruction. The program no longer exists. (gdb) The same problem! (gdb) run Starting program: /net/build2-lucid-cs/scratch/macro/mips-linux-fsf-gcc/isa-bit/foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) set foop = foo32 (gdb) advance foo32 foo32 () at foobar.c:14 14 } (gdb) disassemble Dump of assembler code for function foo32: => 0x00400684 <+0>: jr ra 0x00400688 <+4>: li v0,3 End of assembler dump. (gdb) finish Run till exit from #0 foo32 () at foobar.c:14 main () at foobar.c:24 24 } Value returned is $14 = 3 (gdb) continue Continuing. [Inferior 1 (process 14113) exited with code 03] (gdb) That did work though, so it's the ISA bit only! (gdb) quit Enough! That's the tip of the iceberg only though. So let's rebuild the executable with some dynamic symbols: $ mips-linux-gnu-gcc -mips16 -Wl,--export-dynamic -g -O2 -o foobar-dyn foobar.c $ mips-linux-gnu-readelf -s foobar-dyn | egrep 'table|foo|bar' Symbol table '.dynsym' contains 32 entries: 6: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar 8: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p 9: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop 15: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32 17: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo 25: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi Symbol table '.symtab' contains 95 entries: 55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c 69: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar 71: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p 72: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop 79: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32 81: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo 89: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi $ OK, now the ISA bit is there for a change, but the MIPS16 `st_other' attribute gone, hmm... What does `objdump' do then: $ mips-linux-gnu-objdump -Tt foobar-dyn | egrep 'SYMBOL|foo|bar' foobar-dyn: file format elf32-tradbigmips SYMBOL TABLE: 00000000 l df *ABS* 00000000 foobar.c 004009cc g F .text 00000004 0xf0 bar 00410b88 g O .data 00000004 foo32p 00410b84 g O .data 00000004 foop 004009c4 g F .text 00000008 foo32 004009c0 g F .text 00000004 0xf0 foo 00410b80 g O .data 00000004 fooi DYNAMIC SYMBOL TABLE: 004009cc g DF .text 00000004 Base 0xf0 bar 00410b88 g DO .data 00000004 Base foo32p 00410b84 g DO .data 00000004 Base foop 004009c4 g DF .text 00000008 Base foo32 004009c0 g DF .text 00000004 Base 0xf0 foo 00410b80 g DO .data 00000004 Base fooi $ Hmm, the attribute (0xf0, printed raw) is back, and the ISA bit gone again. Let's have a look at some DWARF-2 records GDB uses (I'll be stripping off a lot here for brevity) -- debug info: $ mips-linux-gnu-readelf -wi foobar Contents of the .debug_info section: [...] Compilation Unit @ offset 0x88: Length: 0xbb (32-bit) Version: 4 Abbrev Offset: 62 Pointer Size: 4 <0><93>: Abbrev Number: 1 (DW_TAG_compile_unit) <94> DW_AT_producer : (indirect string, offset: 0x19e): GNU C 4.8.0 20120513 (experimental) -meb -mips16 -march=mips32r2 -mhard-float -mllsc -mplt -mno-synci -mno-shared -mabi=32 -g -O2 <98> DW_AT_language : 1 (ANSI C) <99> DW_AT_name : (indirect string, offset: 0x190): foobar.c <9d> DW_AT_comp_dir : (indirect string, offset: 0x225): [...] <a1> DW_AT_ranges : 0x0 <a5> DW_AT_low_pc : 0x0 <a9> DW_AT_stmt_list : 0x27 <1><ad>: Abbrev Number: 2 (DW_TAG_subprogram) <ae> DW_AT_external : 1 <ae> DW_AT_name : foo <b2> DW_AT_decl_file : 1 <b3> DW_AT_decl_line : 1 <b4> DW_AT_prototyped : 1 <b4> DW_AT_type : <0xc2> <b8> DW_AT_low_pc : 0x400680 <bc> DW_AT_high_pc : 0x400684 <c0> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <c2> DW_AT_GNU_all_call_sites: 1 <1><c2>: Abbrev Number: 3 (DW_TAG_base_type) <c3> DW_AT_byte_size : 4 <c4> DW_AT_encoding : 5 (signed) <c5> DW_AT_name : int <1><c9>: Abbrev Number: 4 (DW_TAG_subprogram) <ca> DW_AT_external : 1 <ca> DW_AT_name : (indirect string, offset: 0x18a): foo32 <ce> DW_AT_decl_file : 1 <cf> DW_AT_decl_line : 11 <d0> DW_AT_prototyped : 1 <d0> DW_AT_type : <0xc2> <d4> DW_AT_low_pc : 0x400684 <d8> DW_AT_high_pc : 0x40068c <dc> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <de> DW_AT_GNU_all_call_sites: 1 <1><de>: Abbrev Number: 2 (DW_TAG_subprogram) <df> DW_AT_external : 1 <df> DW_AT_name : bar <e3> DW_AT_decl_file : 1 <e4> DW_AT_decl_line : 6 <e5> DW_AT_prototyped : 1 <e5> DW_AT_type : <0xc2> <e9> DW_AT_low_pc : 0x40068c <ed> DW_AT_high_pc : 0x400690 <f1> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <f3> DW_AT_GNU_all_call_sites: 1 <1><f3>: Abbrev Number: 5 (DW_TAG_subprogram) <f4> DW_AT_external : 1 <f4> DW_AT_name : (indirect string, offset: 0x199): main <f8> DW_AT_decl_file : 1 <f9> DW_AT_decl_line : 21 <fa> DW_AT_prototyped : 1 <fa> DW_AT_type : <0xc2> <fe> DW_AT_low_pc : 0x400490 <102> DW_AT_high_pc : 0x4004a4 <106> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <108> DW_AT_GNU_all_tail_call_sites: 1 [...] $ -- no sign of the ISA bit anywhere -- frame info: $ mips-linux-gnu-readelf -wf foobar [...] Contents of the .debug_frame section: 00000000 0000000c ffffffff CIE Version: 1 Augmentation: "" Code alignment factor: 1 Data alignment factor: -4 Return address column: 31 DW_CFA_def_cfa_register: r29 DW_CFA_nop 00000010 0000000c 00000000 FDE cie=00000000 pc=00400680..00400684 00000020 0000000c 00000000 FDE cie=00000000 pc=00400684..0040068c 00000030 0000000c 00000000 FDE cie=00000000 pc=0040068c..00400690 00000040 00000018 00000000 FDE cie=00000000 pc=00400490..004004a4 DW_CFA_advance_loc: 6 to 00400496 DW_CFA_def_cfa_offset: 32 DW_CFA_offset: r31 at cfa-4 DW_CFA_advance_loc: 6 to 0040049c DW_CFA_restore: r31 DW_CFA_def_cfa_offset: 0 DW_CFA_nop DW_CFA_nop DW_CFA_nop [...] $ -- no sign of the ISA bit anywhere -- range info (GDB doesn't use arange): $ mips-linux-gnu-readelf -wR foobar Contents of the .debug_ranges section: Offset Begin End 00000000 00400680 00400690 00000000 00400490 004004a4 00000000 <End of list> $ -- no sign of the ISA bit anywhere -- line info: $ mips-linux-gnu-readelf -wl foobar Raw dump of debug contents of section .debug_line: [...] Offset: 0x27 Length: 78 DWARF Version: 2 Prologue Length: 31 Minimum Instruction Length: 1 Initial value of 'is_stmt': 1 Line Base: -5 Line Range: 14 Opcode Base: 13 Opcodes: Opcode 1 has 0 args Opcode 2 has 1 args Opcode 3 has 1 args Opcode 4 has 1 args Opcode 5 has 1 args Opcode 6 has 0 args Opcode 7 has 0 args Opcode 8 has 0 args Opcode 9 has 1 args Opcode 10 has 0 args Opcode 11 has 0 args Opcode 12 has 1 args The Directory Table is empty. The File Name Table: Entry Dir Time Size Name 1 0 0 0 foobar.c Line Number Statements: Extended opcode 2: set Address to 0x400681 Special opcode 6: advance Address by 0 to 0x400681 and Line by 1 to 2 Special opcode 7: advance Address by 0 to 0x400681 and Line by 2 to 4 Special opcode 55: advance Address by 3 to 0x400684 and Line by 8 to 12 Special opcode 7: advance Address by 0 to 0x400684 and Line by 2 to 14 Advance Line by -7 to 7 Special opcode 131: advance Address by 9 to 0x40068d and Line by 0 to 7 Special opcode 7: advance Address by 0 to 0x40068d and Line by 2 to 9 Advance PC by 3 to 0x400690 Extended opcode 1: End of Sequence Extended opcode 2: set Address to 0x400491 Advance Line by 21 to 22 Copy Special opcode 6: advance Address by 0 to 0x400491 and Line by 1 to 23 Special opcode 60: advance Address by 4 to 0x400495 and Line by -1 to 22 Special opcode 34: advance Address by 2 to 0x400497 and Line by 1 to 23 Special opcode 62: advance Address by 4 to 0x40049b and Line by 1 to 24 Special opcode 32: advance Address by 2 to 0x40049d and Line by -1 to 23 Special opcode 6: advance Address by 0 to 0x40049d and Line by 1 to 24 Advance PC by 7 to 0x4004a4 Extended opcode 1: End of Sequence [...] -- a-ha, the ISA bit is there! However it's not always right for some reason, I don't have a small test case to show it, but here's an excerpt from MIPS16 libc, a prologue of a function: 00019630 <__libc_init_first>: 19630: e8a0 jrc ra 19632: 6500 nop 00019634 <_init>: 19634: f000 6a11 li v0,17 19638: f7d8 0b08 la v1,15e00 <_DYNAMIC+0x15c54> 1963c: f400 3240 sll v0,16 19640: e269 addu v0,v1 19642: 659a move gp,v0 19644: 64f6 save 48,ra,s0-s1 19646: 671c move s0,gp 19648: d204 sw v0,16(sp) 1964a: f352 984c lw v0,-27828(s0) 1964e: 6724 move s1,a0 and the corresponding DWARF-2 line info: Line Number Statements: Extended opcode 2: set Address to 0x19631 Advance Line by 44 to 45 Copy Special opcode 8: advance Address by 0 to 0x19631 and Line by 3 to 48 Special opcode 66: advance Address by 4 to 0x19635 and Line by 5 to 53 Advance PC by constant 17 to 0x19646 Special opcode 25: advance Address by 1 to 0x19647 and Line by 6 to 59 Advance Line by -6 to 53 Special opcode 33: advance Address by 2 to 0x19649 and Line by 0 to 53 Special opcode 39: advance Address by 2 to 0x1964b and Line by 6 to 59 Advance Line by -6 to 53 Special opcode 61: advance Address by 4 to 0x1964f and Line by 0 to 53 -- see that "Advance PC by constant 17" there? It clears the ISA bit, however code at 0x19646 is not standard MIPS code at all. For some reason the constant is always 17, I've never seen DW_LNS_const_add_pc used with any other value -- is that a binutils bug or what? 3. Solution: I think we should retain the value of the ISA bit in code references, that is effectively treat them as cookies as they indeed are (although trivially calculated) rather than raw memory byte addresses. In a perfect world both the static symbol table and the respective DWARF-2 records should be fixed to include the ISA bit in all the cases. I think however that this is infeasible. All the uses of `_bfd_mips_elf_symbol_processing' can not necessarily be tracked down. This function is used by `elf_slurp_symbol_table' that in turn is used by `bfd_canonicalize_symtab' and `bfd_canonicalize_dynamic_symtab', which are public interfaces. Similarly DWARF-2 records are used outside GDB, one notable if a bit questionable is the exception unwinder (libgcc/unwind-dw2.c) -- I have identified at least bits in `execute_cfa_program' and `uw_frame_state_for', both around the calls to `_Unwind_IsSignalFrame', that would need an update as they effectively flip the ISA bit freely; see also the comment about MASK_RETURN_ADDR in gcc/config/mips/mips.h. But there may be more places. Any change in how DWARF-2 records are produced would require an update there and would cause compatibility problems with libgcc.a binaries already distributed; given that this is a static library a complex change involving function renames would likely be required. I propose therefore to accept the existing inconsistencies and deal with them entirely within GDB. I have figured out that the ISA bit lost in various places can still be recovered as long as we have symbol information -- that'll have the `st_other' attribute correctly set to one of standard MIPS/MIPS16/microMIPS encoding. Here's the resulting change. It adds a couple of new `gdbarch' hooks, one to update symbol information with the ISA bit lost in `_bfd_mips_elf_symbol_processing', and two other ones to adjust DWARF-2 records as they're processed. The ISA bit is set in each address handled according to information retrieved from the symbol table for the symbol spanning the address if any; limits are adjusted based on the address they point to related to the respective base address. Additionally minimal symbol information has to be adjusted accordingly in its gdbarch hook. With these changes in place some complications with ISA bit juggling in the PC that never fully worked can be removed from the MIPS backend. Conversely, the generic dynamic linker event special breakpoint symbol handler has to be updated to call the minimal symbol gdbarch hook to record that the symbol is a MIPS16 or microMIPS address if applicable or the breakpoint will be set at the wrong address and either fail to work or cause SIGTRAPs (this is because the symbol is handled early on and bypasses regular symbol processing). 4. Results obtained The change fixes the example above -- to repeat only the crucial steps: (gdb) break main Breakpoint 1 at 0x400491: file foobar.c, line 23. (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) print foo $1 = {int (void)} 0x400681 <foo> (gdb) set foop = bar (gdb) advance bar bar () at foobar.c:9 9 } (gdb) disassemble Dump of assembler code for function bar: => 0x0040068d <+0>: jr ra 0x0040068f <+2>: li v0,2 End of assembler dump. (gdb) finish Run till exit from #0 bar () at foobar.c:9 main () at foobar.c:24 24 } Value returned is $2 = 2 (gdb) continue Continuing. [Inferior 1 (process 14128) exited with code 02] (gdb) -- excellent! The change removes about 90 failures per MIPS16 multilib in mips-sde-elf testing too, results for MIPS16 are now similar to that for standard MIPS; microMIPS results are a bit worse because of host-I/O problems in QEMU used instead of MIPSsim for microMIPS testing only: === gdb Summary === # of expected passes 14299 # of unexpected failures 187 # of expected failures 56 # of known failures 58 # of unresolved testcases 11 # of untested testcases 52 # of unsupported tests 174 MIPS16: === gdb Summary === # of expected passes 14298 # of unexpected failures 187 # of unexpected successes 2 # of expected failures 54 # of known failures 58 # of unresolved testcases 12 # of untested testcases 52 # of unsupported tests 174 microMIPS: === gdb Summary === # of expected passes 14149 # of unexpected failures 201 # of unexpected successes 2 # of expected failures 54 # of known failures 58 # of unresolved testcases 7 # of untested testcases 53 # of unsupported tests 175 2014-12-12 Maciej W. Rozycki <macro@codesourcery.com> Maciej W. Rozycki <macro@mips.com> Pedro Alves <pedro@codesourcery.com> gdb/ * gdbarch.sh (elf_make_msymbol_special): Change type to `F', remove `predefault' and `invalid_p' initializers. (make_symbol_special): New architecture method. (adjust_dwarf2_addr, adjust_dwarf2_line): Likewise. (objfile, symbol): New declarations. * arch-utils.h (default_elf_make_msymbol_special): Remove prototype. (default_make_symbol_special): New prototype. (default_adjust_dwarf2_addr): Likewise. (default_adjust_dwarf2_line): Likewise. * mips-tdep.h (mips_unmake_compact_addr): New prototype. * arch-utils.c (default_elf_make_msymbol_special): Remove function. (default_make_symbol_special): New function. (default_adjust_dwarf2_addr): Likewise. (default_adjust_dwarf2_line): Likewise. * dwarf2-frame.c (decode_frame_entry_1): Call `gdbarch_adjust_dwarf2_addr'. * dwarf2loc.c (dwarf2_find_location_expression): Likewise. * dwarf2read.c (create_addrmap_from_index): Likewise. (process_psymtab_comp_unit_reader): Likewise. (add_partial_symbol): Likewise. (add_partial_subprogram): Likewise. (process_full_comp_unit): Likewise. (read_file_scope): Likewise. (read_func_scope): Likewise. Call `gdbarch_make_symbol_special'. (read_lexical_block_scope): Call `gdbarch_adjust_dwarf2_addr'. (read_call_site_scope): Likewise. (dwarf2_ranges_read): Likewise. (dwarf2_record_block_ranges): Likewise. (read_attribute_value): Likewise. (dwarf_decode_lines_1): Call `gdbarch_adjust_dwarf2_line'. (new_symbol_full): Call `gdbarch_adjust_dwarf2_addr'. * elfread.c (elf_symtab_read): Don't call `gdbarch_elf_make_msymbol_special' if unset. * mips-linux-tdep.c (micromips_linux_sigframe_validate): Strip the ISA bit from the PC. * mips-tdep.c (mips_unmake_compact_addr): New function. (mips_elf_make_msymbol_special): Set the ISA bit in the symbol's address appropriately. (mips_make_symbol_special): New function. (mips_pc_is_mips): Set the ISA bit before symbol lookup. (mips_pc_is_mips16): Likewise. (mips_pc_is_micromips): Likewise. (mips_pc_isa): Likewise. (mips_adjust_dwarf2_addr): New function. (mips_adjust_dwarf2_line): Likewise. (mips_read_pc, mips_unwind_pc): Keep the ISA bit. (mips_addr_bits_remove): Likewise. (mips_skip_trampoline_code): Likewise. (mips_write_pc): Don't set the ISA bit. (mips_eabi_push_dummy_call): Likewise. (mips_o64_push_dummy_call): Likewise. (mips_gdbarch_init): Install `mips_make_symbol_special', `mips_adjust_dwarf2_addr' and `mips_adjust_dwarf2_line' gdbarch handlers. * solib.c (gdb_bfd_lookup_symbol_from_symtab): Get target-specific symbol address adjustments. * gdbarch.h: Regenerate. * gdbarch.c: Regenerate. 2014-12-12 Maciej W. Rozycki <macro@codesourcery.com> gdb/testsuite/ * gdb.base/func-ptrs.c: New file. * gdb.base/func-ptrs.exp: New file.
2014-12-12 14:31:53 +01:00
SET_MSYMBOL_VALUE_ADDRESS (&msym, symaddr);
gdbarch_elf_make_msymbol_special (gdbarch, sym, &msym);
symaddr = MSYMBOL_VALUE_RAW_ADDRESS (&msym);
}
/* BFD symbols are section relative. */
MIPS: Keep the ISA bit in compressed code addresses 1. Background information The MIPS architecture, as originally designed and implemented in mid-1980s has a uniform instruction word size that is 4 bytes, naturally aligned. As such all MIPS instructions are located at addresses that have their bits #1 and #0 set to zeroes, and any attempt to execute an instruction from an address that has any of the two bits set to one causes an address error exception. This may for example happen when a jump-register instruction is executed whose register value used as the jump target has any of these bits set. Then in mid 1990s LSI sought a way to improve code density for their TinyRISC family of MIPS cores and invented an alternatively encoded instruction set in a joint effort with MIPS Technologies (then a subsidiary of SGI). The new instruction set has been named the MIPS16 ASE (Application-Specific Extension) and uses a variable instruction word size, which is 2 bytes (as the name of the ASE suggests) for most, but there are a couple of exceptions that take 4 bytes, and then most of the 2-byte instructions can be treated with a 2-byte extension prefix to expand the range of the immediate operands used. As a result instructions are no longer 4-byte aligned, instead they are aligned to a multiple of 2. That left the bit #0 still unused for code references, be it for the standard MIPS (i.e. as originally invented) or for the MIPS16 instruction set, and based on that observation a clever trick was invented that on one hand allowed the processor to be seamlessly switched between the two instruction sets at any time at the run time while on the other avoided the introduction of any special control register to do that. So it is the bit #0 of the instruction address that was chosen as the selector and named the ISA bit. Any instruction executed at an even address is interpreted as a standard MIPS instruction (the address still has to have its bit #1 clear), any instruction executed at an odd address is interpreted as a MIPS16 instruction. To switch between modes ordinary jump instructions are used, such as used for function calls and returns, specifically the bit #0 of the source register used in jump-register instructions selects the execution (ISA) mode for the following piece of code to be interpreted in. Additionally new jump-immediate instructions were added that flipped the ISA bit to select the opposite mode upon execution. They were considered necessary to avoid the need to make register jumps in all cases as the original jump-immediate instructions provided no way to change the bit #0 at all. This was all important for cases where standard MIPS and MIPS16 code had to be mixed, either for compatibility with the existing binary code base or to access resources not reachable from MIPS16 code (the MIPS16 instruction set only provides access to general-purpose registers, and not for example floating-point unit registers or privileged coprocessor 0 registers) -- pieces of code in the opposite mode can be executed as ordinary subroutine calls. A similar approach has been more recently adopted for the MIPS16 replacement instruction set defined as the so called microMIPS ASE. This is another instruction set encoding introduced to the MIPS architecture. Just like the MIPS16 ASE, the microMIPS instruction set uses a variable-length encoding, where each instruction takes a multiple of 2 bytes. The ISA bit has been reused and for microMIPS-capable processors selects between the standard MIPS and the microMIPS mode instead. 2. Statement of the problem To put it shortly, MIPS16 and microMIPS code pointers used by GDB are different to these observed at the run time. This results in the same expressions being evaluated producing different results in GDB and in the program being debugged. Obviously it's the results obtained at the run time that are correct (they define how the program behaves) and therefore by definition the results obtained in GDB are incorrect. A bit longer description will record that obviously at the run time the ISA bit has to be set correctly (refer to background information above if unsure why so) or the program will not run as expected. This is recorded in all the executable file structures used at the run time: the dynamic symbol table (but not always the static one!), the GOT, and obviously in all the addresses embedded in code or data of the program itself, calculated by applying the appropriate relocations at the static link time. While a program is being processed by GDB, the ISA bit is stripped off from any code addresses, presumably to make them the same as the respective raw memory byte address used by the processor to access the instruction in the instruction fetch access cycle. This stripping is actually performed outside GDB proper, in BFD, specifically _bfd_mips_elf_symbol_processing (elfxx-mips.c, see the piece of code at the very bottom of that function, starting with an: "If this is an odd-valued function symbol, assume it's a MIPS16 or microMIPS one." comment). This function is also responsible for symbol table dumps made by `objdump' too, so you'll never see the ISA bit reported there by that tool, you need to use `readelf'. This is however unlike what is ever done at the run time, the ISA bit once present is never stripped off, for example a cast like this: (short *) main will not strip the ISA bit off and if the resulting pointer is intended to be used to access instructions as data, for example for software instruction decoding (like for fault recovery or emulation in a signal handler) or for self-modifying code then the bit still has to be stripped off by an explicit AND operation. This is probably best illustrated with a simple real program example. Let's consider the following simple program: $ cat foobar.c int __attribute__ ((mips16)) foo (void) { return 1; } int __attribute__ ((mips16)) bar (void) { return 2; } int __attribute__ ((nomips16)) foo32 (void) { return 3; } int (*foo32p) (void) = foo32; int (*foop) (void) = foo; int fooi = (int) foo; int main (void) { return foop (); } $ This is plain C with no odd tricks, except from the instruction mode attributes. They are not necessary to trigger this problem, I just put them here so that the program can be contained in a single source file and to make it obvious which function is MIPS16 code and which is not. Let's try it with Linux, so that everyone can repeat this experiment: $ mips-linux-gnu-gcc -mips16 -g -O2 -o foobar foobar.c $ Let's have a look at some interesting symbols: $ mips-linux-gnu-readelf -s foobar | egrep 'table|foo|bar' Symbol table '.dynsym' contains 7 entries: Symbol table '.symtab' contains 95 entries: 55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c 66: 0040068c 4 FUNC GLOBAL DEFAULT [MIPS16] 12 bar 68: 00410848 4 OBJECT GLOBAL DEFAULT 21 foo32p 70: 00410844 4 OBJECT GLOBAL DEFAULT 21 foop 78: 00400684 8 FUNC GLOBAL DEFAULT 12 foo32 80: 00400680 4 FUNC GLOBAL DEFAULT [MIPS16] 12 foo 88: 00410840 4 OBJECT GLOBAL DEFAULT 21 fooi $ Hmm, no sight of the ISA bit, but notice how foo and bar (but not foo32!) have been marked as MIPS16 functions (ELF symbol structure's `st_other' field is used for that). So let's try to run and poke at this program with GDB. I'll be using a native system for simplicity (I'll be using ellipses here and there to remove unrelated clutter): $ ./foobar $ echo $? 1 $ So far, so good. $ gdb ./foobar [...] (gdb) break main Breakpoint 1 at 0x400490: file foobar.c, line 23. (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) Yay, it worked! OK, so let's poke at it: (gdb) print main $1 = {int (void)} 0x400490 <main> (gdb) print foo32 $2 = {int (void)} 0x400684 <foo32> (gdb) print foo32p $3 = (int (*)(void)) 0x400684 <foo32> (gdb) print bar $4 = {int (void)} 0x40068c <bar> (gdb) print foo $5 = {int (void)} 0x400680 <foo> (gdb) print foop $6 = (int (*)(void)) 0x400681 <foo> (gdb) A-ha! Here's the difference and finally the ISA bit! (gdb) print /x fooi $7 = 0x400681 (gdb) p/x $pc p/x $pc $8 = 0x400491 (gdb) And here as well... (gdb) advance foo foo () at foobar.c:4 4 } (gdb) disassemble Dump of assembler code for function foo: 0x00400680 <+0>: jr ra 0x00400682 <+2>: li v0,1 End of assembler dump. (gdb) finish Run till exit from #0 foo () at foobar.c:4 main () at foobar.c:24 24 } Value returned is $9 = 1 (gdb) continue Continuing. [Inferior 1 (process 14103) exited with code 01] (gdb) So let's be a bit inquisitive... (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) Actually we do not like to run foo here at all. Let's run bar instead! (gdb) set foop = bar (gdb) print foop $10 = (int (*)(void)) 0x40068c <bar> (gdb) Hmm, no ISA bit. Is it going to work? (gdb) advance bar bar () at foobar.c:9 9 } (gdb) p/x $pc $11 = 0x40068c (gdb) disassemble Dump of assembler code for function bar: => 0x0040068c <+0>: jr ra 0x0040068e <+2>: li v0,2 End of assembler dump. (gdb) finish Run till exit from #0 bar () at foobar.c:9 Program received signal SIGILL, Illegal instruction. bar () at foobar.c:9 9 } (gdb) Oops! (gdb) p/x $pc $12 = 0x40068c (gdb) We're still there! (gdb) continue Continuing. Program terminated with signal SIGILL, Illegal instruction. The program no longer exists. (gdb) So let's try something else: (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) set foop = foo (gdb) advance foo foo () at foobar.c:4 4 } (gdb) disassemble Dump of assembler code for function foo: => 0x00400680 <+0>: jr ra 0x00400682 <+2>: li v0,1 End of assembler dump. (gdb) finish Run till exit from #0 foo () at foobar.c:4 Program received signal SIGILL, Illegal instruction. foo () at foobar.c:4 4 } (gdb) continue Continuing. Program terminated with signal SIGILL, Illegal instruction. The program no longer exists. (gdb) The same problem! (gdb) run Starting program: /net/build2-lucid-cs/scratch/macro/mips-linux-fsf-gcc/isa-bit/foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) set foop = foo32 (gdb) advance foo32 foo32 () at foobar.c:14 14 } (gdb) disassemble Dump of assembler code for function foo32: => 0x00400684 <+0>: jr ra 0x00400688 <+4>: li v0,3 End of assembler dump. (gdb) finish Run till exit from #0 foo32 () at foobar.c:14 main () at foobar.c:24 24 } Value returned is $14 = 3 (gdb) continue Continuing. [Inferior 1 (process 14113) exited with code 03] (gdb) That did work though, so it's the ISA bit only! (gdb) quit Enough! That's the tip of the iceberg only though. So let's rebuild the executable with some dynamic symbols: $ mips-linux-gnu-gcc -mips16 -Wl,--export-dynamic -g -O2 -o foobar-dyn foobar.c $ mips-linux-gnu-readelf -s foobar-dyn | egrep 'table|foo|bar' Symbol table '.dynsym' contains 32 entries: 6: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar 8: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p 9: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop 15: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32 17: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo 25: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi Symbol table '.symtab' contains 95 entries: 55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c 69: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar 71: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p 72: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop 79: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32 81: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo 89: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi $ OK, now the ISA bit is there for a change, but the MIPS16 `st_other' attribute gone, hmm... What does `objdump' do then: $ mips-linux-gnu-objdump -Tt foobar-dyn | egrep 'SYMBOL|foo|bar' foobar-dyn: file format elf32-tradbigmips SYMBOL TABLE: 00000000 l df *ABS* 00000000 foobar.c 004009cc g F .text 00000004 0xf0 bar 00410b88 g O .data 00000004 foo32p 00410b84 g O .data 00000004 foop 004009c4 g F .text 00000008 foo32 004009c0 g F .text 00000004 0xf0 foo 00410b80 g O .data 00000004 fooi DYNAMIC SYMBOL TABLE: 004009cc g DF .text 00000004 Base 0xf0 bar 00410b88 g DO .data 00000004 Base foo32p 00410b84 g DO .data 00000004 Base foop 004009c4 g DF .text 00000008 Base foo32 004009c0 g DF .text 00000004 Base 0xf0 foo 00410b80 g DO .data 00000004 Base fooi $ Hmm, the attribute (0xf0, printed raw) is back, and the ISA bit gone again. Let's have a look at some DWARF-2 records GDB uses (I'll be stripping off a lot here for brevity) -- debug info: $ mips-linux-gnu-readelf -wi foobar Contents of the .debug_info section: [...] Compilation Unit @ offset 0x88: Length: 0xbb (32-bit) Version: 4 Abbrev Offset: 62 Pointer Size: 4 <0><93>: Abbrev Number: 1 (DW_TAG_compile_unit) <94> DW_AT_producer : (indirect string, offset: 0x19e): GNU C 4.8.0 20120513 (experimental) -meb -mips16 -march=mips32r2 -mhard-float -mllsc -mplt -mno-synci -mno-shared -mabi=32 -g -O2 <98> DW_AT_language : 1 (ANSI C) <99> DW_AT_name : (indirect string, offset: 0x190): foobar.c <9d> DW_AT_comp_dir : (indirect string, offset: 0x225): [...] <a1> DW_AT_ranges : 0x0 <a5> DW_AT_low_pc : 0x0 <a9> DW_AT_stmt_list : 0x27 <1><ad>: Abbrev Number: 2 (DW_TAG_subprogram) <ae> DW_AT_external : 1 <ae> DW_AT_name : foo <b2> DW_AT_decl_file : 1 <b3> DW_AT_decl_line : 1 <b4> DW_AT_prototyped : 1 <b4> DW_AT_type : <0xc2> <b8> DW_AT_low_pc : 0x400680 <bc> DW_AT_high_pc : 0x400684 <c0> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <c2> DW_AT_GNU_all_call_sites: 1 <1><c2>: Abbrev Number: 3 (DW_TAG_base_type) <c3> DW_AT_byte_size : 4 <c4> DW_AT_encoding : 5 (signed) <c5> DW_AT_name : int <1><c9>: Abbrev Number: 4 (DW_TAG_subprogram) <ca> DW_AT_external : 1 <ca> DW_AT_name : (indirect string, offset: 0x18a): foo32 <ce> DW_AT_decl_file : 1 <cf> DW_AT_decl_line : 11 <d0> DW_AT_prototyped : 1 <d0> DW_AT_type : <0xc2> <d4> DW_AT_low_pc : 0x400684 <d8> DW_AT_high_pc : 0x40068c <dc> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <de> DW_AT_GNU_all_call_sites: 1 <1><de>: Abbrev Number: 2 (DW_TAG_subprogram) <df> DW_AT_external : 1 <df> DW_AT_name : bar <e3> DW_AT_decl_file : 1 <e4> DW_AT_decl_line : 6 <e5> DW_AT_prototyped : 1 <e5> DW_AT_type : <0xc2> <e9> DW_AT_low_pc : 0x40068c <ed> DW_AT_high_pc : 0x400690 <f1> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <f3> DW_AT_GNU_all_call_sites: 1 <1><f3>: Abbrev Number: 5 (DW_TAG_subprogram) <f4> DW_AT_external : 1 <f4> DW_AT_name : (indirect string, offset: 0x199): main <f8> DW_AT_decl_file : 1 <f9> DW_AT_decl_line : 21 <fa> DW_AT_prototyped : 1 <fa> DW_AT_type : <0xc2> <fe> DW_AT_low_pc : 0x400490 <102> DW_AT_high_pc : 0x4004a4 <106> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <108> DW_AT_GNU_all_tail_call_sites: 1 [...] $ -- no sign of the ISA bit anywhere -- frame info: $ mips-linux-gnu-readelf -wf foobar [...] Contents of the .debug_frame section: 00000000 0000000c ffffffff CIE Version: 1 Augmentation: "" Code alignment factor: 1 Data alignment factor: -4 Return address column: 31 DW_CFA_def_cfa_register: r29 DW_CFA_nop 00000010 0000000c 00000000 FDE cie=00000000 pc=00400680..00400684 00000020 0000000c 00000000 FDE cie=00000000 pc=00400684..0040068c 00000030 0000000c 00000000 FDE cie=00000000 pc=0040068c..00400690 00000040 00000018 00000000 FDE cie=00000000 pc=00400490..004004a4 DW_CFA_advance_loc: 6 to 00400496 DW_CFA_def_cfa_offset: 32 DW_CFA_offset: r31 at cfa-4 DW_CFA_advance_loc: 6 to 0040049c DW_CFA_restore: r31 DW_CFA_def_cfa_offset: 0 DW_CFA_nop DW_CFA_nop DW_CFA_nop [...] $ -- no sign of the ISA bit anywhere -- range info (GDB doesn't use arange): $ mips-linux-gnu-readelf -wR foobar Contents of the .debug_ranges section: Offset Begin End 00000000 00400680 00400690 00000000 00400490 004004a4 00000000 <End of list> $ -- no sign of the ISA bit anywhere -- line info: $ mips-linux-gnu-readelf -wl foobar Raw dump of debug contents of section .debug_line: [...] Offset: 0x27 Length: 78 DWARF Version: 2 Prologue Length: 31 Minimum Instruction Length: 1 Initial value of 'is_stmt': 1 Line Base: -5 Line Range: 14 Opcode Base: 13 Opcodes: Opcode 1 has 0 args Opcode 2 has 1 args Opcode 3 has 1 args Opcode 4 has 1 args Opcode 5 has 1 args Opcode 6 has 0 args Opcode 7 has 0 args Opcode 8 has 0 args Opcode 9 has 1 args Opcode 10 has 0 args Opcode 11 has 0 args Opcode 12 has 1 args The Directory Table is empty. The File Name Table: Entry Dir Time Size Name 1 0 0 0 foobar.c Line Number Statements: Extended opcode 2: set Address to 0x400681 Special opcode 6: advance Address by 0 to 0x400681 and Line by 1 to 2 Special opcode 7: advance Address by 0 to 0x400681 and Line by 2 to 4 Special opcode 55: advance Address by 3 to 0x400684 and Line by 8 to 12 Special opcode 7: advance Address by 0 to 0x400684 and Line by 2 to 14 Advance Line by -7 to 7 Special opcode 131: advance Address by 9 to 0x40068d and Line by 0 to 7 Special opcode 7: advance Address by 0 to 0x40068d and Line by 2 to 9 Advance PC by 3 to 0x400690 Extended opcode 1: End of Sequence Extended opcode 2: set Address to 0x400491 Advance Line by 21 to 22 Copy Special opcode 6: advance Address by 0 to 0x400491 and Line by 1 to 23 Special opcode 60: advance Address by 4 to 0x400495 and Line by -1 to 22 Special opcode 34: advance Address by 2 to 0x400497 and Line by 1 to 23 Special opcode 62: advance Address by 4 to 0x40049b and Line by 1 to 24 Special opcode 32: advance Address by 2 to 0x40049d and Line by -1 to 23 Special opcode 6: advance Address by 0 to 0x40049d and Line by 1 to 24 Advance PC by 7 to 0x4004a4 Extended opcode 1: End of Sequence [...] -- a-ha, the ISA bit is there! However it's not always right for some reason, I don't have a small test case to show it, but here's an excerpt from MIPS16 libc, a prologue of a function: 00019630 <__libc_init_first>: 19630: e8a0 jrc ra 19632: 6500 nop 00019634 <_init>: 19634: f000 6a11 li v0,17 19638: f7d8 0b08 la v1,15e00 <_DYNAMIC+0x15c54> 1963c: f400 3240 sll v0,16 19640: e269 addu v0,v1 19642: 659a move gp,v0 19644: 64f6 save 48,ra,s0-s1 19646: 671c move s0,gp 19648: d204 sw v0,16(sp) 1964a: f352 984c lw v0,-27828(s0) 1964e: 6724 move s1,a0 and the corresponding DWARF-2 line info: Line Number Statements: Extended opcode 2: set Address to 0x19631 Advance Line by 44 to 45 Copy Special opcode 8: advance Address by 0 to 0x19631 and Line by 3 to 48 Special opcode 66: advance Address by 4 to 0x19635 and Line by 5 to 53 Advance PC by constant 17 to 0x19646 Special opcode 25: advance Address by 1 to 0x19647 and Line by 6 to 59 Advance Line by -6 to 53 Special opcode 33: advance Address by 2 to 0x19649 and Line by 0 to 53 Special opcode 39: advance Address by 2 to 0x1964b and Line by 6 to 59 Advance Line by -6 to 53 Special opcode 61: advance Address by 4 to 0x1964f and Line by 0 to 53 -- see that "Advance PC by constant 17" there? It clears the ISA bit, however code at 0x19646 is not standard MIPS code at all. For some reason the constant is always 17, I've never seen DW_LNS_const_add_pc used with any other value -- is that a binutils bug or what? 3. Solution: I think we should retain the value of the ISA bit in code references, that is effectively treat them as cookies as they indeed are (although trivially calculated) rather than raw memory byte addresses. In a perfect world both the static symbol table and the respective DWARF-2 records should be fixed to include the ISA bit in all the cases. I think however that this is infeasible. All the uses of `_bfd_mips_elf_symbol_processing' can not necessarily be tracked down. This function is used by `elf_slurp_symbol_table' that in turn is used by `bfd_canonicalize_symtab' and `bfd_canonicalize_dynamic_symtab', which are public interfaces. Similarly DWARF-2 records are used outside GDB, one notable if a bit questionable is the exception unwinder (libgcc/unwind-dw2.c) -- I have identified at least bits in `execute_cfa_program' and `uw_frame_state_for', both around the calls to `_Unwind_IsSignalFrame', that would need an update as they effectively flip the ISA bit freely; see also the comment about MASK_RETURN_ADDR in gcc/config/mips/mips.h. But there may be more places. Any change in how DWARF-2 records are produced would require an update there and would cause compatibility problems with libgcc.a binaries already distributed; given that this is a static library a complex change involving function renames would likely be required. I propose therefore to accept the existing inconsistencies and deal with them entirely within GDB. I have figured out that the ISA bit lost in various places can still be recovered as long as we have symbol information -- that'll have the `st_other' attribute correctly set to one of standard MIPS/MIPS16/microMIPS encoding. Here's the resulting change. It adds a couple of new `gdbarch' hooks, one to update symbol information with the ISA bit lost in `_bfd_mips_elf_symbol_processing', and two other ones to adjust DWARF-2 records as they're processed. The ISA bit is set in each address handled according to information retrieved from the symbol table for the symbol spanning the address if any; limits are adjusted based on the address they point to related to the respective base address. Additionally minimal symbol information has to be adjusted accordingly in its gdbarch hook. With these changes in place some complications with ISA bit juggling in the PC that never fully worked can be removed from the MIPS backend. Conversely, the generic dynamic linker event special breakpoint symbol handler has to be updated to call the minimal symbol gdbarch hook to record that the symbol is a MIPS16 or microMIPS address if applicable or the breakpoint will be set at the wrong address and either fail to work or cause SIGTRAPs (this is because the symbol is handled early on and bypasses regular symbol processing). 4. Results obtained The change fixes the example above -- to repeat only the crucial steps: (gdb) break main Breakpoint 1 at 0x400491: file foobar.c, line 23. (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) print foo $1 = {int (void)} 0x400681 <foo> (gdb) set foop = bar (gdb) advance bar bar () at foobar.c:9 9 } (gdb) disassemble Dump of assembler code for function bar: => 0x0040068d <+0>: jr ra 0x0040068f <+2>: li v0,2 End of assembler dump. (gdb) finish Run till exit from #0 bar () at foobar.c:9 main () at foobar.c:24 24 } Value returned is $2 = 2 (gdb) continue Continuing. [Inferior 1 (process 14128) exited with code 02] (gdb) -- excellent! The change removes about 90 failures per MIPS16 multilib in mips-sde-elf testing too, results for MIPS16 are now similar to that for standard MIPS; microMIPS results are a bit worse because of host-I/O problems in QEMU used instead of MIPSsim for microMIPS testing only: === gdb Summary === # of expected passes 14299 # of unexpected failures 187 # of expected failures 56 # of known failures 58 # of unresolved testcases 11 # of untested testcases 52 # of unsupported tests 174 MIPS16: === gdb Summary === # of expected passes 14298 # of unexpected failures 187 # of unexpected successes 2 # of expected failures 54 # of known failures 58 # of unresolved testcases 12 # of untested testcases 52 # of unsupported tests 174 microMIPS: === gdb Summary === # of expected passes 14149 # of unexpected failures 201 # of unexpected successes 2 # of expected failures 54 # of known failures 58 # of unresolved testcases 7 # of untested testcases 53 # of unsupported tests 175 2014-12-12 Maciej W. Rozycki <macro@codesourcery.com> Maciej W. Rozycki <macro@mips.com> Pedro Alves <pedro@codesourcery.com> gdb/ * gdbarch.sh (elf_make_msymbol_special): Change type to `F', remove `predefault' and `invalid_p' initializers. (make_symbol_special): New architecture method. (adjust_dwarf2_addr, adjust_dwarf2_line): Likewise. (objfile, symbol): New declarations. * arch-utils.h (default_elf_make_msymbol_special): Remove prototype. (default_make_symbol_special): New prototype. (default_adjust_dwarf2_addr): Likewise. (default_adjust_dwarf2_line): Likewise. * mips-tdep.h (mips_unmake_compact_addr): New prototype. * arch-utils.c (default_elf_make_msymbol_special): Remove function. (default_make_symbol_special): New function. (default_adjust_dwarf2_addr): Likewise. (default_adjust_dwarf2_line): Likewise. * dwarf2-frame.c (decode_frame_entry_1): Call `gdbarch_adjust_dwarf2_addr'. * dwarf2loc.c (dwarf2_find_location_expression): Likewise. * dwarf2read.c (create_addrmap_from_index): Likewise. (process_psymtab_comp_unit_reader): Likewise. (add_partial_symbol): Likewise. (add_partial_subprogram): Likewise. (process_full_comp_unit): Likewise. (read_file_scope): Likewise. (read_func_scope): Likewise. Call `gdbarch_make_symbol_special'. (read_lexical_block_scope): Call `gdbarch_adjust_dwarf2_addr'. (read_call_site_scope): Likewise. (dwarf2_ranges_read): Likewise. (dwarf2_record_block_ranges): Likewise. (read_attribute_value): Likewise. (dwarf_decode_lines_1): Call `gdbarch_adjust_dwarf2_line'. (new_symbol_full): Call `gdbarch_adjust_dwarf2_addr'. * elfread.c (elf_symtab_read): Don't call `gdbarch_elf_make_msymbol_special' if unset. * mips-linux-tdep.c (micromips_linux_sigframe_validate): Strip the ISA bit from the PC. * mips-tdep.c (mips_unmake_compact_addr): New function. (mips_elf_make_msymbol_special): Set the ISA bit in the symbol's address appropriately. (mips_make_symbol_special): New function. (mips_pc_is_mips): Set the ISA bit before symbol lookup. (mips_pc_is_mips16): Likewise. (mips_pc_is_micromips): Likewise. (mips_pc_isa): Likewise. (mips_adjust_dwarf2_addr): New function. (mips_adjust_dwarf2_line): Likewise. (mips_read_pc, mips_unwind_pc): Keep the ISA bit. (mips_addr_bits_remove): Likewise. (mips_skip_trampoline_code): Likewise. (mips_write_pc): Don't set the ISA bit. (mips_eabi_push_dummy_call): Likewise. (mips_o64_push_dummy_call): Likewise. (mips_gdbarch_init): Install `mips_make_symbol_special', `mips_adjust_dwarf2_addr' and `mips_adjust_dwarf2_line' gdbarch handlers. * solib.c (gdb_bfd_lookup_symbol_from_symtab): Get target-specific symbol address adjustments. * gdbarch.h: Regenerate. * gdbarch.c: Regenerate. 2014-12-12 Maciej W. Rozycki <macro@codesourcery.com> gdb/testsuite/ * gdb.base/func-ptrs.c: New file. * gdb.base/func-ptrs.exp: New file.
2014-12-12 14:31:53 +01:00
symaddr += sym->section->vma;
break;
}
}
}
return symaddr;
}
/* Lookup the value for a specific symbol from symbol table. Look up symbol
from ABFD. MATCH_SYM is a callback function to determine whether to pick
up a symbol. DATA is the input of this callback function. Return NULL
if symbol is not found. */
static CORE_ADDR
bfd_lookup_symbol_from_dyn_symtab (bfd *abfd,
int (*match_sym) (const asymbol *,
const void *),
const void *data)
{
long storage_needed = bfd_get_dynamic_symtab_upper_bound (abfd);
CORE_ADDR symaddr = 0;
if (storage_needed > 0)
{
unsigned int i;
gdb::def_vector<asymbol *> storage (storage_needed / sizeof (asymbol *));
asymbol **symbol_table = storage.data ();
unsigned int number_of_symbols =
bfd_canonicalize_dynamic_symtab (abfd, symbol_table);
for (i = 0; i < number_of_symbols; i++)
{
asymbol *sym = *symbol_table++;
if (match_sym (sym, data))
{
/* BFD symbols are section relative. */
symaddr = sym->value + sym->section->vma;
break;
}
}
}
return symaddr;
}
/* Lookup the value for a specific symbol from symbol table and dynamic
symbol table. Look up symbol from ABFD. MATCH_SYM is a callback
function to determine whether to pick up a symbol. DATA is the
input of this callback function. Return NULL if symbol is not
found. */
CORE_ADDR
gdb_bfd_lookup_symbol (bfd *abfd,
int (*match_sym) (const asymbol *, const void *),
const void *data)
{
CORE_ADDR symaddr = gdb_bfd_lookup_symbol_from_symtab (abfd, match_sym, data);
/* On FreeBSD, the dynamic linker is stripped by default. So we'll
have to check the dynamic string table too. */
if (symaddr == 0)
symaddr = bfd_lookup_symbol_from_dyn_symtab (abfd, match_sym, data);
return symaddr;
}
/* The shared library list may contain user-loaded object files that
can be removed out-of-band by the user. So upon notification of
free_objfile remove all references to any user-loaded file that is
about to be freed. */
static void
remove_user_added_objfile (struct objfile *objfile)
{
if (objfile != 0 && objfile->flags & OBJF_USERLOADED)
{
for (struct so_list *so : current_program_space->solibs ())
if (so->objfile == objfile)
so->objfile = NULL;
}
}
gdb: add back declarations for _initialize functions I'd like to enable the -Wmissing-declarations warning. However, it warns for every _initialize function, for example: CXX dcache.o /home/smarchi/src/binutils-gdb/gdb/dcache.c: In function ‘void _initialize_dcache()’: /home/smarchi/src/binutils-gdb/gdb/dcache.c:688:1: error: no previous declaration for ‘void _initialize_dcache()’ [-Werror=missing-declarations] _initialize_dcache (void) ^~~~~~~~~~~~~~~~~~ The only practical way forward I found is to add back the declarations, which were removed by this commit: commit 481695ed5f6e0a8a9c9c50bfac1cdd2b3151e6c9 Author: John Baldwin <jhb@FreeBSD.org> Date: Sat Sep 9 11:02:37 2017 -0700 Remove unnecessary function prototypes. I don't think it's a big problem to have the declarations for these functions, but if anybody has a better solution for this, I'll be happy to use it. gdb/ChangeLog: * aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Add declaration. * aarch64-fbsd-tdep.c (_initialize_aarch64_fbsd_tdep): Add declaration. * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Add declaration. * aarch64-linux-tdep.c (_initialize_aarch64_linux_tdep): Add declaration. * aarch64-newlib-tdep.c (_initialize_aarch64_newlib_tdep): Add declaration. * aarch64-tdep.c (_initialize_aarch64_tdep): Add declaration. * ada-exp.y (_initialize_ada_exp): Add declaration. * ada-lang.c (_initialize_ada_language): Add declaration. * ada-tasks.c (_initialize_tasks): Add declaration. * agent.c (_initialize_agent): Add declaration. * aix-thread.c (_initialize_aix_thread): Add declaration. * alpha-bsd-nat.c (_initialize_alphabsd_nat): Add declaration. * alpha-linux-nat.c (_initialize_alpha_linux_nat): Add declaration. * alpha-linux-tdep.c (_initialize_alpha_linux_tdep): Add declaration. * alpha-nbsd-tdep.c (_initialize_alphanbsd_tdep): Add declaration. * alpha-obsd-tdep.c (_initialize_alphaobsd_tdep): Add declaration. * alpha-tdep.c (_initialize_alpha_tdep): Add declaration. * amd64-darwin-tdep.c (_initialize_amd64_darwin_tdep): Add declaration. * amd64-dicos-tdep.c (_initialize_amd64_dicos_tdep): Add declaration. * amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Add declaration. * amd64-fbsd-tdep.c (_initialize_amd64fbsd_tdep): Add declaration. * amd64-linux-nat.c (_initialize_amd64_linux_nat): Add declaration. * amd64-linux-tdep.c (_initialize_amd64_linux_tdep): Add declaration. * amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Add declaration. * amd64-nbsd-tdep.c (_initialize_amd64nbsd_tdep): Add declaration. * amd64-obsd-nat.c (_initialize_amd64obsd_nat): Add declaration. * amd64-obsd-tdep.c (_initialize_amd64obsd_tdep): Add declaration. * amd64-sol2-tdep.c (_initialize_amd64_sol2_tdep): Add declaration. * amd64-tdep.c (_initialize_amd64_tdep): Add declaration. * amd64-windows-nat.c (_initialize_amd64_windows_nat): Add declaration. * amd64-windows-tdep.c (_initialize_amd64_windows_tdep): Add declaration. * annotate.c (_initialize_annotate): Add declaration. * arc-newlib-tdep.c (_initialize_arc_newlib_tdep): Add declaration. * arc-tdep.c (_initialize_arc_tdep): Add declaration. * arch-utils.c (_initialize_gdbarch_utils): Add declaration. * arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Add declaration. * arm-fbsd-tdep.c (_initialize_arm_fbsd_tdep): Add declaration. * arm-linux-nat.c (_initialize_arm_linux_nat): Add declaration. * arm-linux-tdep.c (_initialize_arm_linux_tdep): Add declaration. * arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Add declaration. * arm-nbsd-tdep.c (_initialize_arm_netbsd_tdep): Add declaration. * arm-obsd-tdep.c (_initialize_armobsd_tdep): Add declaration. * arm-pikeos-tdep.c (_initialize_arm_pikeos_tdep): Add declaration. * arm-symbian-tdep.c (_initialize_arm_symbian_tdep): Add declaration. * arm-tdep.c (_initialize_arm_tdep): Add declaration. * arm-wince-tdep.c (_initialize_arm_wince_tdep): Add declaration. * auto-load.c (_initialize_auto_load): Add declaration. * auxv.c (_initialize_auxv): Add declaration. * avr-tdep.c (_initialize_avr_tdep): Add declaration. * ax-gdb.c (_initialize_ax_gdb): Add declaration. * bfin-linux-tdep.c (_initialize_bfin_linux_tdep): Add declaration. * bfin-tdep.c (_initialize_bfin_tdep): Add declaration. * break-catch-sig.c (_initialize_break_catch_sig): Add declaration. * break-catch-syscall.c (_initialize_break_catch_syscall): Add declaration. * break-catch-throw.c (_initialize_break_catch_throw): Add declaration. * breakpoint.c (_initialize_breakpoint): Add declaration. * bsd-uthread.c (_initialize_bsd_uthread): Add declaration. * btrace.c (_initialize_btrace): Add declaration. * charset.c (_initialize_charset): Add declaration. * cli/cli-cmds.c (_initialize_cli_cmds): Add declaration. * cli/cli-dump.c (_initialize_cli_dump): Add declaration. * cli/cli-interp.c (_initialize_cli_interp): Add declaration. * cli/cli-logging.c (_initialize_cli_logging): Add declaration. * cli/cli-script.c (_initialize_cli_script): Add declaration. * cli/cli-style.c (_initialize_cli_style): Add declaration. * coff-pe-read.c (_initialize_coff_pe_read): Add declaration. * coffread.c (_initialize_coffread): Add declaration. * compile/compile-cplus-types.c (_initialize_compile_cplus_types): Add declaration. * compile/compile.c (_initialize_compile): Add declaration. * complaints.c (_initialize_complaints): Add declaration. * completer.c (_initialize_completer): Add declaration. * copying.c (_initialize_copying): Add declaration. * corefile.c (_initialize_core): Add declaration. * corelow.c (_initialize_corelow): Add declaration. * cp-abi.c (_initialize_cp_abi): Add declaration. * cp-namespace.c (_initialize_cp_namespace): Add declaration. * cp-support.c (_initialize_cp_support): Add declaration. * cp-valprint.c (_initialize_cp_valprint): Add declaration. * cris-linux-tdep.c (_initialize_cris_linux_tdep): Add declaration. * cris-tdep.c (_initialize_cris_tdep): Add declaration. * csky-linux-tdep.c (_initialize_csky_linux_tdep): Add declaration. * csky-tdep.c (_initialize_csky_tdep): Add declaration. * ctfread.c (_initialize_ctfread): Add declaration. * d-lang.c (_initialize_d_language): Add declaration. * darwin-nat-info.c (_initialize_darwin_info_commands): Add declaration. * darwin-nat.c (_initialize_darwin_nat): Add declaration. * dbxread.c (_initialize_dbxread): Add declaration. * dcache.c (_initialize_dcache): Add declaration. * disasm-selftests.c (_initialize_disasm_selftests): Add declaration. * disasm.c (_initialize_disasm): Add declaration. * dtrace-probe.c (_initialize_dtrace_probe): Add declaration. * dummy-frame.c (_initialize_dummy_frame): Add declaration. * dwarf-index-cache.c (_initialize_index_cache): Add declaration. * dwarf-index-write.c (_initialize_dwarf_index_write): Add declaration. * dwarf2-frame-tailcall.c (_initialize_tailcall_frame): Add declaration. * dwarf2-frame.c (_initialize_dwarf2_frame): Add declaration. * dwarf2expr.c (_initialize_dwarf2expr): Add declaration. * dwarf2loc.c (_initialize_dwarf2loc): Add declaration. * dwarf2read.c (_initialize_dwarf2_read): Add declaration. * elfread.c (_initialize_elfread): Add declaration. * exec.c (_initialize_exec): Add declaration. * extension.c (_initialize_extension): Add declaration. * f-lang.c (_initialize_f_language): Add declaration. * f-valprint.c (_initialize_f_valprint): Add declaration. * fbsd-nat.c (_initialize_fbsd_nat): Add declaration. * fbsd-tdep.c (_initialize_fbsd_tdep): Add declaration. * filesystem.c (_initialize_filesystem): Add declaration. * findcmd.c (_initialize_mem_search): Add declaration. * findvar.c (_initialize_findvar): Add declaration. * fork-child.c (_initialize_fork_child): Add declaration. * frame-base.c (_initialize_frame_base): Add declaration. * frame-unwind.c (_initialize_frame_unwind): Add declaration. * frame.c (_initialize_frame): Add declaration. * frv-linux-tdep.c (_initialize_frv_linux_tdep): Add declaration. * frv-tdep.c (_initialize_frv_tdep): Add declaration. * ft32-tdep.c (_initialize_ft32_tdep): Add declaration. * gcore.c (_initialize_gcore): Add declaration. * gdb-demangle.c (_initialize_gdb_demangle): Add declaration. * gdb_bfd.c (_initialize_gdb_bfd): Add declaration. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Add declaration. * gdbarch.c (_initialize_gdbarch): Add declaration. * gdbtypes.c (_initialize_gdbtypes): Add declaration. * gnu-nat.c (_initialize_gnu_nat): Add declaration. * gnu-v2-abi.c (_initialize_gnu_v2_abi): Add declaration. * gnu-v3-abi.c (_initialize_gnu_v3_abi): Add declaration. * go-lang.c (_initialize_go_language): Add declaration. * go32-nat.c (_initialize_go32_nat): Add declaration. * guile/guile.c (_initialize_guile): Add declaration. * h8300-tdep.c (_initialize_h8300_tdep): Add declaration. * hppa-linux-nat.c (_initialize_hppa_linux_nat): Add declaration. * hppa-linux-tdep.c (_initialize_hppa_linux_tdep): Add declaration. * hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Add declaration. * hppa-nbsd-tdep.c (_initialize_hppanbsd_tdep): Add declaration. * hppa-obsd-nat.c (_initialize_hppaobsd_nat): Add declaration. * hppa-obsd-tdep.c (_initialize_hppabsd_tdep): Add declaration. * hppa-tdep.c (_initialize_hppa_tdep): Add declaration. * i386-bsd-nat.c (_initialize_i386bsd_nat): Add declaration. * i386-cygwin-tdep.c (_initialize_i386_cygwin_tdep): Add declaration. * i386-darwin-nat.c (_initialize_i386_darwin_nat): Add declaration. * i386-darwin-tdep.c (_initialize_i386_darwin_tdep): Add declaration. * i386-dicos-tdep.c (_initialize_i386_dicos_tdep): Add declaration. * i386-fbsd-nat.c (_initialize_i386fbsd_nat): Add declaration. * i386-fbsd-tdep.c (_initialize_i386fbsd_tdep): Add declaration. * i386-gnu-nat.c (_initialize_i386gnu_nat): Add declaration. * i386-gnu-tdep.c (_initialize_i386gnu_tdep): Add declaration. * i386-go32-tdep.c (_initialize_i386_go32_tdep): Add declaration. * i386-linux-nat.c (_initialize_i386_linux_nat): Add declaration. * i386-linux-tdep.c (_initialize_i386_linux_tdep): Add declaration. * i386-nbsd-nat.c (_initialize_i386nbsd_nat): Add declaration. * i386-nbsd-tdep.c (_initialize_i386nbsd_tdep): Add declaration. * i386-nto-tdep.c (_initialize_i386nto_tdep): Add declaration. * i386-obsd-nat.c (_initialize_i386obsd_nat): Add declaration. * i386-obsd-tdep.c (_initialize_i386obsd_tdep): Add declaration. * i386-sol2-nat.c (_initialize_amd64_sol2_nat): Add declaration. * i386-sol2-tdep.c (_initialize_i386_sol2_tdep): Add declaration. * i386-tdep.c (_initialize_i386_tdep): Add declaration. * i386-windows-nat.c (_initialize_i386_windows_nat): Add declaration. * ia64-libunwind-tdep.c (_initialize_libunwind_frame): Add declaration. * ia64-linux-nat.c (_initialize_ia64_linux_nat): Add declaration. * ia64-linux-tdep.c (_initialize_ia64_linux_tdep): Add declaration. * ia64-tdep.c (_initialize_ia64_tdep): Add declaration. * ia64-vms-tdep.c (_initialize_ia64_vms_tdep): Add declaration. * infcall.c (_initialize_infcall): Add declaration. * infcmd.c (_initialize_infcmd): Add declaration. * inflow.c (_initialize_inflow): Add declaration. * infrun.c (_initialize_infrun): Add declaration. * interps.c (_initialize_interpreter): Add declaration. * iq2000-tdep.c (_initialize_iq2000_tdep): Add declaration. * jit.c (_initialize_jit): Add declaration. * language.c (_initialize_language): Add declaration. * linux-fork.c (_initialize_linux_fork): Add declaration. * linux-nat.c (_initialize_linux_nat): Add declaration. * linux-tdep.c (_initialize_linux_tdep): Add declaration. * linux-thread-db.c (_initialize_thread_db): Add declaration. * lm32-tdep.c (_initialize_lm32_tdep): Add declaration. * m2-lang.c (_initialize_m2_language): Add declaration. * m32c-tdep.c (_initialize_m32c_tdep): Add declaration. * m32r-linux-nat.c (_initialize_m32r_linux_nat): Add declaration. * m32r-linux-tdep.c (_initialize_m32r_linux_tdep): Add declaration. * m32r-tdep.c (_initialize_m32r_tdep): Add declaration. * m68hc11-tdep.c (_initialize_m68hc11_tdep): Add declaration. * m68k-bsd-nat.c (_initialize_m68kbsd_nat): Add declaration. * m68k-bsd-tdep.c (_initialize_m68kbsd_tdep): Add declaration. * m68k-linux-nat.c (_initialize_m68k_linux_nat): Add declaration. * m68k-linux-tdep.c (_initialize_m68k_linux_tdep): Add declaration. * m68k-tdep.c (_initialize_m68k_tdep): Add declaration. * machoread.c (_initialize_machoread): Add declaration. * macrocmd.c (_initialize_macrocmd): Add declaration. * macroscope.c (_initialize_macroscope): Add declaration. * maint-test-options.c (_initialize_maint_test_options): Add declaration. * maint-test-settings.c (_initialize_maint_test_settings): Add declaration. * maint.c (_initialize_maint_cmds): Add declaration. * mdebugread.c (_initialize_mdebugread): Add declaration. * memattr.c (_initialize_mem): Add declaration. * mep-tdep.c (_initialize_mep_tdep): Add declaration. * mi/mi-cmd-env.c (_initialize_mi_cmd_env): Add declaration. * mi/mi-cmds.c (_initialize_mi_cmds): Add declaration. * mi/mi-interp.c (_initialize_mi_interp): Add declaration. * mi/mi-main.c (_initialize_mi_main): Add declaration. * microblaze-linux-tdep.c (_initialize_microblaze_linux_tdep): Add declaration. * microblaze-tdep.c (_initialize_microblaze_tdep): Add declaration. * mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Add declaration. * mips-fbsd-tdep.c (_initialize_mips_fbsd_tdep): Add declaration. * mips-linux-nat.c (_initialize_mips_linux_nat): Add declaration. * mips-linux-tdep.c (_initialize_mips_linux_tdep): Add declaration. * mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Add declaration. * mips-nbsd-tdep.c (_initialize_mipsnbsd_tdep): Add declaration. * mips-sde-tdep.c (_initialize_mips_sde_tdep): Add declaration. * mips-tdep.c (_initialize_mips_tdep): Add declaration. * mips64-obsd-nat.c (_initialize_mips64obsd_nat): Add declaration. * mips64-obsd-tdep.c (_initialize_mips64obsd_tdep): Add declaration. * mipsread.c (_initialize_mipsread): Add declaration. * mn10300-linux-tdep.c (_initialize_mn10300_linux_tdep): Add declaration. * mn10300-tdep.c (_initialize_mn10300_tdep): Add declaration. * moxie-tdep.c (_initialize_moxie_tdep): Add declaration. * msp430-tdep.c (_initialize_msp430_tdep): Add declaration. * nds32-tdep.c (_initialize_nds32_tdep): Add declaration. * nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Add declaration. * nios2-tdep.c (_initialize_nios2_tdep): Add declaration. * nto-procfs.c (_initialize_procfs): Add declaration. * objc-lang.c (_initialize_objc_language): Add declaration. * observable.c (_initialize_observer): Add declaration. * opencl-lang.c (_initialize_opencl_language): Add declaration. * or1k-linux-tdep.c (_initialize_or1k_linux_tdep): Add declaration. * or1k-tdep.c (_initialize_or1k_tdep): Add declaration. * osabi.c (_initialize_gdb_osabi): Add declaration. * osdata.c (_initialize_osdata): Add declaration. * p-valprint.c (_initialize_pascal_valprint): Add declaration. * parse.c (_initialize_parse): Add declaration. * ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Add declaration. * ppc-fbsd-tdep.c (_initialize_ppcfbsd_tdep): Add declaration. * ppc-linux-nat.c (_initialize_ppc_linux_nat): Add declaration. * ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Add declaration. * ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Add declaration. * ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Add declaration. * ppc-obsd-nat.c (_initialize_ppcobsd_nat): Add declaration. * ppc-obsd-tdep.c (_initialize_ppcobsd_tdep): Add declaration. * printcmd.c (_initialize_printcmd): Add declaration. * probe.c (_initialize_probe): Add declaration. * proc-api.c (_initialize_proc_api): Add declaration. * proc-events.c (_initialize_proc_events): Add declaration. * proc-service.c (_initialize_proc_service): Add declaration. * procfs.c (_initialize_procfs): Add declaration. * producer.c (_initialize_producer): Add declaration. * psymtab.c (_initialize_psymtab): Add declaration. * python/python.c (_initialize_python): Add declaration. * ravenscar-thread.c (_initialize_ravenscar): Add declaration. * record-btrace.c (_initialize_record_btrace): Add declaration. * record-full.c (_initialize_record_full): Add declaration. * record.c (_initialize_record): Add declaration. * regcache-dump.c (_initialize_regcache_dump): Add declaration. * regcache.c (_initialize_regcache): Add declaration. * reggroups.c (_initialize_reggroup): Add declaration. * remote-notif.c (_initialize_notif): Add declaration. * remote-sim.c (_initialize_remote_sim): Add declaration. * remote.c (_initialize_remote): Add declaration. * reverse.c (_initialize_reverse): Add declaration. * riscv-fbsd-nat.c (_initialize_riscv_fbsd_nat): Add declaration. * riscv-fbsd-tdep.c (_initialize_riscv_fbsd_tdep): Add declaration. * riscv-linux-nat.c (_initialize_riscv_linux_nat): Add declaration. * riscv-linux-tdep.c (_initialize_riscv_linux_tdep): Add declaration. * riscv-tdep.c (_initialize_riscv_tdep): Add declaration. * rl78-tdep.c (_initialize_rl78_tdep): Add declaration. * rs6000-aix-tdep.c (_initialize_rs6000_aix_tdep): Add declaration. * rs6000-lynx178-tdep.c (_initialize_rs6000_lynx178_tdep): Add declaration. * rs6000-nat.c (_initialize_rs6000_nat): Add declaration. * rs6000-tdep.c (_initialize_rs6000_tdep): Add declaration. * run-on-main-thread.c (_initialize_run_on_main_thread): Add declaration. * rust-exp.y (_initialize_rust_exp): Add declaration. * rx-tdep.c (_initialize_rx_tdep): Add declaration. * s12z-tdep.c (_initialize_s12z_tdep): Add declaration. * s390-linux-nat.c (_initialize_s390_nat): Add declaration. * s390-linux-tdep.c (_initialize_s390_linux_tdep): Add declaration. * s390-tdep.c (_initialize_s390_tdep): Add declaration. * score-tdep.c (_initialize_score_tdep): Add declaration. * ser-go32.c (_initialize_ser_dos): Add declaration. * ser-mingw.c (_initialize_ser_windows): Add declaration. * ser-pipe.c (_initialize_ser_pipe): Add declaration. * ser-tcp.c (_initialize_ser_tcp): Add declaration. * ser-uds.c (_initialize_ser_socket): Add declaration. * ser-unix.c (_initialize_ser_hardwire): Add declaration. * serial.c (_initialize_serial): Add declaration. * sh-linux-tdep.c (_initialize_sh_linux_tdep): Add declaration. * sh-nbsd-nat.c (_initialize_shnbsd_nat): Add declaration. * sh-nbsd-tdep.c (_initialize_shnbsd_tdep): Add declaration. * sh-tdep.c (_initialize_sh_tdep): Add declaration. * skip.c (_initialize_step_skip): Add declaration. * sol-thread.c (_initialize_sol_thread): Add declaration. * solib-aix.c (_initialize_solib_aix): Add declaration. * solib-darwin.c (_initialize_darwin_solib): Add declaration. * solib-dsbt.c (_initialize_dsbt_solib): Add declaration. * solib-frv.c (_initialize_frv_solib): Add declaration. * solib-svr4.c (_initialize_svr4_solib): Add declaration. * solib-target.c (_initialize_solib_target): Add declaration. * solib.c (_initialize_solib): Add declaration. * source-cache.c (_initialize_source_cache): Add declaration. * source.c (_initialize_source): Add declaration. * sparc-linux-nat.c (_initialize_sparc_linux_nat): Add declaration. * sparc-linux-tdep.c (_initialize_sparc_linux_tdep): Add declaration. * sparc-nat.c (_initialize_sparc_nat): Add declaration. * sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Add declaration. * sparc-nbsd-tdep.c (_initialize_sparcnbsd_tdep): Add declaration. * sparc-obsd-tdep.c (_initialize_sparc32obsd_tdep): Add declaration. * sparc-sol2-tdep.c (_initialize_sparc_sol2_tdep): Add declaration. * sparc-tdep.c (_initialize_sparc_tdep): Add declaration. * sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Add declaration. * sparc64-fbsd-tdep.c (_initialize_sparc64fbsd_tdep): Add declaration. * sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Add declaration. * sparc64-linux-tdep.c (_initialize_sparc64_linux_tdep): Add declaration. * sparc64-nat.c (_initialize_sparc64_nat): Add declaration. * sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Add declaration. * sparc64-nbsd-tdep.c (_initialize_sparc64nbsd_tdep): Add declaration. * sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Add declaration. * sparc64-obsd-tdep.c (_initialize_sparc64obsd_tdep): Add declaration. * sparc64-sol2-tdep.c (_initialize_sparc64_sol2_tdep): Add declaration. * sparc64-tdep.c (_initialize_sparc64_adi_tdep): Add declaration. * stabsread.c (_initialize_stabsread): Add declaration. * stack.c (_initialize_stack): Add declaration. * stap-probe.c (_initialize_stap_probe): Add declaration. * std-regs.c (_initialize_frame_reg): Add declaration. * symfile-debug.c (_initialize_symfile_debug): Add declaration. * symfile-mem.c (_initialize_symfile_mem): Add declaration. * symfile.c (_initialize_symfile): Add declaration. * symmisc.c (_initialize_symmisc): Add declaration. * symtab.c (_initialize_symtab): Add declaration. * target.c (_initialize_target): Add declaration. * target-connection.c (_initialize_target_connection): Add declaration. * target-dcache.c (_initialize_target_dcache): Add declaration. * target-descriptions.c (_initialize_target_descriptions): Add declaration. * thread.c (_initialize_thread): Add declaration. * tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Add declaration. * tic6x-tdep.c (_initialize_tic6x_tdep): Add declaration. * tilegx-linux-nat.c (_initialize_tile_linux_nat): Add declaration. * tilegx-linux-tdep.c (_initialize_tilegx_linux_tdep): Add declaration. * tilegx-tdep.c (_initialize_tilegx_tdep): Add declaration. * tracectf.c (_initialize_ctf): Add declaration. * tracefile-tfile.c (_initialize_tracefile_tfile): Add declaration. * tracefile.c (_initialize_tracefile): Add declaration. * tracepoint.c (_initialize_tracepoint): Add declaration. * tui/tui-hooks.c (_initialize_tui_hooks): Add declaration. * tui/tui-interp.c (_initialize_tui_interp): Add declaration. * tui/tui-layout.c (_initialize_tui_layout): Add declaration. * tui/tui-regs.c (_initialize_tui_regs): Add declaration. * tui/tui-stack.c (_initialize_tui_stack): Add declaration. * tui/tui-win.c (_initialize_tui_win): Add declaration. * tui/tui.c (_initialize_tui): Add declaration. * typeprint.c (_initialize_typeprint): Add declaration. * ui-style.c (_initialize_ui_style): Add declaration. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Add declaration. * unittests/child-path-selftests.c (_initialize_child_path_selftests): Add declaration. * unittests/cli-utils-selftests.c (_initialize_cli_utils_selftests): Add declaration. * unittests/common-utils-selftests.c (_initialize_common_utils_selftests): Add declaration. * unittests/copy_bitwise-selftests.c (_initialize_copy_bitwise_utils_selftests): Add declaration. * unittests/environ-selftests.c (_initialize_environ_selftests): Add declaration. * unittests/filtered_iterator-selftests.c (_initialize_filtered_iterator_selftests): Add declaration. * unittests/format_pieces-selftests.c (_initialize_format_pieces_selftests): Add declaration. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Add declaration. * unittests/help-doc-selftests.c (_initialize_help_doc_selftests): Add declaration. * unittests/lookup_name_info-selftests.c (_initialize_lookup_name_info_selftests): Add declaration. * unittests/main-thread-selftests.c (_initialize_main_thread_selftests): Add declaration. * unittests/memory-map-selftests.c (_initialize_memory_map_selftests): Add declaration. * unittests/memrange-selftests.c (_initialize_memrange_selftests): Add declaration. * unittests/mkdir-recursive-selftests.c (_initialize_mkdir_recursive_selftests): Add declaration. * unittests/observable-selftests.c (_initialize_observer_selftest): Add declaration. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Add declaration. * unittests/optional-selftests.c (_initialize_optional_selftests): Add declaration. * unittests/parse-connection-spec-selftests.c (_initialize_parse_connection_spec_selftests): Add declaration. * unittests/rsp-low-selftests.c (_initialize_rsp_low_selftests): Add declaration. * unittests/scoped_fd-selftests.c (_initialize_scoped_fd_selftests): Add declaration. * unittests/scoped_mmap-selftests.c (_initialize_scoped_mmap_selftests): Add declaration. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Add declaration. * unittests/string_view-selftests.c (_initialize_string_view_selftests): Add declaration. * unittests/style-selftests.c (_initialize_style_selftest): Add declaration. * unittests/tracepoint-selftests.c (_initialize_tracepoint_selftests): Add declaration. * unittests/tui-selftests.c (_initialize_tui_selftest): Add declaration. * unittests/unpack-selftests.c (_initialize_unpack_selftests): Add declaration. * unittests/utils-selftests.c (_initialize_utils_selftests): Add declaration. * unittests/vec-utils-selftests.c (_initialize_vec_utils_selftests): Add declaration. * unittests/xml-utils-selftests.c (_initialize_xml_utils): Add declaration. * user-regs.c (_initialize_user_regs): Add declaration. * utils.c (_initialize_utils): Add declaration. * v850-tdep.c (_initialize_v850_tdep): Add declaration. * valops.c (_initialize_valops): Add declaration. * valprint.c (_initialize_valprint): Add declaration. * value.c (_initialize_values): Add declaration. * varobj.c (_initialize_varobj): Add declaration. * vax-bsd-nat.c (_initialize_vaxbsd_nat): Add declaration. * vax-nbsd-tdep.c (_initialize_vaxnbsd_tdep): Add declaration. * vax-tdep.c (_initialize_vax_tdep): Add declaration. * windows-nat.c (_initialize_windows_nat): Add declaration. (_initialize_check_for_gdb_ini): Add declaration. (_initialize_loadable): Add declaration. * windows-tdep.c (_initialize_windows_tdep): Add declaration. * x86-bsd-nat.c (_initialize_x86_bsd_nat): Add declaration. * x86-linux-nat.c (_initialize_x86_linux_nat): Add declaration. * xcoffread.c (_initialize_xcoffread): Add declaration. * xml-support.c (_initialize_xml_support): Add declaration. * xstormy16-tdep.c (_initialize_xstormy16_tdep): Add declaration. * xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Add declaration. * xtensa-linux-tdep.c (_initialize_xtensa_linux_tdep): Add declaration. * xtensa-tdep.c (_initialize_xtensa_tdep): Add declaration. Change-Id: I13eec7e0ed2b3c427377a7bdb055cf46da64def9
2020-01-13 20:01:38 +01:00
void _initialize_solib ();
void
gdb: add back declarations for _initialize functions I'd like to enable the -Wmissing-declarations warning. However, it warns for every _initialize function, for example: CXX dcache.o /home/smarchi/src/binutils-gdb/gdb/dcache.c: In function ‘void _initialize_dcache()’: /home/smarchi/src/binutils-gdb/gdb/dcache.c:688:1: error: no previous declaration for ‘void _initialize_dcache()’ [-Werror=missing-declarations] _initialize_dcache (void) ^~~~~~~~~~~~~~~~~~ The only practical way forward I found is to add back the declarations, which were removed by this commit: commit 481695ed5f6e0a8a9c9c50bfac1cdd2b3151e6c9 Author: John Baldwin <jhb@FreeBSD.org> Date: Sat Sep 9 11:02:37 2017 -0700 Remove unnecessary function prototypes. I don't think it's a big problem to have the declarations for these functions, but if anybody has a better solution for this, I'll be happy to use it. gdb/ChangeLog: * aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Add declaration. * aarch64-fbsd-tdep.c (_initialize_aarch64_fbsd_tdep): Add declaration. * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Add declaration. * aarch64-linux-tdep.c (_initialize_aarch64_linux_tdep): Add declaration. * aarch64-newlib-tdep.c (_initialize_aarch64_newlib_tdep): Add declaration. * aarch64-tdep.c (_initialize_aarch64_tdep): Add declaration. * ada-exp.y (_initialize_ada_exp): Add declaration. * ada-lang.c (_initialize_ada_language): Add declaration. * ada-tasks.c (_initialize_tasks): Add declaration. * agent.c (_initialize_agent): Add declaration. * aix-thread.c (_initialize_aix_thread): Add declaration. * alpha-bsd-nat.c (_initialize_alphabsd_nat): Add declaration. * alpha-linux-nat.c (_initialize_alpha_linux_nat): Add declaration. * alpha-linux-tdep.c (_initialize_alpha_linux_tdep): Add declaration. * alpha-nbsd-tdep.c (_initialize_alphanbsd_tdep): Add declaration. * alpha-obsd-tdep.c (_initialize_alphaobsd_tdep): Add declaration. * alpha-tdep.c (_initialize_alpha_tdep): Add declaration. * amd64-darwin-tdep.c (_initialize_amd64_darwin_tdep): Add declaration. * amd64-dicos-tdep.c (_initialize_amd64_dicos_tdep): Add declaration. * amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Add declaration. * amd64-fbsd-tdep.c (_initialize_amd64fbsd_tdep): Add declaration. * amd64-linux-nat.c (_initialize_amd64_linux_nat): Add declaration. * amd64-linux-tdep.c (_initialize_amd64_linux_tdep): Add declaration. * amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Add declaration. * amd64-nbsd-tdep.c (_initialize_amd64nbsd_tdep): Add declaration. * amd64-obsd-nat.c (_initialize_amd64obsd_nat): Add declaration. * amd64-obsd-tdep.c (_initialize_amd64obsd_tdep): Add declaration. * amd64-sol2-tdep.c (_initialize_amd64_sol2_tdep): Add declaration. * amd64-tdep.c (_initialize_amd64_tdep): Add declaration. * amd64-windows-nat.c (_initialize_amd64_windows_nat): Add declaration. * amd64-windows-tdep.c (_initialize_amd64_windows_tdep): Add declaration. * annotate.c (_initialize_annotate): Add declaration. * arc-newlib-tdep.c (_initialize_arc_newlib_tdep): Add declaration. * arc-tdep.c (_initialize_arc_tdep): Add declaration. * arch-utils.c (_initialize_gdbarch_utils): Add declaration. * arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Add declaration. * arm-fbsd-tdep.c (_initialize_arm_fbsd_tdep): Add declaration. * arm-linux-nat.c (_initialize_arm_linux_nat): Add declaration. * arm-linux-tdep.c (_initialize_arm_linux_tdep): Add declaration. * arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Add declaration. * arm-nbsd-tdep.c (_initialize_arm_netbsd_tdep): Add declaration. * arm-obsd-tdep.c (_initialize_armobsd_tdep): Add declaration. * arm-pikeos-tdep.c (_initialize_arm_pikeos_tdep): Add declaration. * arm-symbian-tdep.c (_initialize_arm_symbian_tdep): Add declaration. * arm-tdep.c (_initialize_arm_tdep): Add declaration. * arm-wince-tdep.c (_initialize_arm_wince_tdep): Add declaration. * auto-load.c (_initialize_auto_load): Add declaration. * auxv.c (_initialize_auxv): Add declaration. * avr-tdep.c (_initialize_avr_tdep): Add declaration. * ax-gdb.c (_initialize_ax_gdb): Add declaration. * bfin-linux-tdep.c (_initialize_bfin_linux_tdep): Add declaration. * bfin-tdep.c (_initialize_bfin_tdep): Add declaration. * break-catch-sig.c (_initialize_break_catch_sig): Add declaration. * break-catch-syscall.c (_initialize_break_catch_syscall): Add declaration. * break-catch-throw.c (_initialize_break_catch_throw): Add declaration. * breakpoint.c (_initialize_breakpoint): Add declaration. * bsd-uthread.c (_initialize_bsd_uthread): Add declaration. * btrace.c (_initialize_btrace): Add declaration. * charset.c (_initialize_charset): Add declaration. * cli/cli-cmds.c (_initialize_cli_cmds): Add declaration. * cli/cli-dump.c (_initialize_cli_dump): Add declaration. * cli/cli-interp.c (_initialize_cli_interp): Add declaration. * cli/cli-logging.c (_initialize_cli_logging): Add declaration. * cli/cli-script.c (_initialize_cli_script): Add declaration. * cli/cli-style.c (_initialize_cli_style): Add declaration. * coff-pe-read.c (_initialize_coff_pe_read): Add declaration. * coffread.c (_initialize_coffread): Add declaration. * compile/compile-cplus-types.c (_initialize_compile_cplus_types): Add declaration. * compile/compile.c (_initialize_compile): Add declaration. * complaints.c (_initialize_complaints): Add declaration. * completer.c (_initialize_completer): Add declaration. * copying.c (_initialize_copying): Add declaration. * corefile.c (_initialize_core): Add declaration. * corelow.c (_initialize_corelow): Add declaration. * cp-abi.c (_initialize_cp_abi): Add declaration. * cp-namespace.c (_initialize_cp_namespace): Add declaration. * cp-support.c (_initialize_cp_support): Add declaration. * cp-valprint.c (_initialize_cp_valprint): Add declaration. * cris-linux-tdep.c (_initialize_cris_linux_tdep): Add declaration. * cris-tdep.c (_initialize_cris_tdep): Add declaration. * csky-linux-tdep.c (_initialize_csky_linux_tdep): Add declaration. * csky-tdep.c (_initialize_csky_tdep): Add declaration. * ctfread.c (_initialize_ctfread): Add declaration. * d-lang.c (_initialize_d_language): Add declaration. * darwin-nat-info.c (_initialize_darwin_info_commands): Add declaration. * darwin-nat.c (_initialize_darwin_nat): Add declaration. * dbxread.c (_initialize_dbxread): Add declaration. * dcache.c (_initialize_dcache): Add declaration. * disasm-selftests.c (_initialize_disasm_selftests): Add declaration. * disasm.c (_initialize_disasm): Add declaration. * dtrace-probe.c (_initialize_dtrace_probe): Add declaration. * dummy-frame.c (_initialize_dummy_frame): Add declaration. * dwarf-index-cache.c (_initialize_index_cache): Add declaration. * dwarf-index-write.c (_initialize_dwarf_index_write): Add declaration. * dwarf2-frame-tailcall.c (_initialize_tailcall_frame): Add declaration. * dwarf2-frame.c (_initialize_dwarf2_frame): Add declaration. * dwarf2expr.c (_initialize_dwarf2expr): Add declaration. * dwarf2loc.c (_initialize_dwarf2loc): Add declaration. * dwarf2read.c (_initialize_dwarf2_read): Add declaration. * elfread.c (_initialize_elfread): Add declaration. * exec.c (_initialize_exec): Add declaration. * extension.c (_initialize_extension): Add declaration. * f-lang.c (_initialize_f_language): Add declaration. * f-valprint.c (_initialize_f_valprint): Add declaration. * fbsd-nat.c (_initialize_fbsd_nat): Add declaration. * fbsd-tdep.c (_initialize_fbsd_tdep): Add declaration. * filesystem.c (_initialize_filesystem): Add declaration. * findcmd.c (_initialize_mem_search): Add declaration. * findvar.c (_initialize_findvar): Add declaration. * fork-child.c (_initialize_fork_child): Add declaration. * frame-base.c (_initialize_frame_base): Add declaration. * frame-unwind.c (_initialize_frame_unwind): Add declaration. * frame.c (_initialize_frame): Add declaration. * frv-linux-tdep.c (_initialize_frv_linux_tdep): Add declaration. * frv-tdep.c (_initialize_frv_tdep): Add declaration. * ft32-tdep.c (_initialize_ft32_tdep): Add declaration. * gcore.c (_initialize_gcore): Add declaration. * gdb-demangle.c (_initialize_gdb_demangle): Add declaration. * gdb_bfd.c (_initialize_gdb_bfd): Add declaration. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Add declaration. * gdbarch.c (_initialize_gdbarch): Add declaration. * gdbtypes.c (_initialize_gdbtypes): Add declaration. * gnu-nat.c (_initialize_gnu_nat): Add declaration. * gnu-v2-abi.c (_initialize_gnu_v2_abi): Add declaration. * gnu-v3-abi.c (_initialize_gnu_v3_abi): Add declaration. * go-lang.c (_initialize_go_language): Add declaration. * go32-nat.c (_initialize_go32_nat): Add declaration. * guile/guile.c (_initialize_guile): Add declaration. * h8300-tdep.c (_initialize_h8300_tdep): Add declaration. * hppa-linux-nat.c (_initialize_hppa_linux_nat): Add declaration. * hppa-linux-tdep.c (_initialize_hppa_linux_tdep): Add declaration. * hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Add declaration. * hppa-nbsd-tdep.c (_initialize_hppanbsd_tdep): Add declaration. * hppa-obsd-nat.c (_initialize_hppaobsd_nat): Add declaration. * hppa-obsd-tdep.c (_initialize_hppabsd_tdep): Add declaration. * hppa-tdep.c (_initialize_hppa_tdep): Add declaration. * i386-bsd-nat.c (_initialize_i386bsd_nat): Add declaration. * i386-cygwin-tdep.c (_initialize_i386_cygwin_tdep): Add declaration. * i386-darwin-nat.c (_initialize_i386_darwin_nat): Add declaration. * i386-darwin-tdep.c (_initialize_i386_darwin_tdep): Add declaration. * i386-dicos-tdep.c (_initialize_i386_dicos_tdep): Add declaration. * i386-fbsd-nat.c (_initialize_i386fbsd_nat): Add declaration. * i386-fbsd-tdep.c (_initialize_i386fbsd_tdep): Add declaration. * i386-gnu-nat.c (_initialize_i386gnu_nat): Add declaration. * i386-gnu-tdep.c (_initialize_i386gnu_tdep): Add declaration. * i386-go32-tdep.c (_initialize_i386_go32_tdep): Add declaration. * i386-linux-nat.c (_initialize_i386_linux_nat): Add declaration. * i386-linux-tdep.c (_initialize_i386_linux_tdep): Add declaration. * i386-nbsd-nat.c (_initialize_i386nbsd_nat): Add declaration. * i386-nbsd-tdep.c (_initialize_i386nbsd_tdep): Add declaration. * i386-nto-tdep.c (_initialize_i386nto_tdep): Add declaration. * i386-obsd-nat.c (_initialize_i386obsd_nat): Add declaration. * i386-obsd-tdep.c (_initialize_i386obsd_tdep): Add declaration. * i386-sol2-nat.c (_initialize_amd64_sol2_nat): Add declaration. * i386-sol2-tdep.c (_initialize_i386_sol2_tdep): Add declaration. * i386-tdep.c (_initialize_i386_tdep): Add declaration. * i386-windows-nat.c (_initialize_i386_windows_nat): Add declaration. * ia64-libunwind-tdep.c (_initialize_libunwind_frame): Add declaration. * ia64-linux-nat.c (_initialize_ia64_linux_nat): Add declaration. * ia64-linux-tdep.c (_initialize_ia64_linux_tdep): Add declaration. * ia64-tdep.c (_initialize_ia64_tdep): Add declaration. * ia64-vms-tdep.c (_initialize_ia64_vms_tdep): Add declaration. * infcall.c (_initialize_infcall): Add declaration. * infcmd.c (_initialize_infcmd): Add declaration. * inflow.c (_initialize_inflow): Add declaration. * infrun.c (_initialize_infrun): Add declaration. * interps.c (_initialize_interpreter): Add declaration. * iq2000-tdep.c (_initialize_iq2000_tdep): Add declaration. * jit.c (_initialize_jit): Add declaration. * language.c (_initialize_language): Add declaration. * linux-fork.c (_initialize_linux_fork): Add declaration. * linux-nat.c (_initialize_linux_nat): Add declaration. * linux-tdep.c (_initialize_linux_tdep): Add declaration. * linux-thread-db.c (_initialize_thread_db): Add declaration. * lm32-tdep.c (_initialize_lm32_tdep): Add declaration. * m2-lang.c (_initialize_m2_language): Add declaration. * m32c-tdep.c (_initialize_m32c_tdep): Add declaration. * m32r-linux-nat.c (_initialize_m32r_linux_nat): Add declaration. * m32r-linux-tdep.c (_initialize_m32r_linux_tdep): Add declaration. * m32r-tdep.c (_initialize_m32r_tdep): Add declaration. * m68hc11-tdep.c (_initialize_m68hc11_tdep): Add declaration. * m68k-bsd-nat.c (_initialize_m68kbsd_nat): Add declaration. * m68k-bsd-tdep.c (_initialize_m68kbsd_tdep): Add declaration. * m68k-linux-nat.c (_initialize_m68k_linux_nat): Add declaration. * m68k-linux-tdep.c (_initialize_m68k_linux_tdep): Add declaration. * m68k-tdep.c (_initialize_m68k_tdep): Add declaration. * machoread.c (_initialize_machoread): Add declaration. * macrocmd.c (_initialize_macrocmd): Add declaration. * macroscope.c (_initialize_macroscope): Add declaration. * maint-test-options.c (_initialize_maint_test_options): Add declaration. * maint-test-settings.c (_initialize_maint_test_settings): Add declaration. * maint.c (_initialize_maint_cmds): Add declaration. * mdebugread.c (_initialize_mdebugread): Add declaration. * memattr.c (_initialize_mem): Add declaration. * mep-tdep.c (_initialize_mep_tdep): Add declaration. * mi/mi-cmd-env.c (_initialize_mi_cmd_env): Add declaration. * mi/mi-cmds.c (_initialize_mi_cmds): Add declaration. * mi/mi-interp.c (_initialize_mi_interp): Add declaration. * mi/mi-main.c (_initialize_mi_main): Add declaration. * microblaze-linux-tdep.c (_initialize_microblaze_linux_tdep): Add declaration. * microblaze-tdep.c (_initialize_microblaze_tdep): Add declaration. * mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Add declaration. * mips-fbsd-tdep.c (_initialize_mips_fbsd_tdep): Add declaration. * mips-linux-nat.c (_initialize_mips_linux_nat): Add declaration. * mips-linux-tdep.c (_initialize_mips_linux_tdep): Add declaration. * mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Add declaration. * mips-nbsd-tdep.c (_initialize_mipsnbsd_tdep): Add declaration. * mips-sde-tdep.c (_initialize_mips_sde_tdep): Add declaration. * mips-tdep.c (_initialize_mips_tdep): Add declaration. * mips64-obsd-nat.c (_initialize_mips64obsd_nat): Add declaration. * mips64-obsd-tdep.c (_initialize_mips64obsd_tdep): Add declaration. * mipsread.c (_initialize_mipsread): Add declaration. * mn10300-linux-tdep.c (_initialize_mn10300_linux_tdep): Add declaration. * mn10300-tdep.c (_initialize_mn10300_tdep): Add declaration. * moxie-tdep.c (_initialize_moxie_tdep): Add declaration. * msp430-tdep.c (_initialize_msp430_tdep): Add declaration. * nds32-tdep.c (_initialize_nds32_tdep): Add declaration. * nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Add declaration. * nios2-tdep.c (_initialize_nios2_tdep): Add declaration. * nto-procfs.c (_initialize_procfs): Add declaration. * objc-lang.c (_initialize_objc_language): Add declaration. * observable.c (_initialize_observer): Add declaration. * opencl-lang.c (_initialize_opencl_language): Add declaration. * or1k-linux-tdep.c (_initialize_or1k_linux_tdep): Add declaration. * or1k-tdep.c (_initialize_or1k_tdep): Add declaration. * osabi.c (_initialize_gdb_osabi): Add declaration. * osdata.c (_initialize_osdata): Add declaration. * p-valprint.c (_initialize_pascal_valprint): Add declaration. * parse.c (_initialize_parse): Add declaration. * ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Add declaration. * ppc-fbsd-tdep.c (_initialize_ppcfbsd_tdep): Add declaration. * ppc-linux-nat.c (_initialize_ppc_linux_nat): Add declaration. * ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Add declaration. * ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Add declaration. * ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Add declaration. * ppc-obsd-nat.c (_initialize_ppcobsd_nat): Add declaration. * ppc-obsd-tdep.c (_initialize_ppcobsd_tdep): Add declaration. * printcmd.c (_initialize_printcmd): Add declaration. * probe.c (_initialize_probe): Add declaration. * proc-api.c (_initialize_proc_api): Add declaration. * proc-events.c (_initialize_proc_events): Add declaration. * proc-service.c (_initialize_proc_service): Add declaration. * procfs.c (_initialize_procfs): Add declaration. * producer.c (_initialize_producer): Add declaration. * psymtab.c (_initialize_psymtab): Add declaration. * python/python.c (_initialize_python): Add declaration. * ravenscar-thread.c (_initialize_ravenscar): Add declaration. * record-btrace.c (_initialize_record_btrace): Add declaration. * record-full.c (_initialize_record_full): Add declaration. * record.c (_initialize_record): Add declaration. * regcache-dump.c (_initialize_regcache_dump): Add declaration. * regcache.c (_initialize_regcache): Add declaration. * reggroups.c (_initialize_reggroup): Add declaration. * remote-notif.c (_initialize_notif): Add declaration. * remote-sim.c (_initialize_remote_sim): Add declaration. * remote.c (_initialize_remote): Add declaration. * reverse.c (_initialize_reverse): Add declaration. * riscv-fbsd-nat.c (_initialize_riscv_fbsd_nat): Add declaration. * riscv-fbsd-tdep.c (_initialize_riscv_fbsd_tdep): Add declaration. * riscv-linux-nat.c (_initialize_riscv_linux_nat): Add declaration. * riscv-linux-tdep.c (_initialize_riscv_linux_tdep): Add declaration. * riscv-tdep.c (_initialize_riscv_tdep): Add declaration. * rl78-tdep.c (_initialize_rl78_tdep): Add declaration. * rs6000-aix-tdep.c (_initialize_rs6000_aix_tdep): Add declaration. * rs6000-lynx178-tdep.c (_initialize_rs6000_lynx178_tdep): Add declaration. * rs6000-nat.c (_initialize_rs6000_nat): Add declaration. * rs6000-tdep.c (_initialize_rs6000_tdep): Add declaration. * run-on-main-thread.c (_initialize_run_on_main_thread): Add declaration. * rust-exp.y (_initialize_rust_exp): Add declaration. * rx-tdep.c (_initialize_rx_tdep): Add declaration. * s12z-tdep.c (_initialize_s12z_tdep): Add declaration. * s390-linux-nat.c (_initialize_s390_nat): Add declaration. * s390-linux-tdep.c (_initialize_s390_linux_tdep): Add declaration. * s390-tdep.c (_initialize_s390_tdep): Add declaration. * score-tdep.c (_initialize_score_tdep): Add declaration. * ser-go32.c (_initialize_ser_dos): Add declaration. * ser-mingw.c (_initialize_ser_windows): Add declaration. * ser-pipe.c (_initialize_ser_pipe): Add declaration. * ser-tcp.c (_initialize_ser_tcp): Add declaration. * ser-uds.c (_initialize_ser_socket): Add declaration. * ser-unix.c (_initialize_ser_hardwire): Add declaration. * serial.c (_initialize_serial): Add declaration. * sh-linux-tdep.c (_initialize_sh_linux_tdep): Add declaration. * sh-nbsd-nat.c (_initialize_shnbsd_nat): Add declaration. * sh-nbsd-tdep.c (_initialize_shnbsd_tdep): Add declaration. * sh-tdep.c (_initialize_sh_tdep): Add declaration. * skip.c (_initialize_step_skip): Add declaration. * sol-thread.c (_initialize_sol_thread): Add declaration. * solib-aix.c (_initialize_solib_aix): Add declaration. * solib-darwin.c (_initialize_darwin_solib): Add declaration. * solib-dsbt.c (_initialize_dsbt_solib): Add declaration. * solib-frv.c (_initialize_frv_solib): Add declaration. * solib-svr4.c (_initialize_svr4_solib): Add declaration. * solib-target.c (_initialize_solib_target): Add declaration. * solib.c (_initialize_solib): Add declaration. * source-cache.c (_initialize_source_cache): Add declaration. * source.c (_initialize_source): Add declaration. * sparc-linux-nat.c (_initialize_sparc_linux_nat): Add declaration. * sparc-linux-tdep.c (_initialize_sparc_linux_tdep): Add declaration. * sparc-nat.c (_initialize_sparc_nat): Add declaration. * sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Add declaration. * sparc-nbsd-tdep.c (_initialize_sparcnbsd_tdep): Add declaration. * sparc-obsd-tdep.c (_initialize_sparc32obsd_tdep): Add declaration. * sparc-sol2-tdep.c (_initialize_sparc_sol2_tdep): Add declaration. * sparc-tdep.c (_initialize_sparc_tdep): Add declaration. * sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Add declaration. * sparc64-fbsd-tdep.c (_initialize_sparc64fbsd_tdep): Add declaration. * sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Add declaration. * sparc64-linux-tdep.c (_initialize_sparc64_linux_tdep): Add declaration. * sparc64-nat.c (_initialize_sparc64_nat): Add declaration. * sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Add declaration. * sparc64-nbsd-tdep.c (_initialize_sparc64nbsd_tdep): Add declaration. * sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Add declaration. * sparc64-obsd-tdep.c (_initialize_sparc64obsd_tdep): Add declaration. * sparc64-sol2-tdep.c (_initialize_sparc64_sol2_tdep): Add declaration. * sparc64-tdep.c (_initialize_sparc64_adi_tdep): Add declaration. * stabsread.c (_initialize_stabsread): Add declaration. * stack.c (_initialize_stack): Add declaration. * stap-probe.c (_initialize_stap_probe): Add declaration. * std-regs.c (_initialize_frame_reg): Add declaration. * symfile-debug.c (_initialize_symfile_debug): Add declaration. * symfile-mem.c (_initialize_symfile_mem): Add declaration. * symfile.c (_initialize_symfile): Add declaration. * symmisc.c (_initialize_symmisc): Add declaration. * symtab.c (_initialize_symtab): Add declaration. * target.c (_initialize_target): Add declaration. * target-connection.c (_initialize_target_connection): Add declaration. * target-dcache.c (_initialize_target_dcache): Add declaration. * target-descriptions.c (_initialize_target_descriptions): Add declaration. * thread.c (_initialize_thread): Add declaration. * tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Add declaration. * tic6x-tdep.c (_initialize_tic6x_tdep): Add declaration. * tilegx-linux-nat.c (_initialize_tile_linux_nat): Add declaration. * tilegx-linux-tdep.c (_initialize_tilegx_linux_tdep): Add declaration. * tilegx-tdep.c (_initialize_tilegx_tdep): Add declaration. * tracectf.c (_initialize_ctf): Add declaration. * tracefile-tfile.c (_initialize_tracefile_tfile): Add declaration. * tracefile.c (_initialize_tracefile): Add declaration. * tracepoint.c (_initialize_tracepoint): Add declaration. * tui/tui-hooks.c (_initialize_tui_hooks): Add declaration. * tui/tui-interp.c (_initialize_tui_interp): Add declaration. * tui/tui-layout.c (_initialize_tui_layout): Add declaration. * tui/tui-regs.c (_initialize_tui_regs): Add declaration. * tui/tui-stack.c (_initialize_tui_stack): Add declaration. * tui/tui-win.c (_initialize_tui_win): Add declaration. * tui/tui.c (_initialize_tui): Add declaration. * typeprint.c (_initialize_typeprint): Add declaration. * ui-style.c (_initialize_ui_style): Add declaration. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Add declaration. * unittests/child-path-selftests.c (_initialize_child_path_selftests): Add declaration. * unittests/cli-utils-selftests.c (_initialize_cli_utils_selftests): Add declaration. * unittests/common-utils-selftests.c (_initialize_common_utils_selftests): Add declaration. * unittests/copy_bitwise-selftests.c (_initialize_copy_bitwise_utils_selftests): Add declaration. * unittests/environ-selftests.c (_initialize_environ_selftests): Add declaration. * unittests/filtered_iterator-selftests.c (_initialize_filtered_iterator_selftests): Add declaration. * unittests/format_pieces-selftests.c (_initialize_format_pieces_selftests): Add declaration. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Add declaration. * unittests/help-doc-selftests.c (_initialize_help_doc_selftests): Add declaration. * unittests/lookup_name_info-selftests.c (_initialize_lookup_name_info_selftests): Add declaration. * unittests/main-thread-selftests.c (_initialize_main_thread_selftests): Add declaration. * unittests/memory-map-selftests.c (_initialize_memory_map_selftests): Add declaration. * unittests/memrange-selftests.c (_initialize_memrange_selftests): Add declaration. * unittests/mkdir-recursive-selftests.c (_initialize_mkdir_recursive_selftests): Add declaration. * unittests/observable-selftests.c (_initialize_observer_selftest): Add declaration. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Add declaration. * unittests/optional-selftests.c (_initialize_optional_selftests): Add declaration. * unittests/parse-connection-spec-selftests.c (_initialize_parse_connection_spec_selftests): Add declaration. * unittests/rsp-low-selftests.c (_initialize_rsp_low_selftests): Add declaration. * unittests/scoped_fd-selftests.c (_initialize_scoped_fd_selftests): Add declaration. * unittests/scoped_mmap-selftests.c (_initialize_scoped_mmap_selftests): Add declaration. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Add declaration. * unittests/string_view-selftests.c (_initialize_string_view_selftests): Add declaration. * unittests/style-selftests.c (_initialize_style_selftest): Add declaration. * unittests/tracepoint-selftests.c (_initialize_tracepoint_selftests): Add declaration. * unittests/tui-selftests.c (_initialize_tui_selftest): Add declaration. * unittests/unpack-selftests.c (_initialize_unpack_selftests): Add declaration. * unittests/utils-selftests.c (_initialize_utils_selftests): Add declaration. * unittests/vec-utils-selftests.c (_initialize_vec_utils_selftests): Add declaration. * unittests/xml-utils-selftests.c (_initialize_xml_utils): Add declaration. * user-regs.c (_initialize_user_regs): Add declaration. * utils.c (_initialize_utils): Add declaration. * v850-tdep.c (_initialize_v850_tdep): Add declaration. * valops.c (_initialize_valops): Add declaration. * valprint.c (_initialize_valprint): Add declaration. * value.c (_initialize_values): Add declaration. * varobj.c (_initialize_varobj): Add declaration. * vax-bsd-nat.c (_initialize_vaxbsd_nat): Add declaration. * vax-nbsd-tdep.c (_initialize_vaxnbsd_tdep): Add declaration. * vax-tdep.c (_initialize_vax_tdep): Add declaration. * windows-nat.c (_initialize_windows_nat): Add declaration. (_initialize_check_for_gdb_ini): Add declaration. (_initialize_loadable): Add declaration. * windows-tdep.c (_initialize_windows_tdep): Add declaration. * x86-bsd-nat.c (_initialize_x86_bsd_nat): Add declaration. * x86-linux-nat.c (_initialize_x86_linux_nat): Add declaration. * xcoffread.c (_initialize_xcoffread): Add declaration. * xml-support.c (_initialize_xml_support): Add declaration. * xstormy16-tdep.c (_initialize_xstormy16_tdep): Add declaration. * xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Add declaration. * xtensa-linux-tdep.c (_initialize_xtensa_linux_tdep): Add declaration. * xtensa-tdep.c (_initialize_xtensa_tdep): Add declaration. Change-Id: I13eec7e0ed2b3c427377a7bdb055cf46da64def9
2020-01-13 20:01:38 +01:00
_initialize_solib ()
{
solib_data = gdbarch_data_register_pre_init (solib_init);
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::free_objfile.attach (remove_user_added_objfile);
add_com ("sharedlibrary", class_files, sharedlibrary_command,
_("Load shared object library symbols for files matching REGEXP."));
1999-07-07 22:19:36 +02:00
add_info ("sharedlibrary", info_sharedlibrary_command,
_("Status of loaded shared object libraries."));
add_info_alias ("dll", "sharedlibrary", 1);
add_com ("nosharedlibrary", class_files, no_shared_libraries,
_("Unload all shared object library symbols."));
add_setshow_boolean_cmd ("auto-solib-add", class_support,
&auto_solib_add, _("\
Set autoloading of shared library symbols."), _("\
Show autoloading of shared library symbols."), _("\
Changes approved by kev@cygnus.com, ezannoni@cygnus.com, eliz@is.elta.co.il. Changelog: 2001-10-27 Fred Fish <fnf@redhat.com> * symfile.c (auto_solib_add): Update comment to note that this variable is now just used as a boolean to control shlib autoloading, and clarify when it is used. * symfile.h (auto_solib_add): Ditto. * symfile.c (auto_solib_limit): New variable that holds the autoloading threshold instead of overloading auto_solib_add. * symfile.h (auto_solib_limit): Ditto. * irix5-nat.c (_initialize_solib): Change auto-solib-add variable from var_zinteger to var_boolean and update help. * osfsolib.c (_initialize_solib): Ditto. * pa64solib.c (_initialize_pa64_solib): Ditto. * solib.c (_initialize_solib): Ditto. * somsolib.c (_initialize_som_solib): Ditto. * xcoffsolib.c (_initialize_solib): Ditto. * pa64solib.c (pa64_solib_total_st_size): Update comment to note that the new auto_solib_limit variable is used instead of overloading auto_solib_add variable. (_initialize_pa64_solib): Ditto. * somsolib.c (som_solib_total_st_size): Ditto. (_initialize_som_solib): Ditto. * pa64solib.c (_initialize_pa64_solib): Add new set/show commands for auto-solib-limit variable. * somsolib.c (_initialize_som_solib): Ditto * pa64solib.c (add_to_solist): Check that auto_solib_add is set and use auto_solib_limit as the threshold size instead of auto_solib_add. * somsolib.c (som_solib_add): Ditto, and also change warning text about size threshold exceeded. doc/ChangeLog: 2001-10-28 Fred Fish <fnf@redhat.com> * gdb.texinfo (auto-solib-add): Change docs to match implementation change. (auto-solib-limit): Add docs for new variable.
2001-10-30 05:05:36 +01:00
If \"on\", symbols from all shared object libraries will be loaded\n\
automatically when the inferior begins execution, when the dynamic linker\n\
informs gdb that a new library has been loaded, or when attaching to the\n\
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
inferior. Otherwise, symbols must be loaded manually, using \
`sharedlibrary'."),
NULL,
2005-02-24 Andrew Cagney <cagney@gnu.org> Add show_VARIABLE functions, update add_setshow call. * varobj.c (_initialize_varobj, show_varobjdebug): Add and update. * valprint.c (_initialize_valprint, show_print_max) (show_stop_print_at_null, show_repeat_count_threshold) (show_prettyprint_structs, show_unionprint) (show_prettyprint_arrays, show_addressprint, show_input_radix) (show_output_radix): Ditto. * valops.c (_initialize_valops, show_overload_resolution): Ditto. * utils.c (initialize_utils, show_chars_per_line) (show_lines_per_page, show_demangle, show_pagination_enabled) (show_sevenbit_strings, show_asm_demangle): Ditto * tui/tui-win.c (_initialize_tui_win, show_tui_border_kind) (show_tui_border_mode, show_tui_active_border_mode): Ditto. * top.c (init_main, show_new_async_prompt) (show_async_command_editing_p, show_write_history_p) (show_history_size, show_history_filename, show_caution) (show_annotation_level, init_main): Ditto. * target.c (initialize_targets, show_targetdebug) (show_trust_readonly): Ditto. * symfile.c (_initialize_symfile, show_symbol_reloading) (show_ext_args, show_download_write_size) (show_debug_file_directory): Ditto. * source.c (_initialize_source, show_lines_to_list): Ditto. * solib.c (_initialize_solib, show_auto_solib_add) (show_solib_search_path): Ditto. * p-valprint.c (_initialize_pascal_valprint) (show_pascal_static_field_print): Ditto. * printcmd.c (_initialize_printcmd, show_max_symbolic_offset) (show_print_symbol_filename): Add and update. * parse.c (_initialize_parse, show_expressiondebug): Dito. * observer.c (_initialize_observer, show_observer_debug): Dito. * maint.c (_initialize_maint_cmds, show_watchdog) (show_maintenance_profile_p): Dito. * linux-nat.c (_initialize_linux_nat, show_debug_linux_nat): Dito. * infrun.c (_initialize_infrun, show_debug_infrun) (show_stop_on_solib_events, show_follow_fork_mode_string) (show_scheduler_mode, show_step_stop_if_no_debug): Ditto. * infcall.c (_initialize_infcall, show_coerce_float_to_double_p) (show_unwind_on_signal_p): Ditto. * gdbtypes.c (build_gdbtypes, show_opaque_type_resolution) (_initialize_gdbtypes, show_overload_debug): Ditto. * gdb-events.c, gdb-events.sh (_initialize_gdb_events) (show_gdb_events_debug): Ditto. * gdbarch.c, gdbarch.sh (show_gdbarch_debug) (_initialize_gdbarch): Ditto. * frame.c (_initialize_frame, show_backtrace_past_main) (show_backtrace_past_entry, show_backtrace_limit) (show_frame_debug): Ditto. * exec.c (_initialize_exec, show_write_files): Ditto. * dwarf2read.c (_initialize_dwarf2_read) (show_dwarf2_max_cache_age): Ditto. * demangle.c (_initialize_demangler) (show_demangling_style_names): Ditto. * dcache.c (_initialize_dcache, show_dcache_enabled_p): Ditto. * cp-valprint.c (show_static_field_print) (_initialize_cp_valprint, show_vtblprint, show_objectprint): Ditto. * corefile.c (_initialize_core, show_gnutarget_string): Ditto. * cli/cli-logging.c (_initialize_cli_logging) (show_logging_overwrite, show_logging_redirect) (show_logging_filename): Ditto. * cli/cli-cmds.c (show_info_verbose, show_history_expansion_p) (init_cli_cmds, show_baud_rate, show_remote_debug) (show_remote_timeout, show_max_user_call_depth): Ditto. * charset.c (show_host_charset_name, show_target_charset_name) (initialize_charset): Ditto. * breakpoint.c (show_can_use_hw_watchpoints) (show_pending_break_support, _initialize_breakpoint): Ditto.
2005-02-24 14:51:36 +01:00
show_auto_solib_add,
&setlist, &showlist);
add_setshow_optional_filename_cmd ("sysroot", class_support,
&gdb_sysroot, _("\
Set an alternate system root."), _("\
Show the current system root."), _("\
The system root is used to load absolute shared library symbol files.\n\
For other (relative) files, you can add directories using\n\
`set solib-search-path'."),
Convert "remote:" sysroots to "target:" and remove "remote:" The functionality of "target:" sysroots is a superset of the functionality of "remote:" sysroots. This commit causes the "set sysroot" command to rewrite "remote:" sysroots as "target:" sysroots and replaces "remote:" specific code with "target:" specific code where still necessary. gdb/ChangeLog: * remote.h (REMOTE_SYSROOT_PREFIX): Remove definition. (remote_filename_p): Remove declaration. (remote_bfd_open): Likewise. * remote.c (remote_bfd_iovec_open): Remove function. (remote_bfd_iovec_close): Likewise. (remote_bfd_iovec_pread): Likewise. (remote_bfd_iovec_stat): Likewise. (remote_filename_p): Likewise. (remote_bfd_open): Likewise. * symfile.h (gdb_bfd_open_maybe_remote): Remove declaration. * symfile.c (separate_debug_file_exists): Use gdb_bfd_open. (gdb_bfd_open_maybe_remote): Remove function. (symfile_bfd_open): Replace remote filename check with target filename check. (reread_symbols): Use gdb_bfd_open. * build-id.c (gdbcore.h): New include. (build_id_to_debug_bfd): Use gdb_bfd_open. * infcmd.c (attach_command_post_wait): Remove remote filename check. * solib.c (solib_find): Replace remote-specific handling with target-specific handling. Update comments where necessary. (solib_bfd_open): Replace remote-specific handling with target-specific handling. (gdb_sysroot_changed): New function. (_initialize_solib): Call the above when gdb_sysroot changes. * windows-tdep.c (gdbcore.h): New include. (windows_xfer_shared_library): Use gdb_bfd_open.
2015-04-02 14:38:29 +02:00
gdb_sysroot_changed,
NULL,
&setlist, &showlist);
add_alias_cmd ("solib-absolute-prefix", "sysroot", class_support, 0,
&setlist);
add_alias_cmd ("solib-absolute-prefix", "sysroot", class_support, 0,
&showlist);
add_setshow_optional_filename_cmd ("solib-search-path", class_support,
&solib_search_path, _("\
2011-01-05 Michael Snyder <msnyder@vmware.com> * addrmap.c: Shorten lines of >= 80 columns. * arch-utils.c: Ditto. * arch-utils.h: Ditto. * ax-gdb.c: Ditto. * ax-general.c: Ditto. * bcache.c: Ditto. * blockframe.c: Ditto. * breakpoint.c: Ditto. * buildsym.c: Ditto. * c-lang.c: Ditto. * c-typeprint.c: Ditto. * charset.c: Ditto. * coffread.c: Ditto. * command.h: Ditto. * corelow.c: Ditto. * cp-abi.c: Ditto. * cp-namespace.c: Ditto. * cp-support.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * defs.h: Ditto. * dfp.c: Ditto. * dfp.h: Ditto. * dictionary.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * eval.c: Ditto. * event-loop.c: Ditto. * event-loop.h: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-lang.c: Ditto. * f-valprint.c: Ditto. * findcmd.c: Ditto. * frame-base.c: Ditto. * frame-unwind.c: Ditto. * frame-unwind.h: Ditto. * frame.c: Ditto. * frame.h: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_dirent.h: Ditto. * gdb_obstack.h: Ditto. * gdbcore.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * inf-ttrace.c: Ditto. * infcall.c: Ditto. * infcmd.c: Ditto. * inflow.c: Ditto. * infrun.c: Ditto. * inline-frame.h: Ditto. * language.c: Ditto. * language.h: Ditto. * libunwind-frame.c: Ditto. * libunwind-frame.h: Ditto. * linespec.c: Ditto. * linux-nat.c: Ditto. * linux-nat.h: Ditto. * linux-thread-db.c: Ditto. * machoread.c: Ditto. * macroexp.c: Ditto. * macrotab.c: Ditto. * main.c: Ditto. * maint.c: Ditto. * mdebugread.c: Ditto. * memattr.c: Ditto. * minsyms.c: Ditto. * monitor.c: Ditto. * monitor.h: Ditto. * objfiles.c: Ditto. * objfiles.h: Ditto. * osabi.c: Ditto. * p-typeprint.c: Ditto. * p-valprint.c: Ditto. * parse.c: Ditto. * printcmd.c: Ditto. * proc-events.c: Ditto. * procfs.c: Ditto. * progspace.c: Ditto. * progspace.h: Ditto. * psympriv.h: Ditto. * psymtab.c: Ditto. * record.c: Ditto. * regcache.c: Ditto. * regcache.h: Ditto. * remote-fileio.c: Ditto. * remote.c: Ditto. * ser-mingw.c: Ditto. * ser-tcp.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * serial.h: Ditto. * solib-frv.c: Ditto. * solib-irix.c: Ditto. * solib-osf.c: Ditto. * solib-pa64.c: Ditto. * solib-som.c: Ditto. * solib-sunos.c: Ditto. * solib-svr4.c: Ditto. * solib-target.c: Ditto. * solib.c: Ditto. * somread.c: Ditto. * source.c: Ditto. * stabsread.c: Ditto. * stabsread.c: Ditto. * stack.c: Ditto. * stack.h: Ditto. * symfile-mem.c: Ditto. * symfile.c: Ditto. * symfile.h: Ditto. * symmisc.c: Ditto. * symtab.c: Ditto. * symtab.h: Ditto. * target-descriptions.c: Ditto. * target-memory.c: Ditto. * target.c: Ditto. * target.h: Ditto. * terminal.h: Ditto. * thread.c: Ditto. * top.c: Ditto. * tracepoint.c: Ditto. * tracepoint.h: Ditto. * ui-file.c: Ditto. * ui-file.h: Ditto. * ui-out.h: Ditto. * user-regs.c: Ditto. * user-regs.h: Ditto. * utils.c: Ditto. * valarith.c: Ditto. * valops.c: Ditto. * valprint.c: Ditto. * valprint.h: Ditto. * value.c: Ditto. * varobj.c: Ditto. * varobj.h: Ditto. * vec.h: Ditto. * xcoffread.c: Ditto. * xcoffsolib.c: Ditto. * xcoffsolib.h: Ditto. * xml-syscall.c: Ditto. * xml-tdesc.c: Ditto.
2011-01-05 23:22:53 +01:00
Set the search path for loading non-absolute shared library symbol files."),
_("\
Show the search path for loading non-absolute shared library symbol files."),
_("\
This takes precedence over the environment variables \
PATH and LD_LIBRARY_PATH."),
reload_shared_libraries,
2005-02-24 Andrew Cagney <cagney@gnu.org> Add show_VARIABLE functions, update add_setshow call. * varobj.c (_initialize_varobj, show_varobjdebug): Add and update. * valprint.c (_initialize_valprint, show_print_max) (show_stop_print_at_null, show_repeat_count_threshold) (show_prettyprint_structs, show_unionprint) (show_prettyprint_arrays, show_addressprint, show_input_radix) (show_output_radix): Ditto. * valops.c (_initialize_valops, show_overload_resolution): Ditto. * utils.c (initialize_utils, show_chars_per_line) (show_lines_per_page, show_demangle, show_pagination_enabled) (show_sevenbit_strings, show_asm_demangle): Ditto * tui/tui-win.c (_initialize_tui_win, show_tui_border_kind) (show_tui_border_mode, show_tui_active_border_mode): Ditto. * top.c (init_main, show_new_async_prompt) (show_async_command_editing_p, show_write_history_p) (show_history_size, show_history_filename, show_caution) (show_annotation_level, init_main): Ditto. * target.c (initialize_targets, show_targetdebug) (show_trust_readonly): Ditto. * symfile.c (_initialize_symfile, show_symbol_reloading) (show_ext_args, show_download_write_size) (show_debug_file_directory): Ditto. * source.c (_initialize_source, show_lines_to_list): Ditto. * solib.c (_initialize_solib, show_auto_solib_add) (show_solib_search_path): Ditto. * p-valprint.c (_initialize_pascal_valprint) (show_pascal_static_field_print): Ditto. * printcmd.c (_initialize_printcmd, show_max_symbolic_offset) (show_print_symbol_filename): Add and update. * parse.c (_initialize_parse, show_expressiondebug): Dito. * observer.c (_initialize_observer, show_observer_debug): Dito. * maint.c (_initialize_maint_cmds, show_watchdog) (show_maintenance_profile_p): Dito. * linux-nat.c (_initialize_linux_nat, show_debug_linux_nat): Dito. * infrun.c (_initialize_infrun, show_debug_infrun) (show_stop_on_solib_events, show_follow_fork_mode_string) (show_scheduler_mode, show_step_stop_if_no_debug): Ditto. * infcall.c (_initialize_infcall, show_coerce_float_to_double_p) (show_unwind_on_signal_p): Ditto. * gdbtypes.c (build_gdbtypes, show_opaque_type_resolution) (_initialize_gdbtypes, show_overload_debug): Ditto. * gdb-events.c, gdb-events.sh (_initialize_gdb_events) (show_gdb_events_debug): Ditto. * gdbarch.c, gdbarch.sh (show_gdbarch_debug) (_initialize_gdbarch): Ditto. * frame.c (_initialize_frame, show_backtrace_past_main) (show_backtrace_past_entry, show_backtrace_limit) (show_frame_debug): Ditto. * exec.c (_initialize_exec, show_write_files): Ditto. * dwarf2read.c (_initialize_dwarf2_read) (show_dwarf2_max_cache_age): Ditto. * demangle.c (_initialize_demangler) (show_demangling_style_names): Ditto. * dcache.c (_initialize_dcache, show_dcache_enabled_p): Ditto. * cp-valprint.c (show_static_field_print) (_initialize_cp_valprint, show_vtblprint, show_objectprint): Ditto. * corefile.c (_initialize_core, show_gnutarget_string): Ditto. * cli/cli-logging.c (_initialize_cli_logging) (show_logging_overwrite, show_logging_redirect) (show_logging_filename): Ditto. * cli/cli-cmds.c (show_info_verbose, show_history_expansion_p) (init_cli_cmds, show_baud_rate, show_remote_debug) (show_remote_timeout, show_max_user_call_depth): Ditto. * charset.c (show_host_charset_name, show_target_charset_name) (initialize_charset): Ditto. * breakpoint.c (show_can_use_hw_watchpoints) (show_pending_break_support, _initialize_breakpoint): Ditto.
2005-02-24 14:51:36 +01:00
show_solib_search_path,
&setlist, &showlist);
}