summaryrefslogtreecommitdiffstats
path: root/runtime/jdwp
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/jdwp')
-rw-r--r--runtime/jdwp/jdwp.h6
-rw-r--r--runtime/jdwp/jdwp_handler.cc1
-rw-r--r--runtime/jdwp/jdwp_main.cc99
3 files changed, 52 insertions, 54 deletions
diff --git a/runtime/jdwp/jdwp.h b/runtime/jdwp/jdwp.h
index 6a5d0d1..40ec431 100644
--- a/runtime/jdwp/jdwp.h
+++ b/runtime/jdwp/jdwp.h
@@ -17,6 +17,7 @@
#ifndef ART_RUNTIME_JDWP_JDWP_H_
#define ART_RUNTIME_JDWP_JDWP_H_
+#include "atomic_integer.h"
#include "base/mutex.h"
#include "jdwp/jdwp_bits.h"
#include "jdwp/jdwp_constants.h"
@@ -319,9 +320,8 @@ struct JdwpState {
int64_t last_activity_time_ms_;
// Global counters and a mutex to protect them.
- Mutex serial_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
- uint32_t request_serial_ GUARDED_BY(serial_lock_);
- uint32_t event_serial_ GUARDED_BY(serial_lock_);
+ AtomicInteger request_serial_;
+ AtomicInteger event_serial_;
// Linked list of events requested by the debugger (breakpoints, class prep, etc).
Mutex event_list_lock_;
diff --git a/runtime/jdwp/jdwp_handler.cc b/runtime/jdwp/jdwp_handler.cc
index 8ef146c..4feeafb 100644
--- a/runtime/jdwp/jdwp_handler.cc
+++ b/runtime/jdwp/jdwp_handler.cc
@@ -1476,7 +1476,6 @@ static JdwpError DDM_Chunk(JdwpState* state, Request& request, ExpandBuf* pReply
// instead of copying it into the expanding buffer. The reduction in
// heap requirements is probably more valuable than the efficiency.
CHECK_GT(replyLen, 0);
- CHECK_LT(replyLen, 1*1024*1024);
memcpy(expandBufAddSpace(pReply, replyLen), replyBuf, replyLen);
free(replyBuf);
}
diff --git a/runtime/jdwp/jdwp_main.cc b/runtime/jdwp/jdwp_main.cc
index 3b6dd81..8e61d23 100644
--- a/runtime/jdwp/jdwp_main.cc
+++ b/runtime/jdwp/jdwp_main.cc
@@ -36,7 +36,7 @@ static void* StartJdwpThread(void* arg);
* JdwpNetStateBase class implementation
*/
JdwpNetStateBase::JdwpNetStateBase(JdwpState* state)
- : state_(state), socket_lock_("JdwpNetStateBase lock", kJdwpSerialSocketLock) {
+ : state_(state), socket_lock_("JdwpNetStateBase lock", kJdwpSocketLock) {
clientSock = -1;
wake_pipe_[0] = -1;
wake_pipe_[1] = -1;
@@ -185,7 +185,6 @@ void JdwpState::SendRequest(ExpandBuf* pReq) {
* packets to the debugger.
*/
uint32_t JdwpState::NextRequestSerial() {
- MutexLock mu(Thread::Current(), serial_lock_);
return request_serial_++;
}
@@ -194,7 +193,6 @@ uint32_t JdwpState::NextRequestSerial() {
* message type EventRequest.Set.
*/
uint32_t JdwpState::NextEventSerial() {
- MutexLock mu(Thread::Current(), serial_lock_);
return event_serial_++;
}
@@ -211,7 +209,6 @@ JdwpState::JdwpState(const JdwpOptions* options)
attach_lock_("JDWP attach lock", kJdwpAttachLock),
attach_cond_("JDWP attach condition variable", attach_lock_),
last_activity_time_ms_(0),
- serial_lock_("JDWP serial lock", kJdwpSerialSocketLock),
request_serial_(0x10000000),
event_serial_(0x20000000),
event_list_lock_("JDWP event list lock", kJdwpEventListLock),
@@ -248,14 +245,30 @@ JdwpState* JdwpState::Create(const JdwpOptions* options) {
LOG(FATAL) << "Unknown transport: " << options->transport;
}
- /*
- * Grab a mutex or two before starting the thread. This ensures they
- * won't signal the cond var before we're waiting.
- */
- {
+ if (!options->suspend) {
+ /*
+ * Grab a mutex before starting the thread. This ensures they
+ * won't signal the cond var before we're waiting.
+ */
MutexLock thread_start_locker(self, state->thread_start_lock_);
- const bool should_suspend = options->suspend;
- if (!should_suspend) {
+ /*
+ * We have bound to a port, or are trying to connect outbound to a
+ * debugger. Create the JDWP thread and let it continue the mission.
+ */
+ CHECK_PTHREAD_CALL(pthread_create, (&state->pthread_, NULL, StartJdwpThread, state.get()), "JDWP thread");
+
+ /*
+ * Wait until the thread finishes basic initialization.
+ * TODO: cond vars should be waited upon in a loop
+ */
+ state->thread_start_cond_.Wait(self);
+ } else {
+ {
+ /*
+ * Grab a mutex before starting the thread. This ensures they
+ * won't signal the cond var before we're waiting.
+ */
+ MutexLock thread_start_locker(self, state->thread_start_lock_);
/*
* We have bound to a port, or are trying to connect outbound to a
* debugger. Create the JDWP thread and let it continue the mission.
@@ -267,47 +280,33 @@ JdwpState* JdwpState::Create(const JdwpOptions* options) {
* TODO: cond vars should be waited upon in a loop
*/
state->thread_start_cond_.Wait(self);
- } else {
- {
- /*
- * We have bound to a port, or are trying to connect outbound to a
- * debugger. Create the JDWP thread and let it continue the mission.
- */
- CHECK_PTHREAD_CALL(pthread_create, (&state->pthread_, NULL, StartJdwpThread, state.get()), "JDWP thread");
-
- /*
- * Wait until the thread finishes basic initialization.
- * TODO: cond vars should be waited upon in a loop
- */
- state->thread_start_cond_.Wait(self);
-
- /*
- * For suspend=y, wait for the debugger to connect to us or for us to
- * connect to the debugger.
- *
- * The JDWP thread will signal us when it connects successfully or
- * times out (for timeout=xxx), so we have to check to see what happened
- * when we wake up.
- */
- {
- ScopedThreadStateChange tsc(self, kWaitingForDebuggerToAttach);
- MutexLock attach_locker(self, state->attach_lock_);
- state->attach_cond_.Wait(self);
- }
- }
- if (!state->IsActive()) {
- LOG(ERROR) << "JDWP connection failed";
- return NULL;
- }
-
- LOG(INFO) << "JDWP connected";
+ }
- /*
- * Ordinarily we would pause briefly to allow the debugger to set
- * breakpoints and so on, but for "suspend=y" the VM init code will
- * pause the VM when it sends the VM_START message.
- */
+ /*
+ * For suspend=y, wait for the debugger to connect to us or for us to
+ * connect to the debugger.
+ *
+ * The JDWP thread will signal us when it connects successfully or
+ * times out (for timeout=xxx), so we have to check to see what happened
+ * when we wake up.
+ */
+ {
+ ScopedThreadStateChange tsc(self, kWaitingForDebuggerToAttach);
+ MutexLock attach_locker(self, state->attach_lock_);
+ state->attach_cond_.Wait(self);
}
+ if (!state->IsActive()) {
+ LOG(ERROR) << "JDWP connection failed";
+ return NULL;
+ }
+
+ LOG(INFO) << "JDWP connected";
+
+ /*
+ * Ordinarily we would pause briefly to allow the debugger to set
+ * breakpoints and so on, but for "suspend=y" the VM init code will
+ * pause the VM when it sends the VM_START message.
+ */
}
return state.release();