[llvm-commits] [compiler-rt] r164367 - /compiler-rt/trunk/utils/llvm-symbolizer/llvm-symbolizer.cpp
Alexey Samsonov
samsonov at google.com
Fri Sep 21 03:54:14 PDT 2012
Author: samsonov
Date: Fri Sep 21 05:54:14 2012
New Revision: 164367
URL: http://llvm.org/viewvc/llvm-project?rev=164367&view=rev
Log:
[Sanitizer] llvm-symbolizer: enable accessing symbol table (libObject is fixed in r164365) and replace string with std::string
Modified:
compiler-rt/trunk/utils/llvm-symbolizer/llvm-symbolizer.cpp
Modified: compiler-rt/trunk/utils/llvm-symbolizer/llvm-symbolizer.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/utils/llvm-symbolizer/llvm-symbolizer.cpp?rev=164367&r1=164366&r2=164367&view=diff
==============================================================================
--- compiler-rt/trunk/utils/llvm-symbolizer/llvm-symbolizer.cpp (original)
+++ compiler-rt/trunk/utils/llvm-symbolizer/llvm-symbolizer.cpp Fri Sep 21 05:54:14 2012
@@ -34,12 +34,9 @@
using namespace llvm;
using namespace object;
-using std::string;
-// FIXME: Enable --use-symbol-table by default when the bug in libObject's
-// Symbol::getAddress is fixed.
static cl::opt<bool>
-UseSymbolTable("use-symbol-table", cl::init(false),
+UseSymbolTable("use-symbol-table", cl::init(true),
cl::desc("Prefer names in symbol table to names "
"in debug info"));
@@ -73,9 +70,9 @@
return Flags;
}
-static void patchFunctionNameInDILineInfo(const string &NewFunctionName,
+static void patchFunctionNameInDILineInfo(const std::string &NewFunctionName,
DILineInfo &LineInfo) {
- string FileName = LineInfo.getFileName();
+ std::string FileName = LineInfo.getFileName();
LineInfo = DILineInfo(StringRef(FileName), StringRef(NewFunctionName),
LineInfo.getLine(), LineInfo.getColumn());
}
@@ -95,7 +92,7 @@
}
// Override function name from symbol table if necessary.
if (PrintFunctions && UseSymbolTable) {
- string Function;
+ std::string Function;
if (getFunctionNameFromSymbolTable(ModuleOffset, Function)) {
patchFunctionNameInDILineInfo(Function, LineInfo);
}
@@ -119,7 +116,7 @@
i != n; i++) {
DILineInfo LineInfo = InlinedContext.getFrame(i);
if (i == n - 1) {
- string Function;
+ std::string Function;
if (getFunctionNameFromSymbolTable(ModuleOffset, Function)) {
patchFunctionNameInDILineInfo(Function, LineInfo);
}
@@ -132,7 +129,7 @@
}
private:
bool getFunctionNameFromSymbolTable(size_t Address,
- string &FunctionName) const {
+ std::string &FunctionName) const {
assert(Module);
error_code ec;
for (symbol_iterator si = Module->begin_symbols(),
@@ -156,7 +153,7 @@
}
};
-typedef std::map<string, ModuleInfo*> ModuleMapTy;
+typedef std::map<std::string, ModuleInfo*> ModuleMapTy;
typedef ModuleMapTy::iterator ModuleMapIter;
typedef ModuleMapTy::const_iterator ModuleMapConstIter;
} // namespace
@@ -183,7 +180,7 @@
return true;
}
-static ModuleInfo *getOrCreateModuleInfo(const string &ModuleName) {
+static ModuleInfo *getOrCreateModuleInfo(const std::string &ModuleName) {
ModuleMapIter I = Modules.find(ModuleName);
if (I != Modules.end())
return I->second;
@@ -250,10 +247,10 @@
static void printDILineInfo(DILineInfo LineInfo) {
// By default, DILineInfo contains "<invalid>" for function/filename it
// cannot fetch. We replace it to "??" to make our output closer to addr2line.
- static const string kDILineInfoBadString = "<invalid>";
- static const string kSymbolizerBadString = "??";
+ static const std::string kDILineInfoBadString = "<invalid>";
+ static const std::string kSymbolizerBadString = "??";
if (PrintFunctions) {
- string FunctionName = LineInfo.getFunctionName();
+ std::string FunctionName = LineInfo.getFunctionName();
if (FunctionName == kDILineInfoBadString)
FunctionName = kSymbolizerBadString;
if (Demangle) {
@@ -267,7 +264,7 @@
}
outs() << FunctionName << "\n";
}
- string Filename = LineInfo.getFileName();
+ std::string Filename = LineInfo.getFileName();
if (Filename == kDILineInfoBadString)
Filename = kSymbolizerBadString;
outs() << Filename <<
@@ -276,7 +273,7 @@
"\n";
}
-static void symbolize(string ModuleName, string ModuleOffsetStr) {
+static void symbolize(std::string ModuleName, std::string ModuleOffsetStr) {
ModuleInfo *Info = getOrCreateModuleInfo(ModuleName);
uint64_t Offset = 0;
if (Info == 0 ||
@@ -299,8 +296,8 @@
outs().flush();
}
-static bool parseModuleNameAndOffset(string &ModuleName,
- string &ModuleOffsetStr) {
+static bool parseModuleNameAndOffset(std::string &ModuleName,
+ std::string &ModuleOffsetStr) {
static const int kMaxInputStringLength = 1024;
static const char kDelimiters[] = " \n";
char InputString[kMaxInputStringLength];
@@ -326,8 +323,8 @@
cl::ParseCommandLineOptions(argc, argv, "llvm symbolizer for compiler-rt\n");
ToolInvocationPath = argv[0];
- string ModuleName;
- string ModuleOffsetStr;
+ std::string ModuleName;
+ std::string ModuleOffsetStr;
while (parseModuleNameAndOffset(ModuleName, ModuleOffsetStr)) {
symbolize(ModuleName, ModuleOffsetStr);
}
More information about the llvm-commits
mailing list