public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/3] [gdb/symtab] Add debuginfod verbose level 2
Date: Mon, 27 May 2024 16:18:07 +0200	[thread overview]
Message-ID: <20240527141808.31563-2-tdevries@suse.de> (raw)
In-Reply-To: <20240527141808.31563-1-tdevries@suse.de>

In print_outcome in debuginfod-support.c, download failures are not mentioned
if the errno is ENOENT, aka as "No such file or directory":
...
static void
print_outcome (int fd, const char *desc, const char *fname)
{
  if (fd < 0 && fd != -ENOENT)
    {
      ui_file *outstream = get_unbuffered (gdb_stdout);
      gdb_printf (outstream,
                  _("Download failed: %s.  Continuing without %s %ps.\n"),
                  safe_strerror (-fd),
                  desc,
                  styled_string (file_name_style.style (), fname));
    }
}
...

Define a new debuginfod verbose level 2 at which also this type of download
failure is mentioned, and use it in the gdb.debuginfod test-cases, such that
we get the explicit:
...
Downloading separate debug info for /lib64/ld-linux-x86-64.so.2...^M
Download failed: No such file or directory.  Continuing without separate \
  debug info for /lib64/ld-linux-x86-64.so.2.^M
...

Tested on x86_64-linux.
---
 gdb/debuginfod-support.c                      |  2 +-
 gdb/doc/gdb.texinfo                           |  4 +--
 .../build-id-no-debug-warning.exp             |  6 +++-
 gdb/testsuite/gdb.debuginfod/crc_mismatch.exp |  7 ++++-
 .../gdb.debuginfod/fetch_src_and_symbols.exp  | 31 ++++++++++++-------
 5 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 841b6f2078c..e65afb7523f 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -288,7 +288,7 @@ debuginfod_is_enabled ()
 static void
 print_outcome (int fd, const char *desc, const char *fname)
 {
-  if (fd < 0 && fd != -ENOENT)
+  if (fd < 0 && (fd != -ENOENT || debuginfod_verbose >= 2))
     {
       ui_file *outstream = get_unbuffered (gdb_stdout);
       gdb_printf (outstream,
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 61f91ef4ad6..fa1812124c1 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -50330,8 +50330,8 @@ Display the list of URLs that @code{debuginfod} will attempt to query.
 @item set debuginfod verbose
 @itemx set debuginfod verbose @var{n}
 Enable or disable @code{debuginfod}-related output.  Use a non-zero value
-to enable and @code{0} to disable.  @code{debuginfod} output is shown by
-default.
+to enable and @code{0} to disable.  Higher values may produce more
+output.  Set to @code{1} by default.
 
 @kindex show debuginfod verbose
 @item show debuginfod verbose
diff --git a/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp b/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp
index 25d800a378b..d63957ac05c 100644
--- a/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp
+++ b/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp
@@ -142,9 +142,13 @@ proc_with_prefix local_debuginfod { } {
     # GDB should now find the symbol and source files.
     clean_restart
 
-    # Enable debuginfod and fetch the debuginfo.
+    # Enable debuginfod.
     gdb_test_no_output "set debuginfod enabled on"
 
+    # Be verbose about observed debuginfod behaviour.
+    gdb_test_no_output "set debuginfod verbose 2"
+
+    # Fetch the debuginfo.
     # "separate debug info file has no debug info" warning should not be
     # reported now because the correct debuginfo should be fetched from
     # debuginfod.
diff --git a/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp b/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp
index 27069b580dc..6dcabf60357 100644
--- a/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp
+++ b/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp
@@ -114,8 +114,13 @@ proc_with_prefix local_debuginfod { } {
     # GDB should now find the symbol and source files.
     clean_restart
 
-    # Enable debuginfod and fetch the debuginfo.
+    # Enable debuginfod.
     gdb_test_no_output "set debuginfod enabled on"
+
+    # Be verbose about observed debuginfod behaviour.
+    gdb_test_no_output -nopass "set debuginfod verbose 2"
+
+    # Fetch the debuginfo.
     gdb_test "file $binfile" ".*Reading symbols from.*debuginfo.*" \
 	"file [file tail $binfile] cmd on"
 
diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
index 0fb752ff6bd..4d2f70261fe 100644
--- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
+++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
@@ -42,6 +42,13 @@ if { [gdb_compile "$sourcetmp" "${binfile}2" executable {debug build-id}] != ""
     return -1
 }
 
+proc clean_restart_local {{executable ""}} {
+    clean_restart $executable
+
+    # Be verbose about observed debuginfod behaviour.
+    gdb_test_no_output -nopass "set debuginfod verbose 2"
+}
+
 # Write some assembly that just has a .gnu_debugaltlink section.
 # Copied from testsuite/gdb.dwarf2/dwzbuildid.exp.
 proc write_just_debugaltlink {filename dwzname buildid} {
@@ -107,7 +114,7 @@ proc_with_prefix no_url { } {
     setenv DEBUGINFOD_URLS ""
 
     # Test that GDB cannot find source without debuginfod.
-    clean_restart $binfile
+    clean_restart_local $binfile
     gdb_test_no_output "set substitute-path $outputdir /dev/null" \
 	"set substitute-path"
     gdb_test "list" ".*No such file or directory.*"
@@ -126,7 +133,7 @@ proc_with_prefix no_url { } {
     file rename -force $debuginfo $debugdir
 
     # Test that GDB cannot find symbols without debuginfod.
-    clean_restart $binfile
+    clean_restart_local $binfile
     gdb_test "file" ".*No symbol file.*"
 
     set buildid "01234567890abcdef0123456"
@@ -150,14 +157,14 @@ proc_with_prefix no_url { } {
     file rename -force ${binfile}_dwz.o $debugdir
 
     # Test that GDB cannot find dwz without debuginfod.
-    clean_restart
+    clean_restart_local
     gdb_test "file ${binfile}_alt.o" \
 	".*could not find '.gnu_debugaltlink'.*" \
 	"file [file tail ${binfile}_alt.o]"
 
     # Generate a core file and test that GDB cannot find the
     # executable.
-    clean_restart ${binfile}2
+    clean_restart_local ${binfile}2
     if ![runto_main] {
 	return -1
     }
@@ -169,7 +176,7 @@ proc_with_prefix no_url { } {
 	"file [file tail $::corefile] gen"
     file rename -force ${binfile}2 $debugdir
 
-    clean_restart
+    clean_restart_local
     gdb_test "core $::corefile" ".*in ?? ().*" "file [file tail $::corefile]"
 }
 
@@ -180,7 +187,7 @@ proc_with_prefix no_url { } {
 
 proc test_urls {urls pattern_re test} {
     setenv DEBUGINFOD_URLS $urls
-    clean_restart
+    clean_restart_local
 
     if {$pattern_re != ""} {
 	set urls_re " +${pattern_re}\r\n"
@@ -222,7 +229,7 @@ proc_with_prefix local_url { } {
     setenv DEBUGINFOD_URLS $url
 
     # GDB should now find the symbol and source files.
-    clean_restart
+    clean_restart_local
     gdb_test_no_output "set debuginfod enabled on" \
 	"enabled debuginfod for initial test"
     gdb_load $binfile
@@ -248,12 +255,12 @@ proc_with_prefix local_url { } {
     # GDB should now find the executable file.
     set enable_debuginfod_question \
 	"Enable debuginfod for this session. \\(y or \\\[n\\\]\\) "
-    clean_restart
+    clean_restart_local
     gdb_test "core $::corefile" ".*return 0.*" "file [file tail $::corefile]" \
 	$enable_debuginfod_question "y"
 
     # GDB should now find the debugaltlink file.
-    clean_restart
+    clean_restart_local
     gdb_test "file ${binfile}_alt.o" \
 	".*Downloading.*separate debug info.*" \
 	"file [file tail ${binfile}_alt.o]" \
@@ -261,7 +268,7 @@ proc_with_prefix local_url { } {
 
     # Configure debuginfod with commands.
     unsetenv DEBUGINFOD_URLS
-    clean_restart
+    clean_restart_local
     gdb_test "file $binfile" ".*No debugging symbols.*" \
 	"file [file tail $binfile] cmd"
     gdb_test_no_output "set debuginfod enabled off"
@@ -282,7 +289,7 @@ proc_with_prefix local_url { } {
 
     # Empty URLS disables Debuginfod.
     setenv DEBUGINFOD_URLS ""
-    clean_restart
+    clean_restart_local
     # Disable confirmation to avoid having to deal with a query.  See
     # test_urls.
     set file_cmd "with confirm off -- file $binfile"
@@ -297,7 +304,7 @@ proc_with_prefix local_url { } {
 
     # Whitespace-only URLS disables Debuginfod.
     setenv DEBUGINFOD_URLS "    "
-    clean_restart
+    clean_restart_local
     gdb_test_multiple $file_cmd "notice whitespace URL" {
 	-re -wrap "This GDB supports auto-downloading.*" {
 	    fail $gdb_test_name
-- 
2.35.3


  reply	other threads:[~2024-05-27 14:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-27 14:18 [PATCH 1/3] [gdb/testsuite] Mention DEBUGINFOD_VERBOSE in gdb.debuginfod test-cases Tom de Vries
2024-05-27 14:18 ` Tom de Vries [this message]
2024-05-27 21:48   ` [PATCH 2/3] [gdb/symtab] Add debuginfod verbose level 2 Andrew Burgess
2024-05-27 14:18 ` [PATCH 3/3] [gdb/symtab] Note success at " Tom de Vries
2024-05-27 21:49   ` Andrew Burgess
2024-05-27 21:40 ` [PATCH 1/3] [gdb/testsuite] Mention DEBUGINFOD_VERBOSE in gdb.debuginfod test-cases Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240527141808.31563-2-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).