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 "api.h" | 5 #include "api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #include <cmath> // For isnan. | 8 #include <cmath> // For isnan. |
9 #include "../include/v8-debug.h" | 9 #include "../include/v8-debug.h" |
10 #include "../include/v8-profiler.h" | 10 #include "../include/v8-profiler.h" |
(...skipping 6806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6817 ENTER_V8(isolate); | 6817 ENTER_V8(isolate); |
6818 isolate->debugger()->SetMessageHandler(handler); | 6818 isolate->debugger()->SetMessageHandler(handler); |
6819 } | 6819 } |
6820 | 6820 |
6821 | 6821 |
6822 void Debug::SendCommand(Isolate* isolate, | 6822 void Debug::SendCommand(Isolate* isolate, |
6823 const uint16_t* command, | 6823 const uint16_t* command, |
6824 int length, | 6824 int length, |
6825 ClientData* client_data) { | 6825 ClientData* client_data) { |
6826 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6826 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6827 internal_isolate->debugger()->ProcessCommand( | 6827 internal_isolate->debugger()->EnqueueCommandMessage( |
6828 i::Vector<const uint16_t>(command, length), client_data); | 6828 i::Vector<const uint16_t>(command, length), client_data); |
6829 } | 6829 } |
6830 | 6830 |
6831 | 6831 |
6832 void Debug::SetDebugMessageDispatchHandler( | |
6833 DebugMessageDispatchHandler handler, bool provide_locker) { | |
6834 i::Isolate* isolate = i::Isolate::Current(); | |
6835 EnsureInitializedForIsolate(isolate, | |
6836 "v8::Debug::SetDebugMessageDispatchHandler"); | |
6837 ENTER_V8(isolate); | |
6838 isolate->debugger()->SetDebugMessageDispatchHandler( | |
6839 handler, provide_locker); | |
6840 } | |
6841 | |
6842 | |
6843 Local<Value> Debug::Call(v8::Handle<v8::Function> fun, | 6832 Local<Value> Debug::Call(v8::Handle<v8::Function> fun, |
6844 v8::Handle<v8::Value> data) { | 6833 v8::Handle<v8::Value> data) { |
6845 i::Isolate* isolate = i::Isolate::Current(); | 6834 i::Isolate* isolate = i::Isolate::Current(); |
6846 if (!isolate->IsInitialized()) return Local<Value>(); | 6835 if (!isolate->IsInitialized()) return Local<Value>(); |
6847 ON_BAILOUT(isolate, "v8::Debug::Call()", return Local<Value>()); | 6836 ON_BAILOUT(isolate, "v8::Debug::Call()", return Local<Value>()); |
6848 ENTER_V8(isolate); | 6837 ENTER_V8(isolate); |
6849 i::MaybeHandle<i::Object> maybe_result; | 6838 i::MaybeHandle<i::Object> maybe_result; |
6850 EXCEPTION_PREAMBLE(isolate); | 6839 EXCEPTION_PREAMBLE(isolate); |
6851 if (data.IsEmpty()) { | 6840 if (data.IsEmpty()) { |
6852 maybe_result = isolate->debugger()->Call( | 6841 maybe_result = isolate->debugger()->Call( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6884 const int kArgc = 1; | 6873 const int kArgc = 1; |
6885 v8::Handle<v8::Value> argv[kArgc] = { obj }; | 6874 v8::Handle<v8::Value> argv[kArgc] = { obj }; |
6886 result = v8_fun->Call(Utils::ToLocal(debug), kArgc, argv); | 6875 result = v8_fun->Call(Utils::ToLocal(debug), kArgc, argv); |
6887 has_pending_exception = result.IsEmpty(); | 6876 has_pending_exception = result.IsEmpty(); |
6888 } | 6877 } |
6889 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 6878 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
6890 return scope.Escape(result); | 6879 return scope.Escape(result); |
6891 } | 6880 } |
6892 | 6881 |
6893 | 6882 |
6894 bool Debug::EnableAgent(const char* name, int port, bool wait_for_connection) { | |
6895 return i::Isolate::Current()->debugger()->StartAgent(name, port, | |
6896 wait_for_connection); | |
6897 } | |
6898 | |
6899 | |
6900 void Debug::DisableAgent() { | |
6901 return i::Isolate::Current()->debugger()->StopAgent(); | |
6902 } | |
6903 | |
6904 | |
6905 void Debug::ProcessDebugMessages() { | 6883 void Debug::ProcessDebugMessages() { |
6906 i::Execution::ProcessDebugMessages(i::Isolate::Current(), true); | 6884 i::Execution::ProcessDebugMessages(i::Isolate::Current(), true); |
6907 } | 6885 } |
6908 | 6886 |
6909 | 6887 |
6910 Local<Context> Debug::GetDebugContext() { | 6888 Local<Context> Debug::GetDebugContext() { |
6911 i::Isolate* isolate = i::Isolate::Current(); | 6889 i::Isolate* isolate = i::Isolate::Current(); |
6912 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()"); | 6890 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()"); |
6913 ENTER_V8(isolate); | 6891 ENTER_V8(isolate); |
6914 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext()); | 6892 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext()); |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7563 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7541 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7564 Address callback_address = | 7542 Address callback_address = |
7565 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7543 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7566 VMState<EXTERNAL> state(isolate); | 7544 VMState<EXTERNAL> state(isolate); |
7567 ExternalCallbackScope call_scope(isolate, callback_address); | 7545 ExternalCallbackScope call_scope(isolate, callback_address); |
7568 callback(info); | 7546 callback(info); |
7569 } | 7547 } |
7570 | 7548 |
7571 | 7549 |
7572 } } // namespace v8::internal | 7550 } } // namespace v8::internal |
OLD | NEW |