summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2015-10-29 23:49:19 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2015-10-29 23:49:19 +0000
commit76f7ecb83a72da43c0da871c8d9937ad0679c93a (patch)
tree84b6efc7ec0566623afe6c898d53ffd844fe0a16 /llvm/lib
parent7a33621fa576cfd75864dbacef3391e1aa9cca28 (diff)
downloadbcm5719-llvm-76f7ecb83a72da43c0da871c8d9937ad0679c93a.tar.gz
bcm5719-llvm-76f7ecb83a72da43c0da871c8d9937ad0679c93a.zip
[LLVMSymbolize] Move printing the description of a global into a separate function. NFC.
llvm-svn: 251669
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp10
-rw-r--r--llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h3
-rw-r--r--llvm/lib/DebugInfo/Symbolize/Symbolize.cpp34
3 files changed, 28 insertions, 19 deletions
diff --git a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
index 65d4cce3dc1..fb2873e8159 100644
--- a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
@@ -239,11 +239,11 @@ DIInliningInfo SymbolizableObjectFile::symbolizeInlinedCode(
return PatchedInlinedContext;
}
-bool SymbolizableObjectFile::symbolizeData(uint64_t ModuleOffset,
- std::string &Name, uint64_t &Start,
- uint64_t &Size) const {
- return getNameFromSymbolTable(SymbolRef::ST_Data, ModuleOffset, Name, Start,
- Size);
+DIGlobal SymbolizableObjectFile::symbolizeData(uint64_t ModuleOffset) const {
+ DIGlobal Res;
+ getNameFromSymbolTable(SymbolRef::ST_Data, ModuleOffset, Res.Name, Res.Start,
+ Res.Size);
+ return Res;
}
} // namespace symbolize
diff --git a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h
index 7c138d3e468..a90e95c376f 100644
--- a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h
+++ b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h
@@ -33,8 +33,7 @@ public:
DIInliningInfo symbolizeInlinedCode(uint64_t ModuleOffset,
FunctionNameKind FNKind,
bool UseSymbolTable) const override;
- bool symbolizeData(uint64_t ModuleOffset, std::string &Name, uint64_t &Start,
- uint64_t &Size) const override;
+ DIGlobal symbolizeData(uint64_t ModuleOffset) const override;
// Return true if this is a 32-bit x86 PE COFF module.
bool isWin32Module() const override;
diff --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
index 2da35f930d0..87f76eda6c7 100644
--- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -56,6 +56,10 @@ static bool error(std::error_code ec) {
}
+// By default, DILineInfo contains "<invalid>" for function/filename it
+// cannot fetch. We replace it to "??" to make our output closer to addr2line.
+static const char kDILineInfoBadString[] = "<invalid>";
+
const char LLVMSymbolizer::kBadString[] = "??";
std::string LLVMSymbolizer::symbolizeCode(const std::string &ModuleName,
@@ -88,9 +92,6 @@ std::string LLVMSymbolizer::symbolizeCode(const std::string &ModuleName,
std::string LLVMSymbolizer::symbolizeData(const std::string &ModuleName,
uint64_t ModuleOffset) {
- std::string Name = kBadString;
- uint64_t Start = 0;
- uint64_t Size = 0;
if (Opts.UseSymbolTable) {
if (SymbolizableModule *Info = getOrCreateModuleInfo(ModuleName)) {
// If the user is giving us relative addresses, add the preferred base of
@@ -98,13 +99,11 @@ std::string LLVMSymbolizer::symbolizeData(const std::string &ModuleName,
// expects.
if (Opts.RelativeAddresses)
ModuleOffset += Info->getModulePreferredBase();
- if (Info->symbolizeData(ModuleOffset, Name, Start, Size) && Opts.Demangle)
- Name = DemangleName(Name, Info);
+ DIGlobal Global = Info->symbolizeData(ModuleOffset);
+ return printDIGlobal(Global, Info);
}
}
- std::stringstream ss;
- ss << Name << "\n" << Start << " " << Size << "\n";
- return ss.str();
+ return printDIGlobal(DIGlobal(), nullptr);
}
void LLVMSymbolizer::flush() {
@@ -359,9 +358,6 @@ LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) {
std::string
LLVMSymbolizer::printDILineInfo(DILineInfo LineInfo,
const SymbolizableModule *ModInfo) const {
- // By default, DILineInfo contains "<invalid>" for function/filename it
- // cannot fetch. We replace it to "??" to make our output closer to addr2line.
- static const std::string kDILineInfoBadString = "<invalid>";
std::stringstream Result;
if (Opts.PrintFunctions != FunctionNameKind::None) {
std::string FunctionName = LineInfo.FunctionName;
@@ -378,6 +374,20 @@ LLVMSymbolizer::printDILineInfo(DILineInfo LineInfo,
return Result.str();
}
+std::string
+LLVMSymbolizer::printDIGlobal(DIGlobal Global,
+ const SymbolizableModule *ModInfo) const {
+ std::stringstream Result;
+ std::string Name = Global.Name;
+ if (Name == kDILineInfoBadString)
+ Name = kBadString;
+ else if (Opts.Demangle)
+ Name = DemangleName(Name, ModInfo);
+ Result << Name << "\n";
+ Result << Global.Start << " " << Global.Size << "\n";
+ return Result.str();
+}
+
// Undo these various manglings for Win32 extern "C" functions:
// cdecl - _foo
// stdcall - _foo@12
@@ -442,7 +452,7 @@ std::string LLVMSymbolizer::DemangleName(const std::string &Name,
return (result == 0) ? Name : std::string(DemangledName);
}
#endif
- if (ModInfo->isWin32Module())
+ if (ModInfo && ModInfo->isWin32Module())
return std::string(demanglePE32ExternCFunc(Name));
return Name;
}
OpenPOWER on IntegriCloud