From: John Baldwin <jhb@FreeBSD.org>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Consolidate calls to bfd_set_cacheable
Date: Fri, 4 Aug 2023 09:31:44 -0700 [thread overview]
Message-ID: <ad3fbb8b-ba0f-eff8-ca89-bfa88697728d@FreeBSD.org> (raw)
In-Reply-To: <20230804161900.384191-1-tom@tromey.com>
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 <jhb@FreeBSD.org>
--
John Baldwin
next prev parent reply other threads:[~2023-08-04 16:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-04 16:19 Tom Tromey
2023-08-04 16:31 ` John Baldwin [this message]
2023-08-04 18:04 ` Tom Tromey
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=ad3fbb8b-ba0f-eff8-ca89-bfa88697728d@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).