Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: src/api.cc

Issue 2537313005: [debug] Revert debug API removal (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 6ab8c72d8c05fa530d7f1c86fe6b3c3d5c17f112..b8210986f6a00540fcd3c4d20e3b966e268f93ec 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -8734,7 +8734,9 @@ bool Debug::CheckDebugBreak(Isolate* isolate) {
void Debug::SetMessageHandler(Isolate* isolate,
v8::Debug::MessageHandler handler) {
- UNIMPLEMENTED();
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ ENTER_V8(i_isolate);
+ i_isolate->debug()->SetMessageHandler(handler);
}
@@ -8742,7 +8744,9 @@ void Debug::SendCommand(Isolate* isolate,
const uint16_t* command,
int length,
ClientData* client_data) {
- UNIMPLEMENTED();
+ i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ internal_isolate->debug()->EnqueueCommandMessage(
+ i::Vector<const uint16_t>(command, length), client_data);
}
@@ -8767,11 +8771,28 @@ MaybeLocal<Value> Debug::Call(Local<Context> context,
MaybeLocal<Value> Debug::GetMirror(Local<Context> context,
v8::Local<v8::Value> obj) {
- UNIMPLEMENTED();
- return MaybeLocal<Value>();
+ PREPARE_FOR_EXECUTION(context, Debug, GetMirror, Value);
+ i::Debug* isolate_debug = isolate->debug();
+ has_pending_exception = !isolate_debug->Load();
+ RETURN_ON_FAILED_EXECUTION(Value);
+ i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object());
+ auto name = isolate->factory()->NewStringFromStaticChars("MakeMirror");
+ auto fun_obj = i::JSReceiver::GetProperty(debug, name).ToHandleChecked();
+ auto v8_fun = Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(fun_obj));
+ const int kArgc = 1;
+ v8::Local<v8::Value> argv[kArgc] = {obj};
+ Local<Value> result;
+ has_pending_exception =
+ !v8_fun->Call(context, Utils::ToLocal(debug), kArgc, argv)
+ .ToLocal(&result);
+ RETURN_ON_FAILED_EXECUTION(Value);
+ RETURN_ESCAPED(result);
+}
+
+void Debug::ProcessDebugMessages(Isolate* isolate) {
+ reinterpret_cast<i::Isolate*>(isolate)->debug()->ProcessDebugMessages(true);
}
-void Debug::ProcessDebugMessages(Isolate* isolate) { UNIMPLEMENTED(); }
Local<Context> Debug::GetDebugContext(Isolate* isolate) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
@@ -8781,8 +8802,12 @@ Local<Context> Debug::GetDebugContext(Isolate* isolate) {
MaybeLocal<Context> Debug::GetDebuggedContext(Isolate* isolate) {
- UNIMPLEMENTED();
- return MaybeLocal<Context>();
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ ENTER_V8(i_isolate);
+ if (!i_isolate->debug()->in_debug_scope()) return MaybeLocal<Context>();
+ i::Handle<i::Object> calling = i_isolate->GetCallingNativeContext();
+ if (calling.is_null()) return MaybeLocal<Context>();
+ return Utils::ToLocal(i::Handle<i::Context>::cast(calling));
}
void Debug::SetLiveEditEnabled(Isolate* isolate, bool enable) {

Powered by Google App Engine
This is Rietveld 408576698