|
@@ -27,6 +27,7 @@ extern "C" {
|
|
|
|
|
|
#include "php_v8js_macros.h"
|
|
|
#include "v8js_v8.h"
|
|
|
+#include "v8js_debug.h"
|
|
|
#include "v8js_exceptions.h"
|
|
|
#include "v8js_v8object_class.h"
|
|
|
#include "v8js_timer.h"
|
|
@@ -64,10 +65,6 @@ struct v8js_jsext {
|
|
|
};
|
|
|
/* }}} */
|
|
|
|
|
|
-#ifdef ENABLE_DEBUGGER_SUPPORT
|
|
|
-static v8js_ctx *v8js_debug_context;
|
|
|
-static int v8js_debug_auto_break_mode;
|
|
|
-#endif
|
|
|
|
|
|
static void v8js_free_storage(void *object TSRMLS_DC) /* {{{ */
|
|
|
{
|
|
@@ -276,25 +273,6 @@ static void v8js_fatal_error_handler(const char *location, const char *message)
|
|
|
}
|
|
|
/* }}} */
|
|
|
|
|
|
-#ifdef ENABLE_DEBUGGER_SUPPORT
|
|
|
-static void DispatchDebugMessages() { /* {{{ */
|
|
|
- if(v8js_debug_context == NULL) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- v8::Isolate* isolate = v8js_debug_context->isolate;
|
|
|
- v8::Isolate::Scope isolate_scope(isolate);
|
|
|
-
|
|
|
- v8::HandleScope handle_scope(isolate);
|
|
|
- v8::Local<v8::Context> context =
|
|
|
- v8::Local<v8::Context>::New(isolate, v8js_debug_context->context);
|
|
|
- v8::Context::Scope scope(context);
|
|
|
-
|
|
|
- v8::Debug::ProcessDebugMessages();
|
|
|
-}
|
|
|
-/* }}} */
|
|
|
-#endif /* ENABLE_DEBUGGER_SUPPORT */
|
|
|
-
|
|
|
/* {{{ proto void V8Js::__construct([string object_name [, array variables [, array extensions [, bool report_uncaught_exceptions]]])
|
|
|
__construct for V8Js */
|
|
|
static PHP_METHOD(V8Js, __construct)
|
|
@@ -616,74 +594,6 @@ static PHP_METHOD(V8Js, checkString)
|
|
|
}
|
|
|
/* }}} */
|
|
|
|
|
|
-
|
|
|
-#ifdef ENABLE_DEBUGGER_SUPPORT
|
|
|
-/* {{{ proto void V8Js::__destruct()
|
|
|
- __destruct for V8Js */
|
|
|
-static PHP_METHOD(V8Js, __destruct)
|
|
|
-{
|
|
|
- v8js_ctx *c = (v8js_ctx *) zend_object_store_get_object(getThis() TSRMLS_CC);
|
|
|
-
|
|
|
- if(!c->isolate) {
|
|
|
- /* c->isolate is initialized by __construct, which wasn't called if this
|
|
|
- * instance was deserialized (which we already caught in __wakeup). */
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- V8JS_CTX_PROLOGUE(c);
|
|
|
- if(v8js_debug_context == c) {
|
|
|
- v8::Debug::DisableAgent();
|
|
|
- v8js_debug_context = NULL;
|
|
|
- }
|
|
|
-}
|
|
|
-/* }}} */
|
|
|
-
|
|
|
-/* {{{ proto bool V8Js::startDebugAgent(string agent_name[, int port[, int auto_break]])
|
|
|
- */
|
|
|
-static PHP_METHOD(V8Js, startDebugAgent)
|
|
|
-{
|
|
|
- char *str = NULL;
|
|
|
- int str_len = 0;
|
|
|
- long port = 0, auto_break = 0;
|
|
|
-
|
|
|
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sll", &str, &str_len, &port, &auto_break) == FAILURE) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if(!port) {
|
|
|
- port = 9222;
|
|
|
- }
|
|
|
-
|
|
|
- V8JS_BEGIN_CTX(c, getThis());
|
|
|
-
|
|
|
- if(v8js_debug_context == c) {
|
|
|
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Debug agent already started for this V8Js instance");
|
|
|
- RETURN_BOOL(0);
|
|
|
- }
|
|
|
-
|
|
|
- if(v8js_debug_context != NULL) {
|
|
|
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Debug agent already started for a different V8Js instance");
|
|
|
- RETURN_BOOL(0);
|
|
|
- }
|
|
|
-
|
|
|
- v8js_debug_context = c;
|
|
|
- v8js_debug_auto_break_mode = auto_break;
|
|
|
-
|
|
|
- v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessages, true);
|
|
|
- v8::Debug::EnableAgent(str_len ? str : "V8Js", port, auto_break > 0);
|
|
|
-
|
|
|
- if(auto_break) {
|
|
|
- /* v8::Debug::EnableAgent doesn't really do what we want it to do,
|
|
|
- since it only breaks processing on the default isolate.
|
|
|
- Hence just trigger another DebugBreak, no for our main isolate. */
|
|
|
- v8::Debug::DebugBreak(c->isolate);
|
|
|
- }
|
|
|
-
|
|
|
- RETURN_BOOL(1);
|
|
|
-}
|
|
|
-/* }}} */
|
|
|
-#endif /* ENABLE_DEBUGGER_SUPPORT */
|
|
|
-
|
|
|
/* {{{ proto mixed V8Js::getPendingException()
|
|
|
*/
|
|
|
static PHP_METHOD(V8Js, getPendingException)
|