summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp26
-rw-r--r--llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h3
2 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
index f0a97827c03..fc09be251e1 100644
--- a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
@@ -227,6 +227,11 @@ SymbolizableObjectFile::symbolizeCode(object::SectionedAddress ModuleOffset,
FunctionNameKind FNKind,
bool UseSymbolTable) const {
DILineInfo LineInfo;
+
+ if (ModuleOffset.SectionIndex == object::SectionedAddress::UndefSection)
+ ModuleOffset.SectionIndex =
+ getModuleSectionIndexForAddress(ModuleOffset.Address);
+
if (DebugInfoContext) {
LineInfo = DebugInfoContext->getLineInfoForAddress(
ModuleOffset, getDILineInfoSpecifier(FNKind));
@@ -248,6 +253,10 @@ DIInliningInfo SymbolizableObjectFile::symbolizeInlinedCode(
bool UseSymbolTable) const {
DIInliningInfo InlinedContext;
+ if (ModuleOffset.SectionIndex == object::SectionedAddress::UndefSection)
+ ModuleOffset.SectionIndex =
+ getModuleSectionIndexForAddress(ModuleOffset.Address);
+
if (DebugInfoContext)
InlinedContext = DebugInfoContext->getInliningInfoForAddress(
ModuleOffset, getDILineInfoSpecifier(FNKind));
@@ -276,3 +285,20 @@ DIGlobal SymbolizableObjectFile::symbolizeData(
Res.Start, Res.Size);
return Res;
}
+
+/// Search for the first occurence of specified Address in ObjectFile.
+uint64_t SymbolizableObjectFile::getModuleSectionIndexForAddress(
+ uint64_t Address) const {
+
+ for (SectionRef Sec : Module->sections()) {
+ if (!Sec.isText() || Sec.isVirtual())
+ continue;
+
+ if (Address >= Sec.getAddress() &&
+ Address <= Sec.getAddress() + Sec.getSize()) {
+ return Sec.getIndex();
+ }
+ }
+
+ return object::SectionedAddress::UndefSection;
+}
diff --git a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h
index a49ab000131..d5ad8d0d3c4 100644
--- a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h
+++ b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h
@@ -63,6 +63,9 @@ private:
uint64_t OpdAddress = 0);
std::error_code addCoffExportSymbols(const object::COFFObjectFile *CoffObj);
+ /// Search for the first occurence of specified Address in ObjectFile.
+ uint64_t getModuleSectionIndexForAddress(uint64_t Address) const;
+
object::ObjectFile *Module;
std::unique_ptr<DIContext> DebugInfoContext;
OpenPOWER on IntegriCloud