Print thread state after failure to suspend

This may help us debug some issues where the thread is failing to
suspend.

Bug: b/151318587
Change-Id: I0d2d539f769ebb1cdd71606e1d23d8fa66673879
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2103411
Commit-Queue: John Bauman <jbauman@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
This commit is contained in:
John Bauman 2020-03-13 13:45:15 -07:00 committed by Commit Bot
parent 6835b8e29d
commit 9a31d3f8e9

View File

@ -41,7 +41,7 @@ ScopedTaskSuspend::ScopedTaskSuspend(const zx::process& process) {
for (const auto& thread : GetThreadHandles(process)) {
// We omit the crashed thread (blocked in an exception) as it is technically
// not suspended, cf. ZX-3772.
zx_info_thread info;
zx_info_thread_t info;
if (thread.get_info(
ZX_INFO_THREAD, &info, sizeof(info), nullptr, nullptr) == ZX_OK) {
if (info.state == ZX_THREAD_STATE_BLOCKED_EXCEPTION) {
@ -52,8 +52,16 @@ ScopedTaskSuspend::ScopedTaskSuspend(const zx::process& process) {
zx_signals_t observed = 0u;
const zx_status_t wait_status = thread.wait_one(
ZX_THREAD_SUSPENDED, zx::deadline_after(zx::msec(50)), &observed);
ZX_LOG_IF(ERROR, wait_status != ZX_OK, wait_status)
<< "thread failed to suspend";
if (wait_status != ZX_OK) {
zx_info_thread_t info = {};
zx_status_t info_status = thread.get_info(
ZX_INFO_THREAD, &info, sizeof(info), nullptr, nullptr);
ZX_LOG(ERROR, wait_status) << "thread failed to suspend";
LOG(ERROR) << "Thread info status " << info_status;
if (info_status == ZX_OK) {
LOG(ERROR) << "Thread state " << info.state;
}
}
}
}