Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
module: fix --debug-brk on symlinked scripts
Browse files Browse the repository at this point in the history
* fixes #1519
  • Loading branch information
indutny authored and piscisaureus committed Jan 24, 2012
1 parent 2775c0e commit ccf7b41
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/module.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ccf7b41

Please sign in to comment.