diff options
author | David Blaikie <dblaikie@gmail.com> | 2017-05-23 06:48:53 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2017-05-23 06:48:53 +0000 |
commit | 15d85fc5378c5ea252cba85eda042be0ecd6d5bb (patch) | |
tree | e56ed42b888a3bb0820db146e38c39e8ec0ce057 /llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | |
parent | 2ade986c9e4bb30dad40cddca91555119a675800 (diff) | |
download | bcm5719-llvm-15d85fc5378c5ea252cba85eda042be0ecd6d5bb.tar.gz bcm5719-llvm-15d85fc5378c5ea252cba85eda042be0ecd6d5bb.zip |
libDebugInfo: Support symbolizing using DWP files
llvm-svn: 303609
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFContext.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 41a4620372e..896837c8547 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -287,6 +287,15 @@ void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType, bool DumpEH, getStringSection(), isLittleEndian()); } +DWARFCompileUnit *DWARFContext::getDWOCompileUnitForHash(uint64_t Hash) { + // FIXME: Improve this for the case where this DWO file is really a DWP file + // with an index - use the index for lookup instead of a linear search. + for (const auto &DWOCU : dwo_compile_units()) + if (DWOCU->getDWOId() == Hash) + return DWOCU.get(); + return nullptr; +} + DWARFDie DWARFContext::getDIEForOffset(uint32_t Offset) { parseCompileUnits(); if (auto *CU = CUs.getUnitForOffset(Offset)) @@ -899,22 +908,47 @@ DWARFContext::getInliningInfoForAddress(uint64_t Address, std::shared_ptr<DWARFContext> DWARFContext::getDWOContext(StringRef AbsolutePath) { - auto &Entry = DWOFiles[AbsolutePath]; - if (auto S = Entry.lock()) { + if (auto S = DWP.lock()) { DWARFContext *Ctxt = S->Context.get(); return std::shared_ptr<DWARFContext>(std::move(S), Ctxt); } - auto S = std::make_shared<DWOFile>(); - auto Obj = object::ObjectFile::createObjectFile(AbsolutePath); + std::weak_ptr<DWOFile> *Entry = &DWOFiles[AbsolutePath]; + + if (auto S = Entry->lock()) { + DWARFContext *Ctxt = S->Context.get(); + return std::shared_ptr<DWARFContext>(std::move(S), Ctxt); + } + + SmallString<128> DWPName; + Expected<OwningBinary<ObjectFile>> Obj = [&] { + if (!CheckedForDWP) { + (getFileName() + ".dwp").toVector(DWPName); + auto Obj = object::ObjectFile::createObjectFile(DWPName); + if (Obj) { + Entry = &DWP; + return Obj; + } else { + CheckedForDWP = true; + // TODO: Should this error be handled (maybe in a high verbosity mode) + // before falling back to .dwo files? + consumeError(Obj.takeError()); + } + } + + return object::ObjectFile::createObjectFile(AbsolutePath); + }(); + if (!Obj) { // TODO: Actually report errors helpfully. consumeError(Obj.takeError()); return nullptr; } + + auto S = std::make_shared<DWOFile>(); S->File = std::move(Obj.get()); S->Context = llvm::make_unique<DWARFContextInMemory>(*S->File.getBinary()); - Entry = S; + *Entry = S; auto *Ctxt = S->Context.get(); return std::shared_ptr<DWARFContext>(std::move(S), Ctxt); } @@ -1011,8 +1045,8 @@ Error DWARFContextInMemory::maybeDecompress(const SectionRef &Sec, } DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj, - const LoadedObjectInfo *L) - : IsLittleEndian(Obj.isLittleEndian()), + const LoadedObjectInfo *L) + : FileName(Obj.getFileName()), IsLittleEndian(Obj.isLittleEndian()), AddressSize(Obj.getBytesInAddress()) { for (const SectionRef &Section : Obj.sections()) { StringRef name; |