summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp')
-rw-r--r--llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp57
1 files changed, 8 insertions, 49 deletions
diff --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
index 9a39c3019cd..bac7fc5f8e7 100644
--- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -194,48 +194,6 @@ static bool parseCommand(StringRef InputString, bool &IsData,
return !StringRef(pos, offset_length).getAsInteger(0, ModuleOffset);
}
-// This routine returns section index for an address.
-// Assumption: would work ambiguously for object files which have sections not
-// assigned to an address(since the same address could belong to various
-// sections).
-static uint64_t getModuleSectionIndexForAddress(const std::string &ModuleName,
- uint64_t Address) {
-
- // following ModuleName processing was copied from
- // LLVMSymbolizer::getOrCreateModuleInfo().
- // it needs to be refactored to avoid code duplication.
- std::string BinaryName = ModuleName;
- size_t ColonPos = ModuleName.find_last_of(':');
- // Verify that substring after colon form a valid arch name.
- if (ColonPos != std::string::npos) {
- std::string ArchStr = ModuleName.substr(ColonPos + 1);
- if (Triple(ArchStr).getArch() != Triple::UnknownArch) {
- BinaryName = ModuleName.substr(0, ColonPos);
- }
- }
-
- Expected<OwningBinary<Binary>> BinaryOrErr = createBinary(BinaryName);
-
- if (error(BinaryOrErr))
- return object::SectionedAddress::UndefSection;
-
- Binary &Binary = *BinaryOrErr->getBinary();
-
- if (ObjectFile *O = dyn_cast<ObjectFile>(&Binary)) {
- for (SectionRef Sec : O->sections()) {
- if (!Sec.isText() || Sec.isVirtual())
- continue;
-
- if (Address >= Sec.getAddress() &&
- Address <= Sec.getAddress() + Sec.getSize()) {
- return Sec.getIndex();
- }
- }
- }
-
- return object::SectionedAddress::UndefSection;
-}
-
static void symbolizeInput(StringRef InputString, LLVMSymbolizer &Symbolizer,
DIPrinter &Printer) {
bool IsData = false;
@@ -253,18 +211,19 @@ static void symbolizeInput(StringRef InputString, LLVMSymbolizer &Symbolizer,
outs() << Delimiter;
}
Offset -= ClAdjustVMA;
- object::SectionedAddress ModuleOffset = {
- Offset, getModuleSectionIndexForAddress(ModuleName, Offset)};
if (IsData) {
- auto ResOrErr = Symbolizer.symbolizeData(ModuleName, ModuleOffset);
+ auto ResOrErr = Symbolizer.symbolizeData(
+ ModuleName, {Offset, object::SectionedAddress::UndefSection});
Printer << (error(ResOrErr) ? DIGlobal() : ResOrErr.get());
} else if (ClPrintInlining) {
- auto ResOrErr =
- Symbolizer.symbolizeInlinedCode(ModuleName, ModuleOffset, ClDwpName);
+ auto ResOrErr = Symbolizer.symbolizeInlinedCode(
+ ModuleName, {Offset, object::SectionedAddress::UndefSection},
+ ClDwpName);
Printer << (error(ResOrErr) ? DIInliningInfo() : ResOrErr.get());
} else {
- auto ResOrErr =
- Symbolizer.symbolizeCode(ModuleName, ModuleOffset, ClDwpName);
+ auto ResOrErr = Symbolizer.symbolizeCode(
+ ModuleName, {Offset, object::SectionedAddress::UndefSection},
+ ClDwpName);
Printer << (error(ResOrErr) ? DILineInfo() : ResOrErr.get());
}
outs() << "\n";
OpenPOWER on IntegriCloud