From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id 3B1EC3858C5F for ; Fri, 4 Aug 2023 16:31:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B1EC3858C5F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4RHWSf57n3z4KKC; Fri, 4 Aug 2023 16:31:46 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RHWSf4PNFz3dN8; Fri, 4 Aug 2023 16:31:46 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691166706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jo3JfgN9FDxqekoQF51GkQ01yRHvoExUW9/y333j100=; b=JVbHM1mdMHP3iRK1YsKB8rJpRrvPM5hfR0hgScVYTnfOt23ChPW8roFgJP6uPWZDK2OP9l /p4p/pmn8h3ONTktqVOKzWKkp/UvKm9dFAdZQe6fU83Kqcavlsv+kPuTAHEavw3owDYEgO 9jWouZKOKyMx4GWDivLjfaBLIlJQS9fN+q3j9Co6AkeJhMsKUXXIpBHvLt1NK9xNDz4pCa naXJrmxP6EbpPJy9+VWPrDcAO4v3T5s0vgA61tM2jg7YTDK3mi7Noa/xziLPDcoEwQ7aKJ 9N8r1FnJP3Mkb9HGN0VovQI+plZbmKuNzj3tCBJYzerHJRhDW5cGc2HX/2rU4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691166706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jo3JfgN9FDxqekoQF51GkQ01yRHvoExUW9/y333j100=; b=xWJuMKf9s0aTxZ8f8/6etWaCWfm7OhDxEocHBAt0DpqCytGCiLTU8KWPmPFmKBYmDDNOmx eP35Z64tHGjqr5ydmtgHNX3eARWkIT7LtS6PSF2p51h3a1Kxhv5EWeMO+cFKb+KsaDLGuz Wlma9t8ij6owamOwxsWoGEBeyuUmgKHkp8HOHC9xTi94piflCSRX+VmNome4KF69zRnFZ8 ReaUHSspwwe4XV7IZNHTEAI++Y2MOOD9ClAulDZmLlzVVUBOmQB9Xdy7nI10IAWglPS74h 7/XcKmL4N8g/4QdvpmNDvYmvNpZ23jJJ9CFsMu5xJOMP7vHO3nV9aPlRxvNEew== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691166706; a=rsa-sha256; cv=none; b=BRw3ZpCh4eQMxRZneilqo/Km+cq66NHH2UZobk5/HCAxQNaa+VuiKFTnQs4qBdtG6GAURp 2NQv+1fpGlH0e1o/eK1ma+O8OaPmRtPd2Z9DaZLbayQ5RwCHzlUPXgmUZx4h9RXDeoS5Y/ 6UYhXCRy5bwq+zLQGuelwRBOu8zxlIOZlr15vVvtex8UIl71W+aUVMK/OcKtzs6WN/iS4Y SaHrSxEUWRAyqElG2sn4yzJ4P3HjhBWpAlavxoL7hzH3tOzZA31ZRmNNhAdLz/fNWGaLsY K5529kSWMuM1Rw41EsKVq+mrdTqm2S5YD7IQ7UzYvmXB7UjTYvuwL58Xcn8nrA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from [IPV6:2601:648:8680:16b0:cdd2:66b:dfd1:f731] (unknown [IPv6:2601:648:8680:16b0:cdd2:66b:dfd1:f731]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4RHWSf1bH4z14l6; Fri, 4 Aug 2023 16:31:46 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Fri, 4 Aug 2023 09:31:44 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Content-Language: en-US To: Tom Tromey , gdb-patches@sourceware.org References: <20230804161900.384191-1-tom@tromey.com> From: John Baldwin Subject: Re: [PATCH] Consolidate calls to bfd_set_cacheable In-Reply-To: <20230804161900.384191-1-tom@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,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 List-Id: On 8/4/23 9:19 AM, Tom Tromey wrote: > I noticed that some spots in gdb call bfd_set_cacheable after opening > a BFD. > > The BFD file cache is a bit odd. BFDs that are opened locally are > unconditionally registered with the cache, and their underlying file > descriptor will always be closed when bfd_cache_close_all is called. > However, only "cacheable" BFDs will be eligible for reopening when > needed -- and by default BFD decides that if a file descriptor is > passed in, then it should not be cacheable. If a non-cacheable BFD's > file descriptor is closed, there is no offical way to reopen it. > > gdb needs to call bfd_cache_close_all, because some systems cannot > start an executable when it has an open file descriptor referencing > it. > > However, gdb also will sometimes passes an open file descriptor to the > various BFD open functions. And, due to lazy DWARF reading, gdb may > also need to reopen these BFDs. > > Rather than having all the callers figure out when exactly to set the > cacheable flag, I think it makes sense to consolidate this logic into > the gdb_bfd.c wrapper functions. > > Regression tested on x86-64 Fedora 38. I think the patch seems sensible (just always marks them as cacheable in GDB APIs that wrap bfd_open). It might be worth explicitly noting in the log perhaps that the relevant functions always provide a filename (even if they provide an existing file descriptor) which is why it is safe to enable reopening. Reviewed-by: John Baldwin -- John Baldwin