aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
diff options
context:
space:
mode:
authorAlexey Lapshin <a.v.lapshin@mail.ru>2019-03-23 08:08:40 +0000
committerAlexey Lapshin <a.v.lapshin@mail.ru>2019-03-23 08:08:40 +0000
commitb2c4b8bded3ff2efaaebe0d8b33c65116f9ef8de (patch)
treea3ad2ed0f7831c14ada39341079973bb2c02b71c /llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
parente7f0455bd183b9472911351894e1e6faa4806b3d (diff)
downloadllvm-b2c4b8bded3ff2efaaebe0d8b33c65116f9ef8de.zip
llvm-b2c4b8bded3ff2efaaebe0d8b33c65116f9ef8de.tar.gz
llvm-b2c4b8bded3ff2efaaebe0d8b33c65116f9ef8de.tar.bz2
[DebugInfo] follow up for "add SectionedAddress to DebugInfo interfaces"
[Symbolizer] Add getModuleSectionIndexForAddress() helper routine The https://reviews.llvm.org/D58194 patch changed symbolizer interface. Particularily it requires not only Address but SectionIndex also. Note object::SectionedAddress parameter: Expected<DILineInfo> symbolizeCode(const std::string &ModuleName, object::SectionedAddress ModuleOffset, StringRef DWPName = ""); There are callers of symbolizer which do not know particular section index. That patch creates getModuleSectionIndexForAddress() routine which will detect section index for the specified address. Thus if caller set ModuleOffset.SectionIndex into object::SectionedAddress::UndefSection state then symbolizer would detect section index using getModuleSectionIndexForAddress routine. Differential Revision: https://reviews.llvm.org/D58848 llvm-svn: 356829
Diffstat (limited to 'llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp')
-rw-r--r--llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
index f0a9782..fc09be2 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;
+}