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

Side by Side Diff: runtime/bin/dbg_message.cc

Issue 15861016: Don't use statically declared Mutex in debugger (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/dbg_message.h ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/dbg_connection.h" 5 #include "bin/dbg_connection.h"
6 #include "bin/dbg_message.h" 6 #include "bin/dbg_message.h"
7 #include "bin/dartutils.h" 7 #include "bin/dartutils.h"
8 #include "bin/thread.h" 8 #include "bin/thread.h"
9 #include "bin/utils.h" 9 #include "bin/utils.h"
10 10
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 msg.Printf("\"reason\": \"shutdown\", "); 1046 msg.Printf("\"reason\": \"shutdown\", ");
1047 } 1047 }
1048 msg.Printf("\"id\": %"Pd64" ", isolate_id); 1048 msg.Printf("\"id\": %"Pd64" ", isolate_id);
1049 msg.Printf("}}"); 1049 msg.Printf("}}");
1050 } 1050 }
1051 DebuggerConnectionHandler::BroadcastMsg(&msg); 1051 DebuggerConnectionHandler::BroadcastMsg(&msg);
1052 } 1052 }
1053 1053
1054 1054
1055 DbgMsgQueue* DbgMsgQueueList::list_ = NULL; 1055 DbgMsgQueue* DbgMsgQueueList::list_ = NULL;
1056 dart::Mutex DbgMsgQueueList::msg_queue_list_lock_; 1056 dart::Mutex* DbgMsgQueueList::msg_queue_list_lock_ = new dart::Mutex();
1057 1057
1058 1058
1059 void DbgMsgQueueList::Initialize() { 1059 void DbgMsgQueueList::Initialize() {
1060 // Setup handlers for isolate events, breakpoints, exceptions and 1060 // Setup handlers for isolate events, breakpoints, exceptions and
1061 // delayed breakpoints. 1061 // delayed breakpoints.
1062 Dart_SetIsolateEventHandler(IsolateEventHandler); 1062 Dart_SetIsolateEventHandler(IsolateEventHandler);
1063 Dart_SetPausedEventHandler(PausedEventHandler); 1063 Dart_SetPausedEventHandler(PausedEventHandler);
1064 Dart_SetBreakpointResolvedHandler(BptResolvedHandler); 1064 Dart_SetBreakpointResolvedHandler(BptResolvedHandler);
1065 Dart_SetExceptionThrownHandler(ExceptionThrownHandler); 1065 Dart_SetExceptionThrownHandler(ExceptionThrownHandler);
1066 } 1066 }
(...skipping 11 matching lines...) Expand all
1078 } 1078 }
1079 return kInvalidCommand; 1079 return kInvalidCommand;
1080 } 1080 }
1081 1081
1082 1082
1083 bool DbgMsgQueueList::AddIsolateMessage(Dart_IsolateId isolate_id, 1083 bool DbgMsgQueueList::AddIsolateMessage(Dart_IsolateId isolate_id,
1084 int32_t cmd_idx, 1084 int32_t cmd_idx,
1085 const char* start, 1085 const char* start,
1086 const char* end, 1086 const char* end,
1087 int debug_fd) { 1087 int debug_fd) {
1088 MutexLocker ml(&msg_queue_list_lock_); 1088 MutexLocker ml(msg_queue_list_lock_);
1089 DbgMsgQueue* queue = DbgMsgQueueList::GetIsolateMsgQueueLocked(isolate_id); 1089 DbgMsgQueue* queue = DbgMsgQueueList::GetIsolateMsgQueueLocked(isolate_id);
1090 if (queue != NULL) { 1090 if (queue != NULL) {
1091 queue->AddMessage(cmd_idx, start, end, debug_fd); 1091 queue->AddMessage(cmd_idx, start, end, debug_fd);
1092 return true; 1092 return true;
1093 } 1093 }
1094 return false; 1094 return false;
1095 } 1095 }
1096 1096
1097 1097
1098 bool DbgMsgQueueList::InterruptIsolate(Dart_IsolateId isolate_id) { 1098 bool DbgMsgQueueList::InterruptIsolate(Dart_IsolateId isolate_id) {
1099 MutexLocker ml(&msg_queue_list_lock_); 1099 MutexLocker ml(msg_queue_list_lock_);
1100 DbgMsgQueue* queue = DbgMsgQueueList::GetIsolateMsgQueueLocked(isolate_id); 1100 DbgMsgQueue* queue = DbgMsgQueueList::GetIsolateMsgQueueLocked(isolate_id);
1101 if (queue != NULL) { 1101 if (queue != NULL) {
1102 queue->InterruptIsolate(); 1102 queue->InterruptIsolate();
1103 return true; 1103 return true;
1104 } 1104 }
1105 return false; 1105 return false;
1106 } 1106 }
1107 1107
1108 1108
1109 DbgMsgQueue* DbgMsgQueueList::AddIsolateMsgQueue(Dart_IsolateId isolate_id) { 1109 DbgMsgQueue* DbgMsgQueueList::AddIsolateMsgQueue(Dart_IsolateId isolate_id) {
1110 MutexLocker ml(&msg_queue_list_lock_); 1110 MutexLocker ml(msg_queue_list_lock_);
1111 1111
1112 DbgMsgQueue* queue = new DbgMsgQueue(isolate_id, list_); 1112 DbgMsgQueue* queue = new DbgMsgQueue(isolate_id, list_);
1113 ASSERT(queue != NULL); 1113 ASSERT(queue != NULL);
1114 list_ = queue; 1114 list_ = queue;
1115 return queue; 1115 return queue;
1116 } 1116 }
1117 1117
1118 1118
1119 DbgMsgQueue* DbgMsgQueueList::GetIsolateMsgQueue(Dart_IsolateId isolate_id) { 1119 DbgMsgQueue* DbgMsgQueueList::GetIsolateMsgQueue(Dart_IsolateId isolate_id) {
1120 MutexLocker ml(&msg_queue_list_lock_); 1120 MutexLocker ml(msg_queue_list_lock_);
1121 ASSERT(Dart_GetIsolate(isolate_id) == Dart_CurrentIsolate()); 1121 ASSERT(Dart_GetIsolate(isolate_id) == Dart_CurrentIsolate());
1122 return GetIsolateMsgQueueLocked(isolate_id); 1122 return GetIsolateMsgQueueLocked(isolate_id);
1123 } 1123 }
1124 1124
1125 1125
1126 DbgMsgQueue* DbgMsgQueueList::GetIsolateMsgQueueLocked(Dart_IsolateId id) { 1126 DbgMsgQueue* DbgMsgQueueList::GetIsolateMsgQueueLocked(Dart_IsolateId id) {
1127 if (list_ == NULL) { 1127 if (list_ == NULL) {
1128 return NULL; // No items in the list. 1128 return NULL; // No items in the list.
1129 } 1129 }
1130 1130
1131 // Find message queue corresponding to isolate id. 1131 // Find message queue corresponding to isolate id.
1132 DbgMsgQueue* iterator = list_; 1132 DbgMsgQueue* iterator = list_;
1133 while (iterator != NULL && iterator->isolate_id() != id) { 1133 while (iterator != NULL && iterator->isolate_id() != id) {
1134 iterator = iterator->next(); 1134 iterator = iterator->next();
1135 } 1135 }
1136 return iterator; 1136 return iterator;
1137 } 1137 }
1138 1138
1139 1139
1140 void DbgMsgQueueList::RemoveIsolateMsgQueue(Dart_IsolateId isolate_id) { 1140 void DbgMsgQueueList::RemoveIsolateMsgQueue(Dart_IsolateId isolate_id) {
1141 MutexLocker ml(&msg_queue_list_lock_); 1141 MutexLocker ml(msg_queue_list_lock_);
1142 if (list_ == NULL) { 1142 if (list_ == NULL) {
1143 return; // No items in the list. 1143 return; // No items in the list.
1144 } 1144 }
1145 DbgMsgQueue* queue = list_; 1145 DbgMsgQueue* queue = list_;
1146 if (queue->isolate_id() == isolate_id) { 1146 if (queue->isolate_id() == isolate_id) {
1147 list_ = queue->next(); // Remove from list. 1147 list_ = queue->next(); // Remove from list.
1148 delete queue; // Delete the message queue. 1148 delete queue; // Delete the message queue.
1149 return; 1149 return;
1150 } else { 1150 } else {
1151 DbgMsgQueue* iterator = queue; 1151 DbgMsgQueue* iterator = queue;
1152 queue = queue->next(); 1152 queue = queue->next();
1153 while (queue != NULL) { 1153 while (queue != NULL) {
1154 if (queue->isolate_id() == isolate_id) { 1154 if (queue->isolate_id() == isolate_id) {
1155 iterator->set_next(queue->next()); // Remove from list. 1155 iterator->set_next(queue->next()); // Remove from list.
1156 delete queue; // Delete the message queue. 1156 delete queue; // Delete the message queue.
1157 return; 1157 return;
1158 } 1158 }
1159 iterator = queue; 1159 iterator = queue;
1160 queue = queue->next(); 1160 queue = queue->next();
1161 } 1161 }
1162 } 1162 }
1163 UNREACHABLE(); 1163 UNREACHABLE();
1164 } 1164 }
1165 1165
1166 1166
1167 void DbgMsgQueueList::ListIsolateIds(dart::TextBuffer* msg) { 1167 void DbgMsgQueueList::ListIsolateIds(dart::TextBuffer* msg) {
1168 MutexLocker ml(&msg_queue_list_lock_); 1168 MutexLocker ml(msg_queue_list_lock_);
1169 if (list_ == NULL) { 1169 if (list_ == NULL) {
1170 return; // No items in the list. 1170 return; // No items in the list.
1171 } 1171 }
1172 DbgMsgQueue* queue = list_; 1172 DbgMsgQueue* queue = list_;
1173 msg->Printf("%"Pd64"", queue->isolate_id()); 1173 msg->Printf("%"Pd64"", queue->isolate_id());
1174 queue = queue->next(); 1174 queue = queue->next();
1175 while (queue != NULL) { 1175 while (queue != NULL) {
1176 msg->Printf(",%"Pd64"", queue->isolate_id()); 1176 msg->Printf(",%"Pd64"", queue->isolate_id());
1177 queue = queue->next(); 1177 queue = queue->next();
1178 } 1178 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 } else { 1246 } else {
1247 ASSERT(kind == kShutdown); 1247 ASSERT(kind == kShutdown);
1248 RemoveIsolateMsgQueue(isolate_id); 1248 RemoveIsolateMsgQueue(isolate_id);
1249 } 1249 }
1250 } 1250 }
1251 Dart_ExitScope(); 1251 Dart_ExitScope();
1252 } 1252 }
1253 1253
1254 } // namespace bin 1254 } // namespace bin
1255 } // namespace dart 1255 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/dbg_message.h ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698