OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 receiver.Start(); | 194 receiver.Start(); |
195 | 195 |
196 // Start the keyboard thread. | 196 // Start the keyboard thread. |
197 KeyboardThread keyboard(this); | 197 KeyboardThread keyboard(this); |
198 keyboard.Start(); | 198 keyboard.Start(); |
199 PrintPrompt(); | 199 PrintPrompt(); |
200 | 200 |
201 // Process events received from debugged VM and from the keyboard. | 201 // Process events received from debugged VM and from the keyboard. |
202 bool terminate = false; | 202 bool terminate = false; |
203 while (!terminate) { | 203 while (!terminate) { |
204 event_available_->Wait(); | 204 event_available_.Wait(); |
205 RemoteDebuggerEvent* event = GetEvent(); | 205 RemoteDebuggerEvent* event = GetEvent(); |
206 switch (event->type()) { | 206 switch (event->type()) { |
207 case RemoteDebuggerEvent::kMessage: | 207 case RemoteDebuggerEvent::kMessage: |
208 HandleMessageReceived(event->data()); | 208 HandleMessageReceived(event->data()); |
209 break; | 209 break; |
210 case RemoteDebuggerEvent::kKeyboard: | 210 case RemoteDebuggerEvent::kKeyboard: |
211 HandleKeyboardCommand(event->data()); | 211 HandleKeyboardCommand(event->data()); |
212 break; | 212 break; |
213 case RemoteDebuggerEvent::kDisconnect: | 213 case RemoteDebuggerEvent::kDisconnect: |
214 terminate = true; | 214 terminate = true; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 i::LockGuard<i::Mutex> lock_guard(&event_access_); | 251 i::LockGuard<i::Mutex> lock_guard(&event_access_); |
252 if (head_ == NULL) { | 252 if (head_ == NULL) { |
253 ASSERT(tail_ == NULL); | 253 ASSERT(tail_ == NULL); |
254 head_ = event; | 254 head_ = event; |
255 tail_ = event; | 255 tail_ = event; |
256 } else { | 256 } else { |
257 ASSERT(tail_ != NULL); | 257 ASSERT(tail_ != NULL); |
258 tail_->set_next(event); | 258 tail_->set_next(event); |
259 tail_ = event; | 259 tail_ = event; |
260 } | 260 } |
261 event_available_->Signal(); | 261 event_available_.Signal(); |
262 } | 262 } |
263 | 263 |
264 | 264 |
265 RemoteDebuggerEvent* RemoteDebugger::GetEvent() { | 265 RemoteDebuggerEvent* RemoteDebugger::GetEvent() { |
266 i::LockGuard<i::Mutex> lock_guard(&event_access_); | 266 i::LockGuard<i::Mutex> lock_guard(&event_access_); |
267 ASSERT(head_ != NULL); | 267 ASSERT(head_ != NULL); |
268 RemoteDebuggerEvent* result = head_; | 268 RemoteDebuggerEvent* result = head_; |
269 head_ = head_->next(); | 269 head_ = head_->next(); |
270 if (head_ == NULL) { | 270 if (head_ == NULL) { |
271 ASSERT(tail_ == result); | 271 ASSERT(tail_ == result); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 // Pass the keyboard command to the main thread. | 365 // Pass the keyboard command to the main thread. |
366 remote_debugger_->KeyboardCommand( | 366 remote_debugger_->KeyboardCommand( |
367 i::SmartArrayPointer<char>(i::StrDup(command))); | 367 i::SmartArrayPointer<char>(i::StrDup(command))); |
368 } | 368 } |
369 } | 369 } |
370 | 370 |
371 | 371 |
372 } // namespace v8 | 372 } // namespace v8 |
373 | 373 |
374 #endif // ENABLE_DEBUGGER_SUPPORT | 374 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |