[2/6,v2] gdb: Add command 'maint set/show debuginfod download-sections'

Message ID 20230601014347.3367489-3-amerey@redhat.com
State New
Headers
Series gdb/debuginfod: Add on-demand debuginfo downloading |

Commit Message

Aaron Merey June 1, 2023, 1:43 a.m. UTC
  v1: https://sourceware.org/pipermail/gdb-patches/2023-February/197461.html

v2 removes 'set debuginfod enabled lazy' and replaces it with
'maint set debuginfod download-sections'.

Commit message:

This setting controls whether GDB may attempt to download ELF/DWARF
sections from debuginfod servers.

This setting is enabled by default if gdb is built with debuginfod
section download support (requires libdebuginfod 0.188).

Also update debuginfod command help text and gdb.texinfo with
information on section downloading and the new command.
---
 gdb/debuginfod-support.c | 66 ++++++++++++++++++++++++++++++++++++++--
 gdb/doc/gdb.texinfo      | 16 ++++++++--
 2 files changed, 77 insertions(+), 5 deletions(-)
  

Comments

Eli Zaretskii June 1, 2023, 6:13 a.m. UTC | #1
> Cc: aburgess@redhat.com,
> 	Aaron Merey <amerey@redhat.com>
> Date: Wed, 31 May 2023 21:43:43 -0400
> From: Aaron Merey via Gdb-patches <gdb-patches@sourceware.org>
> 
>  gdb/debuginfod-support.c | 66 ++++++++++++++++++++++++++++++++++++++--
>  gdb/doc/gdb.texinfo      | 16 ++++++++--
>  2 files changed, 77 insertions(+), 5 deletions(-)

Thanks.

> @@ -568,8 +604,11 @@ _initialize_debuginfod ()
>  			_("Set whether to use debuginfod."),
>  			_("Show whether to use debuginfod."),
>  			_("\
> -When on, enable the use of debuginfod to download missing debug info and\n\
> -source files."),
> +When set to \"on\", enable the use of debuginfod to download missing\n\
> +debug info and source files. GDB may also download components of debug\n\
> +info instead of entire files. \"off\" disables the use of debuginfod.\n\

Our conventions are to leave two spaces between sentences, not one.

> +When set to \"ask\", a prompt may ask whether to enable or disable\n\
> +debuginfod." ),

"a prompt may ask" sounds awkward and somewhat mysterious.  How about

  When set to "ask", prompt whether to enable or disable [...]

instead?

> +@kindex maint set debuginfod
> +@kindex maint show debuginfod
> +@item maint set debuginfod download-sections
> +@itemx maint set debuginfod download-sections @r{[}on|off@r{]}
> +@itemx maint show debuginfod download-sections
> +Controls whether @value{GDBN} will attempt to download individual
> +ELF/DWARF sections from @code{debuginfod}.  If disabled, only
> +whole debug info files will be downloaded.  This could result
> +in @value{GDBN} downloading larger amounts of data.

I'd make the last sentence a part of the one before it, for clarity of
what "this" means.  Like this:

   If disabled, only whole debug info files will be downloaded; this
   could result in @value{GDBN} downloading larger amounts of data.

>  @cindex @value{GDBN} internal error
>  @cindex internal errors, control of @value{GDBN} behavior
>  @cindex demangler crashes
> @@ -49382,8 +49392,10 @@ regarding @code{debuginfod}.
>  @item set debuginfod enabled
>  @itemx set debuginfod enabled on
>  @cindex enable debuginfod
> -@value{GDBN} will attempt to query @code{debuginfod} servers when missing debug
> -info or source files.
> +@value{GDBN} will attempt to query @code{debuginfod} servers for missing debug
> +info or source files.

Why "attempt to query"? why not just "query"?  Or maybe "attempt to
download"?

> @value{GDBN} may attempt to download individual ELF/DWARF
> +sections such as @code{.gdb_index} to help reduce the total amount of data
> +downloaded from debuginfod servers.

Once again, I'd drop the "attempt" part.  More importantly, a
cross-reference to where "maint set debuginfod" is described is
missing here.  I would suggest

  @value{GDBN} may download individual ELF/DWARF sections such as
  @code{.gdb_index} to help reduce the total amount of data downloaded
  from debuginfod servers; this can be controlled by @w{@code{maint
  set debuginfod download-sections}} (@pxref{Maintenance Commands,
  maint set debuginfod download-sections}).

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
  
Andrew Burgess June 7, 2023, 1:57 p.m. UTC | #2
Aaron Merey <amerey@redhat.com> writes:

> v1: https://sourceware.org/pipermail/gdb-patches/2023-February/197461.html
>
> v2 removes 'set debuginfod enabled lazy' and replaces it with
> 'maint set debuginfod download-sections'.
>
> Commit message:
>
> This setting controls whether GDB may attempt to download ELF/DWARF
> sections from debuginfod servers.
>
> This setting is enabled by default if gdb is built with debuginfod
> section download support (requires libdebuginfod 0.188).
>
> Also update debuginfod command help text and gdb.texinfo with
> information on section downloading and the new command.
> ---
>  gdb/debuginfod-support.c | 66 ++++++++++++++++++++++++++++++++++++++--
>  gdb/doc/gdb.texinfo      | 16 ++++++++--
>  2 files changed, 77 insertions(+), 5 deletions(-)
>
> diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
> index 8be43a91dcc..6d0521b64e2 100644
> --- a/gdb/debuginfod-support.c
> +++ b/gdb/debuginfod-support.c
> @@ -31,6 +31,10 @@
>  static cmd_list_element *set_debuginfod_prefix_list;
>  static cmd_list_element *show_debuginfod_prefix_list;
>  
> +/* maint set/show debuginfod commands.  */
> +static cmd_list_element *maint_set_debuginfod_cmdlist;
> +static cmd_list_element *maint_show_debuginfod_cmdlist;
> +
>  static const char debuginfod_on[] = "on";
>  static const char debuginfod_off[] = "off";
>  static const char debuginfod_ask[] = "ask";
> @@ -50,6 +54,13 @@ static const char *debuginfod_enabled =
>    debuginfod_off;
>  #endif
>  
> +static bool debuginfod_download_sections =

Should have a comment.

> +#if defined(HAVE_LIBDEBUGINFOD_FIND_SECTION)
> +  true;
> +#else
> +  false;
> +#endif
> +
>  static unsigned int debuginfod_verbose = 1;
>  
>  #ifndef HAVE_LIBDEBUGINFOD
> @@ -424,7 +435,7 @@ debuginfod_section_query (const unsigned char *build_id,
>    return scoped_fd (-ENOSYS);
>  #else
>  
> - if (!debuginfod_is_enabled ())
> + if (!debuginfod_download_sections || !debuginfod_is_enabled ())
>      return scoped_fd (-ENOSYS);
>  
>    debuginfod_client *c = get_debuginfod_client ();
> @@ -550,6 +561,31 @@ show_debuginfod_verbose_command (ui_file *file, int from_tty,
>  	      value);
>  }
>  
> +/* Set callback for "maint set debuginfod download-sections".  */
> +
> +static void
> +maint_set_debuginfod_download_sections (bool value)
> +{
> +#if !defined(HAVE_LIBDEBUGINFOD_FIND_SECTION)
> +  if (value)
> +    {
> +      error (_("Support for section downloading is not compiled into GDB. " \
> +"Defaulting to \"off\"."));
> +      return;
> +    }

You can drop the return here, error is marked noreturn.  With that gone,
you can remove the '{' and '}' too.

> +#endif
> +
> +  debuginfod_download_sections = value;
> +}
> +
> +/* Get callback for "maint set debuginfod download-sections".  */
> +
> +static bool
> +maint_get_debuginfod_download_sections ()
> +{
> +  return debuginfod_download_sections;
> +}
> +
>  /* Register debuginfod commands.  */
>  
>  void _initialize_debuginfod ();
> @@ -568,8 +604,11 @@ _initialize_debuginfod ()
>  			_("Set whether to use debuginfod."),
>  			_("Show whether to use debuginfod."),
>  			_("\
> -When on, enable the use of debuginfod to download missing debug info and\n\
> -source files."),
> +When set to \"on\", enable the use of debuginfod to download missing\n\
> +debug info and source files. GDB may also download components of debug\n\
> +info instead of entire files. \"off\" disables the use of debuginfod.\n\
> +When set to \"ask\", a prompt may ask whether to enable or disable\n\
> +debuginfod." ),
>  			set_debuginfod_enabled,
>  			get_debuginfod_enabled,
>  			show_debuginfod_enabled,
> @@ -600,4 +639,25 @@ query.\nTo disable, set to zero.  Verbose output is displayed by default."),
>  			     show_debuginfod_verbose_command,
>  			     &set_debuginfod_prefix_list,
>  			     &show_debuginfod_prefix_list);
> +
> +  /* maint set/show debuginfod */

This comment, and the one below, should end with a full stop and double
space.

> +  add_setshow_prefix_cmd ("debuginfod", class_maintenance,
> +			  _("Set debuginfod specific variables."),
> +			  _("Show debuginfod specific variables."),
> +			  &maint_set_debuginfod_cmdlist,
> +			  &maint_show_debuginfod_cmdlist,
> +			  &maintenance_set_cmdlist, &maintenance_show_cmdlist);
> +
> +  /* maint set/show debuginfod download-sections */
> +  add_setshow_boolean_cmd ("download-sections", class_maintenance, _("\
> +Set whether debuginfod may download individual ELF/DWARF sections."), _("\
> +Show whether debuginfod may download individual ELF/DWARF sections."), _("\
> +When enabled, debuginfod may attempt to download individual ELF/DWARF \
> +sections from debug info files.\nIf disabled, only whole debug info files \
> +may be downloaded."),
> +			  maint_set_debuginfod_download_sections,
> +			  maint_get_debuginfod_download_sections,
> +			  nullptr,
> +			  &maint_set_debuginfod_cmdlist,
> +			  &maint_show_debuginfod_cmdlist);

The indentation is off by one here.

I think all the above are pretty minor.  With those fixed this GDB code
changes are good.

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

Thanks,
Andrew

>  }
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index fc55c4e7b43..91da9777fd6 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -40872,6 +40872,16 @@ Create a core file? (y or n) @kbd{n}
>  (@value{GDBP})
>  @end smallexample
>  
> +@kindex maint set debuginfod
> +@kindex maint show debuginfod
> +@item maint set debuginfod download-sections
> +@itemx maint set debuginfod download-sections @r{[}on|off@r{]}
> +@itemx maint show debuginfod download-sections
> +Controls whether @value{GDBN} will attempt to download individual
> +ELF/DWARF sections from @code{debuginfod}.  If disabled, only
> +whole debug info files will be downloaded.  This could result
> +in @value{GDBN} downloading larger amounts of data.
> +
>  @cindex @value{GDBN} internal error
>  @cindex internal errors, control of @value{GDBN} behavior
>  @cindex demangler crashes
> @@ -49382,8 +49392,10 @@ regarding @code{debuginfod}.
>  @item set debuginfod enabled
>  @itemx set debuginfod enabled on
>  @cindex enable debuginfod
> -@value{GDBN} will attempt to query @code{debuginfod} servers when missing debug
> -info or source files.
> +@value{GDBN} will attempt to query @code{debuginfod} servers for missing debug
> +info or source files.  @value{GDBN} may attempt to download individual ELF/DWARF
> +sections such as @code{.gdb_index} to help reduce the total amount of data
> +downloaded from debuginfod servers.
>  
>  @item set debuginfod enabled off
>  @value{GDBN} will not attempt to query @code{debuginfod} servers when missing
> -- 
> 2.40.1
  
Andrew Burgess July 27, 2023, 12:04 p.m. UTC | #3
Aaron Merey <amerey@redhat.com> writes:

> v1: https://sourceware.org/pipermail/gdb-patches/2023-February/197461.html
>
> v2 removes 'set debuginfod enabled lazy' and replaces it with
> 'maint set debuginfod download-sections'.
>
> Commit message:
>
> This setting controls whether GDB may attempt to download ELF/DWARF
> sections from debuginfod servers.
>
> This setting is enabled by default if gdb is built with debuginfod
> section download support (requires libdebuginfod 0.188).
>
> Also update debuginfod command help text and gdb.texinfo with
> information on section downloading and the new command.
> ---
>  gdb/debuginfod-support.c | 66 ++++++++++++++++++++++++++++++++++++++--
>  gdb/doc/gdb.texinfo      | 16 ++++++++--
>  2 files changed, 77 insertions(+), 5 deletions(-)
>
> diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
> index 8be43a91dcc..6d0521b64e2 100644
> --- a/gdb/debuginfod-support.c
> +++ b/gdb/debuginfod-support.c
> @@ -31,6 +31,10 @@
>  static cmd_list_element *set_debuginfod_prefix_list;
>  static cmd_list_element *show_debuginfod_prefix_list;
>  
> +/* maint set/show debuginfod commands.  */
> +static cmd_list_element *maint_set_debuginfod_cmdlist;
> +static cmd_list_element *maint_show_debuginfod_cmdlist;
> +
>  static const char debuginfod_on[] = "on";
>  static const char debuginfod_off[] = "off";
>  static const char debuginfod_ask[] = "ask";
> @@ -50,6 +54,13 @@ static const char *debuginfod_enabled =
>    debuginfod_off;
>  #endif
>  
> +static bool debuginfod_download_sections =
> +#if defined(HAVE_LIBDEBUGINFOD_FIND_SECTION)
> +  true;
> +#else
> +  false;
> +#endif
> +
>  static unsigned int debuginfod_verbose = 1;
>  
>  #ifndef HAVE_LIBDEBUGINFOD
> @@ -424,7 +435,7 @@ debuginfod_section_query (const unsigned char *build_id,
>    return scoped_fd (-ENOSYS);
>  #else
>  
> - if (!debuginfod_is_enabled ())
> + if (!debuginfod_download_sections || !debuginfod_is_enabled ())
>      return scoped_fd (-ENOSYS);
>  
>    debuginfod_client *c = get_debuginfod_client ();
> @@ -550,6 +561,31 @@ show_debuginfod_verbose_command (ui_file *file, int from_tty,
>  	      value);
>  }
>  
> +/* Set callback for "maint set debuginfod download-sections".  */
> +
> +static void
> +maint_set_debuginfod_download_sections (bool value)
> +{
> +#if !defined(HAVE_LIBDEBUGINFOD_FIND_SECTION)
> +  if (value)
> +    {
> +      error (_("Support for section downloading is not compiled into GDB. " \
> +"Defaulting to \"off\"."));
> +      return;
> +    }
> +#endif
> +
> +  debuginfod_download_sections = value;
> +}
> +
> +/* Get callback for "maint set debuginfod download-sections".  */
> +
> +static bool
> +maint_get_debuginfod_download_sections ()
> +{
> +  return debuginfod_download_sections;
> +}
> +
>  /* Register debuginfod commands.  */
>  
>  void _initialize_debuginfod ();
> @@ -568,8 +604,11 @@ _initialize_debuginfod ()
>  			_("Set whether to use debuginfod."),
>  			_("Show whether to use debuginfod."),
>  			_("\
> -When on, enable the use of debuginfod to download missing debug info and\n\
> -source files."),
> +When set to \"on\", enable the use of debuginfod to download missing\n\
> +debug info and source files. GDB may also download components of debug\n\
> +info instead of entire files. \"off\" disables the use of debuginfod.\n\
> +When set to \"ask\", a prompt may ask whether to enable or disable\n\
> +debuginfod." ),
>  			set_debuginfod_enabled,
>  			get_debuginfod_enabled,
>  			show_debuginfod_enabled,
> @@ -600,4 +639,25 @@ query.\nTo disable, set to zero.  Verbose output is displayed by default."),
>  			     show_debuginfod_verbose_command,
>  			     &set_debuginfod_prefix_list,
>  			     &show_debuginfod_prefix_list);
> +
> +  /* maint set/show debuginfod */
> +  add_setshow_prefix_cmd ("debuginfod", class_maintenance,
> +			  _("Set debuginfod specific variables."),
> +			  _("Show debuginfod specific variables."),
> +			  &maint_set_debuginfod_cmdlist,
> +			  &maint_show_debuginfod_cmdlist,
> +			  &maintenance_set_cmdlist, &maintenance_show_cmdlist);
> +
> +  /* maint set/show debuginfod download-sections */
> +  add_setshow_boolean_cmd ("download-sections", class_maintenance, _("\
> +Set whether debuginfod may download individual ELF/DWARF sections."), _("\
> +Show whether debuginfod may download individual ELF/DWARF sections."), _("\
> +When enabled, debuginfod may attempt to download individual ELF/DWARF \
> +sections from debug info files.\nIf disabled, only whole debug info files \
> +may be downloaded."),
> +			  maint_set_debuginfod_download_sections,
> +			  maint_get_debuginfod_download_sections,
> +			  nullptr,
> +			  &maint_set_debuginfod_cmdlist,
> +			  &maint_show_debuginfod_cmdlist);
>  }
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index fc55c4e7b43..91da9777fd6 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -40872,6 +40872,16 @@ Create a core file? (y or n) @kbd{n}
>  (@value{GDBP})
>  @end smallexample
>  
> +@kindex maint set debuginfod
> +@kindex maint show debuginfod

I think these should be:

  @kindex maint set debuginfod download-sections
  @kindex maint show debuginfod download-sections

Other places in the manual where we have multi "level" commands like
this, all levels seem to be included in the @kindex entry.

Thanks,
Andrew


> +@item maint set debuginfod download-sections
> +@itemx maint set debuginfod download-sections @r{[}on|off@r{]}
> +@itemx maint show debuginfod download-sections
> +Controls whether @value{GDBN} will attempt to download individual
> +ELF/DWARF sections from @code{debuginfod}.  If disabled, only
> +whole debug info files will be downloaded.  This could result
> +in @value{GDBN} downloading larger amounts of data.
> +
>  @cindex @value{GDBN} internal error
>  @cindex internal errors, control of @value{GDBN} behavior
>  @cindex demangler crashes
> @@ -49382,8 +49392,10 @@ regarding @code{debuginfod}.
>  @item set debuginfod enabled
>  @itemx set debuginfod enabled on
>  @cindex enable debuginfod
> -@value{GDBN} will attempt to query @code{debuginfod} servers when missing debug
> -info or source files.
> +@value{GDBN} will attempt to query @code{debuginfod} servers for missing debug
> +info or source files.  @value{GDBN} may attempt to download individual ELF/DWARF
> +sections such as @code{.gdb_index} to help reduce the total amount of data
> +downloaded from debuginfod servers.
>  
>  @item set debuginfod enabled off
>  @value{GDBN} will not attempt to query @code{debuginfod} servers when missing
> -- 
> 2.40.1
  
Andrew Burgess July 27, 2023, 12:19 p.m. UTC | #4
Aaron Merey <amerey@redhat.com> writes:

> v1: https://sourceware.org/pipermail/gdb-patches/2023-February/197461.html
>
> v2 removes 'set debuginfod enabled lazy' and replaces it with
> 'maint set debuginfod download-sections'.
>
> Commit message:
>
> This setting controls whether GDB may attempt to download ELF/DWARF
> sections from debuginfod servers.
>
> This setting is enabled by default if gdb is built with debuginfod
> section download support (requires libdebuginfod 0.188).
>
> Also update debuginfod command help text and gdb.texinfo with
> information on section downloading and the new command.
> ---
>  gdb/debuginfod-support.c | 66 ++++++++++++++++++++++++++++++++++++++--
>  gdb/doc/gdb.texinfo      | 16 ++++++++--
>  2 files changed, 77 insertions(+), 5 deletions(-)
>
> diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
> index 8be43a91dcc..6d0521b64e2 100644
> --- a/gdb/debuginfod-support.c
> +++ b/gdb/debuginfod-support.c
> @@ -31,6 +31,10 @@
>  static cmd_list_element *set_debuginfod_prefix_list;
>  static cmd_list_element *show_debuginfod_prefix_list;
>  
> +/* maint set/show debuginfod commands.  */
> +static cmd_list_element *maint_set_debuginfod_cmdlist;
> +static cmd_list_element *maint_show_debuginfod_cmdlist;
> +
>  static const char debuginfod_on[] = "on";
>  static const char debuginfod_off[] = "off";
>  static const char debuginfod_ask[] = "ask";
> @@ -50,6 +54,13 @@ static const char *debuginfod_enabled =
>    debuginfod_off;
>  #endif
>  
> +static bool debuginfod_download_sections =
> +#if defined(HAVE_LIBDEBUGINFOD_FIND_SECTION)
> +  true;
> +#else
> +  false;
> +#endif
> +
>  static unsigned int debuginfod_verbose = 1;
>  
>  #ifndef HAVE_LIBDEBUGINFOD
> @@ -424,7 +435,7 @@ debuginfod_section_query (const unsigned char *build_id,
>    return scoped_fd (-ENOSYS);
>  #else
>  
> - if (!debuginfod_is_enabled ())
> + if (!debuginfod_download_sections || !debuginfod_is_enabled ())
>      return scoped_fd (-ENOSYS);
>  
>    debuginfod_client *c = get_debuginfod_client ();
> @@ -550,6 +561,31 @@ show_debuginfod_verbose_command (ui_file *file, int from_tty,
>  	      value);
>  }
>  
> +/* Set callback for "maint set debuginfod download-sections".  */
> +
> +static void
> +maint_set_debuginfod_download_sections (bool value)
> +{
> +#if !defined(HAVE_LIBDEBUGINFOD_FIND_SECTION)
> +  if (value)
> +    {
> +      error (_("Support for section downloading is not compiled into GDB. " \
> +"Defaulting to \"off\"."));
> +      return;
> +    }
> +#endif
> +
> +  debuginfod_download_sections = value;
> +}
> +
> +/* Get callback for "maint set debuginfod download-sections".  */
> +
> +static bool
> +maint_get_debuginfod_download_sections ()
> +{
> +  return debuginfod_download_sections;
> +}
> +
>  /* Register debuginfod commands.  */
>  
>  void _initialize_debuginfod ();
> @@ -568,8 +604,11 @@ _initialize_debuginfod ()
>  			_("Set whether to use debuginfod."),
>  			_("Show whether to use debuginfod."),
>  			_("\
> -When on, enable the use of debuginfod to download missing debug info and\n\
> -source files."),
> +When set to \"on\", enable the use of debuginfod to download missing\n\
> +debug info and source files. GDB may also download components of debug\n\
> +info instead of entire files. \"off\" disables the use of debuginfod.\n\
> +When set to \"ask\", a prompt may ask whether to enable or disable\n\
> +debuginfod." ),
>  			set_debuginfod_enabled,
>  			get_debuginfod_enabled,
>  			show_debuginfod_enabled,
> @@ -600,4 +639,25 @@ query.\nTo disable, set to zero.  Verbose output is displayed by default."),
>  			     show_debuginfod_verbose_command,
>  			     &set_debuginfod_prefix_list,
>  			     &show_debuginfod_prefix_list);
> +
> +  /* maint set/show debuginfod */
> +  add_setshow_prefix_cmd ("debuginfod", class_maintenance,
> +			  _("Set debuginfod specific variables."),
> +			  _("Show debuginfod specific variables."),
> +			  &maint_set_debuginfod_cmdlist,
> +			  &maint_show_debuginfod_cmdlist,
> +			  &maintenance_set_cmdlist, &maintenance_show_cmdlist);
> +
> +  /* maint set/show debuginfod download-sections */
> +  add_setshow_boolean_cmd ("download-sections", class_maintenance, _("\
> +Set whether debuginfod may download individual ELF/DWARF sections."), _("\
> +Show whether debuginfod may download individual ELF/DWARF sections."), _("\
> +When enabled, debuginfod may attempt to download individual ELF/DWARF \
> +sections from debug info files.\nIf disabled, only whole debug info files \
> +may be downloaded."),
> +			  maint_set_debuginfod_download_sections,
> +			  maint_get_debuginfod_download_sections,
> +			  nullptr,
> +			  &maint_set_debuginfod_cmdlist,
> +			  &maint_show_debuginfod_cmdlist);
>  }
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index fc55c4e7b43..91da9777fd6 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -40872,6 +40872,16 @@ Create a core file? (y or n) @kbd{n}
>  (@value{GDBP})
>  @end smallexample
>  
> +@kindex maint set debuginfod
> +@kindex maint show debuginfod

We should probably add something like:

 @cindex debuginfod, maintenance commands

to help folk find this.

Thanks,
Andrew

> +@item maint set debuginfod download-sections
> +@itemx maint set debuginfod download-sections @r{[}on|off@r{]}
> +@itemx maint show debuginfod download-sections
> +Controls whether @value{GDBN} will attempt to download individual
> +ELF/DWARF sections from @code{debuginfod}.  If disabled, only
> +whole debug info files will be downloaded.  This could result
> +in @value{GDBN} downloading larger amounts of data.
> +
>  @cindex @value{GDBN} internal error
>  @cindex internal errors, control of @value{GDBN} behavior
>  @cindex demangler crashes
> @@ -49382,8 +49392,10 @@ regarding @code{debuginfod}.
>  @item set debuginfod enabled
>  @itemx set debuginfod enabled on
>  @cindex enable debuginfod
> -@value{GDBN} will attempt to query @code{debuginfod} servers when missing debug
> -info or source files.
> +@value{GDBN} will attempt to query @code{debuginfod} servers for missing debug
> +info or source files.  @value{GDBN} may attempt to download individual ELF/DWARF
> +sections such as @code{.gdb_index} to help reduce the total amount of data
> +downloaded from debuginfod servers.
>  
>  @item set debuginfod enabled off
>  @value{GDBN} will not attempt to query @code{debuginfod} servers when missing
> -- 
> 2.40.1
  

Patch

diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 8be43a91dcc..6d0521b64e2 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -31,6 +31,10 @@ 
 static cmd_list_element *set_debuginfod_prefix_list;
 static cmd_list_element *show_debuginfod_prefix_list;
 
+/* maint set/show debuginfod commands.  */
+static cmd_list_element *maint_set_debuginfod_cmdlist;
+static cmd_list_element *maint_show_debuginfod_cmdlist;
+
 static const char debuginfod_on[] = "on";
 static const char debuginfod_off[] = "off";
 static const char debuginfod_ask[] = "ask";
@@ -50,6 +54,13 @@  static const char *debuginfod_enabled =
   debuginfod_off;
 #endif
 
+static bool debuginfod_download_sections =
+#if defined(HAVE_LIBDEBUGINFOD_FIND_SECTION)
+  true;
+#else
+  false;
+#endif
+
 static unsigned int debuginfod_verbose = 1;
 
 #ifndef HAVE_LIBDEBUGINFOD
@@ -424,7 +435,7 @@  debuginfod_section_query (const unsigned char *build_id,
   return scoped_fd (-ENOSYS);
 #else
 
- if (!debuginfod_is_enabled ())
+ if (!debuginfod_download_sections || !debuginfod_is_enabled ())
     return scoped_fd (-ENOSYS);
 
   debuginfod_client *c = get_debuginfod_client ();
@@ -550,6 +561,31 @@  show_debuginfod_verbose_command (ui_file *file, int from_tty,
 	      value);
 }
 
+/* Set callback for "maint set debuginfod download-sections".  */
+
+static void
+maint_set_debuginfod_download_sections (bool value)
+{
+#if !defined(HAVE_LIBDEBUGINFOD_FIND_SECTION)
+  if (value)
+    {
+      error (_("Support for section downloading is not compiled into GDB. " \
+"Defaulting to \"off\"."));
+      return;
+    }
+#endif
+
+  debuginfod_download_sections = value;
+}
+
+/* Get callback for "maint set debuginfod download-sections".  */
+
+static bool
+maint_get_debuginfod_download_sections ()
+{
+  return debuginfod_download_sections;
+}
+
 /* Register debuginfod commands.  */
 
 void _initialize_debuginfod ();
@@ -568,8 +604,11 @@  _initialize_debuginfod ()
 			_("Set whether to use debuginfod."),
 			_("Show whether to use debuginfod."),
 			_("\
-When on, enable the use of debuginfod to download missing debug info and\n\
-source files."),
+When set to \"on\", enable the use of debuginfod to download missing\n\
+debug info and source files. GDB may also download components of debug\n\
+info instead of entire files. \"off\" disables the use of debuginfod.\n\
+When set to \"ask\", a prompt may ask whether to enable or disable\n\
+debuginfod." ),
 			set_debuginfod_enabled,
 			get_debuginfod_enabled,
 			show_debuginfod_enabled,
@@ -600,4 +639,25 @@  query.\nTo disable, set to zero.  Verbose output is displayed by default."),
 			     show_debuginfod_verbose_command,
 			     &set_debuginfod_prefix_list,
 			     &show_debuginfod_prefix_list);
+
+  /* maint set/show debuginfod */
+  add_setshow_prefix_cmd ("debuginfod", class_maintenance,
+			  _("Set debuginfod specific variables."),
+			  _("Show debuginfod specific variables."),
+			  &maint_set_debuginfod_cmdlist,
+			  &maint_show_debuginfod_cmdlist,
+			  &maintenance_set_cmdlist, &maintenance_show_cmdlist);
+
+  /* maint set/show debuginfod download-sections */
+  add_setshow_boolean_cmd ("download-sections", class_maintenance, _("\
+Set whether debuginfod may download individual ELF/DWARF sections."), _("\
+Show whether debuginfod may download individual ELF/DWARF sections."), _("\
+When enabled, debuginfod may attempt to download individual ELF/DWARF \
+sections from debug info files.\nIf disabled, only whole debug info files \
+may be downloaded."),
+			  maint_set_debuginfod_download_sections,
+			  maint_get_debuginfod_download_sections,
+			  nullptr,
+			  &maint_set_debuginfod_cmdlist,
+			  &maint_show_debuginfod_cmdlist);
 }
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index fc55c4e7b43..91da9777fd6 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -40872,6 +40872,16 @@  Create a core file? (y or n) @kbd{n}
 (@value{GDBP})
 @end smallexample
 
+@kindex maint set debuginfod
+@kindex maint show debuginfod
+@item maint set debuginfod download-sections
+@itemx maint set debuginfod download-sections @r{[}on|off@r{]}
+@itemx maint show debuginfod download-sections
+Controls whether @value{GDBN} will attempt to download individual
+ELF/DWARF sections from @code{debuginfod}.  If disabled, only
+whole debug info files will be downloaded.  This could result
+in @value{GDBN} downloading larger amounts of data.
+
 @cindex @value{GDBN} internal error
 @cindex internal errors, control of @value{GDBN} behavior
 @cindex demangler crashes
@@ -49382,8 +49392,10 @@  regarding @code{debuginfod}.
 @item set debuginfod enabled
 @itemx set debuginfod enabled on
 @cindex enable debuginfod
-@value{GDBN} will attempt to query @code{debuginfod} servers when missing debug
-info or source files.
+@value{GDBN} will attempt to query @code{debuginfod} servers for missing debug
+info or source files.  @value{GDBN} may attempt to download individual ELF/DWARF
+sections such as @code{.gdb_index} to help reduce the total amount of data
+downloaded from debuginfod servers.
 
 @item set debuginfod enabled off
 @value{GDBN} will not attempt to query @code{debuginfod} servers when missing