diff options
Diffstat (limited to 'gdb/source.c')
-rw-r--r-- | gdb/source.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gdb/source.c b/gdb/source.c index 4f889e4..051caf5 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -48,6 +48,8 @@ #include "source-cache.h" #include "cli/cli-style.h" #include "observable.h" +#include "build-id.h" +#include "debuginfod-support.h" #define OPEN_MODE (O_RDONLY | O_BINARY) #define FDOPEN_MODE FOPEN_RB @@ -1148,6 +1150,34 @@ open_source_file (struct symtab *s) s->fullname = NULL; scoped_fd fd = find_and_open_source (s->filename, SYMTAB_DIRNAME (s), &fullname); + + if (fd.get () < 0) + { + if (SYMTAB_COMPUNIT (s) != nullptr) + { + const objfile *ofp = COMPUNIT_OBJFILE (SYMTAB_COMPUNIT (s)); + + std::string srcpath; + if (IS_ABSOLUTE_PATH (s->filename)) + srcpath = s->filename; + else + { + srcpath = SYMTAB_DIRNAME (s); + srcpath += SLASH_STRING; + srcpath += s->filename; + } + + const struct bfd_build_id *build_id = build_id_bfd_get (ofp->obfd); + + /* Query debuginfod for the source file. */ + if (build_id != nullptr) + fd = debuginfod_source_query (build_id->data, + build_id->size, + srcpath.c_str (), + &fullname); + } + } + s->fullname = fullname.release (); return fd; } |