Browse files

module: fix --debug-brk on symlinked scripts

* fixes #1519
  • Loading branch information...
1 parent 2775c0e commit ccf7b41a69a8037f721a3eb495c2a82a53613634 @indutny indutny committed with piscisaureus Jan 24, 2012
Showing with 14 additions and 2 deletions.
  1. +14 −2 lib/module.js
View
16 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);

0 comments on commit ccf7b41

Please sign in to comment.