X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fcorelow.c;h=6c1e47a555674ddb20002a9fb40d434b6d7799f7;hb=e623f035020ea7baa64933b4afaaa564b4c7e26d;hp=fa1661ee61ddc8f689136f4fd88f9168efb8dcab;hpb=e0eac551da0afeec8ec17f457e4e1da1756e0aab;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/corelow.c b/gdb/corelow.c index fa1661ee61..6c1e47a555 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -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 @@ -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