[symbolizer] Check existence of input file in GNU mode
authorSerge Pavlov <sepavloff@gmail.com>
Fri, 23 Jun 2023 10:19:38 +0000 (17:19 +0700)
committerSerge Pavlov <sepavloff@gmail.com>
Fri, 23 Jun 2023 10:20:15 +0000 (17:20 +0700)
commit1099208b991ee2ff2d0c0667fdd668702523a4cc
tree04575ff85c3d9e74aa58f1307c5a230e9cc4615e
parent7cf567d46121f4aa8f659554b5e8584cd0fac056
[symbolizer] Check existence of input file in GNU mode

GNU addr2line exits immediately if it cannot open the file specified as
executable/relocatable. In contrast llvm-addr2line does not exit and, if
addresses are not specified in command line, waits for input on stdin. This
causes the test compiler-rt/test/asan/TestCases/Posix/asan-symbolize-bad-path.cc to block
forever on Gentoo (see https://reviews.llvm.org/rG27c4777f41d2ab204c1cf84ff1cccd5ba41354da#1190273).
To fix this issue the behavior llvm-addr2line now exits if
executable/relocatable file cannot be found.

It fixes https://github.com/llvm/llvm-project/issues/42099 (llvm-addr2line
does not exit when passed a non-existent file).

Differential Revision: https://reviews.llvm.org/D147652
llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
llvm/test/tools/llvm-symbolizer/errors.test [new file with mode: 0644]
llvm/test/tools/llvm-symbolizer/input-base.test
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp