| 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 3404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3415 } | 3415 } |
| 3416 | 3416 |
| 3417 | 3417 |
| 3418 static void StubMessageHandler2(const v8::Debug::Message& message) { | 3418 static void StubMessageHandler2(const v8::Debug::Message& message) { |
| 3419 // Simply ignore message. | 3419 // Simply ignore message. |
| 3420 } | 3420 } |
| 3421 | 3421 |
| 3422 | 3422 |
| 3423 bool Debugger::StartAgent(const char* name, int port, | 3423 bool Debugger::StartAgent(const char* name, int port, |
| 3424 bool wait_for_connection) { | 3424 bool wait_for_connection) { |
| 3425 ASSERT(Isolate::Current() == isolate_); | |
| 3426 if (wait_for_connection) { | 3425 if (wait_for_connection) { |
| 3427 // Suspend V8 if it is already running or set V8 to suspend whenever | 3426 // Suspend V8 if it is already running or set V8 to suspend whenever |
| 3428 // it starts. | 3427 // it starts. |
| 3429 // Provide stub message handler; V8 auto-continues each suspend | 3428 // Provide stub message handler; V8 auto-continues each suspend |
| 3430 // when there is no message handler; we doesn't need it. | 3429 // when there is no message handler; we doesn't need it. |
| 3431 // Once become suspended, V8 will stay so indefinitely long, until remote | 3430 // Once become suspended, V8 will stay so indefinitely long, until remote |
| 3432 // debugger connects and issues "continue" command. | 3431 // debugger connects and issues "continue" command. |
| 3433 Debugger::message_handler_ = StubMessageHandler2; | 3432 Debugger::message_handler_ = StubMessageHandler2; |
| 3434 v8::Debug::DebugBreak(); | 3433 v8::Debug::DebugBreak(); |
| 3435 } | 3434 } |
| 3436 | 3435 |
| 3437 if (agent_ == NULL) { | 3436 if (agent_ == NULL) { |
| 3438 agent_ = new DebuggerAgent(isolate_, name, port); | 3437 agent_ = new DebuggerAgent(isolate_, name, port); |
| 3439 agent_->Start(); | 3438 agent_->Start(); |
| 3440 } | 3439 } |
| 3441 return true; | 3440 return true; |
| 3442 } | 3441 } |
| 3443 | 3442 |
| 3444 | 3443 |
| 3445 void Debugger::StopAgent() { | 3444 void Debugger::StopAgent() { |
| 3446 ASSERT(Isolate::Current() == isolate_); | |
| 3447 if (agent_ != NULL) { | 3445 if (agent_ != NULL) { |
| 3448 agent_->Shutdown(); | 3446 agent_->Shutdown(); |
| 3449 agent_->Join(); | 3447 agent_->Join(); |
| 3450 delete agent_; | 3448 delete agent_; |
| 3451 agent_ = NULL; | 3449 agent_ = NULL; |
| 3452 } | 3450 } |
| 3453 } | 3451 } |
| 3454 | 3452 |
| 3455 | 3453 |
| 3456 void Debugger::WaitForAgent() { | 3454 void Debugger::WaitForAgent() { |
| 3457 ASSERT(Isolate::Current() == isolate_); | |
| 3458 if (agent_ != NULL) | 3455 if (agent_ != NULL) |
| 3459 agent_->WaitUntilListening(); | 3456 agent_->WaitUntilListening(); |
| 3460 } | 3457 } |
| 3461 | 3458 |
| 3462 | 3459 |
| 3463 void Debugger::CallMessageDispatchHandler() { | 3460 void Debugger::CallMessageDispatchHandler() { |
| 3464 v8::Debug::DebugMessageDispatchHandler handler; | 3461 v8::Debug::DebugMessageDispatchHandler handler; |
| 3465 { | 3462 { |
| 3466 LockGuard<Mutex> lock_guard(&dispatch_handler_access_); | 3463 LockGuard<Mutex> lock_guard(&dispatch_handler_access_); |
| 3467 handler = Debugger::debug_message_dispatch_handler_; | 3464 handler = Debugger::debug_message_dispatch_handler_; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3501 load_failed_ = !debug->Load(); | 3498 load_failed_ = !debug->Load(); |
| 3502 if (!load_failed_) { | 3499 if (!load_failed_) { |
| 3503 // NOTE the member variable save which saves the previous context before | 3500 // NOTE the member variable save which saves the previous context before |
| 3504 // this change. | 3501 // this change. |
| 3505 isolate_->set_context(*debug->debug_context()); | 3502 isolate_->set_context(*debug->debug_context()); |
| 3506 } | 3503 } |
| 3507 } | 3504 } |
| 3508 | 3505 |
| 3509 | 3506 |
| 3510 EnterDebugger::~EnterDebugger() { | 3507 EnterDebugger::~EnterDebugger() { |
| 3511 ASSERT(Isolate::Current() == isolate_); | |
| 3512 Debug* debug = isolate_->debug(); | 3508 Debug* debug = isolate_->debug(); |
| 3513 | 3509 |
| 3514 // Restore to the previous break state. | 3510 // Restore to the previous break state. |
| 3515 debug->SetBreak(break_frame_id_, break_id_); | 3511 debug->SetBreak(break_frame_id_, break_id_); |
| 3516 | 3512 |
| 3517 // Check for leaving the debugger. | 3513 // Check for leaving the debugger. |
| 3518 if (!load_failed_ && prev_ == NULL) { | 3514 if (!load_failed_ && prev_ == NULL) { |
| 3519 // Clear mirror cache when leaving the debugger. Skip this if there is a | 3515 // Clear mirror cache when leaving the debugger. Skip this if there is a |
| 3520 // pending exception as clearing the mirror cache calls back into | 3516 // pending exception as clearing the mirror cache calls back into |
| 3521 // JavaScript. This can happen if the v8::Debug::Call is used in which | 3517 // JavaScript. This can happen if the v8::Debug::Call is used in which |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3843 { | 3839 { |
| 3844 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3840 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
| 3845 isolate_->debugger()->CallMessageDispatchHandler(); | 3841 isolate_->debugger()->CallMessageDispatchHandler(); |
| 3846 } | 3842 } |
| 3847 } | 3843 } |
| 3848 } | 3844 } |
| 3849 | 3845 |
| 3850 #endif // ENABLE_DEBUGGER_SUPPORT | 3846 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3851 | 3847 |
| 3852 } } // namespace v8::internal | 3848 } } // namespace v8::internal |
| OLD | NEW |