]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
add warning in case of build-id mismatch, style filenames
authorAaron Merey <amerey@redhat.com>
Mon, 24 Feb 2020 19:18:16 +0000 (14:18 -0500)
committerAaron Merey <amerey@redhat.com>
Mon, 24 Feb 2020 19:18:16 +0000 (14:18 -0500)
gdb/debuginfod-support.c
gdb/debuginfod-support.h
gdb/dwarf2read.c
gdb/elfread.c

index 7d075e0d4ac746556c5c02dc072c5fb94f09923c..6e0ee43c4fcb7febe57718787fd9d061e69f132c 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <errno.h>
 #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<char> *destname)
+                        gdb::unique_xmalloc_ptr<char> *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
index 2e500a99f3da856995a12e80d22a073324f8bcc6..94d4eba99b5b692cb774b1ebaa8ac988d09b560c 100644 (file)
@@ -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<char> *destname);
+                        const char *src_path,
+                        gdb::unique_xmalloc_ptr<char> *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.
index 595e021701183b8a2a0660341664c5deefb2030d..2d61250d892bb8cdf254aee2e4aff3d7b04a953f 100644 (file)
@@ -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);
        }
     }
index f86c9548bea96638f72f32b12a777f3aa8c53763..d842d5b573dd5ed67634d8545f3bcf92002fc905 100644 (file)
@@ -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;
                    }
                }
            }