From 01349bbd70985ba80771a32ed428ffe907b0c42d Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Fri, 9 Sep 2011 02:33:28 +0700 Subject: [PATCH] [debugger] added synonyms for run, cont, next, step, out, shorten breakpoint message and do not output explicit debug> on breaks --- lib/_debugger.js | 68 +++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/lib/_debugger.js b/lib/_debugger.js index 1c5ea6d35b8..be5d946590e 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -649,14 +649,26 @@ function Interface() { var proto = Interface.prototype, ignored = ['pause', 'resume', 'exitRepl', 'handleBreak', 'requireConnection', 'killChild', 'trySpawn', - 'controlEval', 'debugEval']; + 'controlEval', 'debugEval'], + synonym = { + 'run': 'r', + 'cont': 'c', + 'next': 'n', + 'step': 's', + 'out': 'o' + }; + + function defineProperty(key, protoKey) { + Object.defineProperty(self.repl.context, key, { + get: proto[protoKey].bind(self), + enumerable: true + }); + }; for (var i in proto) { if (proto.hasOwnProperty(i) && ignored.indexOf(i) === -1) { - Object.defineProperty(this.repl.context, i, { - get: proto[i].bind(this), - enumerable: true - }); + defineProperty(i, i); + if (synonym[i]) defineProperty(synonym[i], i); } } @@ -689,35 +701,19 @@ Interface.prototype.resume = function() { Interface.prototype.handleBreak = function(r) { + var expected = this.paused !== 0; + this.pause(); - var result = '\n'; - if (r.breakpoints) { - result += 'breakpoint'; - if (r.breakpoints.length > 1) { - result += 's'; - } - result += ' #'; - for (var i = 0; i < r.breakpoints.length; i++) { - if (i > 0) { - result += ', #'; - } - result += r.breakpoints[i]; - } - } else { - result += 'break'; - } - result += ' in '; - result += r.invocationText; - result += ', '; - result += SourceInfo(r); - result += '\n'; - result += SourceUnderline(r.sourceLineText, r.sourceColumn); this.client.currentSourceLine = r.sourceLine; this.client.currentFrame = 0; this.client.currentScript = r.script.name; - console.log(result); + if (!expected) { + console.log(''); + } + console.log(SourceInfo(r)); + console.log(SourceUnderline(r.sourceLineText, r.sourceColumn)); this.resume(); }; @@ -942,7 +938,9 @@ Interface.prototype.cont = function() { var self = this; this.client.reqContinue(function() { - self.resume(); + process.nextTick(function() { + self.resume(); + }); }); }; @@ -955,7 +953,9 @@ Interface.prototype.next = function() { var self = this; this.client.step('next', 1, function(res) { - self.resume(); + process.nextTick(function() { + self.resume(); + }); }); }; @@ -968,7 +968,9 @@ Interface.prototype.step = function() { var self = this; this.client.step('in', 1, function(res) { - self.resume(); + process.nextTick(function() { + self.resume(); + }); }); }; @@ -981,7 +983,9 @@ Interface.prototype.out = function() { var self = this; this.client.step('out', 1, function(res) { - self.resume(); + process.nextTick(function() { + self.resume(); + }); }); };