Skip to content

Commit 1792852

Browse files
committed
[symbolizer] Change reaction on invalid input
If llvm-symbolizer finds a malformed command, it echoes it to the standard output. New versions of binutils (starting from 2.39) allow to specify an address by a symbols. Implementation of this feature in llvm-symbolizer makes the current reaction on invalid input inappropriate. Almost any invalid command may be treated as a symbol name, so the right reaction should be "symbol not found" in such case. The exception are commands that are recognized but have incorrect syntax, like "FILE:FILE:". The utility must produce descriptive diagnostic for such input and route it to the stderr. This change implements the new reaction on invalid input and is a prerequisite for implementation of symbol lookup in llvm-symbolizer. Differential Revision: https://reviews.llvm.org/D157210
1 parent 38c92c1 commit 1792852

21 files changed

+187
-108
lines changed

llvm/docs/CommandGuide/llvm-symbolizer.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ symbolize logs containing :doc:`Symbolizer Markup </SymbolizerMarkupFormat>` via
1818

1919
If no address is specified on the command-line, it reads the addresses from
2020
standard input. If no input name is specified on the command-line, but addresses
21-
are, or if at any time an input value is not recognized, the input is simply
22-
echoed to the output.
21+
are, the first address value is treated as an input name. If an input value is not
22+
recognized, it reports that source information is not found.
2323

2424
Input names can be specified together with the addresses either on standard
2525
input or as positional arguments on the command-line. By default, input names

llvm/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ Changes to the Debug Info
160160
Changes to the LLVM tools
161161
---------------------------------
162162

163+
* llvm-symbolizer now treats invalid input as an address for which source
164+
information is not found.
165+
163166
Changes to LLDB
164167
---------------------------------
165168

llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ class DIPrinter {
4747
virtual void print(const Request &Request,
4848
const std::vector<DILocal> &Locals) = 0;
4949

50-
virtual void printInvalidCommand(const Request &Request,
51-
StringRef Command) = 0;
52-
5350
virtual bool printError(const Request &Request,
5451
const ErrorInfoBase &ErrorInfo) = 0;
5552

@@ -83,7 +80,7 @@ class PlainPrinterBase : public DIPrinter {
8380
virtual void printFooter() {}
8481

8582
private:
86-
void printHeader(uint64_t Address);
83+
void printHeader(std::optional<uint64_t> Address);
8784

8885
public:
8986
PlainPrinterBase(raw_ostream &OS, ErrorHandler EH, PrinterConfig &Config)
@@ -95,8 +92,6 @@ class PlainPrinterBase : public DIPrinter {
9592
void print(const Request &Request,
9693
const std::vector<DILocal> &Locals) override;
9794

98-
void printInvalidCommand(const Request &Request, StringRef Command) override;
99-
10095
bool printError(const Request &Request,
10196
const ErrorInfoBase &ErrorInfo) override;
10297

@@ -147,8 +142,6 @@ class JSONPrinter : public DIPrinter {
147142
void print(const Request &Request,
148143
const std::vector<DILocal> &Locals) override;
149144

150-
void printInvalidCommand(const Request &Request, StringRef Command) override;
151-
152145
bool printError(const Request &Request,
153146
const ErrorInfoBase &ErrorInfo) override;
154147

llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ class SourceCode {
105105
}
106106
};
107107

108-
void PlainPrinterBase::printHeader(uint64_t Address) {
109-
if (Config.PrintAddress) {
108+
void PlainPrinterBase::printHeader(std::optional<uint64_t> Address) {
109+
if (Address.has_value() && Config.PrintAddress) {
110110
OS << "0x";
111-
OS.write_hex(Address);
111+
OS.write_hex(*Address);
112112
StringRef Delimiter = Config.Pretty ? ": " : "\n";
113113
OS << Delimiter;
114114
}
@@ -182,7 +182,7 @@ void PlainPrinterBase::print(const DILineInfo &Info, bool Inlined) {
182182
}
183183

184184
void PlainPrinterBase::print(const Request &Request, const DILineInfo &Info) {
185-
printHeader(*Request.Address);
185+
printHeader(Request.Address);
186186
print(Info, false);
187187
printFooter();
188188
}
@@ -260,11 +260,6 @@ void PlainPrinterBase::print(const Request &Request,
260260
printFooter();
261261
}
262262

263-
void PlainPrinterBase::printInvalidCommand(const Request &Request,
264-
StringRef Command) {
265-
OS << Command << '\n';
266-
}
267-
268263
bool PlainPrinterBase::printError(const Request &Request,
269264
const ErrorInfoBase &ErrorInfo) {
270265
ErrHandler(ErrorInfo, Request.ModuleName);
@@ -367,13 +362,6 @@ void JSONPrinter::print(const Request &Request,
367362
printJSON(std::move(Json));
368363
}
369364

370-
void JSONPrinter::printInvalidCommand(const Request &Request,
371-
StringRef Command) {
372-
printError(Request,
373-
StringError("unable to parse arguments: " + Command,
374-
std::make_error_code(std::errc::invalid_argument)));
375-
}
376-
377365
bool JSONPrinter::printError(const Request &Request,
378366
const ErrorInfoBase &ErrorInfo) {
379367
json::Object Json = toJSON(Request, ErrorInfo.message());

llvm/test/Support/interrupts.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import time
1212
def run_symbolizer():
1313
proc = subprocess.Popen([sys.argv[2]], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
1414
# Write then read some output to ensure the process has started fully.
15-
proc.stdin.write(b'foo\n')
15+
proc.stdin.write(b'foo bar\n')
1616
proc.stdin.flush()
1717
proc.stdout.readline()
1818
# Windows handles signals differently.

llvm/test/tools/llvm-symbolizer/debuginfod.test

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ RUN: FileCheck %s --check-prefix=FOUND
3939

4040
# Passing BUILDID twice is a syntax error.
4141
RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
42-
RUN: "BUILDID:BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" | \
42+
RUN: "BUILDID:BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" 2>&1 | \
4343
RUN: FileCheck %s --check-prefix=BUILDIDBUILDID
44-
BUILDIDBUILDID: BUILDID:BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d
44+
BUILDIDBUILDID: error: 'BUILDID:BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d': duplicate input file specification prefix
4545

4646
# CODE should work preceding build ID.
4747
RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
@@ -63,16 +63,16 @@ NOTHINGFOUND-NEXT: ??:0:0
6363
# BUILDID shouldn't be parsed if --obj is given, just like regular filenames.
6464
RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
6565
RUN: --obj=%t/addr.exe \
66-
RUN: "BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" | \
66+
RUN: "BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" 2>&1 | \
6767
RUN: FileCheck %s --check-prefix=BUILDIDIGNORED
68-
BUILDIDIGNORED: BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d
68+
BUILDIDIGNORED: error: 'BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d': input file has already been specified
6969

7070
# Providing both BUILDID and FILE is a syntax error.
7171
RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
72-
RUN: "BUILDID:FILE:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" | \
72+
RUN: "BUILDID:FILE:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" 2>&1 | \
7373
RUN: FileCheck %s --check-prefix=BUILDIDFILE
74-
BUILDIDFILE: BUILDID:FILE:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d
74+
BUILDIDFILE: error: 'BUILDID:FILE:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d': duplicate input file specification prefix
7575
RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
76-
RUN: "FILE:BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" | \
76+
RUN: "FILE:BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" 2>&1 | \
7777
RUN: FileCheck %s --check-prefix=FILEBUILDID
78-
FILEBUILDID: FILE:BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d
78+
FILEBUILDID: error: 'FILE:BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d': duplicate input file specification prefix

llvm/test/tools/llvm-symbolizer/file-prefix.test

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ RUN: FileCheck %s --check-prefix=FOUND
44
FOUND: {{[/\]+}}tmp{{[/\]+}}x.c:14:0
55

66
# Passing FILE twice is a syntax error.
7-
RUN: llvm-symbolizer "CODE FILE:FILE:%p/Inputs/addr.exe 0x40054d" | \
8-
RUN: FileCheck %s --check-prefix=FILEFILE
9-
FILEFILE: CODE FILE:FILE:{{.*}}/Inputs/addr.exe 0x40054d
7+
RUN: llvm-symbolizer "CODE FILE:FILE:%p/Inputs/addr.exe 0x40054d" 2>%t.err | FileCheck --check-prefix=NOTFOUND %s
8+
RUN: FileCheck %s --check-prefix=FILEFILE --input-file %t.err
9+
NOTFOUND: ??
10+
NOTFOUND-NEXT: ??:0:0
11+
FILEFILE: error: 'CODE FILE:FILE:{{.*}}/Inputs/addr.exe 0x40054d': duplicate input file specification prefix

llvm/test/tools/llvm-symbolizer/flag-grouping.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ RUN: llvm-symbolizer -apCie %p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck
33
RUN: llvm-symbolizer -apCie=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck %s
44
RUN: llvm-symbolizer -apCie%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck %s
55

6-
CHECK: some text
6+
CHECK: ?? at ??:0:0
77
CHECK: 0x40054d: inctwo
88
CHECK: (inlined by) inc
99
CHECK (inlined by) main
10-
CHECK: some text2
10+
CHECK: ?? at ??:0:0

llvm/test/tools/llvm-symbolizer/flush-output.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ foo:
1414
# RUN: | FileCheck %s
1515

1616
# CHECK: flush-output.s:10
17-
# CHECK: bad
17+
# CHECK: ??:0

llvm/test/tools/llvm-symbolizer/functions.s

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
# NONE-NOT: foo
2727
# NONE: functions.cpp:2:0
2828

29-
# ERR: none
29+
# ERR: ??
30+
# ERR-NEXT: ??:0
3031

3132
# The assembly below is a stripped down version of the output of:
3233
# clang -S -g --target=x86_64-pc-linux
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# If binary input file is not specified, llvm-symbolizer assumes it is the first
2+
# item in the command.
3+
4+
# No input items at all, complain about missing input file.
5+
RUN: echo | llvm-symbolizer 2>%t.1.err | FileCheck %s --check-prefix=NOSOURCE
6+
RUN: FileCheck --input-file=%t.1.err --check-prefix=NOFILE %s
7+
8+
# Only one input item, complain about missing addresses.
9+
RUN: llvm-symbolizer "foo" 2>%t.2.err | FileCheck %s --check-prefix=NOSOURCE
10+
RUN: FileCheck --input-file=%t.2.err --check-prefix=NOADDR %s
11+
12+
# Two items specified, check if the first one is an existing file.
13+
RUN: llvm-symbolizer "foo 400" 2>%t.3.err | FileCheck %s --check-prefix=NOSOURCE
14+
RUN: FileCheck --input-file=%t.3.err --check-prefix=NOTFOUND %s
15+
16+
# FILE: must be followed by a file name.
17+
RUN: llvm-symbolizer "FILE:" 2>%t.4.err | FileCheck %s --check-prefix=NOSOURCE
18+
RUN: FileCheck --input-file=%t.4.err --check-prefix=MISSING-FILE %s
19+
20+
# BUILDID: must be followed by a hash.
21+
RUN: llvm-symbolizer "BUILDID:" 2>%t.5.err | FileCheck %s --check-prefix=NOSOURCE
22+
RUN: FileCheck --input-file=%t.5.err --check-prefix=MISSING-HASH %s
23+
24+
# Wrong build-id.
25+
RUN: llvm-symbolizer "BUILDID: foo" 2>%t.6.err | FileCheck %s --check-prefix=NOSOURCE
26+
RUN: FileCheck --input-file=%t.6.err --check-prefix=BAD-HASH %s
27+
28+
# Unbalanced string quotes in the file name.
29+
RUN: llvm-symbolizer "FILE:\"foo" 2>%t.7.err | FileCheck %s --check-prefix=NOSOURCE
30+
RUN: FileCheck --input-file=%t.7.err --check-prefix=BAD-QUOTE %s
31+
32+
NOSOURCE: ??
33+
NOSOURCE-NEXT: ??:0:0
34+
35+
NOFILE: error: no input filename has been specified
36+
37+
NOADDR: error: 'foo': no module offset has been specified
38+
39+
NOTFOUND: error: 'foo': {{[nN]}}o such file or directory
40+
41+
MISSING-FILE: error: 'FILE:': must be followed by an input file
42+
43+
MISSING-HASH: error: 'BUILDID:': must be followed by a hash
44+
45+
BAD-HASH: error: 'BUILDID: foo': wrong format of build-id
46+
47+
BAD-QUOTE: error: 'FILE:"foo': unbalanced quotes in input file name

llvm/test/tools/llvm-symbolizer/input-base.test

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN: llvm-symbolizer -e %p/Inputs/addr.exe -a 0B1001000110100 | FileCheck %s
88
RUN: llvm-symbolizer -e %p/Inputs/addr.exe -a 0o11064 | FileCheck %s
99

1010
# llvm-symbolizer / StringRef::getAsInteger only accepts the 0o prefix in lowercase.
11-
RUN: llvm-symbolizer -e %p/Inputs/addr.exe -a 0O1234 | FileCheck %s --check-prefix=INVALID-NOT-OCTAL-UPPER
11+
RUN: llvm-symbolizer -e %p/Inputs/addr.exe -a 0O1234 | FileCheck %s --check-prefix=INVALID
1212

1313
# llvm-addr2line always requires hexadecimal, but accepts an optional 0x prefix.
1414
RUN: llvm-addr2line -e %p/Inputs/addr.exe -a 0x1234 | FileCheck %s
@@ -17,17 +17,16 @@ RUN: llvm-addr2line -e %p/Inputs/addr.exe -a 1234 | FileCheck %s
1717
RUN: llvm-addr2line -e %p/Inputs/addr.exe -a 01234 | FileCheck %s
1818
RUN: llvm-addr2line -e %p/Inputs/addr.exe -a 0b1010 | FileCheck %s --check-prefix=HEXADECIMAL-NOT-BINARY
1919
RUN: llvm-addr2line -e %p/Inputs/addr.exe -a 0B1010 | FileCheck %s --check-prefix=HEXADECIMAL-NOT-BINARY
20-
RUN: llvm-addr2line -e %p/Inputs/addr.exe -a 0o1234 | FileCheck %s --check-prefix=INVALID-NOT-OCTAL-LOWER
21-
RUN: llvm-addr2line -e %p/Inputs/addr.exe -a 0O1234 | FileCheck %s --check-prefix=INVALID-NOT-OCTAL-UPPER
20+
RUN: llvm-addr2line -e %p/Inputs/addr.exe -a 0o1234 | FileCheck %s --check-prefix=INVALID-NOT-OCTAL
21+
RUN: llvm-addr2line -e %p/Inputs/addr.exe -a 0O1234 | FileCheck %s --check-prefix=INVALID-NOT-OCTAL
2222

2323
CHECK: 0x1234
2424
CHECK-NEXT: ??
2525

26+
INVALID: ??
27+
INVALID-NEXT: ??:0
28+
2629
HEXADECIMAL-NOT-BINARY: 0xb1010
2730
HEXADECIMAL-NOT-BINARY: ??
2831

29-
INVALID-NOT-OCTAL-LOWER: 0o1234
30-
INVALID-NOT-OCTAL-LOWER-NOT: ??
31-
32-
INVALID-NOT-OCTAL-UPPER: 0O1234
33-
INVALID-NOT-OCTAL-UPPER-NOT: ??
32+
INVALID-NOT-OCTAL: ??:0

llvm/test/tools/llvm-symbolizer/invalid-input-address.test

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Use address that can't fit in a 64-bit number. Show that llvm-symbolizer
2-
# simply echoes it as per other malformed input addresses.
2+
# simply treats it as an unknown symbol.
33
RUN: llvm-symbolizer --obj=%p/Inputs/addr.exe 0x10000000000000000 | FileCheck --check-prefix=LARGE-ADDR %s
44

5-
LARGE-ADDR-NOT: {{.}}
6-
LARGE-ADDR: 0x10000000000000000
7-
LARGE-ADDR-NOT: {{.}}
5+
LARGE-ADDR-NOT: {{.}}
6+
LARGE-ADDR: ??
7+
LARGE-ADDR-NEXT: ??:0:0
8+
LARGE-ADDR-EMPTY:
9+
LARGE-ADDR-NOT: {{.}}
810

911
RUN: echo '"some text"' '"some text2"' > %t.rsp
1012
RUN: echo -e 'some text\nsome text2\n' > %t.inp
@@ -19,5 +21,5 @@ RUN: llvm-addr2line --obj=%p/Inputs/addr.exe < %t.inp | FileCheck --check-prefix
1921
RUN: llvm-addr2line --obj=%p/Inputs/addr.exe "some text" "some text2" | FileCheck --check-prefix=BAD-INPUT %s
2022
RUN: llvm-addr2line --obj=%p/Inputs/addr.exe @%t.rsp | FileCheck --check-prefix=BAD-INPUT %s
2123

22-
BAD-INPUT: some text
23-
BAD-INPUT-NEXT: some text2
24+
BAD-INPUT: ??
25+
BAD-INPUT-NEXT: ??:0
Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
# RUN: env LLVM_SYMBOLIZER_OPTS='0 1 --verbose' llvm-symbolizer 2 | FileCheck %s
2-
# RUN: env LLVM_ADDR2LINE_OPTS='0 1 --verbose' llvm-addr2line 2 | FileCheck %s
1+
RUN: env LLVM_SYMBOLIZER_OPTS='-e %p/Inputs/discrim --verbose' llvm-symbolizer 0x400590 | FileCheck --check-prefix=LLVM %s
2+
RUN: env LLVM_ADDR2LINE_OPTS='-e %p/Inputs/discrim --verbose' llvm-addr2line 0x400590 | FileCheck --check-prefix=GNU %s
33

4-
# CHECK: 0
5-
# CHECK-NEXT: 1
6-
# CHECK-NEXT: 2
4+
LLVM: foo
5+
LLVM-NEXT: Filename: /tmp{{[\\/]}}discrim.c
6+
LLVM-NEXT: Function start filename: /tmp{{[\\/]}}discrim.c
7+
LLVM-NEXT: Function start line: 4
8+
LLVM-NEXT: Function start address: 0x400590
9+
LLVM-NEXT: Line: 5
10+
LLVM-NEXT: Column: 7
11+
12+
GNU: Filename: /tmp{{[\\/]}}discrim.c
13+
GNU-NEXT: Function start filename: /tmp{{[\\/]}}discrim.c
14+
GNU-NEXT: Function start line: 4
15+
GNU-NEXT: Line: 5
16+
GNU-NEXT: Column: 7

llvm/test/tools/llvm-symbolizer/output-style-empty-line.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN: | FileCheck %s --check-prefix=LLVM
1313

1414
LLVM: x.c:14:0
1515
LLVM-EMPTY:
16-
LLVM-NEXT: some text2
16+
LLVM-NEXT: ??
1717

1818
RUN: llvm-symbolizer --output-style=GNU -e %p/Inputs/addr.exe < %p/Inputs/addr.inp \
1919
RUN: | FileCheck %s --check-prefix=GNU
@@ -25,4 +25,4 @@ RUN: llvm-addr2line --output-style=GNU -i -e %p/Inputs/addr.exe < %p/Inputs/addr
2525
RUN: | FileCheck %s --check-prefix=GNU
2626

2727
GNU: x.c:14
28-
GNU-NEXT: some text2
28+
GNU-NEXT: ??

llvm/test/tools/llvm-symbolizer/output-style-json-code.test

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,39 @@
2525
# RUN: llvm-symbolizer --output-style=JSON --no-inlines -e %p/Inputs/addr.exe < %p/Inputs/addr.inp | \
2626
# RUN: FileCheck %s --check-prefix=NO-INLINES --strict-whitespace --match-full-lines --implicit-check-not={{.}}
2727
## Invalid first argument before any valid one.
28-
# NO-INLINES:{"Error":{"Message":"unable to parse arguments: some text"},"ModuleName":"{{.*}}/Inputs/addr.exe"}
28+
# NO-INLINES:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}
2929
## Resolve valid address.
3030
# NO-INLINES-NEXT:{"Address":"0x40054d","ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":3,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"main","Line":3,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":2}]}
3131
## Invalid argument after a valid one.
32-
# NO-INLINES-NEXT:{"Error":{"Message":"unable to parse arguments: some text2"},"ModuleName":"{{.*}}/Inputs/addr.exe"}
32+
# NO-INLINES-NEXT:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}
3333

3434
## This test case is testing stdin input, inlines by default.
3535
# RUN: llvm-symbolizer --output-style=JSON -e %p/Inputs/addr.exe < %p/Inputs/addr.inp | \
3636
# RUN: FileCheck %s --check-prefix=INLINE --strict-whitespace --match-full-lines --implicit-check-not={{.}}
3737
## Invalid first argument before any valid one.
38-
# INLINE:{"Error":{"Message":"unable to parse arguments: some text"},"ModuleName":"{{.*}}/Inputs/addr.exe"}
38+
# INLINE:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}
3939
## Resolve valid address.
4040
# INLINE-NEXT:{"Address":"0x40054d","ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":3,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"inctwo","Line":3,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":2},{"Column":0,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"inc","Line":7,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":6},{"Column":0,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"main","Line":14,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":12}]}
4141
## Invalid argument after a valid one.
42-
# INLINE-NEXT:{"Error":{"Message":"unable to parse arguments: some text2"},"ModuleName":"{{.*}}/Inputs/addr.exe"}
42+
# INLINE-NEXT:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}
4343

4444
## Also check the last test case with llvm-adr2line.
4545
## The expected result is the same with -f -i.
4646
# RUN: llvm-addr2line --output-style=JSON -f -i -e %p/Inputs/addr.exe < %p/Inputs/addr.inp | \
4747
# RUN: FileCheck %s --check-prefix=INLINE-A2L --strict-whitespace --match-full-lines --implicit-check-not={{.}}
4848
## Invalid first argument before any valid one.
49-
# INLINE-A2L:{"Error":{"Message":"unable to parse arguments: some text"},"ModuleName":"{{.*}}/Inputs/addr.exe"}
49+
# INLINE-A2L:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}
5050
## Resolve valid address.
5151
# INLINE-A2L-NEXT:{"Address":"0x40054d","ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":3,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"inctwo","Line":3,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":2},{"Column":0,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"inc","Line":7,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":6},{"Column":0,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"main","Line":14,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":12}]}
5252
## Invalid argument after a valid one.
53-
# INLINE-A2L-NEXT:{"Error":{"Message":"unable to parse arguments: some text2"},"ModuleName":"{{.*}}/Inputs/addr.exe"}
53+
# INLINE-A2L-NEXT:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}
5454

5555
## Note llvm-addr2line without -f does not print the function name in JSON too.
5656
# RUN: llvm-addr2line --output-style=JSON -i -e %p/Inputs/addr.exe < %p/Inputs/addr.inp | \
5757
# RUN: FileCheck %s --check-prefix=NO-FUNC-A2L --strict-whitespace --match-full-lines --implicit-check-not={{.}}
5858
## Invalid first argument before any valid one.
59-
# NO-FUNC-A2L:{"Error":{"Message":"unable to parse arguments: some text"},"ModuleName":"{{.*}}/Inputs/addr.exe"}
59+
# NO-FUNC-A2L:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}
6060
## Resolve valid address.
6161
# NO-FUNC-A2L-NEXT:{"Address":"0x40054d","ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":3,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"","Line":3,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":2},{"Column":0,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"","Line":7,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":6},{"Column":0,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"","Line":14,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":12}]}
6262
## Invalid argument after a valid one.
63-
# NO-FUNC-A2L-NEXT:{"Error":{"Message":"unable to parse arguments: some text2"},"ModuleName":"{{.*}}/Inputs/addr.exe"}
63+
# NO-FUNC-A2L-NEXT:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}

0 commit comments

Comments
 (0)