aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvm-symbolizer
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-06-28 12:06:25 +0000
committerAlexey Samsonov <samsonov@google.com>2013-06-28 12:06:25 +0000
commitc071f89a770d6c66e6b29fdf013fa88454fc0ac6 (patch)
treee6deeec9c800b37b8200407d9067448d8465c4a7 /tools/llvm-symbolizer
parent4157466bdc41173a1ebd777739ea219162ae13e0 (diff)
downloadexternal_llvm-c071f89a770d6c66e6b29fdf013fa88454fc0ac6.zip
external_llvm-c071f89a770d6c66e6b29fdf013fa88454fc0ac6.tar.gz
external_llvm-c071f89a770d6c66e6b29fdf013fa88454fc0ac6.tar.bz2
llvm-symbolizer: make name demangling a public static method of LLVMSymbolizer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185143 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-symbolizer')
-rw-r--r--tools/llvm-symbolizer/LLVMSymbolize.cpp18
-rw-r--r--tools/llvm-symbolizer/LLVMSymbolize.h2
2 files changed, 11 insertions, 9 deletions
diff --git a/tools/llvm-symbolizer/LLVMSymbolize.cpp b/tools/llvm-symbolizer/LLVMSymbolize.cpp
index 74e9843..dfcbacf 100644
--- a/tools/llvm-symbolizer/LLVMSymbolize.cpp
+++ b/tools/llvm-symbolizer/LLVMSymbolize.cpp
@@ -187,8 +187,8 @@ std::string LLVMSymbolizer::symbolizeData(const std::string &ModuleName,
uint64_t Size = 0;
if (Opts.UseSymbolTable) {
if (ModuleInfo *Info = getOrCreateModuleInfo(ModuleName)) {
- if (Info->symbolizeData(ModuleOffset, Name, Start, Size))
- DemangleName(Name);
+ if (Info->symbolizeData(ModuleOffset, Name, Start, Size) && Opts.Demangle)
+ Name = DemangleName(Name);
}
}
std::stringstream ss;
@@ -303,7 +303,8 @@ std::string LLVMSymbolizer::printDILineInfo(DILineInfo LineInfo) const {
std::string FunctionName = LineInfo.getFunctionName();
if (FunctionName == kDILineInfoBadString)
FunctionName = kBadString;
- DemangleName(FunctionName);
+ else if (Opts.Demangle)
+ FunctionName = DemangleName(FunctionName);
Result << FunctionName << "\n";
}
std::string Filename = LineInfo.getFileName();
@@ -320,16 +321,17 @@ extern "C" char *__cxa_demangle(const char *mangled_name, char *output_buffer,
size_t *length, int *status);
#endif
-void LLVMSymbolizer::DemangleName(std::string &Name) const {
+std::string LLVMSymbolizer::DemangleName(const std::string &Name) {
#if !defined(_MSC_VER)
- if (!Opts.Demangle)
- return;
int status = 0;
char *DemangledName = __cxa_demangle(Name.c_str(), 0, 0, &status);
if (status != 0)
- return;
- Name = DemangledName;
+ return Name;
+ std::string Result = DemangledName;
free(DemangledName);
+ return Result;
+#else
+ return Name;
#endif
}
diff --git a/tools/llvm-symbolizer/LLVMSymbolize.h b/tools/llvm-symbolizer/LLVMSymbolize.h
index c7f87b1..d1f2285 100644
--- a/tools/llvm-symbolizer/LLVMSymbolize.h
+++ b/tools/llvm-symbolizer/LLVMSymbolize.h
@@ -56,6 +56,7 @@ public:
std::string
symbolizeData(const std::string &ModuleName, uint64_t ModuleOffset);
void flush();
+ static std::string DemangleName(const std::string &Name);
private:
typedef std::pair<Binary*, Binary*> BinaryPair;
@@ -67,7 +68,6 @@ private:
ObjectFile *getObjectFileFromBinary(Binary *Bin, const std::string &ArchName);
std::string printDILineInfo(DILineInfo LineInfo) const;
- void DemangleName(std::string &Name) const;
// Owns all the parsed binaries and object files.
SmallVector<Binary*, 4> ParsedBinariesAndObjects;