For JDWP, suspend thread before configuring it for single stepping.
Change-Id: I05a7c28c9e977885195797a78a492aa0f72801b7
diff --git a/src/jdwp/jdwp_event.cc b/src/jdwp/jdwp_event.cc
index 5b65aa4..56ba131 100644
--- a/src/jdwp/jdwp_event.cc
+++ b/src/jdwp/jdwp_event.cc
@@ -143,8 +143,6 @@
* not be added to the list, and an appropriate error will be returned.
*/
JdwpError JdwpState::RegisterEvent(JdwpEvent* pEvent) {
- MutexLock mu(Thread::Current(), event_list_lock_);
-
CHECK(pEvent != NULL);
CHECK(pEvent->prev == NULL);
CHECK(pEvent->next == NULL);
@@ -175,6 +173,7 @@
/*
* Add to list.
*/
+ MutexLock mu(Thread::Current(), event_list_lock_);
if (event_list_ != NULL) {
pEvent->next = event_list_;
event_list_->prev = pEvent;
diff --git a/src/jdwp/object_registry.cc b/src/jdwp/object_registry.cc
index 1e21ed0..54e7a8e 100644
--- a/src/jdwp/object_registry.cc
+++ b/src/jdwp/object_registry.cc
@@ -117,6 +117,15 @@
return self->DecodeJObject(entry.jni_reference);
}
+jobject ObjectRegistry::GetJObject(JDWP::ObjectId id) {
+ Thread* self = Thread::Current();
+ MutexLock mu(self, lock_);
+ id_iterator it = id_to_entry_.find(id);
+ CHECK(it != id_to_entry_.end()) << id;
+ ObjectRegistryEntry& entry = *(it->second);
+ return entry.jni_reference;
+}
+
void ObjectRegistry::DisableCollection(JDWP::ObjectId id) {
Thread* self = Thread::Current();
MutexLock mu(self, lock_);
diff --git a/src/jdwp/object_registry.h b/src/jdwp/object_registry.h
index e2893ca..734bb86 100644
--- a/src/jdwp/object_registry.h
+++ b/src/jdwp/object_registry.h
@@ -76,6 +76,10 @@
// Returned by Get when passed an invalid object id.
static mirror::Object* const kInvalidObject;
+ // This is needed to get the jobject of a thread instead of the Object*.
+ // Avoid using this and use standard Get when possible.
+ jobject GetJObject(JDWP::ObjectId id) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+
private:
JDWP::ObjectId InternalAdd(mirror::Object* o) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
mirror::Object* InternalGet(JDWP::ObjectId id) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);