| 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 2657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2668 : debugger_access_(isolate->debugger_access()), | 2668 : debugger_access_(isolate->debugger_access()), |
| 2669 event_listener_(Handle<Object>()), | 2669 event_listener_(Handle<Object>()), |
| 2670 event_listener_data_(Handle<Object>()), | 2670 event_listener_data_(Handle<Object>()), |
| 2671 compiling_natives_(false), | 2671 compiling_natives_(false), |
| 2672 is_loading_debugger_(false), | 2672 is_loading_debugger_(false), |
| 2673 live_edit_enabled_(true), | 2673 live_edit_enabled_(true), |
| 2674 never_unload_debugger_(false), | 2674 never_unload_debugger_(false), |
| 2675 force_debugger_active_(false), | 2675 force_debugger_active_(false), |
| 2676 message_handler_(NULL), | 2676 message_handler_(NULL), |
| 2677 debugger_unload_pending_(false), | 2677 debugger_unload_pending_(false), |
| 2678 host_dispatch_handler_(NULL), | |
| 2679 debug_message_dispatch_handler_(NULL), | 2678 debug_message_dispatch_handler_(NULL), |
| 2680 message_dispatch_helper_thread_(NULL), | 2679 message_dispatch_helper_thread_(NULL), |
| 2681 host_dispatch_period_(TimeDelta::FromMilliseconds(100)), | |
| 2682 agent_(NULL), | 2680 agent_(NULL), |
| 2683 command_queue_(isolate->logger(), kQueueInitialSize), | 2681 command_queue_(isolate->logger(), kQueueInitialSize), |
| 2684 command_received_(0), | 2682 command_received_(0), |
| 2685 event_command_queue_(isolate->logger(), kQueueInitialSize), | 2683 event_command_queue_(isolate->logger(), kQueueInitialSize), |
| 2686 isolate_(isolate) { | 2684 isolate_(isolate) { |
| 2687 } | 2685 } |
| 2688 | 2686 |
| 2689 | 2687 |
| 2690 Debugger::~Debugger() {} | 2688 Debugger::~Debugger() {} |
| 2691 | 2689 |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3143 PrintLn(try_catch.Exception()); | 3141 PrintLn(try_catch.Exception()); |
| 3144 return; | 3142 return; |
| 3145 } | 3143 } |
| 3146 } | 3144 } |
| 3147 | 3145 |
| 3148 bool running = auto_continue; | 3146 bool running = auto_continue; |
| 3149 | 3147 |
| 3150 // Process requests from the debugger. | 3148 // Process requests from the debugger. |
| 3151 while (true) { | 3149 while (true) { |
| 3152 // Wait for new command in the queue. | 3150 // Wait for new command in the queue. |
| 3153 if (Debugger::host_dispatch_handler_) { | 3151 command_received_.Wait(); |
| 3154 // In case there is a host dispatch - do periodic dispatches. | |
| 3155 if (!command_received_.WaitFor(host_dispatch_period_)) { | |
| 3156 // Timout expired, do the dispatch. | |
| 3157 Debugger::host_dispatch_handler_(); | |
| 3158 continue; | |
| 3159 } | |
| 3160 } else { | |
| 3161 // In case there is no host dispatch - just wait. | |
| 3162 command_received_.Wait(); | |
| 3163 } | |
| 3164 | 3152 |
| 3165 // Get the command from the queue. | 3153 // Get the command from the queue. |
| 3166 CommandMessage command = command_queue_.Get(); | 3154 CommandMessage command = command_queue_.Get(); |
| 3167 isolate_->logger()->DebugTag( | 3155 isolate_->logger()->DebugTag( |
| 3168 "Got request from command queue, in interactive loop."); | 3156 "Got request from command queue, in interactive loop."); |
| 3169 if (!Debugger::IsDebuggerActive()) { | 3157 if (!Debugger::IsDebuggerActive()) { |
| 3170 // Delete command text and user data. | 3158 // Delete command text and user data. |
| 3171 command.Dispose(); | 3159 command.Dispose(); |
| 3172 return; | 3160 return; |
| 3173 } | 3161 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3295 debugger_unload_pending_ = false; | 3283 debugger_unload_pending_ = false; |
| 3296 } else { | 3284 } else { |
| 3297 isolate_->compilation_cache()->Enable(); | 3285 isolate_->compilation_cache()->Enable(); |
| 3298 // Unload the debugger if event listener and message handler cleared. | 3286 // Unload the debugger if event listener and message handler cleared. |
| 3299 // Schedule this for later, because we may be in non-V8 thread. | 3287 // Schedule this for later, because we may be in non-V8 thread. |
| 3300 debugger_unload_pending_ = true; | 3288 debugger_unload_pending_ = true; |
| 3301 } | 3289 } |
| 3302 } | 3290 } |
| 3303 | 3291 |
| 3304 | 3292 |
| 3305 void Debugger::SetHostDispatchHandler(v8::Debug::HostDispatchHandler handler, | |
| 3306 TimeDelta period) { | |
| 3307 host_dispatch_handler_ = handler; | |
| 3308 host_dispatch_period_ = period; | |
| 3309 } | |
| 3310 | |
| 3311 | |
| 3312 void Debugger::SetDebugMessageDispatchHandler( | 3293 void Debugger::SetDebugMessageDispatchHandler( |
| 3313 v8::Debug::DebugMessageDispatchHandler handler, bool provide_locker) { | 3294 v8::Debug::DebugMessageDispatchHandler handler, bool provide_locker) { |
| 3314 LockGuard<Mutex> lock_guard(&dispatch_handler_access_); | 3295 LockGuard<Mutex> lock_guard(&dispatch_handler_access_); |
| 3315 debug_message_dispatch_handler_ = handler; | 3296 debug_message_dispatch_handler_ = handler; |
| 3316 | 3297 |
| 3317 if (provide_locker && message_dispatch_helper_thread_ == NULL) { | 3298 if (provide_locker && message_dispatch_helper_thread_ == NULL) { |
| 3318 message_dispatch_helper_thread_ = new MessageDispatchHelperThread(isolate_); | 3299 message_dispatch_helper_thread_ = new MessageDispatchHelperThread(isolate_); |
| 3319 message_dispatch_helper_thread_->Start(); | 3300 message_dispatch_helper_thread_->Start(); |
| 3320 } | 3301 } |
| 3321 } | 3302 } |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3847 already_signalled_ = false; | 3828 already_signalled_ = false; |
| 3848 } | 3829 } |
| 3849 { | 3830 { |
| 3850 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3831 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
| 3851 isolate_->debugger()->CallMessageDispatchHandler(); | 3832 isolate_->debugger()->CallMessageDispatchHandler(); |
| 3852 } | 3833 } |
| 3853 } | 3834 } |
| 3854 } | 3835 } |
| 3855 | 3836 |
| 3856 } } // namespace v8::internal | 3837 } } // namespace v8::internal |
| OLD | NEW |