ART: Clean up timeout_dumper
Address previous comments. Use cerr for stack trace to avoid visual
clutter.
Test: m test-art-host
Test: manual
Change-Id: I1ce1c9b6ef4787ad9489055af01ab115fc462efd
diff --git a/tools/timeout_dumper/timeout_dumper.cc b/tools/timeout_dumper/timeout_dumper.cc
index eeaf7de..30e194c 100644
--- a/tools/timeout_dumper/timeout_dumper.cc
+++ b/tools/timeout_dumper/timeout_dumper.cc
@@ -25,6 +25,7 @@
#include <csignal>
#include <cstdlib>
#include <cstring>
+#include <iostream>
#include <thread>
#include <memory>
#include <set>
@@ -246,10 +247,7 @@
break;
} else {
- char saved = *(new_line + 1);
- *(new_line + 1) = 0;
- os << tmp;
- *(new_line + 1) = saved;
+ os << std::string(tmp, new_line - tmp + 1);
tmp = new_line + 1;
prefix_written = false;
@@ -284,7 +282,7 @@
}
pipe->reset(); // Close early.
- const char* args[7] = {
+ const char* args[] = {
addr2line.c_str(),
"--functions",
"--inlines",
@@ -421,6 +419,9 @@
const std::string* addr2line_path,
const char* prefix,
BacktraceMap* map) {
+ // Use std::cerr to avoid the LOG prefix.
+ std::cerr << std::endl << "=== pid: " << pid << " tid: " << tid << " ===" << std::endl;
+
constexpr uint32_t kMaxWaitMicros = 1000 * 1000; // 1s.
if (pid != tid && !WaitForSigStopped(tid, kMaxWaitMicros)) {
LOG(ERROR) << "Failed to wait for sigstop on " << tid;
@@ -477,19 +478,19 @@
}
oss << ")";
}
- LOG(ERROR) << oss.str();
+ std::cerr << oss.str() << std::endl;
if (try_addr2line && addr2line_path != nullptr) {
addr2line::Addr2line(*addr2line_path,
it->map.name,
it->rel_pc,
- LOG_STREAM(ERROR),
+ std::cerr,
prefix,
&addr2line_state);
}
}
if (addr2line_state != nullptr) {
- addr2line::Drain(0, prefix, &addr2line_state, LOG_STREAM(ERROR));
+ addr2line::Drain(0, prefix, &addr2line_state, std::cerr);
}
}
@@ -519,7 +520,6 @@
}
for (pid_t tid : tids) {
- LOG(ERROR) << "pid: " << forked_pid << " tid: " << tid;
DumpThread(forked_pid,
tid,
use_addr2line ? addr2line_path.get() : nullptr,