diff options
author | Tom Tromey <tom@tromey.com> | 2023-08-04 05:58:35 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-08-04 12:05:53 -0600 |
commit | 0ecf4403168bb53c6ce729b1f042610f82043d45 (patch) | |
tree | 72e15beec46f90f9ee8193f7727543dcdfdad19c /gdb/machoread.c | |
parent | c8f6fc9200d0611d688d830b7c92c182e59ea632 (diff) | |
download | binutils-0ecf4403168bb53c6ce729b1f042610f82043d45.zip binutils-0ecf4403168bb53c6ce729b1f042610f82043d45.tar.gz binutils-0ecf4403168bb53c6ce729b1f042610f82043d45.tar.bz2 |
Consolidate calls to bfd_set_cacheable
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. It is ok to do this because gdb
always passes a filename to these open functions, so reopening should
work ok.
Regression tested on x86-64 Fedora 38.
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Diffstat (limited to 'gdb/machoread.c')
-rw-r--r-- | gdb/machoread.c | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/gdb/machoread.c b/gdb/machoread.c index daf6256..5154d1a 100644 --- a/gdb/machoread.c +++ b/gdb/machoread.c @@ -447,8 +447,6 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd, return; } - bfd_set_cacheable (abfd.get (), 1); - /* Read symbols table. */ storage = bfd_get_symtab_upper_bound (abfd.get ()); symbol_table = (asymbol **) xmalloc (storage); |