/* If the timestamp of the exec file has changed, reopen it. */
struct stat st;
- int res = bfd_stat (exec_bfd, &st);
+ int res = gdb_bfd_stat (exec_bfd, &st);
if (res == 0
&& current_program_space->ebfd_mtime != 0
if (!core_file_matches_executable_p (current_program_space->core_bfd (),
current_program_space->exec_bfd ()))
warning (_("core file may not match specified executable file."));
- else if (bfd_get_mtime (current_program_space->exec_bfd ())
- > bfd_get_mtime (current_program_space->core_bfd ()))
+ else if (gdb_bfd_get_mtime (current_program_space->exec_bfd ())
+ > gdb_bfd_get_mtime (current_program_space->core_bfd ()))
warning (_("exec file is newer than core file."));
}
}
= build_section_table (current_program_space->exec_bfd ());
current_program_space->ebfd_mtime
- = bfd_get_mtime (current_program_space->exec_bfd ());
+ = gdb_bfd_get_mtime (current_program_space->exec_bfd ());
validate_files ();
section_size);
}
+/* See gdb_bfd.h. */
+
+int
+gdb_bfd_stat (bfd *abfd, struct stat *sbuf)
+{
+#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
+
+ return bfd_stat (abfd, sbuf);
+}
+
+/* See gdb_bfd.h. */
+
+long
+gdb_bfd_get_mtime (bfd *abfd)
+{
+#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
+
+ return bfd_get_mtime (abfd);
+}
+
#define AMBIGUOUS_MESS1 ".\nMatching formats:"
#define AMBIGUOUS_MESS2 \
".\nUse \"set gnutarget format-name\" to specify the format."
return gdb_bfd_section_range (abfd->sections);
};
+/* A wrapper for bfd_stat that acquires the per-BFD lock on ABFD. */
+
+extern int gdb_bfd_stat (bfd *abfd, struct stat *sbuf)
+ ATTRIBUTE_WARN_UNUSED_RESULT;
+
+/* A wrapper for bfd_get_mtime that acquires the per-BFD lock on
+ ABFD. */
+
+extern long gdb_bfd_get_mtime (bfd *abfd)
+ ATTRIBUTE_WARN_UNUSED_RESULT;
+
/* A wrapper for bfd_errmsg to produce a more helpful error message
in the case of bfd_error_file_ambiguously recognized.
MATCHING, if non-NULL, is the corresponding argument to
return;
}
- if (abfd->my_archive == NULL && oso->mtime != bfd_get_mtime (abfd.get ()))
+ if (abfd->my_archive == nullptr
+ && oso->mtime != gdb_bfd_get_mtime (abfd.get ()))
{
warning (_("`%s': file time stamp mismatch."), oso->name);
return;
if (obfd != nullptr)
{
- mtime = bfd_get_mtime (obfd.get ());
+ mtime = gdb_bfd_get_mtime (obfd.get ());
/* Build section table. */
build_objfile_section_table (this);
numbers will never set st_ino to zero, this is merely an
optimization, so we do not need to worry about false negatives. */
- if (bfd_stat (abfd.get (), &abfd_stat) == 0
+ if (gdb_bfd_stat (abfd.get (), &abfd_stat) == 0
&& abfd_stat.st_ino != 0
- && bfd_stat (parent_objfile->obfd.get (), &parent_stat) == 0)
+ && gdb_bfd_stat (parent_objfile->obfd.get (), &parent_stat) == 0)
{
if (abfd_stat.st_dev == parent_stat.st_dev
&& abfd_stat.st_ino == parent_stat.st_ino)
continue;
struct stat new_statbuf;
- int res = bfd_stat (objfile->obfd.get (), &new_statbuf);
+ int res = gdb_bfd_stat (objfile->obfd.get (), &new_statbuf);
if (res != 0)
{
/* If this object is from an archive (what you usually create