X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fcorelow.c;h=bdbfae372d74f187d1ebde7f03ab823e7c741b7d;hb=c8ec2f433c54dae7746db144a872da6f808e5d73;hp=cea9210a52039ebc753b969e761d1d0adf14b0d0;hpb=abf516c6931af1683d1e51203de1ca01467f9f85;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/corelow.c b/gdb/corelow.c index cea9210a52..bdbfae372d 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -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,7 @@ #include "gdb_bfd.h" #include "completer.h" #include "gdbsupport/filestuff.h" +#include "build-id.h" #ifndef O_LARGEFILE #define O_LARGEFILE 0 @@ -330,7 +331,7 @@ maybe_say_no_core_file_now (int from_tty) printf_filtered (_("No core file now.\n")); } -/* Backward compatability with old way of specifying core files. */ +/* Backward compatibility with old way of specifying core files. */ void core_file_command (const char *filename, int from_tty) @@ -351,6 +352,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 @@ -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