Rewrite DIContext interface to take an object. Update all callers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167757 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher
2012-11-12 21:40:38 +00:00
parent f4e3309e84
commit d1726a4580
8 changed files with 116 additions and 264 deletions

View File

@ -309,16 +309,10 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
raw_ostream &DebugOut = nulls();
#endif
StringRef DebugAbbrevSection, DebugInfoSection, DebugArangesSection,
DebugLineSection, DebugStrSection;
OwningPtr<DIContext> diContext;
OwningPtr<MachOObjectFile> DSYMObj;
MachOObject *DbgInfoObj = MachOObj;
ObjectFile *DbgObj = MachOOF.get();
// Try to find debug info and set up the DIContext for it.
if (UseDbg) {
ArrayRef<SectionRef> DebugSections = Sections;
std::vector<SectionRef> DSYMSections;
// A separate DSym file path was specified, parse it as a macho file,
// get the sections and supply it to the section name parsing machinery.
if (!DSYMFile.empty()) {
@ -327,42 +321,11 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
errs() << "llvm-objdump: " << Filename << ": " << ec.message() << '\n';
return;
}
DSYMObj.reset(static_cast<MachOObjectFile*>(
ObjectFile::createMachOObjectFile(Buf.take())));
const macho::Header &Header = DSYMObj->getObject()->getHeader();
std::vector<SymbolRef> Symbols;
SmallVector<uint64_t, 8> FoundFns;
getSectionsAndSymbols(Header, DSYMObj.get(), 0, DSYMSections, Symbols,
FoundFns);
DebugSections = DSYMSections;
DbgInfoObj = DSYMObj.get()->getObject();
DbgObj = ObjectFile::createMachOObjectFile(Buf.take());
}
// Find the named debug info sections.
for (unsigned SectIdx = 0; SectIdx != DebugSections.size(); SectIdx++) {
StringRef SectName;
if (!DebugSections[SectIdx].getName(SectName)) {
if (SectName.equals("__DWARF,__debug_abbrev"))
DebugSections[SectIdx].getContents(DebugAbbrevSection);
else if (SectName.equals("__DWARF,__debug_info"))
DebugSections[SectIdx].getContents(DebugInfoSection);
else if (SectName.equals("__DWARF,__debug_aranges"))
DebugSections[SectIdx].getContents(DebugArangesSection);
else if (SectName.equals("__DWARF,__debug_line"))
DebugSections[SectIdx].getContents(DebugLineSection);
else if (SectName.equals("__DWARF,__debug_str"))
DebugSections[SectIdx].getContents(DebugStrSection);
}
}
// Setup the DIContext.
diContext.reset(DIContext::getDWARFContext(DbgInfoObj->isLittleEndian(),
DebugInfoSection,
DebugAbbrevSection,
DebugArangesSection,
DebugLineSection,
DebugStrSection));
// Setup the DIContext
diContext.reset(DIContext::getDWARFContext(DbgObj));
}
FunctionMapTy FunctionMap;