[PATCH 2/3] [gdb/symtab] Add debuginfod verbose level 2

Andrew Burgess aburgess@redhat.com
Mon May 27 21:48:33 GMT 2024


Tom de Vries <tdevries@suse.de> writes:

> 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));
>     }
> }

I believe ENOENT is what we get back when the debuginfod server doesn't
have anything to give us, in which case, in normal usage we prefer not
to spam the user that the server couldn't help us.

But I can see how this might be useful.

There is some possible cross over here between a flag to make user
commands more or less verbose, and the possibility of adding a 'set
debug debuginfod on/off' option.  When does "extra verbose user output"
become "debug output only useful for GDB maintainers"?  I'm not really
sure what the answer is.

Anyway, I figure we can always tweak these messages later if needed.  So
I'd be happy with these going in.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew

> ...
>
> 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



More information about the Gdb-patches mailing list