diff options
Diffstat (limited to 'tools/llvm-symbolizer/llvm-symbolizer.cpp')
-rw-r--r-- | tools/llvm-symbolizer/llvm-symbolizer.cpp | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/tools/llvm-symbolizer/llvm-symbolizer.cpp b/tools/llvm-symbolizer/llvm-symbolizer.cpp index c32e949..83f5c5e 100644 --- a/tools/llvm-symbolizer/llvm-symbolizer.cpp +++ b/tools/llvm-symbolizer/llvm-symbolizer.cpp @@ -51,6 +51,11 @@ static cl::opt<std::string> ClDefaultArch("default-arch", cl::init(""), cl::desc("Default architecture " "(for multi-arch objects)")); +static cl::opt<std::string> +ClBinaryName("obj", cl::init(""), + cl::desc("Path to object file to be symbolized (if not provided, " + "object file should be specified for each input line)")); + static bool parseCommand(bool &IsData, std::string &ModuleName, uint64_t &ModuleOffset) { const char *kDataCmd = "DATA "; @@ -62,7 +67,6 @@ static bool parseCommand(bool &IsData, std::string &ModuleName, return false; IsData = false; ModuleName = ""; - std::string ModuleOffsetStr = ""; char *pos = InputString; if (strncmp(pos, kDataCmd, strlen(kDataCmd)) == 0) { IsData = true; @@ -74,26 +78,29 @@ static bool parseCommand(bool &IsData, std::string &ModuleName, // If no cmd, assume it's CODE. IsData = false; } - // Skip delimiters and parse input filename. - pos += strspn(pos, kDelimiters); - if (*pos == '"' || *pos == '\'') { - char quote = *pos; - pos++; - char *end = strchr(pos, quote); - if (end == 0) - return false; - ModuleName = std::string(pos, end - pos); - pos = end + 1; + // Skip delimiters and parse input filename (if needed). + if (ClBinaryName == "") { + pos += strspn(pos, kDelimiters); + if (*pos == '"' || *pos == '\'') { + char quote = *pos; + pos++; + char *end = strchr(pos, quote); + if (end == 0) + return false; + ModuleName = std::string(pos, end - pos); + pos = end + 1; + } else { + int name_length = strcspn(pos, kDelimiters); + ModuleName = std::string(pos, name_length); + pos += name_length; + } } else { - int name_length = strcspn(pos, kDelimiters); - ModuleName = std::string(pos, name_length); - pos += name_length; + ModuleName = ClBinaryName; } // Skip delimiters and parse module offset. pos += strspn(pos, kDelimiters); int offset_length = strcspn(pos, kDelimiters); - ModuleOffsetStr = std::string(pos, offset_length); - if (StringRef(ModuleOffsetStr).getAsInteger(0, ModuleOffset)) + if (StringRef(pos, offset_length).getAsInteger(0, ModuleOffset)) return false; return true; } @@ -104,7 +111,7 @@ int main(int argc, char **argv) { PrettyStackTraceProgram X(argc, argv); llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. - cl::ParseCommandLineOptions(argc, argv, "llvm symbolizer for compiler-rt\n"); + cl::ParseCommandLineOptions(argc, argv, "llvm-symbolizer\n"); LLVMSymbolizer::Options Opts(ClUseSymbolTable, ClPrintFunctions, ClPrintInlining, ClDemangle, ClDefaultArch); LLVMSymbolizer Symbolizer(Opts); |