diff options
author | Ali Ijaz Sheikh <ofrobots@google.com> | 2016-05-05 17:31:34 +0200 |
---|---|---|
committer | Ali Ijaz Sheikh <ofrobots@google.com> | 2016-05-07 05:23:47 +0200 |
commit | 4d4cfb27ca7718c7df381ac3b257175927cd17d1 (patch) | |
tree | d9fbf87325c7ea35f4e8da5473086b56b871d481 /lib/module.js | |
parent | 5d0b1f4ffa194b65b5320dfc6889ca0b17db2168 (diff) | |
download | android-node-v8-4d4cfb27ca7718c7df381ac3b257175927cd17d1.tar.gz android-node-v8-4d4cfb27ca7718c7df381ac3b257175927cd17d1.tar.bz2 android-node-v8-4d4cfb27ca7718c7df381ac3b257175927cd17d1.zip |
src,lib: minor --debug-brk cleanup
Minor cleanup of how --debug-brk works:
* We no longer need to use command line flags to expose the debug
object.
* Do not depend on the existence of global.v8debug as a mechanism to
determine if --debug-brk was specified.
* We no longer need to set a dummy listener with --debug-brk.
PR-URL: https://github.com/nodejs/node/pull/6599
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'lib/module.js')
-rw-r--r-- | lib/module.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/module.js b/lib/module.js index fb233d6c45..344ea97af9 100644 --- a/lib/module.js +++ b/lib/module.js @@ -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'); @@ -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]) { @@ -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); |