Follow-up for r217020: actually commit the fix for PR20800,

revert the accidentally committed changes to LLVMSymbolize.cpp


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217021 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alexander Potapenko 2014-09-03 07:37:20 +00:00
parent fac68d2d70
commit 42ebff8c99
2 changed files with 23 additions and 14 deletions

View File

@ -437,10 +437,30 @@ class DarwinX86AsmBackend : public X86AsmBackend {
bool Is64Bit;
unsigned OffsetSize; ///< Offset of a "push" instruction.
unsigned PushInstrSize; ///< Size of a "push" instruction.
unsigned MoveInstrSize; ///< Size of a "move" instruction.
unsigned StackDivide; ///< Amount to adjust stack size by.
protected:
/// \brief Size of a "push" instruction for the given register.
unsigned PushInstrSize(unsigned Reg) const {
switch (Reg) {
case X86::EBX:
case X86::ECX:
case X86::EDX:
case X86::EDI:
case X86::ESI:
case X86::EBP:
case X86::RBX:
case X86::RBP:
return 1;
case X86::R12:
case X86::R13:
case X86::R14:
case X86::R15:
return 2;
}
return 1;
}
/// \brief Implementation of algorithm to generate the compact unwind encoding
/// for the CFI instructions.
uint32_t
@ -530,7 +550,7 @@ protected:
unsigned Reg = MRI.getLLVMRegNum(Inst.getRegister(), true);
SavedRegs[SavedRegIdx++] = Reg;
StackAdjust += OffsetSize;
InstrOffset += PushInstrSize;
InstrOffset += PushInstrSize(Reg);
break;
}
}
@ -724,7 +744,6 @@ public:
OffsetSize = Is64Bit ? 8 : 4;
MoveInstrSize = Is64Bit ? 3 : 2;
StackDivide = Is64Bit ? 8 : 4;
PushInstrSize = 1;
}
};

View File

@ -306,26 +306,19 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) {
// Check if it's a universal binary.
Bin = ParsedBinary.getBinary().get();
addOwningBinary(std::move(ParsedBinary));
errs() << "HERE: " << __FILE__ << ":" << __LINE__ << ", DbgBin: " << DbgBin << "\n";
if (Bin->isMachO() || Bin->isMachOUniversalBinary()) {
// On Darwin we may find DWARF in separate object file in
// resource directory.
const std::string &ResourcePath =
getDarwinDWARFResourceForPath(Path);
errs() << "Resource path: " << ResourcePath << "\n";
BinaryOrErr = createBinary(ResourcePath);
std::error_code EC = BinaryOrErr.getError();
errs() << "HERE: " << __FILE__ << ":" << __LINE__ << ", DbgBin: " << DbgBin << "\n";
if (EC != errc::no_such_file_or_directory && !error(EC)) {
errs() << "HERE: " << __FILE__ << ":" << __LINE__ << ", DbgBin: " << DbgBin << "\n";
OwningBinary<Binary> B = std::move(BinaryOrErr.get());
DbgBin = B.getBinary().get();
addOwningBinary(std::move(B));
}
if (EC == errc::no_such_file_or_directory)
errs() << "no_such_file_or_directory: " << ResourcePath << "\n";
}
errs() << "HERE: " << __FILE__ << ":" << __LINE__ << ", DbgBin: " << DbgBin << "\n";
// Try to locate the debug binary using .gnu_debuglink section.
if (!DbgBin) {
std::string DebuglinkName;
@ -342,11 +335,8 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) {
}
}
}
errs() << "HERE: " << __FILE__ << ":" << __LINE__ << ", DbgBin: " << DbgBin << "\n";
if (!DbgBin) {
errs() << "Failed to open DbgBin, falling back to Bin\n";
if (!DbgBin)
DbgBin = Bin;
}
BinaryPair Res = std::make_pair(Bin, DbgBin);
BinaryForPath[Path] = Res;
return Res;