Add SuspendReason enum and change Suspension functions.
More self-documenting and more type safe.
Bug: 62821960
Test: ./test.py
Change-Id: Ic7a1ae6a25e687d65f5aa10c1aad54a7b80dd086
diff --git a/runtime/thread_list.h b/runtime/thread_list.h
index 92702c6..41c5e32 100644
--- a/runtime/thread_list.h
+++ b/runtime/thread_list.h
@@ -23,6 +23,7 @@
#include "base/time_utils.h"
#include "base/value_object.h"
#include "jni.h"
+#include "suspend_reason.h"
#include <bitset>
#include <list>
@@ -64,7 +65,7 @@
void ResumeAll()
REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_)
UNLOCK_FUNCTION(Locks::mutator_lock_);
- void Resume(Thread* thread, bool for_debugger = false)
+ void Resume(Thread* thread, SuspendReason reason = SuspendReason::kInternal)
REQUIRES(!Locks::thread_suspend_count_lock_);
// Suspends all threads and gets exclusive access to the mutator_lock_.
@@ -81,7 +82,9 @@
// If the thread should be suspended then value of request_suspension should be true otherwise
// the routine will wait for a previous suspend request. If the suspension times out then *timeout
// is set to true.
- Thread* SuspendThreadByPeer(jobject peer, bool request_suspension, bool debug_suspension,
+ Thread* SuspendThreadByPeer(jobject peer,
+ bool request_suspension,
+ SuspendReason reason,
bool* timed_out)
REQUIRES(!Locks::mutator_lock_,
!Locks::thread_list_lock_,
@@ -91,7 +94,7 @@
// thread on success else null. The thread id is used to identify the thread to avoid races with
// the thread terminating. Note that as thread ids are recycled this may not suspend the expected
// thread, that may be terminating. If the suspension times out then *timeout is set to true.
- Thread* SuspendThreadByThreadId(uint32_t thread_id, bool debug_suspension, bool* timed_out)
+ Thread* SuspendThreadByThreadId(uint32_t thread_id, SuspendReason reason, bool* timed_out)
REQUIRES(!Locks::mutator_lock_,
!Locks::thread_list_lock_,
!Locks::thread_suspend_count_lock_);
@@ -198,7 +201,7 @@
void SuspendAllInternal(Thread* self,
Thread* ignore1,
Thread* ignore2 = nullptr,
- bool debug_suspend = false)
+ SuspendReason reason = SuspendReason::kInternal)
REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
void AssertThreadsAreSuspended(Thread* self, Thread* ignore1, Thread* ignore2 = nullptr)