Read stdout from llvm-symbolizer during native stack dump.
We initially run llvm-symbolizer just to test if it is available
and functioning. However, we run with it own stdout pipe,
which we promptly close before it even starts executing.
Properly consume the stdout output instead, to stop the tool spamming
stderr with (justified) complains. (however, other than the log spam,
this had no other negative consequences on symbolization)
Test: check logcat of crashing test; the extra errors are gone
Change-Id: Id96f8a3202976ea7208860e131e8eddb4beae612
diff --git a/runtime/native_stack_dump.cc b/runtime/native_stack_dump.cc
index f68a229..b7c3665 100644
--- a/runtime/native_stack_dump.cc
+++ b/runtime/native_stack_dump.cc
@@ -287,6 +287,10 @@
static bool RunCommand(const std::string& cmd) {
FILE* stream = popen(cmd.c_str(), "r");
if (stream) {
+ // Consume the stdout until we encounter EOF when the tool exits.
+ // Otherwise the tool would complain to stderr when the stream is closed.
+ char buffer[64];
+ while (fread(buffer, 1, sizeof(buffer), stream) == sizeof(buffer)) {}
pclose(stream);
return true;
} else {