| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/gavin/workspace/happymandarin/node_modules/v8-debug/src/ |
Upload File : |
#include <v8-debug.h>
#include <nan.h>
#include "tools.h"
#if (NODE_NEXT)
#include "InjectedScriptHost.h"
#endif
using v8::Isolate;
using v8::Local;
using v8::Value;
using v8::String;
using v8::Object;
using v8::Context;
using v8::Function;
using Nan::To;
using Nan::New;
using Nan::Set;
using Nan::SetMethod;
using Nan::HandleScope;
using Nan::Undefined;
using Nan::TryCatch;
using Nan::ThrowError;
using Nan::RunScript;
using Nan::MaybeLocal;
namespace nodex {
class Debug {
public:
static NAN_METHOD(Call) {
if (info.Length() < 1) {
return ThrowError("Error");
}
Local<Function> fn = Local<Function>::Cast(info[0]);
v8::Debug::Call(fn);
RETURN(Undefined());
};
static NAN_METHOD(SendCommand) {
String::Value command(info[0]);
#if (NODE_MODULE_VERSION > 11)
Isolate* debug_isolate = v8::Debug::GetDebugContext()->GetIsolate();
v8::HandleScope debug_scope(debug_isolate);
v8::Debug::SendCommand(debug_isolate, *command, command.length());
#else
v8::Debug::SendCommand(*command, command.length());
#endif
RETURN(Undefined());
};
static NAN_METHOD(RunScript) {
Local<String> expression = CHK(To<String>(info[0]));
if (expression.IsEmpty())
RETURN(Undefined());
Local<Context> debug_context = v8::Debug::GetDebugContext();
#if (NODE_MODULE_VERSION > 45)
if (debug_context.IsEmpty()) {
// Force-load the debug context.
v8::Debug::GetMirror(info.GetIsolate()->GetCurrentContext(), info[0]);
debug_context = v8::Debug::GetDebugContext();
}
#endif
Context::Scope context_scope(debug_context);
TryCatch tryCatch;
MaybeLocal<Value> result;
RUNSCRIPT(expression, result);
MAYBE_RETHROW();
RETURN(CHK(result));
};
static NAN_METHOD(AllowNatives) {
const char allow_natives_syntax[] = "--allow_natives_syntax";
v8::V8::SetFlagsFromString(allow_natives_syntax, sizeof(allow_natives_syntax) - 1);
RETURN(Undefined());
}
private:
Debug() {}
~Debug() {}
};
NAN_MODULE_INIT(Initialize) {
#if (NODE_NEXT)
InjectedScriptHost::Initialize(target);
#endif
SetMethod(target, "call", Debug::Call);
SetMethod(target, "sendCommand", Debug::SendCommand);
SetMethod(target, "runScript", Debug::RunScript);
SetMethod(target, "allowNatives", Debug::AllowNatives);
}
NODE_MODULE(debug, Initialize)
}