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

Unified Diff: runtime/bin/dbg_message.h

Issue 11028040: - Add support to interrupt a running isolate (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 months 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
Index: runtime/bin/dbg_message.h
===================================================================
--- runtime/bin/dbg_message.h (revision 13208)
+++ runtime/bin/dbg_message.h (working copy)
@@ -121,20 +121,34 @@
// Class which represents a queue of debug command messages sent to an isolate.
-class DbgMessageQueue {
+class DbgMsgQueue {
public:
- static const int32_t kInvalidCommand = -1;
-
- DbgMessageQueue() : is_running_(true),
- is_interrupted_(false),
- msglist_head_(NULL),
- msglist_tail_(NULL),
- queued_output_messages_(64) {
+ DbgMsgQueue(Dart_IsolateId isolate_id, DbgMsgQueue* next)
+ : is_running_(true),
+ is_interrupted_(false),
+ msglist_head_(NULL),
+ msglist_tail_(NULL),
+ queued_output_messages_(64),
+ isolate_id_(isolate_id),
+ next_(next) {
}
- ~DbgMessageQueue() {
- // Cleanup the message queue
+ ~DbgMsgQueue() {
+ DbgMessage* msg = msglist_head_;
+ while (msglist_head_ != NULL) {
+ msglist_head_ = msglist_head_->next();
+ delete msg;
+ msg = msglist_head_;
+ }
+ msglist_tail_ = NULL;
+ isolate_id_ = ILLEGAL_ISOLATE_ID;
+ next_ = NULL;
}
+ // Accessors.
+ Dart_IsolateId isolate_id() const { return isolate_id_; }
+ DbgMsgQueue* next() const { return next_; }
+ void set_next(DbgMsgQueue* next) { next_ = next; }
+
// Add specified debug command message to the queue.
void AddMessage(int32_t cmd_idx,
const char* start,
@@ -144,6 +158,9 @@
// Handle all debug command messages in the queue.
void HandleMessages();
+ // Interrupt Isolate.
+ void InterruptIsolate();
+
// Queue output messages, these are sent out when we hit an event.
void QueueOutputMsg(dart::TextBuffer* msg);
@@ -156,6 +173,36 @@
// Send Exception event message over to the debugger.
void SendExceptionEvent(Dart_Handle exception, Dart_StackTrace trace);
+ // Send Isolate event message over to the debugger.
+ void SendIsolateEvent(Dart_IsolateId isolate_id, Dart_IsolateEvent kind);
+
+ private:
+ bool is_running_; // True if isolate is running and not in the debugger loop.
+ bool is_interrupted_; // True if interrupt command is pending.
+
+ DbgMessage* msglist_head_; // Start of debugger messages list.
+ DbgMessage* msglist_tail_; // End of debugger messages list.
+
+ // Text buffer that accumulates messages to be output.
+ dart::TextBuffer queued_output_messages_;
+
+ Dart_IsolateId isolate_id_; // Id of the isolate tied to this queue.
+
+ DbgMsgQueue* next_; // Used for creating a list of message queues.
+
+ // The isolate waits on this condition variable when it needs to process
+ // debug messages.
+ dart::Monitor msg_queue_lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(DbgMsgQueue);
+};
+
+
+// Maintains a list of message queues.
+class DbgMsgQueueList {
+ public:
+ static const int32_t kInvalidCommand = -1;
+
// Initialize the message queue processing by setting up the appropriate
// handlers.
static void Initialize();
@@ -165,35 +212,36 @@
// It returns kInvalidCommand otherwise.
static int32_t LookupIsolateCommand(const char* buf, int32_t buflen);
+ // Add Debugger Message Queue corresponding to the Isolate.
+ static DbgMsgQueue* AddIsolateMsgQueue(Dart_IsolateId isolate_id);
+
// Get Debugger Message Queue corresponding to the Isolate.
- static DbgMessageQueue* GetIsolateMessageQueue(Dart_Isolate isolate);
+ static DbgMsgQueue* GetIsolateMsgQueue(Dart_IsolateId isolate_id);
+ // Remove Debugger Message Queue corresponding to the Isolate.
+ static void RemoveIsolateMsgQueue(Dart_IsolateId isolate_id);
+
// Generic handlers for breakpoints, exceptions and delayed breakpoint
// resolution.
- static void BptResolvedHandler(intptr_t bp_id,
+ static void BptResolvedHandler(Dart_IsolateId isolate_id,
+ intptr_t bp_id,
Dart_Handle url,
intptr_t line_number);
- static void BreakpointHandler(Dart_Breakpoint bpt, Dart_StackTrace trace);
- static void ExceptionThrownHandler(Dart_Handle exception,
+ static void BreakpointHandler(Dart_IsolateId isolate_id,
+ Dart_Breakpoint bpt,
+ Dart_StackTrace trace);
+ static void ExceptionThrownHandler(Dart_IsolateId isolate_id,
+ Dart_Handle exception,
Dart_StackTrace stack_trace);
static void IsolateEventHandler(Dart_IsolateId isolate_id,
Dart_IsolateEvent kind);
private:
- bool is_running_; // True if isolate is running and not in the debugger loop.
- bool is_interrupted_; // True if interrupt command is pending.
+ static DbgMsgQueue* list_;
+ static dart::Mutex msg_queue_list_lock_;
- DbgMessage* msglist_head_; // Start of debugger messages list.
- DbgMessage* msglist_tail_; // End of debugger messages list.
-
- // Text buffer that accumulates messages to be output.
- dart::TextBuffer queued_output_messages_;
-
- // The waits on this condition variable when it needs to process
- // debug messages.
- dart::Monitor msg_queue_lock_;
-
- DISALLOW_COPY_AND_ASSIGN(DbgMessageQueue);
+ DISALLOW_ALLOCATION();
+ DISALLOW_IMPLICIT_CONSTRUCTORS(DbgMsgQueueList);
};
#endif // BIN_DBG_MESSAGE_H_

Powered by Google App Engine
This is Rietveld 408576698