OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "api.h" | 7 #include "api.h" |
8 #include "arguments.h" | 8 #include "arguments.h" |
9 #include "bootstrapper.h" | 9 #include "bootstrapper.h" |
10 #include "code-stubs.h" | 10 #include "code-stubs.h" |
(...skipping 3121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3132 UpdateState(); | 3132 UpdateState(); |
3133 if (handler == NULL && isolate_->debug()->InDebugger()) { | 3133 if (handler == NULL && isolate_->debug()->InDebugger()) { |
3134 // Send an empty command to the debugger if in a break to make JavaScript | 3134 // Send an empty command to the debugger if in a break to make JavaScript |
3135 // run again if the debugger is closed. | 3135 // run again if the debugger is closed. |
3136 EnqueueCommandMessage(Vector<const uint16_t>::empty()); | 3136 EnqueueCommandMessage(Vector<const uint16_t>::empty()); |
3137 } | 3137 } |
3138 } | 3138 } |
3139 | 3139 |
3140 | 3140 |
3141 void Debugger::UpdateState() { | 3141 void Debugger::UpdateState() { |
| 3142 Debug* debug = isolate_->debug(); |
3142 bool activate = message_handler_ != NULL || | 3143 bool activate = message_handler_ != NULL || |
3143 !event_listener_.is_null() || | 3144 !event_listener_.is_null() || |
3144 isolate_->debug()->InDebugger(); | 3145 debug->InDebugger(); |
3145 if (!is_active_ && activate) { | 3146 if (!is_active_ && activate) { |
3146 // Note that the debug context could have already been loaded to | 3147 // Note that the debug context could have already been loaded to |
3147 // bootstrap test cases. | 3148 // bootstrap test cases. |
3148 isolate_->compilation_cache()->Disable(); | 3149 isolate_->compilation_cache()->Disable(); |
3149 activate = isolate_->debug()->Load(); | 3150 activate = debug->Load(); |
3150 } else if (is_active_ && !activate) { | 3151 } else if (debug->IsLoaded() && !activate) { |
3151 isolate_->compilation_cache()->Enable(); | 3152 isolate_->compilation_cache()->Enable(); |
3152 isolate_->debug()->ClearAllBreakPoints(); | 3153 debug->ClearAllBreakPoints(); |
3153 isolate_->debug()->Unload(); | 3154 debug->Unload(); |
3154 } | 3155 } |
3155 is_active_ = activate; | 3156 is_active_ = activate; |
3156 // At this point the debug context is loaded iff the debugger is active. | 3157 // At this point the debug context is loaded iff the debugger is active. |
3157 ASSERT(isolate_->debug()->IsLoaded() == is_active_); | 3158 ASSERT(debug->IsLoaded() == is_active_); |
3158 } | 3159 } |
3159 | 3160 |
3160 | 3161 |
3161 // Calls the registered debug message handler. This callback is part of the | 3162 // Calls the registered debug message handler. This callback is part of the |
3162 // public API. | 3163 // public API. |
3163 void Debugger::InvokeMessageHandler(MessageImpl message) { | 3164 void Debugger::InvokeMessageHandler(MessageImpl message) { |
3164 if (message_handler_ != NULL) message_handler_(message); | 3165 if (message_handler_ != NULL) message_handler_(message); |
3165 } | 3166 } |
3166 | 3167 |
3167 | 3168 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3264 // Restore to the previous break state. | 3265 // Restore to the previous break state. |
3265 debug->SetBreak(break_frame_id_, break_id_); | 3266 debug->SetBreak(break_frame_id_, break_id_); |
3266 | 3267 |
3267 // Check for leaving the debugger. | 3268 // Check for leaving the debugger. |
3268 if (!load_failed_ && prev_ == NULL) { | 3269 if (!load_failed_ && prev_ == NULL) { |
3269 // Clear mirror cache when leaving the debugger. Skip this if there is a | 3270 // Clear mirror cache when leaving the debugger. Skip this if there is a |
3270 // pending exception as clearing the mirror cache calls back into | 3271 // pending exception as clearing the mirror cache calls back into |
3271 // JavaScript. This can happen if the v8::Debug::Call is used in which | 3272 // JavaScript. This can happen if the v8::Debug::Call is used in which |
3272 // case the exception should end up in the calling code. | 3273 // case the exception should end up in the calling code. |
3273 if (!isolate_->has_pending_exception()) { | 3274 if (!isolate_->has_pending_exception()) { |
3274 // Try to avoid any pending debug break breaking in the clear mirror | |
3275 // cache JavaScript code. | |
3276 if (isolate_->stack_guard()->CheckDebugBreak()) { | |
3277 debug->set_has_pending_interrupt(true); | |
3278 isolate_->stack_guard()->ClearDebugBreak(); | |
3279 } | |
3280 debug->ClearMirrorCache(); | 3275 debug->ClearMirrorCache(); |
3281 } | 3276 } |
3282 | 3277 |
3283 // Request debug break when leaving the last debugger entry | |
3284 // if one was recorded while debugging. | |
3285 if (debug->has_pending_interrupt()) { | |
3286 debug->set_has_pending_interrupt(false); | |
3287 isolate_->stack_guard()->RequestDebugBreak(); | |
3288 } | |
3289 | |
3290 // If there are commands in the queue when leaving the debugger request | 3278 // If there are commands in the queue when leaving the debugger request |
3291 // that these commands are processed. | 3279 // that these commands are processed. |
3292 if (isolate_->debugger()->HasCommands()) { | 3280 if (isolate_->debugger()->HasCommands()) { |
3293 isolate_->stack_guard()->RequestDebugCommand(); | 3281 isolate_->stack_guard()->RequestDebugCommand(); |
3294 } | 3282 } |
3295 } | 3283 } |
3296 | 3284 |
3297 isolate_->debugger()->UpdateState(); | 3285 isolate_->debugger()->UpdateState(); |
3298 } | 3286 } |
3299 | 3287 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3551 logger_->DebugEvent("Put", message.text()); | 3539 logger_->DebugEvent("Put", message.text()); |
3552 } | 3540 } |
3553 | 3541 |
3554 | 3542 |
3555 void LockingCommandMessageQueue::Clear() { | 3543 void LockingCommandMessageQueue::Clear() { |
3556 LockGuard<Mutex> lock_guard(&mutex_); | 3544 LockGuard<Mutex> lock_guard(&mutex_); |
3557 queue_.Clear(); | 3545 queue_.Clear(); |
3558 } | 3546 } |
3559 | 3547 |
3560 } } // namespace v8::internal | 3548 } } // namespace v8::internal |
OLD | NEW |