mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 13:46:06 +00:00
[symbolizer] Exit early if input file is absent
If binary file specified as input with option --obj or -e is absent, now llvm-addr2line exits immediately. This patch extends this behavior to llvm-symbolizer. Previously llvm-symbolizer waited addresses from input stream or command line in this case. Differential Revision: https://reviews.llvm.org/D153219
This commit is contained in:
parent
789f012d50
commit
f5ded4eaa4
@ -47,14 +47,9 @@ Symbols:
|
||||
## If st_name of the STT_FILE symbols is invalid, the symbol name is lost as well.
|
||||
## TODO Keep the symbol name.
|
||||
# RUN: yaml2obj --docnum=2 %s -o %t2
|
||||
# RUN: llvm-symbolizer --obj=%t2 0 0 2>&1 | FileCheck %s --check-prefix=CHECK2
|
||||
# RUN: not llvm-symbolizer --obj=%t2 0 0 2>&1 | FileCheck %s --check-prefix=CHECK2
|
||||
|
||||
# CHECK2: llvm-symbolizer{{.*}}: error: '{{.*}}symtab-file2.yaml.tmp2': st_name (0xffff) is past the end of the string table of size
|
||||
# CHECK2-NEXT: ??
|
||||
# CHECK2-NEXT: ??:0:0
|
||||
# CHECK2-EMPTY:
|
||||
# CHECK2-NEXT: ??
|
||||
# CHECK2-NEXT: ??:0:0
|
||||
|
||||
--- !ELF
|
||||
FileHeader:
|
||||
|
@ -1,5 +1,5 @@
|
||||
RUN: llvm-symbolizer --obj=%p/Inputs/macho-universal 0x1f84 | FileCheck %s
|
||||
RUN: not llvm-symbolizer --obj=%p/Inputs/macho-universal 0x1f84 2>&1 | FileCheck %s
|
||||
|
||||
CHECK-NOT: main
|
||||
CHECK: ??
|
||||
CHECK: {{.*}}llvm-symbolizer{{.*}}: error: '{{.*}}macho-universal': Unknown architecture
|
||||
CHECK-NOT: main
|
||||
|
@ -1,3 +0,0 @@
|
||||
RUN: llvm-symbolizer --obj=unexisting-file 0x1234 2>&1 | FileCheck -DMSG=%errc_ENOENT %s
|
||||
|
||||
CHECK: llvm-symbolizer{{.*}}: error: 'unexisting-file': [[MSG]]
|
@ -1,14 +1,14 @@
|
||||
# llvm-symbolizer infers the number base from the form of the address.
|
||||
RUN: llvm-symbolizer -e /dev/null -a 0x1234 | FileCheck %s
|
||||
RUN: llvm-symbolizer -e /dev/null -a 0X1234 | FileCheck %s
|
||||
RUN: llvm-symbolizer -e /dev/null -a 4660 | FileCheck %s
|
||||
RUN: llvm-symbolizer -e /dev/null -a 011064 | FileCheck %s
|
||||
RUN: llvm-symbolizer -e /dev/null -a 0b1001000110100 | FileCheck %s
|
||||
RUN: llvm-symbolizer -e /dev/null -a 0B1001000110100 | FileCheck %s
|
||||
RUN: llvm-symbolizer -e /dev/null -a 0o11064 | FileCheck %s
|
||||
RUN: llvm-symbolizer -e %p/Inputs/addr.exe -a 0x1234 | FileCheck %s
|
||||
RUN: llvm-symbolizer -e %p/Inputs/addr.exe -a 0X1234 | FileCheck %s
|
||||
RUN: llvm-symbolizer -e %p/Inputs/addr.exe -a 4660 | FileCheck %s
|
||||
RUN: llvm-symbolizer -e %p/Inputs/addr.exe -a 011064 | FileCheck %s
|
||||
RUN: llvm-symbolizer -e %p/Inputs/addr.exe -a 0b1001000110100 | FileCheck %s
|
||||
RUN: llvm-symbolizer -e %p/Inputs/addr.exe -a 0B1001000110100 | FileCheck %s
|
||||
RUN: llvm-symbolizer -e %p/Inputs/addr.exe -a 0o11064 | FileCheck %s
|
||||
|
||||
# llvm-symbolizer / StringRef::getAsInteger only accepts the 0o prefix in lowercase.
|
||||
RUN: llvm-symbolizer -e /dev/null -a 0O1234 | FileCheck %s --check-prefix=INVALID-NOT-OCTAL-UPPER
|
||||
RUN: llvm-symbolizer -e %p/Inputs/addr.exe -a 0O1234 | FileCheck %s --check-prefix=INVALID-NOT-OCTAL-UPPER
|
||||
|
||||
# llvm-addr2line always requires hexadecimal, but accepts an optional 0x prefix.
|
||||
RUN: llvm-addr2line -e %p/Inputs/addr.exe -a 0x1234 | FileCheck %s
|
||||
|
@ -4,9 +4,14 @@ RUN: not llvm-addr2line -e %p/Inputs/nonexistent 0x12 2>&1 | FileCheck %s --chec
|
||||
RUN: not llvm-addr2line -e %p/Inputs/nonexistent 2>&1 | FileCheck %s --check-prefix=CHECK-NONEXISTENT-A2L -DMSG=%errc_ENOENT
|
||||
CHECK-NONEXISTENT-A2L: llvm-addr2line{{.*}}: error: '{{.*}}Inputs/nonexistent': [[MSG]]
|
||||
|
||||
RUN: not llvm-symbolizer -e %p/Inputs/nonexistent 0x12 2>&1 | FileCheck %s --check-prefix=CHECK-NONEXISTENT -DMSG=%errc_ENOENT
|
||||
RUN: not llvm-symbolizer -e %p/Inputs/nonexistent 2>&1 | FileCheck %s --check-prefix=CHECK-NONEXISTENT -DMSG=%errc_ENOENT
|
||||
CHECK-NONEXISTENT: llvm-symbolizer{{.*}}: error: '{{.*}}Inputs/nonexistent': [[MSG]]
|
||||
|
||||
RUN: not llvm-addr2line -e %p/Inputs 0x12 2>&1 | FileCheck %s --check-prefix=CHECK-DIRECTORY-A2L -DMSG=%errc_EISDIR
|
||||
RUN: not llvm-addr2line -e %p/Inputs 2>&1 | FileCheck %s --check-prefix=CHECK-DIRECTORY-A2L -DMSG=%errc_EISDIR
|
||||
CHECK-DIRECTORY-A2L: llvm-addr2line{{.*}}: error: '{{.*}}Inputs': [[MSG]]
|
||||
|
||||
not llvm-addr2line --output-style=JSON -e %p/Inputs/nonexistent 2>&1 | FileCheck %s --check-prefix=NONEXIST-JSON -DMSG=%errc_ENOENT
|
||||
NONEXIST-JSON: {"Address":"0x0","Error":{"Message":"[[MSG]]"},"ModuleName":"{{.*}}nonexistent"}
|
||||
RUN: not llvm-symbolizer -e %p/Inputs 0x12 2>&1 | FileCheck %s --check-prefix=CHECK-DIRECTORY -DMSG=%errc_EISDIR
|
||||
RUN: not llvm-symbolizer -e %p/Inputs 2>&1 | FileCheck %s --check-prefix=CHECK-DIRECTORY -DMSG=%errc_EISDIR
|
||||
CHECK-DIRECTORY: llvm-symbolizer{{.*}}: error: '{{.*}}Inputs': [[MSG]]
|
||||
|
@ -1,6 +1,6 @@
|
||||
# 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 --check-prefix=LARGE-ADDR %s
|
||||
RUN: llvm-symbolizer --obj=%p/Inputs/addr.exe 0x10000000000000000 | FileCheck --check-prefix=LARGE-ADDR %s
|
||||
|
||||
LARGE-ADDR-NOT: {{.}}
|
||||
LARGE-ADDR: 0x10000000000000000
|
||||
|
@ -32,20 +32,9 @@ GNU: inctwo
|
||||
## Check that we are able to produce an output properly when the --no-inlines option
|
||||
## is specified, but a file doesn't exist. Check we report an error.
|
||||
|
||||
RUN: llvm-symbolizer --output-style=GNU --obj=%p/Inputs/not.exist 0x1 0x2 --no-inlines 2>&1 \
|
||||
RUN: | FileCheck %s --check-prefix=NOT-EXIST-GNU -DMSG=%errc_ENOENT
|
||||
RUN: llvm-symbolizer --output-style=LLVM --obj=%p/Inputs/not.exist 0x1 0x2 --no-inlines 2>&1 \
|
||||
RUN: | FileCheck %s --check-prefix=NOT-EXIST-LLVM -DMSG=%errc_ENOENT
|
||||
RUN: not llvm-symbolizer --output-style=GNU --obj=%p/Inputs/not.exist 0x1 0x2 --no-inlines 2>&1 \
|
||||
RUN: | FileCheck %s --check-prefix=NOT-EXIST -DMSG=%errc_ENOENT
|
||||
RUN: not llvm-symbolizer --output-style=LLVM --obj=%p/Inputs/not.exist 0x1 0x2 --no-inlines 2>&1 \
|
||||
RUN: | FileCheck %s --check-prefix=NOT-EXIST -DMSG=%errc_ENOENT
|
||||
|
||||
# NOT-EXIST-GNU: llvm-symbolizer{{.*}}: error: '{{.*}}Inputs/not.exist': [[MSG]]
|
||||
# NOT-EXIST-GNU-NEXT: ??
|
||||
# NOT-EXIST-GNU-NEXT: ??:0
|
||||
# NOT-EXIST-GNU-NEXT: ??
|
||||
# NOT-EXIST-GNU-NEXT: ??:0
|
||||
|
||||
# NOT-EXIST-LLVM: llvm-symbolizer{{.*}}: error: '{{.*}}Inputs/not.exist': [[MSG]]
|
||||
# NOT-EXIST-LLVM-NEXT: ??
|
||||
# NOT-EXIST-LLVM-NEXT: ??:0:0
|
||||
# NOT-EXIST-LLVM-EMPTY:
|
||||
# NOT-EXIST-LLVM-NEXT: ??
|
||||
# NOT-EXIST-LLVM-NEXT: ??:0:0
|
||||
NOT-EXIST: llvm-symbolizer{{.*}}: error: '{{.*}}Inputs/not.exist': [[MSG]]
|
||||
|
@ -4,9 +4,9 @@
|
||||
## contain an array of the results for all of the given addresses.
|
||||
|
||||
## Show how library errors are reported in the output.
|
||||
# RUN: llvm-symbolizer --output-style=JSON -e %p/no-file.exe 0 | \
|
||||
# RUN: not llvm-symbolizer --output-style=JSON -e %p/no-file.exe 0 | \
|
||||
# RUN: FileCheck %s -DMSG=%errc_ENOENT --check-prefix=NO-FILE --strict-whitespace --match-full-lines --implicit-check-not={{.}}
|
||||
# NO-FILE:[{"Address":"0x0","Error":{"Message":"[[MSG]]"},"ModuleName":"{{.*}}/no-file.exe"}]
|
||||
# NO-FILE:{"Address":"0x0","Error":{"Message":"[[MSG]]"},"ModuleName":"{{.*}}/no-file.exe"}
|
||||
|
||||
## Resolve out of range address.
|
||||
## Expected a list with one empty object with default values.
|
||||
|
@ -1,13 +1,5 @@
|
||||
RUN: llvm-symbolizer 0x401000 0x401001 --obj="%p/Inputs/missing_pdb.exe" 2>%t.err \
|
||||
RUN: | FileCheck %s
|
||||
RUN: FileCheck -DMSG=%errc_ENOENT --check-prefix=ERROR %s < %t.err
|
||||
RUN: not llvm-symbolizer 0x401000 0x401001 --obj="%p/Inputs/missing_pdb.exe" 2> %t.err \
|
||||
RUN: | count 0
|
||||
RUN: FileCheck -DMSG=%errc_ENOENT %s --input-file=%t.err
|
||||
|
||||
llvm-symbolizer should print one error and two unknown line info records.
|
||||
|
||||
ERROR: llvm-symbolizer{{.*}}: error: '{{.*}}missing_pdb.pdb': [[MSG]]
|
||||
ERROR-NOT: error reading file
|
||||
|
||||
CHECK: ??
|
||||
CHECK: ??:0:0
|
||||
CHECK: ??
|
||||
CHECK: ??:0:0
|
||||
CHECK: llvm-symbolizer{{.*}}: error: '{{.*}}missing_pdb.pdb': [[MSG]]
|
||||
|
@ -30,9 +30,6 @@ RUN: llvm-symbolizer -i --print-address -p --obj=%p/Inputs/addr.exe < %p/Inputs/
|
||||
## Support this compatibility alias for a while.
|
||||
RUN: llvm-symbolizer --inlining=true --print-address -p --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefix="PRETTY" %s
|
||||
|
||||
RUN: echo "0x1" > %t.input
|
||||
RUN: llvm-symbolizer --obj=%p/Inputs/zero < %t.input | FileCheck -check-prefix="ZERO" %s
|
||||
|
||||
RUN: llvm-addr2line --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefix=A2L %s
|
||||
RUN: llvm-addr2line -a --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefixes=A2L,A2L_A %s
|
||||
RUN: llvm-addr2line -f --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck -check-prefixes=A2L,A2L_F %s
|
||||
@ -63,9 +60,6 @@ RUN: llvm-addr2line -pafi --obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCh
|
||||
#PRETTY: (inlined by) main at {{[/\]+}}tmp{{[/\]+}}x.c:14:0
|
||||
#PRETTY: some text2
|
||||
#
|
||||
#ZERO: ??
|
||||
#ZERO: ??:0:0
|
||||
#
|
||||
#A2L: some text
|
||||
#A2L_A-NEXT: 0x40054d
|
||||
#A2L_F-NEXT: inctwo
|
||||
|
@ -481,7 +481,7 @@ int main(int argc, char **argv) {
|
||||
// When an input file is specified, exit immediately if the file cannot be
|
||||
// read. If getOrCreateModuleInfo succeeds, symbolizeInput will reuse the
|
||||
// cached file handle.
|
||||
if (auto *Arg = Args.getLastArg(OPT_obj_EQ); Arg && IsAddr2Line) {
|
||||
if (auto *Arg = Args.getLastArg(OPT_obj_EQ); Arg) {
|
||||
auto Status = Symbolizer.getOrCreateModuleInfo(Arg->getValue());
|
||||
if (!Status) {
|
||||
Request SymRequest = {Arg->getValue(), 0};
|
||||
|
Loading…
x
Reference in New Issue
Block a user