/* The registry. */
registry<bfd> registry_fields;
+
+#if CXX_STD_THREAD
+ /* Most of the locking needed for multi-threaded operation is
+ handled by BFD itself. However, the current BFD model is that
+ locking is only needed for global operations -- but it turned out
+ that the background DWARF reader could race with the auto-load
+ code reading the .debug_gdb_scripts section from the same BFD.
+
+ This lock is the fix: wrappers for important BFD functions will
+ acquire this lock before performing operations that might modify
+ the state of this BFD. */
+ std::mutex per_bfd_mutex;
+#endif
};
registry<bfd> *
abfd = sectp->owner;
+#if CXX_STD_THREAD
+ gdb_bfd_data *gdata = (gdb_bfd_data *) bfd_usrdata (abfd);
+ std::lock_guard<std::mutex> guard (gdata->per_bfd_mutex);
+#endif
+
descriptor = get_section_descriptor (sectp);
/* If the data was already read for this BFD, just reuse it. */
gdb_bfd_get_full_section_contents (bfd *abfd, asection *section,
gdb::byte_vector *contents)
{
+#if CXX_STD_THREAD
+ gdb_bfd_data *gdata = (gdb_bfd_data *) bfd_usrdata (abfd);
+ std::lock_guard<std::mutex> guard (gdata->per_bfd_mutex);
+#endif
+
bfd_size_type section_size = bfd_section_size (section);
contents->resize (section_size);