Skip to content

src,lib: minor --debug-brk cleanup #6599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/internal/bootstrap_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@

preloadModules();

if (global.v8debug &&
if (process._debugWaitConnect &&
process.execArgv.some(function(arg) {
return arg.match(/^--debug-brk(=[0-9]*)?$/);
})) {
Expand All @@ -149,7 +149,7 @@
// breakpoint message on line 1.
//
// A better fix would be to somehow get a message from the
// global.v8debug object about a connection, and runMain when
// V8 debug object about a connection, and runMain when
// that occurs. --isaacs

var debugTimeout = +process.env.NODE_DEBUG_TIMEOUT || 50;
Expand Down
14 changes: 6 additions & 8 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const NativeModule = require('native_module');
const util = require('util');
const internalModule = require('internal/module');
const internalUtil = require('internal/util');
const runInThisContext = require('vm').runInThisContext;
const vm = require('vm');
const assert = require('assert').ok;
const fs = require('fs');
const path = require('path');
Expand Down Expand Up @@ -508,13 +508,13 @@ Module.prototype._compile = function(content, filename) {
// create wrapper function
var wrapper = Module.wrap(content);

var compiledWrapper = runInThisContext(wrapper, {
var compiledWrapper = vm.runInThisContext(wrapper, {
filename: filename,
lineOffset: 0,
displayErrors: true
});

if (global.v8debug) {
if (process._debugWaitConnect) {
if (!resolvedArgv) {
// we enter the repl if we're not given a filename argument.
if (process.argv[1]) {
Expand All @@ -526,11 +526,9 @@ Module.prototype._compile = function(content, filename) {

// Set breakpoint on module start
if (filename === resolvedArgv) {
// Installing this dummy debug event listener tells V8 to start
// the debugger. Without it, the setBreakPoint() fails with an
// 'illegal access' error.
global.v8debug.Debug.setListener(function() {});
global.v8debug.Debug.setBreakPoint(compiledWrapper, 0, 0);
delete process._debugWaitConnect;
const Debug = vm.runInDebugContext('Debug');
Debug.setBreakPoint(compiledWrapper, 0, 0);
}
}
var dirname = path.dirname(filename);
Expand Down
10 changes: 5 additions & 5 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3179,6 +3179,11 @@ void SetupProcessObject(Environment* env,
READONLY_PROPERTY(process, "traceDeprecation", True(env->isolate()));
}

// --debug-brk
if (debug_wait_connect) {
READONLY_PROPERTY(process, "_debugWaitConnect", True(env->isolate()));
}

// --security-revert flags
#define V(code, _, __) \
do { \
Expand Down Expand Up @@ -4087,11 +4092,6 @@ void Init(int* argc,
exit(9);
}

if (debug_wait_connect) {
const char expose_debug_as[] = "--expose_debug_as=v8debug";
V8::SetFlagsFromString(expose_debug_as, sizeof(expose_debug_as) - 1);
}

// Unconditionally force typed arrays to allocate outside the v8 heap. This
// is to prevent memory pointers from being moved around that are returned by
// Buffer::Data().
Expand Down