diff --git a/llvm/test/tools/llvm-symbolizer/sym.test b/llvm/test/tools/llvm-symbolizer/sym.test --- a/llvm/test/tools/llvm-symbolizer/sym.test +++ b/llvm/test/tools/llvm-symbolizer/sym.test @@ -18,6 +18,7 @@ #Build as : clang -g -O2 addr.c RUN: llvm-symbolizer -print-address -obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck %s +RUN: llvm-symbolizer -print-address -obj=%p/Inputs/addr.exe "some text" 0x40054d "some text2" | FileCheck %s RUN: llvm-symbolizer -addresses -obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck %s RUN: llvm-symbolizer -a -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 @@ -42,11 +43,16 @@ RUN: llvm-addr2line -pfi -obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefixes=A2LP,A2LP_F,A2LP_FI %s RUN: llvm-addr2line -pafi -obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefixes=A2LP,A2LP_AF,A2LP_FI %s -#CHECK: some text -#CHECK: 0x40054d -#CHECK: main -#CHECK: {{[/\]+}}tmp{{[/\]+}}x.c:14:0 -#CHECK: some text2 +# CHECK: some text +# CHECK-NEXT: 0x40054d +# CHECK-NEXT: inctwo +# CHECK-NEXT: {{[/\]+}}tmp{{[/\]+}}x.c:3:3 +# CHECK-NEXT: inc +# CHECK-NEXT: {{[/\]+}}tmp{{[/\]+}}x.c:7:0 +# CHECK-NEXT: main +# CHECK-NEXT: {{[/\]+}}tmp{{[/\]+}}x.c:14:0 +# CHECK-EMPTY: +# CHECK-NEXT: some text2 # #PRETTY: some text #PRETTY: {{[0x]+}}40054d: inctwo at {{[/\]+}}tmp{{[/\]+}}x.c:3:3 diff --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp --- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp +++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp @@ -24,6 +24,7 @@ #include "llvm/Support/InitLLVM.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +#include #include #include #include @@ -228,7 +229,7 @@ std::string ModuleName; uint64_t Offset = 0; if (!parseCommand(StringRef(InputString), Cmd, ModuleName, Offset)) { - outs() << InputString; + outs() << InputString << "\n"; return; } @@ -328,7 +329,10 @@ char InputString[kMaxInputStringLength]; while (fgets(InputString, sizeof(InputString), stdin)) { - symbolizeInput(InputString, Symbolizer, Printer); + // strip newline characters + std::string StrippedInputString(InputString); + StrippedInputString.erase(std::remove(StrippedInputString.begin(), StrippedInputString.end(), '\n'), StrippedInputString.end()); + symbolizeInput(StrippedInputString, Symbolizer, Printer); outs().flush(); } } else {