| 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 "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 in_debug_event_listener_(false), | 41 in_debug_event_listener_(false), |
| 42 break_on_exception_(false), | 42 break_on_exception_(false), |
| 43 break_on_uncaught_exception_(false), | 43 break_on_uncaught_exception_(false), |
| 44 script_cache_(NULL), | 44 script_cache_(NULL), |
| 45 debug_info_list_(NULL), | 45 debug_info_list_(NULL), |
| 46 isolate_(isolate) { | 46 isolate_(isolate) { |
| 47 ThreadInit(); | 47 ThreadInit(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 | 50 |
| 51 static v8::Handle<v8::Context> GetDebugEventContext(Isolate* isolate) { | 51 static v8::Local<v8::Context> GetDebugEventContext(Isolate* isolate) { |
| 52 Handle<Context> context = isolate->debug()->debugger_entry()->GetContext(); | 52 Handle<Context> context = isolate->debug()->debugger_entry()->GetContext(); |
| 53 // Isolate::context() may have been NULL when "script collected" event | 53 // Isolate::context() may have been NULL when "script collected" event |
| 54 // occured. | 54 // occured. |
| 55 if (context.is_null()) return v8::Local<v8::Context>(); | 55 if (context.is_null()) return v8::Local<v8::Context>(); |
| 56 Handle<Context> native_context(context->native_context()); | 56 Handle<Context> native_context(context->native_context()); |
| 57 return v8::Utils::ToLocal(native_context); | 57 return v8::Utils::ToLocal(native_context); |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 BreakLocation::BreakLocation(Handle<DebugInfo> debug_info, RelocInfo* rinfo, | 61 BreakLocation::BreakLocation(Handle<DebugInfo> debug_info, RelocInfo* rinfo, |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 SuppressDebug while_loading(this); | 677 SuppressDebug while_loading(this); |
| 678 | 678 |
| 679 // Disable breakpoints and interrupts while compiling and running the | 679 // Disable breakpoints and interrupts while compiling and running the |
| 680 // debugger scripts including the context creation code. | 680 // debugger scripts including the context creation code. |
| 681 DisableBreak disable(this, true); | 681 DisableBreak disable(this, true); |
| 682 PostponeInterruptsScope postpone(isolate_); | 682 PostponeInterruptsScope postpone(isolate_); |
| 683 | 683 |
| 684 // Create the debugger context. | 684 // Create the debugger context. |
| 685 HandleScope scope(isolate_); | 685 HandleScope scope(isolate_); |
| 686 ExtensionConfiguration no_extensions; | 686 ExtensionConfiguration no_extensions; |
| 687 Handle<Context> context = | 687 Handle<Context> context = isolate_->bootstrapper()->CreateEnvironment( |
| 688 isolate_->bootstrapper()->CreateEnvironment( | 688 MaybeHandle<JSGlobalProxy>(), v8::Local<ObjectTemplate>(), |
| 689 MaybeHandle<JSGlobalProxy>(), | 689 &no_extensions); |
| 690 v8::Handle<ObjectTemplate>(), | |
| 691 &no_extensions); | |
| 692 | 690 |
| 693 // Fail if no context could be created. | 691 // Fail if no context could be created. |
| 694 if (context.is_null()) return false; | 692 if (context.is_null()) return false; |
| 695 | 693 |
| 696 // Use the debugger context. | 694 // Use the debugger context. |
| 697 SaveContext save(isolate_); | 695 SaveContext save(isolate_); |
| 698 isolate_->set_context(*context); | 696 isolate_->set_context(*context); |
| 699 | 697 |
| 700 // Expose the builtins object in the debugger context. | 698 // Expose the builtins object in the debugger context. |
| 701 Handle<String> key = isolate_->factory()->InternalizeOneByteString( | 699 Handle<String> key = isolate_->factory()->InternalizeOneByteString( |
| (...skipping 2492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3194 DebugEvent MessageImpl::GetEvent() const { | 3192 DebugEvent MessageImpl::GetEvent() const { |
| 3195 return event_; | 3193 return event_; |
| 3196 } | 3194 } |
| 3197 | 3195 |
| 3198 | 3196 |
| 3199 bool MessageImpl::WillStartRunning() const { | 3197 bool MessageImpl::WillStartRunning() const { |
| 3200 return running_; | 3198 return running_; |
| 3201 } | 3199 } |
| 3202 | 3200 |
| 3203 | 3201 |
| 3204 v8::Handle<v8::Object> MessageImpl::GetExecutionState() const { | 3202 v8::Local<v8::Object> MessageImpl::GetExecutionState() const { |
| 3205 return v8::Utils::ToLocal(exec_state_); | 3203 return v8::Utils::ToLocal(exec_state_); |
| 3206 } | 3204 } |
| 3207 | 3205 |
| 3208 | 3206 |
| 3209 v8::Isolate* MessageImpl::GetIsolate() const { | 3207 v8::Isolate* MessageImpl::GetIsolate() const { |
| 3210 return reinterpret_cast<v8::Isolate*>(exec_state_->GetIsolate()); | 3208 return reinterpret_cast<v8::Isolate*>(exec_state_->GetIsolate()); |
| 3211 } | 3209 } |
| 3212 | 3210 |
| 3213 | 3211 |
| 3214 v8::Handle<v8::Object> MessageImpl::GetEventData() const { | 3212 v8::Local<v8::Object> MessageImpl::GetEventData() const { |
| 3215 return v8::Utils::ToLocal(event_data_); | 3213 return v8::Utils::ToLocal(event_data_); |
| 3216 } | 3214 } |
| 3217 | 3215 |
| 3218 | 3216 |
| 3219 v8::Handle<v8::String> MessageImpl::GetJSON() const { | 3217 v8::Local<v8::String> MessageImpl::GetJSON() const { |
| 3220 Isolate* isolate = event_data_->GetIsolate(); | 3218 Isolate* isolate = event_data_->GetIsolate(); |
| 3221 v8::EscapableHandleScope scope(reinterpret_cast<v8::Isolate*>(isolate)); | 3219 v8::EscapableHandleScope scope(reinterpret_cast<v8::Isolate*>(isolate)); |
| 3222 | 3220 |
| 3223 if (IsEvent()) { | 3221 if (IsEvent()) { |
| 3224 // Call toJSONProtocol on the debug event object. | 3222 // Call toJSONProtocol on the debug event object. |
| 3225 Handle<Object> fun = Object::GetProperty( | 3223 Handle<Object> fun = Object::GetProperty( |
| 3226 isolate, event_data_, "toJSONProtocol").ToHandleChecked(); | 3224 isolate, event_data_, "toJSONProtocol").ToHandleChecked(); |
| 3227 if (!fun->IsJSFunction()) { | 3225 if (!fun->IsJSFunction()) { |
| 3228 return v8::Handle<v8::String>(); | 3226 return v8::Local<v8::String>(); |
| 3229 } | 3227 } |
| 3230 | 3228 |
| 3231 MaybeHandle<Object> maybe_json = | 3229 MaybeHandle<Object> maybe_json = |
| 3232 Execution::TryCall(Handle<JSFunction>::cast(fun), event_data_, 0, NULL); | 3230 Execution::TryCall(Handle<JSFunction>::cast(fun), event_data_, 0, NULL); |
| 3233 Handle<Object> json; | 3231 Handle<Object> json; |
| 3234 if (!maybe_json.ToHandle(&json) || !json->IsString()) { | 3232 if (!maybe_json.ToHandle(&json) || !json->IsString()) { |
| 3235 return v8::Handle<v8::String>(); | 3233 return v8::Local<v8::String>(); |
| 3236 } | 3234 } |
| 3237 return scope.Escape(v8::Utils::ToLocal(Handle<String>::cast(json))); | 3235 return scope.Escape(v8::Utils::ToLocal(Handle<String>::cast(json))); |
| 3238 } else { | 3236 } else { |
| 3239 return v8::Utils::ToLocal(response_json_); | 3237 return v8::Utils::ToLocal(response_json_); |
| 3240 } | 3238 } |
| 3241 } | 3239 } |
| 3242 | 3240 |
| 3243 | 3241 |
| 3244 v8::Handle<v8::Context> MessageImpl::GetEventContext() const { | 3242 v8::Local<v8::Context> MessageImpl::GetEventContext() const { |
| 3245 Isolate* isolate = event_data_->GetIsolate(); | 3243 Isolate* isolate = event_data_->GetIsolate(); |
| 3246 v8::Handle<v8::Context> context = GetDebugEventContext(isolate); | 3244 v8::Local<v8::Context> context = GetDebugEventContext(isolate); |
| 3247 // Isolate::context() may be NULL when "script collected" event occurs. | 3245 // Isolate::context() may be NULL when "script collected" event occurs. |
| 3248 DCHECK(!context.IsEmpty()); | 3246 DCHECK(!context.IsEmpty()); |
| 3249 return context; | 3247 return context; |
| 3250 } | 3248 } |
| 3251 | 3249 |
| 3252 | 3250 |
| 3253 v8::Debug::ClientData* MessageImpl::GetClientData() const { | 3251 v8::Debug::ClientData* MessageImpl::GetClientData() const { |
| 3254 return client_data_; | 3252 return client_data_; |
| 3255 } | 3253 } |
| 3256 | 3254 |
| 3257 | 3255 |
| 3258 EventDetailsImpl::EventDetailsImpl(DebugEvent event, | 3256 EventDetailsImpl::EventDetailsImpl(DebugEvent event, |
| 3259 Handle<JSObject> exec_state, | 3257 Handle<JSObject> exec_state, |
| 3260 Handle<JSObject> event_data, | 3258 Handle<JSObject> event_data, |
| 3261 Handle<Object> callback_data, | 3259 Handle<Object> callback_data, |
| 3262 v8::Debug::ClientData* client_data) | 3260 v8::Debug::ClientData* client_data) |
| 3263 : event_(event), | 3261 : event_(event), |
| 3264 exec_state_(exec_state), | 3262 exec_state_(exec_state), |
| 3265 event_data_(event_data), | 3263 event_data_(event_data), |
| 3266 callback_data_(callback_data), | 3264 callback_data_(callback_data), |
| 3267 client_data_(client_data) {} | 3265 client_data_(client_data) {} |
| 3268 | 3266 |
| 3269 | 3267 |
| 3270 DebugEvent EventDetailsImpl::GetEvent() const { | 3268 DebugEvent EventDetailsImpl::GetEvent() const { |
| 3271 return event_; | 3269 return event_; |
| 3272 } | 3270 } |
| 3273 | 3271 |
| 3274 | 3272 |
| 3275 v8::Handle<v8::Object> EventDetailsImpl::GetExecutionState() const { | 3273 v8::Local<v8::Object> EventDetailsImpl::GetExecutionState() const { |
| 3276 return v8::Utils::ToLocal(exec_state_); | 3274 return v8::Utils::ToLocal(exec_state_); |
| 3277 } | 3275 } |
| 3278 | 3276 |
| 3279 | 3277 |
| 3280 v8::Handle<v8::Object> EventDetailsImpl::GetEventData() const { | 3278 v8::Local<v8::Object> EventDetailsImpl::GetEventData() const { |
| 3281 return v8::Utils::ToLocal(event_data_); | 3279 return v8::Utils::ToLocal(event_data_); |
| 3282 } | 3280 } |
| 3283 | 3281 |
| 3284 | 3282 |
| 3285 v8::Handle<v8::Context> EventDetailsImpl::GetEventContext() const { | 3283 v8::Local<v8::Context> EventDetailsImpl::GetEventContext() const { |
| 3286 return GetDebugEventContext(exec_state_->GetIsolate()); | 3284 return GetDebugEventContext(exec_state_->GetIsolate()); |
| 3287 } | 3285 } |
| 3288 | 3286 |
| 3289 | 3287 |
| 3290 v8::Handle<v8::Value> EventDetailsImpl::GetCallbackData() const { | 3288 v8::Local<v8::Value> EventDetailsImpl::GetCallbackData() const { |
| 3291 return v8::Utils::ToLocal(callback_data_); | 3289 return v8::Utils::ToLocal(callback_data_); |
| 3292 } | 3290 } |
| 3293 | 3291 |
| 3294 | 3292 |
| 3295 v8::Debug::ClientData* EventDetailsImpl::GetClientData() const { | 3293 v8::Debug::ClientData* EventDetailsImpl::GetClientData() const { |
| 3296 return client_data_; | 3294 return client_data_; |
| 3297 } | 3295 } |
| 3298 | 3296 |
| 3299 | 3297 |
| 3300 CommandMessage::CommandMessage() : text_(Vector<uint16_t>::empty()), | 3298 CommandMessage::CommandMessage() : text_(Vector<uint16_t>::empty()), |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3390 } | 3388 } |
| 3391 | 3389 |
| 3392 | 3390 |
| 3393 void LockingCommandMessageQueue::Clear() { | 3391 void LockingCommandMessageQueue::Clear() { |
| 3394 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 3392 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
| 3395 queue_.Clear(); | 3393 queue_.Clear(); |
| 3396 } | 3394 } |
| 3397 | 3395 |
| 3398 } // namespace internal | 3396 } // namespace internal |
| 3399 } // namespace v8 | 3397 } // namespace v8 |
| OLD | NEW |