[llvm] r257115 - [llvm-symbolizer] Print out non-address lines verbatim.
Mike Aizatsky via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 7 15:57:41 PST 2016
Author: aizatsky
Date: Thu Jan 7 17:57:41 2016
New Revision: 257115
URL: http://llvm.org/viewvc/llvm-project?rev=257115&view=rev
Log:
[llvm-symbolizer] Print out non-address lines verbatim.
Differential Revision: http://reviews.llvm.org/D15876
Modified:
llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst
llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.inp
llvm/trunk/test/tools/llvm-symbolizer/sym.test
llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp
Modified: llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst?rev=257115&r1=257114&r2=257115&view=diff
==============================================================================
--- llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst (original)
+++ llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst Thu Jan 7 17:57:41 2016
@@ -11,9 +11,9 @@ DESCRIPTION
:program:`llvm-symbolizer` reads object file names and addresses from standard
input and prints corresponding source code locations to standard output.
-If object file is specified in command line, :program:`llvm-symbolizer` reads
-only addresses from standard input. This
-program uses debug info sections and symbol table in the object files.
+If object file is specified in command line, :program:`llvm-symbolizer`
+processes only addresses from standard input, the rest is output verbatim.
+This program uses debug info sections and symbol table in the object files.
EXAMPLE
--------
Modified: llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.inp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.inp?rev=257115&r1=257114&r2=257115&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.inp (original)
+++ llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.inp Thu Jan 7 17:57:41 2016
@@ -1 +1,3 @@
+some text
0x40054d
+some text2
Modified: llvm/trunk/test/tools/llvm-symbolizer/sym.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/sym.test?rev=257115&r1=257114&r2=257115&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-symbolizer/sym.test (original)
+++ llvm/trunk/test/tools/llvm-symbolizer/sym.test Thu Jan 7 17:57:41 2016
@@ -20,11 +20,15 @@
RUN: llvm-symbolizer -print-address -obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck %s
RUN: llvm-symbolizer -inlining -print-address -pretty-print -obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck --check-prefix="PRETTY" %s
+#CHECK: some text
#CHECK: 0x40054d
#CHECK: main
#CHECK: {{[/\]+}}tmp{{[/\]+}}x.c:14:0
+#CHECK: some text2
#
+#PRETTY: some text
#PRETTY: {{[0x]+}}40054d: inctwo at {{[/\]+}}tmp{{[/\]+}}x.c:3:3
#PRETTY: (inlined by) inc at {{[/\]+}}tmp{{[/\]+}}x.c:7:0
#PRETTY (inlined by) main at {{[/\]+}}tmp{{[/\]+}}x.c:14:0
+#PRETTY: some text2
Modified: llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp?rev=257115&r1=257114&r2=257115&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp (original)
+++ llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp Thu Jan 7 17:57:41 2016
@@ -89,18 +89,14 @@ static bool error(std::error_code ec) {
return true;
}
-static bool parseCommand(bool &IsData, std::string &ModuleName,
- uint64_t &ModuleOffset) {
+static bool parseCommand(StringRef InputString, bool &IsData,
+ std::string &ModuleName, uint64_t &ModuleOffset) {
const char *kDataCmd = "DATA ";
const char *kCodeCmd = "CODE ";
- const int kMaxInputStringLength = 1024;
- const char kDelimiters[] = " \n";
- char InputString[kMaxInputStringLength];
- if (!fgets(InputString, sizeof(InputString), stdin))
- return false;
+ const char kDelimiters[] = " \n\r";
IsData = false;
ModuleName = "";
- char *pos = InputString;
+ const char *pos = InputString.data();
if (strncmp(pos, kDataCmd, strlen(kDataCmd)) == 0) {
IsData = true;
pos += strlen(kDataCmd);
@@ -117,7 +113,7 @@ static bool parseCommand(bool &IsData, s
if (*pos == '"' || *pos == '\'') {
char quote = *pos;
pos++;
- char *end = strchr(pos, quote);
+ const char *end = strchr(pos, quote);
if (!end)
return false;
ModuleName = std::string(pos, end - pos);
@@ -158,13 +154,25 @@ int main(int argc, char **argv) {
}
LLVMSymbolizer Symbolizer(Opts);
- bool IsData = false;
- std::string ModuleName;
- uint64_t ModuleOffset;
DIPrinter Printer(outs(), ClPrintFunctions != FunctionNameKind::None,
ClPrettyPrint);
- while (parseCommand(IsData, ModuleName, ModuleOffset)) {
+ const int kMaxInputStringLength = 1024;
+ char InputString[kMaxInputStringLength];
+
+ while (true) {
+ if (!fgets(InputString, sizeof(InputString), stdin))
+ break;
+
+ bool IsData = false;
+ std::string ModuleName;
+ uint64_t ModuleOffset = 0;
+ if (!parseCommand(StringRef(InputString), IsData, ModuleName,
+ ModuleOffset)) {
+ outs() << InputString;
+ continue;
+ }
+
if (ClPrintAddress) {
outs() << "0x";
outs().write_hex(ModuleOffset);
More information about the llvm-commits
mailing list