summaryrefslogtreecommitdiff
path: root/tools/llvm-symbolizer
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-04-05 09:22:24 +0000
committerAlexey Samsonov <samsonov@google.com>2013-04-05 09:22:24 +0000
commitef148afba873b1e24af1b3c22148f967b9b8a232 (patch)
treeb0532453f4545e67dc4436b595de4dce58f1a102 /tools/llvm-symbolizer
parent1c4d286f5cf3a13d658a4b1930a5ead12bd59918 (diff)
downloadllvm-ef148afba873b1e24af1b3c22148f967b9b8a232.tar.gz
llvm-ef148afba873b1e24af1b3c22148f967b9b8a232.tar.bz2
llvm-ef148afba873b1e24af1b3c22148f967b9b8a232.tar.xz
llvm-symbolizer: correctly parse filenames given in quotes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178859 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-symbolizer')
-rw-r--r--tools/llvm-symbolizer/llvm-symbolizer.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/tools/llvm-symbolizer/llvm-symbolizer.cpp b/tools/llvm-symbolizer/llvm-symbolizer.cpp
index d039ec691f..0cafffaf71 100644
--- a/tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ b/tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -70,12 +70,25 @@ static bool parseCommand(bool &IsData, std::string &ModuleName,
// If no cmd, assume it's CODE.
IsData = false;
}
- // FIXME: Handle case when filename is given in quotes.
- if (char *FilePath = strtok(pos, kDelimiters)) {
- ModuleName = FilePath;
- if (char *OffsetStr = strtok((char *)0, kDelimiters))
- ModuleOffsetStr = OffsetStr;
+ // 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;
+ } else {
+ int name_length = strcspn(pos, kDelimiters);
+ ModuleName = std::string(pos, name_length);
+ pos += name_length;
}
+ // 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))
return false;
return true;