Reland "Set SA_SIGINFO. Rename thread to include perfetto."
This would work before because sa_handler and sa_sigaction are in a
union, so we also assigned sa_handler. Because we do not use
any of the arguments passed to the functions, our function is also a
valid sa_handler.
This reverts commit a8fe58f0512a2147580b798e1cb8308420f8ae99
and updates another use of the old name to fix issues
with the original change.
Change-Id: I00aebe34438f7905f9b626e92252abbfe949b638
diff --git a/openjdkjvmti/ti_thread.cc b/openjdkjvmti/ti_thread.cc
index b0a7f1f..1a5b227 100644
--- a/openjdkjvmti/ti_thread.cc
+++ b/openjdkjvmti/ti_thread.cc
@@ -122,13 +122,14 @@
}
if (!started) {
// Runtime isn't started. We only expect at most the signal handler or JIT threads to be
- // started here; this includes the hprof_listener signal handler thread for perfetto_hprof.
+ // started here; this includes the perfetto_hprof_listener signal handler thread for
+ // perfetto_hprof.
if (art::kIsDebugBuild) {
std::string name;
self->GetThreadName(name);
if (name != "JDWP" &&
name != "Signal Catcher" &&
- name != "hprof_listener" &&
+ name != "perfetto_hprof_listener" &&
!android::base::StartsWith(name, "Jit thread pool") &&
!android::base::StartsWith(name, "Runtime worker thread")) {
LOG(FATAL) << "Unexpected thread before start: " << name << " id: "
diff --git a/perfetto_hprof/perfetto_hprof.cc b/perfetto_hprof/perfetto_hprof.cc
index 5536b20..4f20094 100644
--- a/perfetto_hprof/perfetto_hprof.cc
+++ b/perfetto_hprof/perfetto_hprof.cc
@@ -528,6 +528,7 @@
}
struct sigaction act = {};
+ act.sa_flags = SA_SIGINFO | SA_RESTART;
act.sa_sigaction = [](int, siginfo_t*, void*) {
if (write(g_signal_pipe_fds[1], kByte, sizeof(kByte)) == -1) {
PLOG(ERROR) << "Failed to trigger heap dump";
@@ -546,17 +547,17 @@
std::thread th([] {
art::Runtime* runtime = art::Runtime::Current();
if (!runtime) {
- LOG(FATAL_WITHOUT_ABORT) << "no runtime in hprof_listener";
+ LOG(FATAL_WITHOUT_ABORT) << "no runtime in perfetto_hprof_listener";
return;
}
- if (!runtime->AttachCurrentThread("hprof_listener", /*as_daemon=*/ true,
+ if (!runtime->AttachCurrentThread("perfetto_hprof_listener", /*as_daemon=*/ true,
runtime->GetSystemThreadGroup(), /*create_peer=*/ false)) {
LOG(ERROR) << "failed to attach thread.";
return;
}
art::Thread* self = art::Thread::Current();
if (!self) {
- LOG(FATAL_WITHOUT_ABORT) << "no thread in hprof_listener";
+ LOG(FATAL_WITHOUT_ABORT) << "no thread in perfetto_hprof_listener";
return;
}
{