From patchwork Mon Feb 27 19:42:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Merey X-Patchwork-Id: 65698 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E2603858409 for ; Mon, 27 Feb 2023 19:44:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E2603858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677527053; bh=/zBez1DI0DEz97jKsc20XwsvfE5H3aORXCYqokpujLY=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=tHqQBEbaDwiNrK8ffbDkjOLp9q6gYcTfk+77Ql6YIq95LPEReOO/SoEYCcg//AadV Hl8GaZXK5In6KyDuCTy7jO6vghmWJFu220zNyUNkDvZnmW/8ZV0Piuf7VxF+SlZu0G tfqKxIOXRWUzGx+aaQQt2Xne90AnkokUKV2R5xK8= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 2AFF43858425 for ; Mon, 27 Feb 2023 19:42:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2AFF43858425 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-193-QTfQY0AyPnmSAX10CpnXxw-1; Mon, 27 Feb 2023 14:42:15 -0500 X-MC-Unique: QTfQY0AyPnmSAX10CpnXxw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D7084802C18 for ; Mon, 27 Feb 2023 19:42:14 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.18.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id A74C6492B0E; Mon, 27 Feb 2023 19:42:14 +0000 (UTC) To: gdb-patches@sourceware.org Cc: Aaron Merey Subject: [PATCH 2/7] gdb: add 'lazy' setting for command 'set debuginfod enabled' Date: Mon, 27 Feb 2023 14:42:07 -0500 Message-Id: <20230227194212.348003-2-amerey@redhat.com> In-Reply-To: <20230227194212.348003-1-amerey@redhat.com> References: <20230227194212.348003-1-amerey@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Aaron Merey via Gdb-patches From: Aaron Merey Reply-To: Aaron Merey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 'set debuginfod enabled lazy' turns on debuginfod downloading like 'set debuginfod enabled on' but also enables ELF/DWARFs section downloading via debuginfod_section_query. If support for debuginfod section queries was not found at configure time, 'set debuginfod enabled lazy' will print an error message indicating the missing support and default to 'set debuginfod enabled on'. Also update the help text and gdb.texinfo section for 'set debuginfod enabled' with information on the lazy setting. Reviewed-By: Eli Zaretskii --- gdb/debuginfod-support.c | 20 +++++++++++++++++--- gdb/doc/gdb.texinfo | 9 +++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index f909742362f..12025fcf0c0 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -34,12 +34,14 @@ static cmd_list_element *show_debuginfod_prefix_list; static const char debuginfod_on[] = "on"; static const char debuginfod_off[] = "off"; static const char debuginfod_ask[] = "ask"; +static const char debuginfod_lazy[] = "lazy"; static const char *debuginfod_enabled_enum[] = { debuginfod_on, debuginfod_off, debuginfod_ask, + debuginfod_lazy, nullptr }; @@ -411,7 +413,7 @@ debuginfod_section_query (const unsigned char *build_id, return scoped_fd (-ENOSYS); #else - if (!debuginfod_is_enabled ()) + if (debuginfod_enabled != debuginfod_lazy || !debuginfod_is_enabled ()) return scoped_fd (-ENOSYS); debuginfod_client *c = get_debuginfod_client (); @@ -451,6 +453,14 @@ static void set_debuginfod_enabled (const char *value) { #if defined(HAVE_LIBDEBUGINFOD) +#if !defined(HAVE_DEBUGINFOD_FIND_SECTION) + if (value == debuginfod_lazy) + { + debuginfod_enabled = debuginfod_on; + error (_("Support for lazy downloading is not compiled into GDB. " \ +"Defaulting to \"on\".")); + } +#endif debuginfod_enabled = value; #else /* Disabling debuginfod when gdb is not built with it is a no-op. */ @@ -550,8 +560,12 @@ _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. \"off\" disables the use of debuginfod.\n\ +When set to \"ask\", a prompt may ask whether to enable or disable\n\ +debuginfod. When set to \"lazy\", debug info downloading will be\n\ +deferred until it is required. GDB may also download components of\n\ +debug info instead of entire files." ), set_debuginfod_enabled, get_debuginfod_enabled, show_debuginfod_enabled, diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index c1ca45521ea..ac0636e3115 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -48757,10 +48757,15 @@ debug info or source files. By default, @code{debuginfod enabled} is set to attempting to perform the next query. By default, @code{debuginfod enabled} is set to @code{ask} for interactive sessions. +@item set debuginfod enabled lazy +@value{GDBN} will attempt to defer downloading entire debug info files until +necessary. @value{GDBN} may instead download individual components of the +debug info files such as @code{.gdb_index}. + @kindex show debuginfod enabled @item show debuginfod enabled -Display whether @code{debuginfod enabled} is set to @code{on}, @code{off} or -@code{ask}. +Display whether @code{debuginfod enabled} is set to @code{on}, @code{off}, +@code{ask} or @code{lazy}. @kindex set debuginfod urls @cindex configure debuginfod URLs