X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fsource.c;h=0c2b5a4f83de7f57ec587c66cfaa3c5f701f6562;hb=cbd7581f343d85b4216db2eefdf601f6d988062d;hp=4f889e4b95ad9b2105f66a538bf455ce0acd83ea;hpb=5abbbe1d13e03496af5564b997f3c3a2e79b4d73;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/source.c b/gdb/source.c index 4f889e4b95..0c2b5a4f83 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 @@ -419,9 +421,7 @@ forget_cached_source_info_for_objfile (struct objfile *objfile) void forget_cached_source_info (void) { - struct program_space *pspace; - - ALL_PSPACES (pspace) + for (struct program_space *pspace : program_spaces) for (objfile *objfile : pspace->objfiles ()) { forget_cached_source_info_for_objfile (objfile); @@ -1148,6 +1148,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 if (SYMTAB_DIRNAME (s) != nullptr) + { + 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 && !srcpath.empty ()) + fd = debuginfod_source_query (build_id->data, + build_id->size, + srcpath.c_str (), + &fullname); + } + } + s->fullname = fullname.release (); return fd; } @@ -1469,8 +1497,7 @@ info_line_command (const char *arg, int from_tty) else if (sal.line > 0 && find_line_pc_range (sal, &start_pc, &end_pc)) { - struct gdbarch *gdbarch - = get_objfile_arch (SYMTAB_OBJFILE (sal.symtab)); + struct gdbarch *gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch (); if (start_pc == end_pc) { @@ -1505,7 +1532,7 @@ info_line_command (const char *arg, int from_tty) /* If this is the only line, show the source code. If it could not find the file, don't do anything special. */ - if (sals.size () == 1) + if (annotation_level > 0 && sals.size () == 1) annotate_source_line (sal.symtab, sal.line, 0, start_pc); } else