OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 UNREACHABLE(); | 214 UNREACHABLE(); |
215 } | 215 } |
216 delete event; | 216 delete event; |
217 } | 217 } |
218 | 218 |
219 // Wait for the receiver thread to end. | 219 // Wait for the receiver thread to end. |
220 receiver.Join(); | 220 receiver.Join(); |
221 } | 221 } |
222 | 222 |
223 | 223 |
224 void RemoteDebugger::MessageReceived(i::SmartPointer<char> message) { | 224 void RemoteDebugger::MessageReceived(i::SmartArrayPointer<char> message) { |
225 RemoteDebuggerEvent* event = | 225 RemoteDebuggerEvent* event = |
226 new RemoteDebuggerEvent(RemoteDebuggerEvent::kMessage, message); | 226 new RemoteDebuggerEvent(RemoteDebuggerEvent::kMessage, message); |
227 AddEvent(event); | 227 AddEvent(event); |
228 } | 228 } |
229 | 229 |
230 | 230 |
231 void RemoteDebugger::KeyboardCommand(i::SmartPointer<char> command) { | 231 void RemoteDebugger::KeyboardCommand(i::SmartArrayPointer<char> command) { |
232 RemoteDebuggerEvent* event = | 232 RemoteDebuggerEvent* event = |
233 new RemoteDebuggerEvent(RemoteDebuggerEvent::kKeyboard, command); | 233 new RemoteDebuggerEvent(RemoteDebuggerEvent::kKeyboard, command); |
234 AddEvent(event); | 234 AddEvent(event); |
235 } | 235 } |
236 | 236 |
237 | 237 |
238 void RemoteDebugger::ConnectionClosed() { | 238 void RemoteDebugger::ConnectionClosed() { |
239 RemoteDebuggerEvent* event = | 239 RemoteDebuggerEvent* event = |
240 new RemoteDebuggerEvent(RemoteDebuggerEvent::kDisconnect, | 240 new RemoteDebuggerEvent(RemoteDebuggerEvent::kDisconnect, |
241 i::SmartPointer<char>()); | 241 i::SmartArrayPointer<char>()); |
242 AddEvent(event); | 242 AddEvent(event); |
243 } | 243 } |
244 | 244 |
245 | 245 |
246 void RemoteDebugger::AddEvent(RemoteDebuggerEvent* event) { | 246 void RemoteDebugger::AddEvent(RemoteDebuggerEvent* event) { |
247 i::ScopedLock lock(event_access_); | 247 i::ScopedLock lock(event_access_); |
248 if (head_ == NULL) { | 248 if (head_ == NULL) { |
249 ASSERT(tail_ == NULL); | 249 ASSERT(tail_ == NULL); |
250 head_ = event; | 250 head_ = event; |
251 tail_ = event; | 251 tail_ = event; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 return; | 323 return; |
324 } | 324 } |
325 | 325 |
326 // Send the JSON debugger request. | 326 // Send the JSON debugger request. |
327 i::DebuggerAgentUtil::SendMessage(conn_, Handle<String>::Cast(request)); | 327 i::DebuggerAgentUtil::SendMessage(conn_, Handle<String>::Cast(request)); |
328 } | 328 } |
329 | 329 |
330 | 330 |
331 void ReceiverThread::Run() { | 331 void ReceiverThread::Run() { |
332 // Receive the connect message (with empty body). | 332 // Receive the connect message (with empty body). |
333 i::SmartPointer<char> message = | 333 i::SmartArrayPointer<char> message = |
334 i::DebuggerAgentUtil::ReceiveMessage(remote_debugger_->conn()); | 334 i::DebuggerAgentUtil::ReceiveMessage(remote_debugger_->conn()); |
335 ASSERT(*message == NULL); | 335 ASSERT(*message == NULL); |
336 | 336 |
337 while (true) { | 337 while (true) { |
338 // Receive a message. | 338 // Receive a message. |
339 i::SmartPointer<char> message = | 339 i::SmartArrayPointer<char> message = |
340 i::DebuggerAgentUtil::ReceiveMessage(remote_debugger_->conn()); | 340 i::DebuggerAgentUtil::ReceiveMessage(remote_debugger_->conn()); |
341 if (*message == NULL) { | 341 if (*message == NULL) { |
342 remote_debugger_->ConnectionClosed(); | 342 remote_debugger_->ConnectionClosed(); |
343 return; | 343 return; |
344 } | 344 } |
345 | 345 |
346 // Pass the message to the main thread. | 346 // Pass the message to the main thread. |
347 remote_debugger_->MessageReceived(message); | 347 remote_debugger_->MessageReceived(message); |
348 } | 348 } |
349 } | 349 } |
350 | 350 |
351 | 351 |
352 void KeyboardThread::Run() { | 352 void KeyboardThread::Run() { |
353 static const int kBufferSize = 256; | 353 static const int kBufferSize = 256; |
354 while (true) { | 354 while (true) { |
355 // read keyboard input. | 355 // read keyboard input. |
356 char command[kBufferSize]; | 356 char command[kBufferSize]; |
357 char* str = fgets(command, kBufferSize, stdin); | 357 char* str = fgets(command, kBufferSize, stdin); |
358 if (str == NULL) { | 358 if (str == NULL) { |
359 break; | 359 break; |
360 } | 360 } |
361 | 361 |
362 // Pass the keyboard command to the main thread. | 362 // Pass the keyboard command to the main thread. |
363 remote_debugger_->KeyboardCommand( | 363 remote_debugger_->KeyboardCommand( |
364 i::SmartPointer<char>(i::StrDup(command))); | 364 i::SmartArrayPointer<char>(i::StrDup(command))); |
365 } | 365 } |
366 } | 366 } |
367 | 367 |
368 | 368 |
369 } // namespace v8 | 369 } // namespace v8 |
OLD | NEW |