diff options
author | David Blaikie <dblaikie@gmail.com> | 2017-05-23 00:30:42 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2017-05-23 00:30:42 +0000 |
commit | f9803fb4bb4fbc9e7507fa89c44aa81b1003daf2 (patch) | |
tree | 23d77177b5d2462fa58b5aa8eddc3813437c06e4 /llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | |
parent | 2db1369c1f007559a350356cf49a143afc6f3c5c (diff) | |
download | bcm5719-llvm-f9803fb4bb4fbc9e7507fa89c44aa81b1003daf2.tar.gz bcm5719-llvm-f9803fb4bb4fbc9e7507fa89c44aa81b1003daf2.zip |
libDebugInfo: Avoid independently parsing the same .dwo file for two separate CUs residing there
NFC, just an optimization. Will be building on this for DWP support
shortly.
llvm-svn: 303591
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFContext.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 8e7c6c43d1a..41a4620372e 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -897,6 +897,28 @@ DWARFContext::getInliningInfoForAddress(uint64_t Address, return InliningInfo; } +std::shared_ptr<DWARFContext> +DWARFContext::getDWOContext(StringRef AbsolutePath) { + auto &Entry = DWOFiles[AbsolutePath]; + if (auto S = Entry.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); + if (!Obj) { + // TODO: Actually report errors helpfully. + consumeError(Obj.takeError()); + return nullptr; + } + S->File = std::move(Obj.get()); + S->Context = llvm::make_unique<DWARFContextInMemory>(*S->File.getBinary()); + Entry = S; + auto *Ctxt = S->Context.get(); + return std::shared_ptr<DWARFContext>(std::move(S), Ctxt); +} + static Error createError(const Twine &Reason, llvm::Error E) { return make_error<StringError>(Reason + toString(std::move(E)), inconvertibleErrorCode()); |