[v3,03/18] Add a couple of bfd_cache_close calls

Message ID 20231122-t-bg-dwarf-reading-v3-3-fc3180de63c4@tromey.com
State New
Headers
Series Index DWARF in the background |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm pending Patch applied

Commit Message

Tom Tromey Nov. 23, 2023, 5:32 a.m. UTC
  This adds a couple of calls to bfd_cache_close at points where a BFD
isn't actively needed by gdb.  Normally at these points, all the
needed section data is already mapped, so we can simply close the file
descriptor.  This is harmless at worst, because if this is needed
after all, the BFD file descriptor cache will reopen it.
---
 gdb/dwarf2/read.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 1c2f3f62399..6e6609ef86c 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9182,6 +9182,8 @@  open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name,
 
   dwarf_read_debug_printf ("DWO file found: %s", dwo_name);
 
+  bfd_cache_close (dwo_file->dbfd.get ());
+
   return dwo_file.release ();
 }
 
@@ -9474,6 +9476,8 @@  open_and_init_dwp_file (dwarf2_per_objfile *per_objfile)
 			   pulongest (dwp_file->cus ? dwp_file->cus->nr_units : 0),
 			   pulongest (dwp_file->tus ? dwp_file->tus->nr_units : 0));
 
+  bfd_cache_close (dwp_file->dbfd.get ());
+
   return dwp_file;
 }