|
|
@ -1217,29 +1217,40 @@ Interface.prototype.setBreakpoint = function(script, line, |
|
|
|
line = this.client.currentSourceLine + 1; |
|
|
|
} |
|
|
|
|
|
|
|
if (script != +script && !this.client.scripts[script]) { |
|
|
|
Object.keys(this.client.scripts).forEach(function(id) { |
|
|
|
if (self.client.scripts[id].name.indexOf(script) !== -1) { |
|
|
|
if (scriptId) { |
|
|
|
ambiguous = true; |
|
|
|
} |
|
|
|
scriptId = id; |
|
|
|
} |
|
|
|
}); |
|
|
|
if (/\(\)$/.test(script)) { |
|
|
|
// setBreakpoint('functionname()');
|
|
|
|
var req = { |
|
|
|
type: 'function', |
|
|
|
target: script.replace(/\(\)$/, ''), |
|
|
|
condition: condition |
|
|
|
}; |
|
|
|
} else { |
|
|
|
scriptId = script; |
|
|
|
} |
|
|
|
// setBreakpoint('scriptname')
|
|
|
|
if (script != +script && !this.client.scripts[script]) { |
|
|
|
var scripts = this.client.scripts; |
|
|
|
Object.keys(scripts).forEach(function(id) { |
|
|
|
if (scripts[id] && scripts[id].name.indexOf(script) !== -1) { |
|
|
|
if (scriptId) { |
|
|
|
ambiguous = true; |
|
|
|
} |
|
|
|
scriptId = id; |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
scriptId = script; |
|
|
|
} |
|
|
|
|
|
|
|
if (!scriptId) return this.error('Script : ' + script + ' not found'); |
|
|
|
if (ambiguous) return this.error('Script name is ambiguous'); |
|
|
|
if (line <= 0) return this.error('Line should be a positive value'); |
|
|
|
if (!scriptId) return this.error('Script : ' + script + ' not found'); |
|
|
|
if (ambiguous) return this.error('Script name is ambiguous'); |
|
|
|
if (line <= 0) return this.error('Line should be a positive value'); |
|
|
|
|
|
|
|
var req = { |
|
|
|
type: 'scriptId', |
|
|
|
target: scriptId, |
|
|
|
line: line - 1, |
|
|
|
condition: condition |
|
|
|
}; |
|
|
|
var req = { |
|
|
|
type: 'scriptId', |
|
|
|
target: scriptId, |
|
|
|
line: line - 1, |
|
|
|
condition: condition |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
self.pause(); |
|
|
|
self.client.setBreakpoint(req, function(res) { |
|
|
@ -1247,17 +1258,27 @@ Interface.prototype.setBreakpoint = function(script, line, |
|
|
|
if (!silent) { |
|
|
|
self.list(5); |
|
|
|
} |
|
|
|
self.client.breakpoints.push({ |
|
|
|
id: res.body.breakpoint, |
|
|
|
scriptId: scriptId, |
|
|
|
script: (self.client.scripts[scriptId] || {}).name, |
|
|
|
line: line, |
|
|
|
condition: condition |
|
|
|
}); |
|
|
|
|
|
|
|
// Try load scriptId and line from response
|
|
|
|
if (!scriptId) { |
|
|
|
scriptId = res.body.script_id; |
|
|
|
line = res.body.line; |
|
|
|
} |
|
|
|
|
|
|
|
// If we finally have one - remember this breakpoint
|
|
|
|
if (scriptId) { |
|
|
|
self.client.breakpoints.push({ |
|
|
|
id: res.body.breakpoint, |
|
|
|
scriptId: scriptId, |
|
|
|
script: (self.client.scripts[scriptId] || {}).name, |
|
|
|
line: line, |
|
|
|
condition: condition |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
if (!silent) { |
|
|
|
self.print(req.message || 'error!'); |
|
|
|
self.print(res.message || 'error!'); |
|
|
|
} |
|
|
|
} |
|
|
|
self.resume(); |
|
|
|