mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[llvm-symbolizer]Fix printing of malformed address values not passed via stdin
Summary: relates https://bugs.llvm.org/show_bug.cgi?id=44443 Adding missing newline when printing bad input values. Fix testcase Reviewers: jhenderson Reviewed By: jhenderson Subscribers: rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72313
This commit is contained in:
parent
95287dad6e
commit
a5bc6713d8
@ -1,7 +1,23 @@
|
||||
# Use address that can't fit in a 64-bit number. Show that llvm-symbolizer
|
||||
# simply echoes it as per other malformed input addresses.
|
||||
RUN: llvm-symbolizer --obj=addr.exe 0x10000000000000000 | FileCheck %s
|
||||
RUN: llvm-symbolizer --obj=addr.exe 0x10000000000000000 | FileCheck --check-prefix=LARGE-ADDR %s
|
||||
|
||||
CHECK-NOT: {{.}}
|
||||
CHECK: 0x10000000000000000
|
||||
CHECK-NOT: {{.}}
|
||||
LARGE-ADDR-NOT: {{.}}
|
||||
LARGE-ADDR: 0x10000000000000000
|
||||
LARGE-ADDR-NOT: {{.}}
|
||||
|
||||
RUN: echo '"some text"' '"some text2"' > %t.rsp
|
||||
RUN: echo -e 'some text\nsome text2\n' > %t.inp
|
||||
|
||||
# Test bad input address values, via stdin, command line and response file.
|
||||
RUN: llvm-symbolizer --obj=%p/Inputs/addr.exe < %t.inp | FileCheck --check-prefix=BAD-INPUT %s
|
||||
RUN: llvm-symbolizer --obj=%p/Inputs/addr.exe "some text" "some text2" | FileCheck --check-prefix=BAD-INPUT %s
|
||||
RUN: llvm-symbolizer --obj=%p/Inputs/addr.exe @%t.rsp | FileCheck --check-prefix=BAD-INPUT %s
|
||||
|
||||
# Test bad input address values for the GNU-compatible version.
|
||||
RUN: llvm-addr2line --obj=%p/Inputs/addr.exe < %t.inp | FileCheck --check-prefix=BAD-INPUT %s
|
||||
RUN: llvm-addr2line --obj=%p/Inputs/addr.exe "some text" "some text2" | FileCheck --check-prefix=BAD-INPUT %s
|
||||
RUN: llvm-addr2line --obj=%p/Inputs/addr.exe @%t.rsp | FileCheck --check-prefix=BAD-INPUT %s
|
||||
|
||||
BAD-INPUT: some text
|
||||
BAD-INPUT-NEXT: some text2
|
||||
|
@ -42,11 +42,16 @@ RUN: llvm-addr2line -pai -obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileChec
|
||||
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
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "llvm/Support/InitLLVM.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
@ -228,7 +229,7 @@ static void symbolizeInput(StringRef InputString, LLVMSymbolizer &Symbolizer,
|
||||
std::string ModuleName;
|
||||
uint64_t Offset = 0;
|
||||
if (!parseCommand(StringRef(InputString), Cmd, ModuleName, Offset)) {
|
||||
outs() << InputString;
|
||||
outs() << InputString << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -328,7 +329,13 @@ int main(int argc, char **argv) {
|
||||
char InputString[kMaxInputStringLength];
|
||||
|
||||
while (fgets(InputString, sizeof(InputString), stdin)) {
|
||||
symbolizeInput(InputString, Symbolizer, Printer);
|
||||
// Strip newline characters.
|
||||
std::string StrippedInputString(InputString);
|
||||
StrippedInputString.erase(
|
||||
std::remove_if(StrippedInputString.begin(), StrippedInputString.end(),
|
||||
[](char c) { return c == '\r' || c == '\n'; }),
|
||||
StrippedInputString.end());
|
||||
symbolizeInput(StrippedInputString, Symbolizer, Printer);
|
||||
outs().flush();
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user