aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdb_bfd.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2023-02-18 09:27:58 -0700
committerTom Tromey <tom@tromey.com>2024-01-08 18:40:21 -0700
commitda0e2ac4f7c34114da60178b4077cf6410618353 (patch)
tree30eac7ac1b5d3f2b2138ae8edf4d0faa829ab7ed /gdb/gdb_bfd.h
parenta2eb3f887cba11c87b625dbbd058557025e57596 (diff)
downloadbinutils-da0e2ac4f7c34114da60178b4077cf6410618353.zip
binutils-da0e2ac4f7c34114da60178b4077cf6410618353.tar.gz
binutils-da0e2ac4f7c34114da60178b4077cf6410618353.tar.bz2
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.
Diffstat (limited to 'gdb/gdb_bfd.h')
-rw-r--r--gdb/gdb_bfd.h5
1 files changed, 5 insertions, 0 deletions
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 */