Reviewers: sgjesse_chomium.org,
Description:
Expose debug context into the native code. This change is doing several
things:
1) Exposes Local<Context> v8::Debug::GetDebugContext().
Rationale: We can already get debugger context instance using various
workarounds,
so exposing it explicitly in the API only makes things more clear.
2) Removes debugger.HasJavaScriptFrames() requirement for entering debugger
context.
Rationale: Sometimes we'd like to call into debugger from the external
native
code.
3) Makes Debugger v8::Debug::Call execute on debugger context's global
object.
Rationale: This is somewhat arguable, but temporary measure. We've agreed
that we
should introduce a DebugAPI object that would expose necessary API in the
debug-delay.
The problem is that it would take some time to define this API and it is
not
really
convenient to do that on the v8 land given the difference in v8 / host
lifecycle.
The plan is to compose this API as a Debug.* wrapper outside v8 by means
of
exposing
debugger context's global object here, and once API settles down,
upstream it
to v8 and
start making Debug::Calls on this new DebugAPI object instead.
Please review this at http://codereview.chromium.org/1025004
SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/
Affected files:
M include/v8-debug.h
M src/api.cc
M src/debug.cc
Index: src/api.cc
===================================================================
--- src/api.cc (revision 4167)
+++ src/api.cc (working copy)
@@ -3928,6 +3928,11 @@
i::Execution::ProcessDebugMesssages(true);
}
+Local<Context> Debug::GetDebugContext() {
+ i::EnterDebugger debugger;
+ return Utils::ToLocal(i::Debug::debug_context());
+}
+
#endif // ENABLE_DEBUGGER_SUPPORT
namespace internal {
Index: src/debug.cc
===================================================================
--- src/debug.cc (revision 4167)
+++ src/debug.cc (working copy)
@@ -2476,7 +2476,7 @@
// Enter the debugger.
EnterDebugger debugger;
- if (debugger.FailedToEnter() || !debugger.HasJavaScriptFrames()) {
+ if (debugger.FailedToEnter()) {
return Factory::undefined_value();
}
@@ -2489,8 +2489,12 @@
static const int kArgc = 2;
Object** argv[kArgc] = { exec_state.location(), data.location() };
- Handle<Object> result = Execution::Call(fun, Factory::undefined_value(),
- kArgc, argv, pending_exception);
+ Handle<Object> result = Execution::Call(
+ fun,
+ Handle<Object>(Debug::debug_context_->global()),
+ kArgc,
+ argv,
+ pending_exception);
return result;
}
Index: include/v8-debug.h
===================================================================
--- include/v8-debug.h (revision 4167)
+++ include/v8-debug.h (working copy)
@@ -302,6 +302,13 @@
* of this method.
*/
static void ProcessDebugMessages();
+
+ /**
+ * Debugger is running in it's own context which is entered while
debugger
+ * messages are being dispatched. This is an explicit getter for this
+ * debugger context.
+ */
+ static Local<Context> GetDebugContext();
};
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev