From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 3qE6JHaZjGCucwAAWB0awg (envelope-from ) for ; Fri, 30 Apr 2021 19:57:42 -0400 Received: by simark.ca (Postfix, from userid 112) id 868B71F11C; Fri, 30 Apr 2021 19:57:42 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id DDBD81E813 for ; Fri, 30 Apr 2021 19:57:41 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 837B93858025; Fri, 30 Apr 2021 23:57:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 837B93858025 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1619827061; bh=SLXiC6OKVedzS1qwzs+h2hLNGtXICkEJYJNtjL4IxAM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=QZlZ/YUeoeq8HzmVzxpJ8Vm4MOeMB+3Vp+O0NUzric/ZXfAqxju1i6Sph3ybnB0wQ Mw5TkE3SIwDTF1PEvwvCyVD4EPzYqlZRPnwcoqKHrbJ7GQlGOFzfDxDt+10TEGHhQD VmWjiLCcNutKlXH/eE0e2U7/H1A1j6qWTGlT3XgI= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 1D1933858025 for ; Fri, 30 Apr 2021 23:57:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1D1933858025 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-152-Go7fD1BvO_SpCGD3osVaAg-1; Fri, 30 Apr 2021 19:57:37 -0400 X-MC-Unique: Go7fD1BvO_SpCGD3osVaAg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 498A9801B13 for ; Fri, 30 Apr 2021 23:57:36 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-118-162.phx2.redhat.com [10.3.118.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECEDF19C66 for ; Fri, 30 Apr 2021 23:57:35 +0000 (UTC) To: gdb-patches@sourceware.org Subject: [PATCH] debuginfod-support.c: Use long-lived debuginfod_client Date: Fri, 30 Apr 2021 19:57:35 -0400 Message-Id: <20210430235735.1371915-1-amerey@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" 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: , From: Aaron Merey via Gdb-patches Reply-To: Aaron Merey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Apologies, resending this patch with a proper subject. Aaron >From 54fa19c47f9beca1eaabd0f758333a9445084c0c Mon Sep 17 00:00:00 2001 From: Aaron Merey Date: Fri, 30 Apr 2021 18:58:36 -0400 Subject: [PATCH] debuginfod-support.c: Use long-lived debuginfod_client Instead of initializing a new debuginfod_client for each query, store the first initialized client for the remainder of the GDB session and use it for every debuginfod query. In conjunction with upcoming changes to libdebuginfod, using one client for all queries will avoid latency caused by unneccesarily setting up TCP connections multiple times. Tested on Fedora 33 x86_64. gdb/ChangeLog: * debuginfod-support.c (debuginfod_init): Use one client for all queries. (struct debuginfod_client_deleter): Remove. --- gdb/debuginfod-support.c | 41 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index 9778e2e4cfe..357cd3f6d01 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -55,23 +55,13 @@ struct user_data gdb::optional meter; }; -/* Deleter for a debuginfod_client. */ - -struct debuginfod_client_deleter -{ - void operator() (debuginfod_client *c) - { - debuginfod_end (c); - } -}; - -using debuginfod_client_up - = std::unique_ptr; +static debuginfod_client *global_client = nullptr; static int progressfn (debuginfod_client *c, long cur, long total) { user_data *data = static_cast (debuginfod_get_user_data (c)); + gdb_assert (data != nullptr); if (check_quit_flag ()) { @@ -103,15 +93,18 @@ progressfn (debuginfod_client *c, long cur, long total) return 0; } -static debuginfod_client_up +static debuginfod_client * debuginfod_init () { - debuginfod_client_up c (debuginfod_begin ()); + if (global_client == nullptr) + { + global_client = debuginfod_begin (); - if (c != nullptr) - debuginfod_set_progressfn (c.get (), progressfn); + if (global_client != nullptr) + debuginfod_set_progressfn (global_client, progressfn); + } - return c; + return global_client; } /* See debuginfod-support.h */ @@ -126,19 +119,20 @@ debuginfod_source_query (const unsigned char *build_id, if (urls_env_var == NULL || urls_env_var[0] == '\0') return scoped_fd (-ENOSYS); - debuginfod_client_up c = debuginfod_init (); + debuginfod_client *c = debuginfod_init (); if (c == nullptr) return scoped_fd (-ENOMEM); user_data data ("source file", srcpath); - debuginfod_set_user_data (c.get (), &data); - scoped_fd fd (debuginfod_find_source (c.get (), + debuginfod_set_user_data (c, &data); + scoped_fd fd (debuginfod_find_source (c, build_id, build_id_len, srcpath, nullptr)); + debuginfod_set_user_data (c, nullptr); /* TODO: Add 'set debug debuginfod' command to control when error messages are shown. */ if (fd.get () < 0 && fd.get () != -ENOENT) @@ -164,7 +158,7 @@ debuginfod_debuginfo_query (const unsigned char *build_id, if (urls_env_var == NULL || urls_env_var[0] == '\0') return scoped_fd (-ENOSYS); - debuginfod_client_up c = debuginfod_init (); + debuginfod_client *c = debuginfod_init (); if (c == nullptr) return scoped_fd (-ENOMEM); @@ -172,9 +166,10 @@ debuginfod_debuginfo_query (const unsigned char *build_id, char *dname = nullptr; user_data data ("separate debug info for", filename); - debuginfod_set_user_data (c.get (), &data); - scoped_fd fd (debuginfod_find_debuginfo (c.get (), build_id, build_id_len, + debuginfod_set_user_data (c, &data); + scoped_fd fd (debuginfod_find_debuginfo (c, build_id, build_id_len, &dname)); + debuginfod_set_user_data (c, nullptr); if (fd.get () < 0 && fd.get () != -ENOENT) printf_filtered (_("Download failed: %s. Continuing without debug info for %ps.\n"), -- 2.30.2