Permalink
Browse files

module: fix --debug-brk on symlinked scripts

  • Loading branch information...
1 parent e806ad3 commit bff6e702a99ba270fa0ea84b240bd24bb1fd4035 @indutny committed Jan 24, 2012
Showing with 14 additions and 2 deletions.
  1. +14 −2 lib/module.js
View
@@ -360,6 +360,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;
@@ -427,8 +432,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);

0 comments on commit bff6e70

Please sign in to comment.