diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2012-01-24 20:45:34 +0400 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2012-01-24 22:07:38 +0400 |
commit | ccf7b41a69a8037f721a3eb495c2a82a53613634 (patch) | |
tree | 00beb60b0aa98a37f357b66595b7ed0c454b5dd7 /lib | |
parent | 2775c0e97ebdeed64743e4f56741118fdcfd8dda (diff) |
module: fix --debug-brk on symlinked scripts
* fixes #1519
Diffstat (limited to 'lib')
-rw-r--r-- | lib/module.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/module.js b/lib/module.js index a5963545b8d..da67ef65d26 100644 --- a/lib/module.js +++ b/lib/module.js @@ -358,6 +358,11 @@ Module.prototype.require = function(path) { }; +// Resolved path to process.argv[1] will be lazily placed here +// (needed for setting breakpoint when called with --debug-brk) +var resolvedArgv; + + // Returns exception if any Module.prototype._compile = function(content, filename) { var self = this; @@ -425,8 +430,15 @@ Module.prototype._compile = function(content, filename) { var wrapper = Module.wrap(content); var compiledWrapper = runInThisContext(wrapper, filename, true); - if (filename === process.argv[1] && global.v8debug) { - global.v8debug.Debug.setBreakPoint(compiledWrapper, 0, 0); + if (global.v8debug) { + if (!resolvedArgv) { + resolvedArgv = Module._resolveFilename(process.argv[1], null)[1]; + } + + // Set breakpoint on module start + if (filename === resolvedArgv) { + global.v8debug.Debug.setBreakPoint(compiledWrapper, 0, 0); + } } var args = [self.exports, require, self, filename, dirname]; return compiledWrapper.apply(self.exports, args); |