X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fcorelow.c;h=74f660828df2b6b085f5f55b8ea433399303e4ef;hb=5018ce90c1205d79f29adf954b0fd5e613d08430;hp=b32fa955fdab305a812636518e3b7758db57f8f6;hpb=30baf67b6505d903bf678f9a0ba3645eb337ce49;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/corelow.c b/gdb/corelow.c index b32fa955fd..74f660828d 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -1,6 +1,6 @@ /* Core dump and executable file functions below target vector, for GDB. - Copyright (C) 1986-2019 Free Software Foundation, Inc. + Copyright (C) 1986-2020 Free Software Foundation, Inc. This file is part of GDB. @@ -35,7 +35,7 @@ #include "regset.h" #include "symfile.h" #include "exec.h" -#include "readline/readline.h" +#include "readline/tilde.h" #include "solib.h" #include "filenames.h" #include "progspace.h" @@ -43,6 +43,8 @@ #include "gdb_bfd.h" #include "completer.h" #include "gdbsupport/filestuff.h" +#include "build-id.h" +#include "gdbsupport/pathstuff.h" #ifndef O_LARGEFILE #define O_LARGEFILE 0 @@ -92,7 +94,7 @@ public: bool has_memory () override; bool has_stack () override; bool has_registers () override; - bool has_execution (ptid_t) override { return false; } + bool has_execution (inferior *inf) override { return false; } bool info_proc (const char *, enum info_proc_what) override; @@ -351,6 +353,27 @@ core_file_command (const char *filename, int from_tty) core_target_open (filename, from_tty); } +/* Locate (and load) an executable file (and symbols) given the core file + BFD ABFD. */ + +static void +locate_exec_from_corefile_build_id (bfd *abfd, int from_tty) +{ + const bfd_build_id *build_id = build_id_bfd_get (abfd); + if (build_id == nullptr) + return; + + gdb_bfd_ref_ptr execbfd + = build_id_to_exec_bfd (build_id->size, build_id->data); + + if (execbfd != nullptr) + { + exec_file_attach (bfd_get_filename (execbfd.get ()), from_tty); + symbol_file_add_main (bfd_get_filename (execbfd.get ()), + symfile_add_flag (from_tty ? SYMFILE_VERBOSE : 0)); + } +} + /* See gdbcore.h. */ void @@ -373,8 +396,7 @@ core_target_open (const char *arg, int from_tty) gdb::unique_xmalloc_ptr filename (tilde_expand (arg)); if (!IS_ABSOLUTE_PATH (filename.get ())) - filename.reset (concat (current_directory, "/", - filename.get (), (char *) NULL)); + filename = gdb_abspath (filename.get ()); flags = O_BINARY | O_LARGEFILE; if (write_files) @@ -456,6 +478,9 @@ core_target_open (const char *arg, int from_tty) switch_to_thread (thread); } + if (exec_bfd == nullptr) + locate_exec_from_corefile_build_id (core_bfd, from_tty); + post_create_inferior (target, from_tty); /* Now go through the target stack looking for threads since there