Skip to content

Commit 06e3020

Browse files
committed
[dsymutil] Initialize the debug map before loading the main binary
Fix a crash when a warning is emitted while loading the symbols from the main binary. The warning helper assumes that the resulting debug map is initialized, but this happened after loading the main binary. Since there's no dependency between the two the initialization can be moved up. rdar://107298776 (cherry picked from commit 568be31)
1 parent d7024c4 commit 06e3020

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/tools/dsymutil/MachODebugMapParser.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ class MachODebugMapParser {
113113
StringRef BinaryPath);
114114

115115
void Warning(const Twine &Msg, StringRef File = StringRef()) {
116+
assert(Result &&
117+
"The debug map must be initialized before calling this function");
116118
WithColor::warning() << "("
117119
<< MachOUtils::getArchName(
118120
Result->getTriple().getArchName())
@@ -199,10 +201,9 @@ static std::string getArchName(const object::MachOObjectFile &Obj) {
199201
std::unique_ptr<DebugMap>
200202
MachODebugMapParser::parseOneBinary(const MachOObjectFile &MainBinary,
201203
StringRef BinaryPath) {
204+
Result = std::make_unique<DebugMap>(MainBinary.getArchTriple(), BinaryPath,
205+
MainBinary.getUuid());
202206
loadMainBinarySymbols(MainBinary);
203-
ArrayRef<uint8_t> UUID = MainBinary.getUuid();
204-
Result =
205-
std::make_unique<DebugMap>(MainBinary.getArchTriple(), BinaryPath, UUID);
206207
MainBinaryStrings = MainBinary.getStringTableData();
207208
for (const SymbolRef &Symbol : MainBinary.symbols()) {
208209
const DataRefImpl &DRI = Symbol.getRawDataRefImpl();

0 commit comments

Comments
 (0)