Skip to content
Browse files

added custom-debug source

  • Loading branch information...
1 parent 039bfc9 commit 12423750009d8e5e07aa01eabe69923165c8215d @bobrik committed Sep 23, 2011
Showing with 53 additions and 0 deletions.
  1. +16 −0 custom-debug.js
  2. +37 −0 src/debugger.cc
View
16 custom-debug.js
@@ -0,0 +1,16 @@
+var debug = require("./build/default/debugger");
+
+var started = false;
+
+exports.start = function(port) {
+ if (!started) {
+ started = true;
+ return debug.start(port);
+ }
+
+ return false;
+}
+
+exports.isStarted = function() {
+ return started;
+}
View
37 src/debugger.cc
@@ -0,0 +1,37 @@
+#include <node.h>
+#include <v8.h>
+#include <v8-debug.h>
+
+using namespace node;
+using namespace v8;
+
+
+class StaticDebugger {
+ public:
+ static void
+ Initialize(Handle<Object> target) {
+ HandleScope scope;
+
+ NODE_SET_METHOD(target, "start", Start);
+ }
+
+ static Handle<Value>
+ Start(const Arguments &args) {
+ int port = args[0]->Int32Value();
+
+ if (port > 1024 && port < 65546) {
+ return Boolean::New(v8::Debug::EnableAgent("node custom debugger", port));
+ } else {
+ return ThrowException(Exception::Error(String::New("Invalid port")));
+ }
+ }
+};
+
+
+extern "C" void
+init (Handle<Object> target)
+{
+ HandleScope scope;
+
+ StaticDebugger::Initialize(target);
+}

0 comments on commit 1242375

Please sign in to comment.
Something went wrong with that request. Please try again.