debugger: improve clearBreakpoint error and docs
Currently clearBreakpoint error is confusing, it says "Script not found" when there is no breakpoint, also documentation doesn't include signature for clearBreakpoint. PR-URL: https://github.com/iojs/io.js/pull/175 Reviewed-By: Miroslav Bajtoš <miroslav@strongloop.com>
This commit is contained in:
parent
5678595856
commit
c4a308d223
@ -107,7 +107,8 @@ prints the active watchers. To remove a watcher, type
|
|||||||
functions body
|
functions body
|
||||||
* `setBreakpoint('script.js', 1)`, `sb(...)` - Set breakpoint on first line of
|
* `setBreakpoint('script.js', 1)`, `sb(...)` - Set breakpoint on first line of
|
||||||
script.js
|
script.js
|
||||||
* `clearBreakpoint`, `cb(...)` - Clear breakpoint
|
* `clearBreakpoint('script.js', 1)`, `cb(...)` - Clear breakpoint in script.js
|
||||||
|
on line 1
|
||||||
|
|
||||||
It is also possible to set a breakpoint in a file (module) that
|
It is also possible to set a breakpoint in a file (module) that
|
||||||
isn't loaded yet:
|
isn't loaded yet:
|
||||||
|
@ -1375,9 +1375,7 @@ Interface.prototype.setBreakpoint = function(script, line,
|
|||||||
// setBreakpoint('scriptname')
|
// setBreakpoint('scriptname')
|
||||||
if (script != +script && !this.client.scripts[script]) {
|
if (script != +script && !this.client.scripts[script]) {
|
||||||
var scripts = this.client.scripts;
|
var scripts = this.client.scripts;
|
||||||
var keys = Object.keys(scripts);
|
for (var id in scripts) {
|
||||||
for (var v = 0; v < keys.length; v++) {
|
|
||||||
var id = keys[v];
|
|
||||||
if (scripts[id] &&
|
if (scripts[id] &&
|
||||||
scripts[id].name &&
|
scripts[id].name &&
|
||||||
scripts[id].name.indexOf(script) !== -1) {
|
scripts[id].name.indexOf(script) !== -1) {
|
||||||
@ -1452,6 +1450,7 @@ Interface.prototype.clearBreakpoint = function(script, line) {
|
|||||||
|
|
||||||
var ambiguous,
|
var ambiguous,
|
||||||
breakpoint,
|
breakpoint,
|
||||||
|
scriptId,
|
||||||
index;
|
index;
|
||||||
|
|
||||||
this.client.breakpoints.some(function(bp, i) {
|
this.client.breakpoints.some(function(bp, i) {
|
||||||
@ -1461,6 +1460,7 @@ Interface.prototype.clearBreakpoint = function(script, line) {
|
|||||||
if (!util.isUndefined(index)) {
|
if (!util.isUndefined(index)) {
|
||||||
ambiguous = true;
|
ambiguous = true;
|
||||||
}
|
}
|
||||||
|
scriptId = script;
|
||||||
if (bp.line === line) {
|
if (bp.line === line) {
|
||||||
index = i;
|
index = i;
|
||||||
breakpoint = bp.id;
|
breakpoint = bp.id;
|
||||||
@ -1469,10 +1469,28 @@ Interface.prototype.clearBreakpoint = function(script, line) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!scriptId && !this.client.scripts[script]) {
|
||||||
|
var scripts = this.client.scripts;
|
||||||
|
for (var id in scripts) {
|
||||||
|
if (scripts[id] &&
|
||||||
|
scripts[id].name &&
|
||||||
|
scripts[id].name.indexOf(script) !== -1) {
|
||||||
|
if (scriptId) {
|
||||||
|
ambiguous = true;
|
||||||
|
}
|
||||||
|
scriptId = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ambiguous) return this.error('Script name is ambiguous');
|
if (ambiguous) return this.error('Script name is ambiguous');
|
||||||
|
|
||||||
|
if (util.isUndefined(scriptId)) {
|
||||||
|
return this.error('Script ' + script + ' not found');
|
||||||
|
}
|
||||||
|
|
||||||
if (util.isUndefined(breakpoint)) {
|
if (util.isUndefined(breakpoint)) {
|
||||||
return this.error('Script : ' + script + ' not found');
|
return this.error('Breakpoint not found on line ' + line);
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this,
|
var self = this,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user