From da0e2ac4f7c34114da60178b4077cf6410618353 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 18 Feb 2023 09:27:58 -0700 Subject: Add thread-safety to gdb's BFD wrappers This changes gdb to ensure that gdb's BFD cache is guarded by a lock. This avoids any races when multiple threads might open a BFD (and thus use the BFD cache) at the same time. Currently, this change is not needed because the the main thread waits for some DWARF scanning to be completed before returning. The only locking that's required is when opening DWO files, and there's a local lock to this end in dwarf2/read.c. However, in the coming patches, the DWARF reader will begin its work earlier, in the background. This means there is the potential for the DWARF reader and other code on the main thread to both attempt to open BFDs at the same time. --- gdb/gdb_bfd.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gdb/gdb_bfd.h') diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h index eeb782e..3de9cd9 100644 --- a/gdb/gdb_bfd.h +++ b/gdb/gdb_bfd.h @@ -258,4 +258,9 @@ gdb_bfd_sections (const gdb_bfd_ref_ptr &abfd) extern std::string gdb_bfd_errmsg (bfd_error_type error_tag, char **matching); +/* A wrapper for bfd_init that also handles setting up for + multi-threading. */ + +extern void gdb_bfd_init (); + #endif /* GDB_BFD_H */ -- cgit v1.1