]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/gdb_bfd.c
Add thread-safety to gdb's BFD wrappers
authorTom Tromey <tom@tromey.com>
Sat, 18 Feb 2023 16:27:58 +0000 (09:27 -0700)
committerTom Tromey <tom@tromey.com>
Tue, 9 Jan 2024 01:40:21 +0000 (18:40 -0700)
commitda0e2ac4f7c34114da60178b4077cf6410618353
tree30eac7ac1b5d3f2b2138ae8edf4d0faa829ab7ed
parenta2eb3f887cba11c87b625dbbd058557025e57596
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/dwarf2/read.c
gdb/gdb_bfd.c
gdb/gdb_bfd.h
gdb/main.c