From: Aaron Merey Date: Mon, 24 Feb 2020 19:18:16 +0000 (-0500) Subject: add warning in case of build-id mismatch, style filenames X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70eb9acb8b959f2481f322ad4c4cfff4da2fed68;p=thirdparty%2Fbinutils-gdb.git add warning in case of build-id mismatch, style filenames --- diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index 7d075e0d4ac..6e0ee43c4fc 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -18,6 +18,7 @@ #include #include "defs.h" +#include "cli/cli-style.h" #include "gdbsupport/scoped_fd.h" #include "debuginfod-support.h" @@ -46,14 +47,10 @@ progressfn (debuginfod_client *c, long cur, long total) { if (check_quit_flag ()) { - printf_unfiltered ("Cancelling download...\n"); + printf_filtered ("Cancelling download...\n"); return 1; } - printf_unfiltered ("Downloading... %.0f%% (%ld/%ld)%s", - (cur * 100.0f) / total, - cur, total, - (cur == total) ? "\n" : "\r"); return 0; } @@ -74,31 +71,31 @@ scoped_fd debuginfod_source_query (const unsigned char *build_id, int build_id_len, const char *srcpath, - gdb::unique_xmalloc_ptr *destname) + gdb::unique_xmalloc_ptr *destname) { debuginfod_client *c = debuginfod_init (); if (c == nullptr) return scoped_fd (-ENOMEM); - char *dname = nullptr; + printf_filtered (_("Debuginfod fetching source file %ps...\n"), + styled_string (file_name_style.style (), srcpath)); - printf_unfiltered ("Attempting to download source file %s\n", srcpath); scoped_fd fd (debuginfod_find_source (c, build_id, build_id_len, srcpath, - &dname)); + nullptr)); if (fd.get () < 0) - printf_unfiltered ("Download unsuccessful. Continuing without source file %s.\n", - srcpath); + { + printf_filtered (_("Download failed. Continuing without source file %ps.\n"), + styled_string (file_name_style.style (), srcpath)); + } else - printf_unfiltered ("Download successful.\n"); + destname->reset (xstrdup (srcpath)); - destname->reset (dname); debuginfod_end (c); - return fd; } @@ -115,20 +112,18 @@ debuginfod_debuginfo_query (const unsigned char *build_id, if (c == nullptr) return scoped_fd (-ENOMEM); - char *dname = nullptr; + printf_filtered (_("Debuginfod fetching debug info for %ps...\n"), + styled_string (file_name_style.style (), filename)); - printf_filtered ("Attempting to download debug info for %s\n", filename); + char *dname = nullptr; scoped_fd fd (debuginfod_find_debuginfo (c, build_id, build_id_len, &dname)); if (fd.get () < 0) - printf_unfiltered ("Download unsuccessful. Continuing without debug info for %s.\n", - filename); - else - printf_unfiltered ("Download successful.\n"); + printf_filtered (_("Download failed. Continuing without debug info for %ps.\n"), + styled_string (file_name_style.style (), filename)); - debuginfod_end (c); destname->reset (dname); - + debuginfod_end (c); return fd; } #endif diff --git a/gdb/debuginfod-support.h b/gdb/debuginfod-support.h index 2e500a99f3d..94d4eba99b5 100644 --- a/gdb/debuginfod-support.h +++ b/gdb/debuginfod-support.h @@ -38,8 +38,8 @@ extern scoped_fd debuginfod_source_query (const unsigned char *build_id, int build_id_len, - const char *src_path, - gdb::unique_xmalloc_ptr *destname); + const char *src_path, + gdb::unique_xmalloc_ptr *destname); /* Query debuginfod servers for a debuginfo file with BUILD_ID. BUILD_ID can be given as a binary blob or a null-terminated string. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 595e0217011..2d61250d892 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -2758,12 +2758,14 @@ dwarf2_get_dwz_file (struct dwarf2_per_objfile *dwarf2_per_objfile) &alt_filename)); if (fd.get () >= 0) - { - /* File successfully retrieved from server. */ - dwz_bfd = gdb_bfd_open (alt_filename.get (), gnutarget, -1); + { + /* File successfully retrieved from server. */ + dwz_bfd = gdb_bfd_open (alt_filename.get (), gnutarget, -1); - if (dwz_bfd != nullptr - && !build_id_verify (dwz_bfd.get (), buildid_len, buildid)) + if (dwz_bfd == nullptr) + warning (_("File \"%s\" from debuginfod cannot be opened as bfd"), + alt_filename.get ()); + else if (!build_id_verify (dwz_bfd.get (), buildid_len, buildid)) dwz_bfd.reset (nullptr); } } diff --git a/gdb/elfread.c b/gdb/elfread.c index f86c9548bea..d842d5b573d 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1336,12 +1336,14 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) /* File successfully retrieved from server. */ gdb_bfd_ref_ptr debug_bfd (symfile_bfd_open (symfile_path.get ())); - if (debug_bfd != nullptr - && build_id_verify (debug_bfd.get (), build_id->size, build_id->data)) + if (debug_bfd == nullptr) + warning (_("File \"%s\" from debuginfod cannot be opened as bfd"), + objfile->original_name); + else if (build_id_verify (debug_bfd.get (), build_id->size, build_id->data)) { symbol_file_add_separate (debug_bfd.get (), symfile_path.get (), symfile_flags, objfile); - has_dwarf2 = true; + has_dwarf2 = true; } } }