Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Unified Diff: runtime/bin/dbg_message.cc

Issue 113513004: Handle vmservice messages while at breakpoint. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/dbg_message.h ('k') | runtime/bin/vmservice/client/deployed/web/index.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/dbg_message.cc
===================================================================
--- runtime/bin/dbg_message.cc (revision 31232)
+++ runtime/bin/dbg_message.cc (working copy)
@@ -1017,27 +1017,54 @@
}
-void DbgMsgQueue::HandleMessages() {
+void DbgMsgQueue::Notify() {
+ MonitorLocker ml(&msg_queue_lock_);
+ ml.Notify();
+}
+
+
+bool DbgMsgQueue::HandlePendingMessages() {
+ // Handle all available debug messages, up to a resume request.
bool resume_requested = false;
+ while (msglist_head_ != NULL && !resume_requested) {
+ ASSERT(msglist_tail_ != NULL);
+ DbgMessage* msg = msglist_head_;
+ msglist_head_ = msglist_head_->next();
+ if (msglist_head_ == NULL) {
+ msglist_tail_ = NULL;
+ }
+ resume_requested = msg->HandleMessage();
+ delete msg;
+ }
+ return resume_requested;
+}
+
+
+void DbgMsgQueue::MessageLoop() {
MonitorLocker ml(&msg_queue_lock_);
is_running_ = false;
- while (!resume_requested) {
- while (msglist_head_ == NULL) {
- ASSERT(msglist_tail_ == NULL);
- dart::Monitor::WaitResult res = ml.Wait(); // Wait for debugger commands.
- ASSERT(res == dart::Monitor::kNotified);
+
+ // Request notification on isolate messages. This allows us to
+ // respond to vm service messages while at breakpoint.
+ Dart_SetMessageNotifyCallback(DbgMsgQueueList::NotifyIsolate);
+
+ while (true) {
+ // Handle all available vm service messages, up to a resume
+ // request.
+ if (Dart_HandleServiceMessages()) {
+ break;
}
- while (msglist_head_ != NULL && !resume_requested) {
- ASSERT(msglist_tail_ != NULL);
- DbgMessage* msg = msglist_head_;
- msglist_head_ = msglist_head_->next();
- resume_requested = msg->HandleMessage();
- delete msg;
+
+ // Handle all available debug messages, up to a resume request.
+ if (HandlePendingMessages()) {
+ break;
}
- if (msglist_head_ == NULL) {
- msglist_tail_ = NULL;
- }
+
+ // Wait for more debug or vm service messages.
+ dart::Monitor::WaitResult res = ml.Wait();
+ ASSERT(res == dart::Monitor::kNotified);
}
+ Dart_SetMessageNotifyCallback(NULL);
is_interrupted_ = false;
is_running_ = true;
}
@@ -1177,6 +1204,16 @@
}
+void DbgMsgQueueList::NotifyIsolate(Dart_Isolate isolate) {
+ MutexLocker ml(msg_queue_list_lock_);
+ Dart_IsolateId isolate_id = Dart_GetIsolateId(isolate);
+ DbgMsgQueue* queue = DbgMsgQueueList::GetIsolateMsgQueueLocked(isolate_id);
+ if (queue != NULL) {
+ queue->Notify();
+ }
+}
+
+
bool DbgMsgQueueList::InterruptIsolate(Dart_IsolateId isolate_id) {
MutexLocker ml(msg_queue_list_lock_);
DbgMsgQueue* queue = DbgMsgQueueList::GetIsolateMsgQueueLocked(isolate_id);
@@ -1293,7 +1330,7 @@
ASSERT(msg_queue != NULL);
msg_queue->SendQueuedMsgs();
msg_queue->SendBreakpointEvent(bp_id, loc);
- msg_queue->HandleMessages();
+ msg_queue->MessageLoop();
Dart_ExitScope();
}
@@ -1307,7 +1344,7 @@
ASSERT(msg_queue != NULL);
msg_queue->SendQueuedMsgs();
msg_queue->SendExceptionEvent(exception, stack_trace);
- msg_queue->HandleMessages();
+ msg_queue->MessageLoop();
Dart_ExitScope();
}
@@ -1325,7 +1362,7 @@
msg_queue->SendQueuedMsgs();
msg_queue->SendIsolateEvent(isolate_id, kind);
if (kind == kInterrupted) {
- msg_queue->HandleMessages();
+ msg_queue->MessageLoop();
} else {
ASSERT(kind == kShutdown);
RemoveIsolateMsgQueue(isolate_id);
« no previous file with comments | « runtime/bin/dbg_message.h ('k') | runtime/bin/vmservice/client/deployed/web/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698