[PATCH] D147652: [symbolizer] Check existence of input file in GNU mode
Serge Pavlov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 14 02:18:53 PDT 2023
sepavloff added a comment.
In D147652#4257424 <https://reviews.llvm.org/D147652#4257424>, @jhenderson wrote:
> 2. IMHO, if an explicitly specified input file does not exist (at the time of command-line parsing at least), I could get behind an error message being reported by BOTH llvm-symbolizer and llvm-addr2line during command-line parsing (or more likely, slightly after, but before the business logic of the symbolizer code kicks in). We'd still need to check for file existence as in the current library code, in case the file has been deleted since command-line parsing happened. The early check should just be a file existence check (don't try to open the file), and should exit the program in the event of failure. It might be worth raising this issue on the mailing lists to confirm changing the llvm-symbolizer behaviour too is okay with others. My reasoning for why this should impact both tools is that a user has requested an explicit file, so if it doesn't exist, trying to use it doesn't make sense, but I could see theoretical use cases where the file is created after the opening of the program in interactive mode (so hence the need for discussion).
Both `llvm-symbolizer` and GNU `addr2line` report error if an explicitly specified input file does not exist. They differ in what they do after. The difference can be shown in such invocation:
addr2line -e inexistent_file
Here no addresses are specified in command line and both utilities would read them from input stream. However `addr2line` finds that the source file does not exists and exits immediately, no attempt to read imput stream is made. It is reasonable because `-e` is the only way to provide input file. `llvm-symbolize` in this case tries to interpret addresses from input stream or command line. It does not make sense because in this case because in this case llvm-symbolizer cannot override binary file.
It looks like llvm-symbolizer also should check input file existence early. It need a separate patch, maybe someone uses such unusual mode.
When llvm-symbolizer check existence of binary file, it creates its representation in memory. Even if the file then disappears or is changed, that does not affect decoding process, with uses the cached representation.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147652/new/
https://reviews.llvm.org/D147652
More information about the llvm-commits
mailing list