d27f55e39a
(RHBZ 2024875, Simon Marchi).
477 lines
15 KiB
Diff
477 lines
15 KiB
Diff
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
|
|
Date: Tue, 11 Jan 2022 12:46:05 +0100
|
|
Subject: gdb-rhbz202487-rework-set-debuginfod.patch
|
|
|
|
;;Backport upstream commit from Simon Marchi
|
|
;;333f35b6315 gdb: pass/return setting setter/getter
|
|
;;scalar values by value
|
|
|
|
gdb: rework "set debuginfod" commands
|
|
|
|
As discussed here [1], do some re-work in the "set debuginfod commands".
|
|
|
|
First, use "set debuginfod enabled on/off/ask" instead of "set
|
|
debuginfod on/off/ask". This is more MI-friendly, and it gives an
|
|
output that makes more sense in "info set", for example.
|
|
|
|
Then, make the show commands not call "error" when debuginfod support is
|
|
not compiled in. This makes the commands "show" and "show debuginfod"
|
|
stop early, breaking gdb.base/default.exp:
|
|
|
|
Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/default.exp ...
|
|
FAIL: gdb.base/default.exp: info set
|
|
FAIL: gdb.base/default.exp: show
|
|
|
|
- Make the "debuginfod enabled" setting default to "off" when debuginfod
|
|
support is not compiled in, and "ask" otherwise.
|
|
- Make the setter of "debuginfod enabled" error out when debuginfod
|
|
support is not compiled in, so that "debuginfod enabled" will always
|
|
remain "off" in that case.
|
|
- Make the setter of "debuginfod verbose" work in any case. I don't
|
|
see the harm in letting the user change that setting, since the user will
|
|
hit an error if they try to enable the use of debuginfod.
|
|
- I would do the same for the "debuginfod urls" setter, but because
|
|
this one needs to see the DEBUGINFOD_URLS_ENV_VAR macro, provided by
|
|
libdebuginfod, I made that one error out as well if debuginfod
|
|
support is not compiled it (otherwise, I would have left it like
|
|
"debuginfod verbose". Alternatively, we could hard-code
|
|
"DEBUGINFOD_URLS" in the code (in fact, it was prior to this patch,
|
|
but I think it was an oversight, as other spots use
|
|
DEBUGINFOD_URLS_ENV_VAR), or use a dummy string to store the setting,
|
|
but I don't really see the value in that.
|
|
|
|
Rename debuginfod_enable to debuginfod_enabled, just so it matches the
|
|
setting name.
|
|
|
|
[1] https://sourceware.org/pipermail/gdb-patches/2021-October/182937.html
|
|
|
|
Change-Id: I45fdb2993f668226a5639228951362b7800f09d5
|
|
Co-Authored-By: Aaron Merey <amerey@redhat.com>
|
|
|
|
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
|
|
--- a/gdb/debuginfod-support.c
|
|
+++ b/gdb/debuginfod-support.c
|
|
@@ -32,8 +32,22 @@ static const char debuginfod_on[] = "on";
|
|
static const char debuginfod_off[] = "off";
|
|
static const char debuginfod_ask[] = "ask";
|
|
|
|
-static const char *debuginfod_enable = debuginfod_ask;
|
|
-static unsigned debuginfod_verbose = 1;
|
|
+static const char *debuginfod_enabled_enum[] =
|
|
+{
|
|
+ debuginfod_on,
|
|
+ debuginfod_off,
|
|
+ debuginfod_ask,
|
|
+ nullptr
|
|
+};
|
|
+
|
|
+static const char *debuginfod_enabled =
|
|
+#if defined(HAVE_LIBDEBUGINFOD)
|
|
+ debuginfod_ask;
|
|
+#else
|
|
+ debuginfod_off;
|
|
+#endif
|
|
+
|
|
+static unsigned int debuginfod_verbose = 1;
|
|
|
|
/* This is never actually used. URLs are always pulled from the
|
|
environment. */
|
|
@@ -60,64 +74,6 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
|
|
|
|
#define NO_IMPL _("Support for debuginfod is not compiled into GDB.")
|
|
|
|
-/* Stub set/show commands that indicate debuginfod is not supported. */
|
|
-
|
|
-static void
|
|
-set_debuginfod_on_command (const char *args, int from_tty)
|
|
-{
|
|
- error (NO_IMPL);
|
|
- debuginfod_enable = debuginfod_off;
|
|
-}
|
|
-
|
|
-static void
|
|
-set_debuginfod_off_command (const char *args, int from_tty)
|
|
-{
|
|
- error (NO_IMPL);
|
|
- debuginfod_enable = debuginfod_off;
|
|
-}
|
|
-
|
|
-static void
|
|
-set_debuginfod_ask_command (const char *args, int from_tty)
|
|
-{
|
|
- error (NO_IMPL);
|
|
- debuginfod_enable = debuginfod_off;
|
|
-}
|
|
-
|
|
-static void
|
|
-show_debuginfod_status_command (const char *args, int from_tty)
|
|
-{
|
|
- error (NO_IMPL);
|
|
-}
|
|
-
|
|
-static void
|
|
-set_debuginfod_urls_command (const char *ignore, int from_tty,
|
|
- struct cmd_list_element *c)
|
|
-{
|
|
- error (NO_IMPL);
|
|
-}
|
|
-
|
|
-static void
|
|
-show_debuginfod_urls_command (struct ui_file *file, int from_tty,
|
|
- struct cmd_list_element *cmd, const char *value)
|
|
-{
|
|
- error (NO_IMPL);
|
|
-}
|
|
-
|
|
-static void
|
|
-set_debuginfod_verbose_command (const char *args, int from_tty,
|
|
- struct cmd_list_element *c)
|
|
-{
|
|
- error (NO_IMPL);
|
|
- debuginfod_verbose = 0;
|
|
-}
|
|
-
|
|
-static void
|
|
-show_debuginfod_verbose_command (struct ui_file *file, int from_tty,
|
|
- struct cmd_list_element *cmd,
|
|
- const char *value)
|
|
-{
|
|
- error (NO_IMPL);
|
|
-}
|
|
#else
|
|
#include <elfutils/debuginfod.h>
|
|
|
|
@@ -145,82 +101,6 @@ struct debuginfod_client_deleter
|
|
using debuginfod_client_up
|
|
= std::unique_ptr<debuginfod_client, debuginfod_client_deleter>;
|
|
|
|
-/* Enable debuginfod. */
|
|
-
|
|
-static void
|
|
-set_debuginfod_on_command (const char *args, int from_tty)
|
|
-{
|
|
- debuginfod_enable = debuginfod_on;
|
|
-}
|
|
-
|
|
-/* Disable debuginfod. */
|
|
-
|
|
-static void
|
|
-set_debuginfod_off_command (const char *args, int from_tty)
|
|
-{
|
|
- debuginfod_enable = debuginfod_off;
|
|
-}
|
|
-
|
|
-/* Before next query, ask user whether to enable debuginfod. */
|
|
-
|
|
-static void
|
|
-set_debuginfod_ask_command (const char *args, int from_tty)
|
|
-{
|
|
- debuginfod_enable = debuginfod_ask;
|
|
-}
|
|
-
|
|
-/* Show whether debuginfod is enabled. */
|
|
-
|
|
-static void
|
|
-show_debuginfod_status_command (const char *args, int from_tty)
|
|
-{
|
|
- printf_unfiltered (_("Debuginfod functionality is currently set to " \
|
|
- "\"%s\".\n"), debuginfod_enable);
|
|
-}
|
|
-
|
|
-/* Set the URLs that debuginfod will query. */
|
|
-
|
|
-static void
|
|
-set_debuginfod_urls_command (const char *ignore, int from_tty,
|
|
- struct cmd_list_element *c)
|
|
-{
|
|
- gdb_assert (debuginfod_urls != nullptr);
|
|
- if (setenv ("DEBUGINFOD_URLS", debuginfod_urls, 1) != 0)
|
|
- warning (_("Unable to set debuginfod URLs: %s"), safe_strerror (errno));
|
|
-}
|
|
-
|
|
-/* Show the URLs that debuginfod will query. */
|
|
-
|
|
-static void
|
|
-show_debuginfod_urls_command (struct ui_file *file, int from_tty,
|
|
- struct cmd_list_element *cmd, const char *value)
|
|
-{
|
|
- if (value == nullptr || value[0] == '\0')
|
|
- fprintf_unfiltered (file, _("Debuginfod URLs have not been set.\n"));
|
|
- else
|
|
- fprintf_filtered (file, _("Debuginfod URLs are currently set to:\n%s\n"),
|
|
- value);
|
|
-}
|
|
-
|
|
-/* No-op setter used for compatibility when gdb is built without debuginfod. */
|
|
-
|
|
-static void
|
|
-set_debuginfod_verbose_command (const char *args, int from_tty,
|
|
- struct cmd_list_element *c)
|
|
-{
|
|
- return;
|
|
-}
|
|
-
|
|
-/* Show verbosity. */
|
|
-
|
|
-static void
|
|
-show_debuginfod_verbose_command (struct ui_file *file, int from_tty,
|
|
- struct cmd_list_element *cmd, const char *value)
|
|
-{
|
|
- fprintf_filtered (file, _("Debuginfod verbose output is set to %s.\n"),
|
|
- value);
|
|
-}
|
|
-
|
|
static int
|
|
progressfn (debuginfod_client *c, long cur, long total)
|
|
{
|
|
@@ -277,15 +157,15 @@ get_debuginfod_client ()
|
|
whether to enable debuginfod. */
|
|
|
|
static bool
|
|
-debuginfod_enabled ()
|
|
+debuginfod_is_enabled ()
|
|
{
|
|
const char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR);
|
|
|
|
if (urls == nullptr || urls[0] == '\0'
|
|
- || debuginfod_enable == debuginfod_off)
|
|
+ || debuginfod_enabled == debuginfod_off)
|
|
return false;
|
|
|
|
- if (debuginfod_enable == debuginfod_ask)
|
|
+ if (debuginfod_enabled == debuginfod_ask)
|
|
{
|
|
int resp = nquery (_("\nThis GDB supports auto-downloading debuginfo " \
|
|
"from the following URLs:\n%s\nEnable debuginfod " \
|
|
@@ -294,16 +174,16 @@ debuginfod_enabled ()
|
|
if (!resp)
|
|
{
|
|
printf_filtered (_("Debuginfod has been disabled.\nTo make this " \
|
|
- "setting permanent, add \'set debuginfod off\' " \
|
|
- "to .gdbinit.\n"));
|
|
- debuginfod_enable = debuginfod_off;
|
|
+ "setting permanent, add \'set debuginfod " \
|
|
+ "enabled off\' to .gdbinit.\n"));
|
|
+ debuginfod_enabled = debuginfod_off;
|
|
return false;
|
|
}
|
|
|
|
printf_filtered (_("Debuginfod has been enabled.\nTo make this " \
|
|
- "setting permanent, add \'set debuginfod on\' " \
|
|
- "to .gdbinit.\n"));
|
|
- debuginfod_enable = debuginfod_on;
|
|
+ "setting permanent, add \'set debuginfod enabled " \
|
|
+ "on\' to .gdbinit.\n"));
|
|
+ debuginfod_enabled = debuginfod_on;
|
|
}
|
|
|
|
return true;
|
|
@@ -317,7 +197,7 @@ debuginfod_source_query (const unsigned char *build_id,
|
|
const char *srcpath,
|
|
gdb::unique_xmalloc_ptr<char> *destname)
|
|
{
|
|
- if (!debuginfod_enabled ())
|
|
+ if (!debuginfod_is_enabled ())
|
|
return scoped_fd (-ENOSYS);
|
|
|
|
debuginfod_client *c = get_debuginfod_client ();
|
|
@@ -354,7 +234,7 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
|
|
const char *filename,
|
|
gdb::unique_xmalloc_ptr<char> *destname)
|
|
{
|
|
- if (!debuginfod_enabled ())
|
|
+ if (!debuginfod_is_enabled ())
|
|
return scoped_fd (-ENOSYS);
|
|
|
|
debuginfod_client *c = get_debuginfod_client ();
|
|
@@ -382,6 +262,67 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
|
|
}
|
|
#endif
|
|
|
|
+/* Set callback for "set debuginfod enabled". */
|
|
+
|
|
+static void
|
|
+set_debuginfod_enabled (const char *args, int from_tty,
|
|
+ struct cmd_list_element *c)
|
|
+{
|
|
+#if defined(HAVE_LIBDEBUGINFOD)
|
|
+ /* Value is already set. */
|
|
+#else
|
|
+ error (NO_IMPL);
|
|
+#endif
|
|
+}
|
|
+
|
|
+/* Show callback for "set debuginfod enabled". */
|
|
+
|
|
+static void
|
|
+show_debuginfod_enabled (ui_file *file, int from_tty, cmd_list_element *cmd,
|
|
+ const char *value)
|
|
+{
|
|
+ printf_unfiltered (_("Debuginfod functionality is currently set to "
|
|
+ "\"%s\".\n"), debuginfod_enabled);
|
|
+}
|
|
+
|
|
+/* Set callback for "set debuginfod urls". */
|
|
+
|
|
+static void
|
|
+set_debuginfod_urls (const char *args, int from_tty,
|
|
+ struct cmd_list_element *c)
|
|
+{
|
|
+#if defined(HAVE_LIBDEBUGINFOD)
|
|
+ gdb_assert (debuginfod_urls != nullptr);
|
|
+ if (setenv (DEBUGINFOD_URLS_ENV_VAR, debuginfod_urls, 1) != 0)
|
|
+ warning (_("Unable to set debuginfod URLs: %s"), safe_strerror (errno));
|
|
+#else
|
|
+ error (NO_IMPL);
|
|
+#endif
|
|
+}
|
|
+
|
|
+/* Show callback for "set debuginfod urls". */
|
|
+
|
|
+static void
|
|
+show_debuginfod_urls (ui_file *file, int from_tty, cmd_list_element *cmd,
|
|
+ const char *value)
|
|
+{
|
|
+ if (value[0] == '\0')
|
|
+ fprintf_unfiltered (file, _("Debuginfod URLs have not been set.\n"));
|
|
+ else
|
|
+ fprintf_filtered (file, _("Debuginfod URLs are currently set to:\n%s\n"),
|
|
+ value);
|
|
+}
|
|
+
|
|
+/* Show callback for "set debuginfod verbose". */
|
|
+
|
|
+static void
|
|
+show_debuginfod_verbose_command (ui_file *file, int from_tty,
|
|
+ cmd_list_element *cmd, const char *value)
|
|
+{
|
|
+ fprintf_filtered (file, _("Debuginfod verbose output is set to %s.\n"),
|
|
+ value);
|
|
+}
|
|
+
|
|
/* Register debuginfod commands. */
|
|
|
|
void _initialize_debuginfod ();
|
|
@@ -397,23 +338,17 @@ _initialize_debuginfod ()
|
|
_("Show debuginfod option."),
|
|
&show_debuginfod_prefix_list, 0, &showlist);
|
|
|
|
- /* set debuginfod on */
|
|
- add_cmd ("on", class_run, set_debuginfod_on_command,
|
|
- _("Enable debuginfod."), &set_debuginfod_prefix_list);
|
|
-
|
|
- /* set debuginfod off */
|
|
- add_cmd ("off", class_run, set_debuginfod_off_command,
|
|
- _("Disable debuginfod."), &set_debuginfod_prefix_list);
|
|
-
|
|
- /* set debuginfod ask */
|
|
- add_cmd ("ask", class_run, set_debuginfod_ask_command, _("\
|
|
-Ask the user whether to enable debuginfod before performing the next query."),
|
|
- &set_debuginfod_prefix_list);
|
|
-
|
|
- /* show debuginfod status */
|
|
- add_cmd ("status", class_run, show_debuginfod_status_command,
|
|
- _("Show whether debuginfod is set to \"on\", \"off\" or \"ask\"."),
|
|
- &show_debuginfod_prefix_list);
|
|
+ add_setshow_enum_cmd ("enabled", class_run, debuginfod_enabled_enum,
|
|
+ &debuginfod_enabled,
|
|
+ _("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."),
|
|
+ set_debuginfod_enabled,
|
|
+ show_debuginfod_enabled,
|
|
+ &set_debuginfod_prefix_list,
|
|
+ &show_debuginfod_prefix_list);
|
|
|
|
/* set/show debuginfod urls */
|
|
add_setshow_string_noescape_cmd ("urls", class_run, &debuginfod_urls, _("\
|
|
@@ -422,8 +357,8 @@ Show the list of debuginfod server URLs."), _("\
|
|
Manage the space-separated list of debuginfod server URLs that GDB will query \
|
|
when missing debuginfo, executables or source files.\nThe default value is \
|
|
copied from the DEBUGINFOD_URLS environment variable."),
|
|
- set_debuginfod_urls_command,
|
|
- show_debuginfod_urls_command,
|
|
+ set_debuginfod_urls,
|
|
+ show_debuginfod_urls,
|
|
&set_debuginfod_prefix_list,
|
|
&show_debuginfod_prefix_list);
|
|
if (getenv ("DEBUGINFOD_URLS") != nullptr)
|
|
@@ -436,7 +371,7 @@ Set verbosity of debuginfod output."), _("\
|
|
Show debuginfod debugging."), _("\
|
|
When set to a non-zero value, display verbose output for each debuginfod \
|
|
query.\nTo disable, set to zero. Verbose output is displayed by default."),
|
|
- set_debuginfod_verbose_command,
|
|
+ nullptr,
|
|
show_debuginfod_verbose_command,
|
|
&set_debuginfod_prefix_list,
|
|
&show_debuginfod_prefix_list);
|
|
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
|
|
--- a/gdb/doc/gdb.texinfo
|
|
+++ b/gdb/doc/gdb.texinfo
|
|
@@ -47046,27 +47046,28 @@ regarding @code{debuginfod}.
|
|
@value{GDBN} provides the following commands for configuring @code{debuginfod}.
|
|
|
|
@table @code
|
|
-@kindex set debuginfod
|
|
-@anchor{set debuginfod}
|
|
-@item set debuginfod
|
|
-@itemx set debuginfod on
|
|
+@kindex set debuginfod enabled
|
|
+@anchor{set debuginfod enabled}
|
|
+@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.
|
|
|
|
-@item set debuginfod off
|
|
+@item set debuginfod enabled off
|
|
@value{GDBN} will not attempt to query @code{debuginfod} servers when missing
|
|
-debug info or source files. By default, @code{debuginfod} is set to @code{off}
|
|
-for non-interactive sessions.
|
|
+debug info or source files. By default, @code{debuginfod enabled} is set to
|
|
+@code{off} for non-interactive sessions.
|
|
|
|
-@item set debuginfod ask
|
|
+@item set debuginfod enabled ask
|
|
@value{GDBN} will prompt the user to enable or disable @code{debuginfod} before
|
|
-attempting to perform the next query. By default, @code{debuginfod} is set to
|
|
-@code{ask} for interactive sessions.
|
|
+attempting to perform the next query. By default, @code{debuginfod enabled}
|
|
+is set to @code{ask} for interactive sessions.
|
|
|
|
-@kindex show debuginfod status
|
|
-@item show debuginfod status
|
|
-Show whether @code{debuginfod} is set to @code{on}, @code{off} or @code{ask}.
|
|
+@kindex show debuginfod enabled
|
|
+@item show debuginfod enabled
|
|
+Display whether @code{debuginfod enabled} is set to @code{on}, @code{off} or
|
|
+@code{ask}.
|
|
|
|
@kindex set debuginfod urls
|
|
@cindex configure debuginfod URLs
|
|
diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
|
|
--- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
|
|
+++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
|
|
@@ -236,7 +236,7 @@ proc local_url { } {
|
|
clean_restart
|
|
gdb_test "file $binfile" ".*No debugging symbols.*" \
|
|
"file [file tail $binfile] cmd"
|
|
- gdb_test_no_output "set debuginfod off"
|
|
+ gdb_test_no_output "set debuginfod enabled off"
|
|
gdb_test_no_output "set debuginfod urls http://127.0.0.1:$port"
|
|
|
|
# gdb shouldn't find the debuginfo since debuginfod has been disabled
|
|
@@ -244,7 +244,7 @@ proc local_url { } {
|
|
"file [file tail $binfile] cmd off"
|
|
|
|
# Enable debuginfod and fetch the debuginfo
|
|
- gdb_test_no_output "set debuginfod on"
|
|
+ gdb_test_no_output "set debuginfod enabled on"
|
|
gdb_test "file $binfile" ".*Reading symbols from.*debuginfo.*" \
|
|
"file [file tail $binfile] cmd on"
|
|
}
|