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 8878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8889 } | 8889 } |
8890 | 8890 |
8891 | 8891 |
8892 // --- D e b u g S u p p o r t --- | 8892 // --- D e b u g S u p p o r t --- |
8893 | 8893 |
8894 bool Debug::SetDebugEventListener(Isolate* isolate, EventCallback that, | 8894 bool Debug::SetDebugEventListener(Isolate* isolate, EventCallback that, |
8895 Local<Value> data) { | 8895 Local<Value> data) { |
8896 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 8896 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
8897 ENTER_V8(i_isolate); | 8897 ENTER_V8(i_isolate); |
8898 i::HandleScope scope(i_isolate); | 8898 i::HandleScope scope(i_isolate); |
8899 i::Handle<i::Object> foreign = i_isolate->factory()->undefined_value(); | 8899 if (that == nullptr) { |
8900 if (that != NULL) { | 8900 i_isolate->debug()->SetDebugDelegate(nullptr, false); |
8901 foreign = i_isolate->factory()->NewForeign(FUNCTION_ADDR(that)); | 8901 } else { |
| 8902 i::Handle<i::Object> i_data = i_isolate->factory()->undefined_value(); |
| 8903 if (!data.IsEmpty()) i_data = Utils::OpenHandle(*data); |
| 8904 i::NativeDebugDelegate* delegate = |
| 8905 new i::NativeDebugDelegate(i_isolate, that, i_data); |
| 8906 i_isolate->debug()->SetDebugDelegate(delegate, true); |
8902 } | 8907 } |
8903 i_isolate->debug()->SetEventListener(foreign, Utils::OpenHandle(*data, true)); | |
8904 return true; | 8908 return true; |
8905 } | 8909 } |
8906 | 8910 |
8907 void Debug::DebugBreak(Isolate* isolate) { | 8911 void Debug::DebugBreak(Isolate* isolate) { |
8908 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->RequestDebugBreak(); | 8912 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->RequestDebugBreak(); |
8909 } | 8913 } |
8910 | 8914 |
8911 | 8915 |
8912 void Debug::CancelDebugBreak(Isolate* isolate) { | 8916 void Debug::CancelDebugBreak(Isolate* isolate) { |
8913 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 8917 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9346 has_pending_exception = result.is_null(); | 9350 has_pending_exception = result.is_null(); |
9347 RETURN_ON_FAILED_EXECUTION(UnboundScript); | 9351 RETURN_ON_FAILED_EXECUTION(UnboundScript); |
9348 } | 9352 } |
9349 RETURN_ESCAPED(ToApiHandle<UnboundScript>(result)); | 9353 RETURN_ESCAPED(ToApiHandle<UnboundScript>(result)); |
9350 } | 9354 } |
9351 | 9355 |
9352 void debug::SetDebugDelegate(Isolate* v8_isolate, | 9356 void debug::SetDebugDelegate(Isolate* v8_isolate, |
9353 debug::DebugDelegate* delegate) { | 9357 debug::DebugDelegate* delegate) { |
9354 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 9358 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
9355 ENTER_V8(isolate); | 9359 ENTER_V8(isolate); |
9356 isolate->debug()->SetDebugDelegate(delegate); | 9360 isolate->debug()->SetDebugDelegate(delegate, false); |
9357 } | 9361 } |
9358 | 9362 |
9359 void debug::ResetBlackboxedStateCache(Isolate* v8_isolate, | 9363 void debug::ResetBlackboxedStateCache(Isolate* v8_isolate, |
9360 v8::Local<debug::Script> script) { | 9364 v8::Local<debug::Script> script) { |
9361 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 9365 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
9362 ENTER_V8(isolate); | 9366 ENTER_V8(isolate); |
9363 i::DisallowHeapAllocation no_gc; | 9367 i::DisallowHeapAllocation no_gc; |
9364 i::SharedFunctionInfo::ScriptIterator iter(Utils::OpenHandle(*script)); | 9368 i::SharedFunctionInfo::ScriptIterator iter(Utils::OpenHandle(*script)); |
9365 while (i::SharedFunctionInfo* info = iter.Next()) { | 9369 while (i::SharedFunctionInfo* info = iter.Next()) { |
9366 info->set_computed_debug_is_blackboxed(false); | 9370 info->set_computed_debug_is_blackboxed(false); |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10136 Address callback_address = | 10140 Address callback_address = |
10137 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10141 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10138 VMState<EXTERNAL> state(isolate); | 10142 VMState<EXTERNAL> state(isolate); |
10139 ExternalCallbackScope call_scope(isolate, callback_address); | 10143 ExternalCallbackScope call_scope(isolate, callback_address); |
10140 callback(info); | 10144 callback(info); |
10141 } | 10145 } |
10142 | 10146 |
10143 | 10147 |
10144 } // namespace internal | 10148 } // namespace internal |
10145 } // namespace v8 | 10149 } // namespace v8 |
OLD | NEW |