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/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 8894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8905 } | 8905 } |
8906 | 8906 |
8907 | 8907 |
8908 // --- D e b u g S u p p o r t --- | 8908 // --- D e b u g S u p p o r t --- |
8909 | 8909 |
8910 bool Debug::SetDebugEventListener(Isolate* isolate, EventCallback that, | 8910 bool Debug::SetDebugEventListener(Isolate* isolate, EventCallback that, |
8911 Local<Value> data) { | 8911 Local<Value> data) { |
8912 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 8912 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
8913 ENTER_V8(i_isolate); | 8913 ENTER_V8(i_isolate); |
8914 i::HandleScope scope(i_isolate); | 8914 i::HandleScope scope(i_isolate); |
8915 i::Handle<i::Object> foreign = i_isolate->factory()->undefined_value(); | 8915 if (that == nullptr) { |
8916 if (that != NULL) { | 8916 i_isolate->debug()->SetDebugDelegate(nullptr, false); |
8917 foreign = i_isolate->factory()->NewForeign(FUNCTION_ADDR(that)); | 8917 } else { |
| 8918 i::Handle<i::Object> i_data = i_isolate->factory()->undefined_value(); |
| 8919 if (!data.IsEmpty()) i_data = Utils::OpenHandle(*data); |
| 8920 i::NativeDebugDelegate* delegate = |
| 8921 new i::NativeDebugDelegate(i_isolate, that, i_data); |
| 8922 i_isolate->debug()->SetDebugDelegate(delegate, true); |
8918 } | 8923 } |
8919 i_isolate->debug()->SetEventListener(foreign, Utils::OpenHandle(*data, true)); | |
8920 return true; | 8924 return true; |
8921 } | 8925 } |
8922 | 8926 |
8923 void Debug::DebugBreak(Isolate* isolate) { | 8927 void Debug::DebugBreak(Isolate* isolate) { |
8924 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->RequestDebugBreak(); | 8928 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->RequestDebugBreak(); |
8925 } | 8929 } |
8926 | 8930 |
8927 | 8931 |
8928 void Debug::CancelDebugBreak(Isolate* isolate) { | 8932 void Debug::CancelDebugBreak(Isolate* isolate) { |
8929 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 8933 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9362 has_pending_exception = result.is_null(); | 9366 has_pending_exception = result.is_null(); |
9363 RETURN_ON_FAILED_EXECUTION(UnboundScript); | 9367 RETURN_ON_FAILED_EXECUTION(UnboundScript); |
9364 } | 9368 } |
9365 RETURN_ESCAPED(ToApiHandle<UnboundScript>(result)); | 9369 RETURN_ESCAPED(ToApiHandle<UnboundScript>(result)); |
9366 } | 9370 } |
9367 | 9371 |
9368 void debug::SetDebugDelegate(Isolate* v8_isolate, | 9372 void debug::SetDebugDelegate(Isolate* v8_isolate, |
9369 debug::DebugDelegate* delegate) { | 9373 debug::DebugDelegate* delegate) { |
9370 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 9374 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
9371 ENTER_V8(isolate); | 9375 ENTER_V8(isolate); |
9372 isolate->debug()->SetDebugDelegate(delegate); | 9376 isolate->debug()->SetDebugDelegate(delegate, false); |
9373 } | 9377 } |
9374 | 9378 |
9375 void debug::ResetBlackboxedStateCache(Isolate* v8_isolate, | 9379 void debug::ResetBlackboxedStateCache(Isolate* v8_isolate, |
9376 v8::Local<debug::Script> script) { | 9380 v8::Local<debug::Script> script) { |
9377 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 9381 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
9378 ENTER_V8(isolate); | 9382 ENTER_V8(isolate); |
9379 i::DisallowHeapAllocation no_gc; | 9383 i::DisallowHeapAllocation no_gc; |
9380 i::SharedFunctionInfo::ScriptIterator iter(Utils::OpenHandle(*script)); | 9384 i::SharedFunctionInfo::ScriptIterator iter(Utils::OpenHandle(*script)); |
9381 while (i::SharedFunctionInfo* info = iter.Next()) { | 9385 while (i::SharedFunctionInfo* info = iter.Next()) { |
9382 info->set_computed_debug_is_blackboxed(false); | 9386 info->set_computed_debug_is_blackboxed(false); |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10152 Address callback_address = | 10156 Address callback_address = |
10153 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10157 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10154 VMState<EXTERNAL> state(isolate); | 10158 VMState<EXTERNAL> state(isolate); |
10155 ExternalCallbackScope call_scope(isolate, callback_address); | 10159 ExternalCallbackScope call_scope(isolate, callback_address); |
10156 callback(info); | 10160 callback(info); |
10157 } | 10161 } |
10158 | 10162 |
10159 | 10163 |
10160 } // namespace internal | 10164 } // namespace internal |
10161 } // namespace v8 | 10165 } // namespace v8 |
OLD | NEW |