/// specific \p DIE related to the warning.
void DwarfLinkerForBinary::reportWarning(Twine Warning, Twine Context,
const DWARFDie *DIE) const {
-
+ std::lock_guard<std::mutex> Guard(ErrorHandlerMutex);
warn(Warning, Context);
dumpDIE(DIE, Options.Verbose);
}
void DwarfLinkerForBinary::reportError(Twine Error, Twine Context,
const DWARFDie *DIE) const {
+ std::lock_guard<std::mutex> Guard(ErrorHandlerMutex);
error(Error, Context);
dumpDIE(DIE, Options.Verbose);
}
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/Remarks/RemarkFormat.h"
#include "llvm/Remarks/RemarkLinker.h"
+#include <mutex>
namespace llvm {
namespace dsymutil {
class DwarfLinkerForBinary {
public:
DwarfLinkerForBinary(raw_fd_ostream &OutFile, BinaryHolder &BinHolder,
- LinkOptions Options)
- : OutFile(OutFile), BinHolder(BinHolder), Options(std::move(Options)) {}
+ LinkOptions Options, std::mutex &ErrorHandlerMutex)
+ : OutFile(OutFile), BinHolder(BinHolder), Options(std::move(Options)),
+ ErrorHandlerMutex(ErrorHandlerMutex) {}
/// Link the contents of the DebugMap.
bool link(const DebugMap &);
raw_fd_ostream &OutFile;
BinaryHolder &BinHolder;
LinkOptions Options;
+ std::mutex &ErrorHandlerMutex;
+
std::unique_ptr<DwarfStreamer> Streamer;
std::vector<std::unique_ptr<DWARFFile>> ObjectsForLinking;
std::vector<std::unique_ptr<DWARFContext>> ContextForLinking;
std::atomic_char AllOK(1);
SmallVector<MachOUtils::ArchAndFile, 4> TempFiles;
+ std::mutex ErrorHandlerMutex;
+
const bool Crashed = !CRC.RunSafely([&]() {
for (auto &Map : *DebugMapPtrsOrErr) {
if (Options.LinkOpts.Verbose || Options.DumpDebugMap)
auto LinkLambda = [&,
OutputFile](std::shared_ptr<raw_fd_ostream> Stream) {
- DwarfLinkerForBinary Linker(*Stream, BinHolder, Options.LinkOpts);
+ DwarfLinkerForBinary Linker(*Stream, BinHolder, Options.LinkOpts,
+ ErrorHandlerMutex);
AllOK.fetch_and(Linker.link(*Map));
Stream->flush();
if (flagIsSet(Options.Verify, DWARFVerify::Output) ||