Browse Source

[debugger] added synonyms for run, cont, next, step, out, shorten breakpoint message and do not output explicit debug> on breaks

Fedor Indutny 13 years ago
parent
commit
01349bbd70
  1. 68
      lib/_debugger.js

68
lib/_debugger.js

@ -649,14 +649,26 @@ function Interface() {
var proto = Interface.prototype, var proto = Interface.prototype,
ignored = ['pause', 'resume', 'exitRepl', 'handleBreak', ignored = ['pause', 'resume', 'exitRepl', 'handleBreak',
'requireConnection', 'killChild', 'trySpawn', '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) { for (var i in proto) {
if (proto.hasOwnProperty(i) && ignored.indexOf(i) === -1) { if (proto.hasOwnProperty(i) && ignored.indexOf(i) === -1) {
Object.defineProperty(this.repl.context, i, { defineProperty(i, i);
get: proto[i].bind(this), if (synonym[i]) defineProperty(synonym[i], i);
enumerable: true
});
} }
} }
@ -689,35 +701,19 @@ Interface.prototype.resume = function() {
Interface.prototype.handleBreak = function(r) { Interface.prototype.handleBreak = function(r) {
var expected = this.paused !== 0;
this.pause(); 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.currentSourceLine = r.sourceLine;
this.client.currentFrame = 0; this.client.currentFrame = 0;
this.client.currentScript = r.script.name; 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(); this.resume();
}; };
@ -942,7 +938,9 @@ Interface.prototype.cont = function() {
var self = this; var self = this;
this.client.reqContinue(function() { this.client.reqContinue(function() {
self.resume(); process.nextTick(function() {
self.resume();
});
}); });
}; };
@ -955,7 +953,9 @@ Interface.prototype.next = function() {
var self = this; var self = this;
this.client.step('next', 1, function(res) { 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; var self = this;
this.client.step('in', 1, function(res) { 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; var self = this;
this.client.step('out', 1, function(res) { this.client.step('out', 1, function(res) {
self.resume(); process.nextTick(function() {
self.resume();
});
}); });
}; };

Loading…
Cancel
Save