[llvm-symbolizer] Flush output on bad input
authorJames Henderson <jh7370@my.bristol.ac.uk>
Tue, 4 Jun 2019 15:34:58 +0000 (15:34 +0000)
committerJames Henderson <jh7370@my.bristol.ac.uk>
Tue, 4 Jun 2019 15:34:58 +0000 (15:34 +0000)
commit7f3135037dd44620b231a975d313ce62f93fe873
treeff996097953d1ec2195ea8fe964933c62caf0f4b
parentdbb4322e511b6be756c8fd0a1ee1697b5b110de9
[llvm-symbolizer] Flush output on bad input

One way of using llvm-symbolizer is to interactively within a process
write a line from a parent process to llvm-symbolizer's stdin, and then
read the output, then write the next line, read, etc. This worked as
long as all the lines were good. However, this didn't work prior to this
patch if any of the inputs were bad inputs, because the output is not
flushed after a bad input, meaning the parent process is sat waiting for
output, whilst llvm-symbolizer is sat waiting for input. This patch
flushes the output after every invocation of symbolizeInput when reading
from stdin. It also removes unnecessary flushing when llvm-symbolizer is
not reading addresses from stdin, which should give a slight performance
boost in these situations.

Reviewed by: ikudrin

Differential Revision: https://reviews.llvm.org/D62371

llvm-svn: 362511
llvm/test/tools/llvm-symbolizer/Inputs/flush-output.py [new file with mode: 0644]
llvm/test/tools/llvm-symbolizer/flush-output.s [new file with mode: 0644]
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp