OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 7248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7259 } | 7259 } |
7260 i::Handle<i::Object> result(error, isolate); | 7260 i::Handle<i::Object> result(error, isolate); |
7261 return Utils::ToLocal(result); | 7261 return Utils::ToLocal(result); |
7262 } | 7262 } |
7263 | 7263 |
7264 | 7264 |
7265 // --- D e b u g S u p p o r t --- | 7265 // --- D e b u g S u p p o r t --- |
7266 | 7266 |
7267 #ifdef ENABLE_DEBUGGER_SUPPORT | 7267 #ifdef ENABLE_DEBUGGER_SUPPORT |
7268 | 7268 |
7269 static void EventCallbackWrapper(const v8::Debug::EventDetails& event_details) { | |
7270 i::Isolate* isolate = i::Isolate::Current(); | |
7271 if (isolate->debug_event_callback() != NULL) { | |
7272 isolate->debug_event_callback()(event_details.GetEvent(), | |
7273 event_details.GetExecutionState(), | |
7274 event_details.GetEventData(), | |
7275 event_details.GetCallbackData()); | |
7276 } | |
7277 } | |
7278 | |
7279 | |
7280 bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) { | |
7281 i::Isolate* isolate = i::Isolate::Current(); | |
7282 EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener()"); | |
7283 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false); | |
7284 ENTER_V8(isolate); | |
7285 | |
7286 isolate->set_debug_event_callback(that); | |
7287 | |
7288 i::HandleScope scope(isolate); | |
7289 i::Handle<i::Object> foreign = isolate->factory()->undefined_value(); | |
7290 if (that != NULL) { | |
7291 foreign = | |
7292 isolate->factory()->NewForeign(FUNCTION_ADDR(EventCallbackWrapper)); | |
7293 } | |
7294 isolate->debugger()->SetEventListener(foreign, | |
7295 Utils::OpenHandle(*data, true)); | |
7296 return true; | |
7297 } | |
7298 | |
7299 | |
7300 bool Debug::SetDebugEventListener2(EventCallback2 that, Handle<Value> data) { | 7269 bool Debug::SetDebugEventListener2(EventCallback2 that, Handle<Value> data) { |
7301 i::Isolate* isolate = i::Isolate::Current(); | 7270 i::Isolate* isolate = i::Isolate::Current(); |
7302 EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener2()"); | 7271 EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener2()"); |
7303 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener2()", return false); | 7272 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener2()", return false); |
7304 ENTER_V8(isolate); | 7273 ENTER_V8(isolate); |
7305 i::HandleScope scope(isolate); | 7274 i::HandleScope scope(isolate); |
7306 i::Handle<i::Object> foreign = isolate->factory()->undefined_value(); | 7275 i::Handle<i::Object> foreign = isolate->factory()->undefined_value(); |
7307 if (that != NULL) { | 7276 if (that != NULL) { |
7308 foreign = isolate->factory()->NewForeign(FUNCTION_ADDR(that)); | 7277 foreign = isolate->factory()->NewForeign(FUNCTION_ADDR(that)); |
7309 } | 7278 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7349 // If no isolate is supplied, use the default isolate. | 7318 // If no isolate is supplied, use the default isolate. |
7350 if (isolate != NULL) { | 7319 if (isolate != NULL) { |
7351 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7320 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
7352 internal_isolate->debugger()->EnqueueDebugCommand(data); | 7321 internal_isolate->debugger()->EnqueueDebugCommand(data); |
7353 } else { | 7322 } else { |
7354 i::Isolate::GetDefaultIsolateDebugger()->EnqueueDebugCommand(data); | 7323 i::Isolate::GetDefaultIsolateDebugger()->EnqueueDebugCommand(data); |
7355 } | 7324 } |
7356 } | 7325 } |
7357 | 7326 |
7358 | 7327 |
7359 static void MessageHandlerWrapper(const v8::Debug::Message& message) { | |
7360 i::Isolate* isolate = i::Isolate::Current(); | |
7361 if (isolate->message_handler()) { | |
7362 v8::String::Value json(message.GetJSON()); | |
7363 (isolate->message_handler())(*json, json.length(), message.GetClientData()); | |
7364 } | |
7365 } | |
7366 | |
7367 | |
7368 void Debug::SetMessageHandler(v8::Debug::MessageHandler handler, | |
7369 bool message_handler_thread) { | |
7370 i::Isolate* isolate = i::Isolate::Current(); | |
7371 EnsureInitializedForIsolate(isolate, "v8::Debug::SetMessageHandler"); | |
7372 ENTER_V8(isolate); | |
7373 | |
7374 // Message handler thread not supported any more. Parameter temporally left in | |
7375 // the API for client compatibility reasons. | |
7376 CHECK(!message_handler_thread); | |
7377 | |
7378 // TODO(sgjesse) support the old message handler API through a simple wrapper. | |
7379 isolate->set_message_handler(handler); | |
7380 if (handler != NULL) { | |
7381 isolate->debugger()->SetMessageHandler(MessageHandlerWrapper); | |
7382 } else { | |
7383 isolate->debugger()->SetMessageHandler(NULL); | |
7384 } | |
7385 } | |
7386 | |
7387 | |
7388 void Debug::SetMessageHandler2(v8::Debug::MessageHandler2 handler) { | 7328 void Debug::SetMessageHandler2(v8::Debug::MessageHandler2 handler) { |
7389 i::Isolate* isolate = i::Isolate::Current(); | 7329 i::Isolate* isolate = i::Isolate::Current(); |
7390 EnsureInitializedForIsolate(isolate, "v8::Debug::SetMessageHandler"); | 7330 EnsureInitializedForIsolate(isolate, "v8::Debug::SetMessageHandler"); |
7391 ENTER_V8(isolate); | 7331 ENTER_V8(isolate); |
7392 isolate->debugger()->SetMessageHandler(handler); | 7332 isolate->debugger()->SetMessageHandler(handler); |
7393 } | 7333 } |
7394 | 7334 |
7395 | 7335 |
7396 void Debug::SendCommand(const uint16_t* command, int length, | 7336 void Debug::SendCommand(const uint16_t* command, int length, |
7397 ClientData* client_data, | 7337 ClientData* client_data, |
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8228 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8168 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
8229 Address callback_address = | 8169 Address callback_address = |
8230 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8170 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8231 VMState<EXTERNAL> state(isolate); | 8171 VMState<EXTERNAL> state(isolate); |
8232 ExternalCallbackScope call_scope(isolate, callback_address); | 8172 ExternalCallbackScope call_scope(isolate, callback_address); |
8233 return callback(info); | 8173 return callback(info); |
8234 } | 8174 } |
8235 | 8175 |
8236 | 8176 |
8237 } } // namespace v8::internal | 8177 } } // namespace v8::internal |
OLD | NEW |