Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH v6 2/4] [gdb] Add debuginfod_enabled_ask_p
Date: Fri, 17 Apr 2026 09:57:17 +0200	[thread overview]
Message-ID: <20260417075719.852558-3-tdevries@suse.de> (raw)
In-Reply-To: <20260417075719.852558-1-tdevries@suse.de>

Factor out debuginfod_is_enabled_1 out of debuginfod_is_enabled, and use it to
implement debuginfod_enabled_ask_p.
---
 gdb/debuginfod-support.c | 40 +++++++++++++++++++++++++++++++---------
 gdb/debuginfod-support.h |  5 +++++
 2 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 0d666692ff8..56e284fbb7b 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -224,20 +224,20 @@ get_debuginfod_client ()
   return global_client;
 }
 
-/* Check if debuginfod is enabled.  If configured to do so, ask the user
-   whether to enable debuginfod.  */
+/* Check if debuginfod is enabled.  If configured to do so and ALLOW_ASK, ask
+   the user whether to enable debuginfod.  */
 
-static bool
-debuginfod_is_enabled ()
+static const char *
+debuginfod_is_enabled_1 (bool allow_ask)
 {
   const char *urls = skip_spaces (getenv (DEBUGINFOD_URLS_ENV_VAR));
 
   if (urls == nullptr
       || *urls == '\0')
-    return false;
+    return debuginfod_off;
 
-  if (debuginfod_enabled != debuginfod_ask)
-    return debuginfod_enabled == debuginfod_on;
+  if (debuginfod_enabled != debuginfod_ask || !allow_ask)
+    return debuginfod_enabled;
 
   gdb_printf (_("\nThis GDB supports auto-downloading debuginfo " \
 		"from the following URLs:\n"));
@@ -285,8 +285,18 @@ debuginfod_is_enabled ()
       debuginfod_enabled = debuginfod_on;
     }
 
-  gdb_assert (debuginfod_enabled != debuginfod_ask);
-  return debuginfod_enabled == debuginfod_on;
+  return debuginfod_enabled;
+}
+
+/* Check if debuginfod is enabled.  If configured to do so, ask the user
+   whether to enable debuginfod.  */
+
+static bool
+debuginfod_is_enabled ()
+{
+  const char *res = debuginfod_is_enabled_1 (true);
+  gdb_assert (res != debuginfod_ask);
+  return res == debuginfod_on;
 }
 
 /* Print the result of the most recent attempted download.  */
@@ -489,6 +499,18 @@ debuginfod_section_query (const unsigned char *build_id,
 
 #endif
 
+/* See debuginfod-support.h.  */
+
+bool
+debuginfod_enabled_ask_p ()
+{
+#if defined(HAVE_LIBDEBUGINFOD)
+  return debuginfod_is_enabled_1 (false) == debuginfod_ask;
+#else
+  return false;
+#endif
+}
+
 /* Set callback for "set debuginfod enabled".  */
 
 static void
diff --git a/gdb/debuginfod-support.h b/gdb/debuginfod-support.h
index cc5bf331812..7e7b5965c3b 100644
--- a/gdb/debuginfod-support.h
+++ b/gdb/debuginfod-support.h
@@ -105,4 +105,9 @@ extern scoped_fd debuginfod_section_query (const unsigned char *build_id,
 					   const char *section_name,
 					   gdb::unique_xmalloc_ptr<char>
 					     *destname);
+
+/* Check if debuginfod enabled is set to ask.  */
+
+extern bool debuginfod_enabled_ask_p ();
+
 #endif /* GDB_DEBUGINFOD_SUPPORT_H */
-- 
2.51.0


  parent reply	other threads:[~2026-04-17  7:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-17  7:57 [PATCH v6 0/4] [gdb/tui] Fix crash with debuginfod query Tom de Vries
2026-04-17  7:57 ` [PATCH v6 1/4] [gdb/tui] Fix crash with debuginfod query (tui enable) Tom de Vries
2026-04-17  7:57 ` Tom de Vries [this message]
2026-04-17  7:57 ` [PATCH v6 3/4] [gdb] Add defaulted_query_auto_answers_p Tom de Vries
2026-04-17  7:57 ` [PATCH v6 4/4] [gdb/tui] Fix crash with debuginfod query (C-x C-a) Tom de Vries
2026-04-25 14:40 ` [PATCH v6 0/4] [gdb/tui] Fix crash with debuginfod query Andrew Burgess
2026-05-01 14:26   ` Andrew Burgess
2026-05-01 16:34     ` Tom de Vries

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=20260417075719.852558-3-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