Chromium Code Reviews| Index: src/debug-debugger.js |
| diff --git a/src/debug-debugger.js b/src/debug-debugger.js |
| index 908fcd2120ffa8cafe61fb959a8fa007aeadd855..709f3833820dbb981be9d894191a295e4cb9057a 100644 |
| --- a/src/debug-debugger.js |
| +++ b/src/debug-debugger.js |
| @@ -68,7 +68,8 @@ Debug.ScriptCompilationType = { Host: 0, |
| // The different script break point types. |
| Debug.ScriptBreakPointType = { ScriptId: 0, |
| - ScriptName: 1 }; |
| + ScriptName: 1, |
| + ScriptRegExp: 2 }; |
| function ScriptTypeFlag(type) { |
| return (1 << type); |
| @@ -255,8 +256,12 @@ function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, |
| this.type_ = type; |
| if (type == Debug.ScriptBreakPointType.ScriptId) { |
| this.script_id_ = script_id_or_name; |
| - } else { // type == Debug.ScriptBreakPointType.ScriptName |
| + } else if (type == Debug.ScriptBreakPointType.ScriptName) { |
| this.script_name_ = script_id_or_name; |
| + } else if (type == Debug.ScriptBreakPointType.ScriptRegExp) { |
| + this.script_regexp_object_ = new RegExp(script_id_or_name); |
| + } else { |
| + throw new Error("Unexpected breakpoint type " + type); |
| } |
| this.line_ = opt_line || 0; |
| this.column_ = opt_column; |
| @@ -309,6 +314,11 @@ ScriptBreakPoint.prototype.script_name = function() { |
| }; |
| +ScriptBreakPoint.prototype.script_regexp_object = function() { |
| + return this.script_regexp_object_; |
| +}; |
| + |
| + |
| ScriptBreakPoint.prototype.line = function() { |
| return this.line_; |
| }; |
| @@ -384,10 +394,19 @@ ScriptBreakPoint.prototype.setIgnoreCount = function(ignoreCount) { |
| ScriptBreakPoint.prototype.matchesScript = function(script) { |
| if (this.type_ == Debug.ScriptBreakPointType.ScriptId) { |
| return this.script_id_ == script.id; |
| - } else { // this.type_ == Debug.ScriptBreakPointType.ScriptName |
| - return this.script_name_ == script.nameOrSourceURL() && |
| - script.line_offset <= this.line_ && |
| - this.line_ < script.line_offset + script.lineCount(); |
| + } else { |
| + // We might want to account columns here as well. |
| + if (!(script.line_offset <= this.line_ && |
| + this.line_ < script.line_offset + script.lineCount())) { |
| + return false; |
| + } |
| + if (this.type_ == Debug.ScriptBreakPointType.ScriptName) { |
| + return this.script_name_ == script.nameOrSourceURL(); |
| + } else if (this.type_ == Debug.ScriptBreakPointType.ScriptRegExp) { |
| + return this.script_regexp_object_.test(script.nameOrSourceURL()); |
| + } else { |
| + throw new Error("Unexpected breakpoint type " + this.type_); |
| + } |
| } |
| }; |
| @@ -431,7 +450,8 @@ ScriptBreakPoint.prototype.set = function (script) { |
| } |
| var actual_location = script.locationFromPosition(actual_position, true); |
| break_point.actual_location = { line: actual_location.line, |
| - column: actual_location.column }; |
| + column: actual_location.column, |
| + script_id: script.id }; |
| this.break_points_.push(break_point); |
| return break_point; |
| }; |
| @@ -644,7 +664,8 @@ Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) { |
| actual_position += this.sourcePosition(func); |
| var actual_location = script.locationFromPosition(actual_position, true); |
| break_point.actual_location = { line: actual_location.line, |
| - column: actual_location.column }; |
| + column: actual_location.column, |
| + script_id: script.id }; |
| break_point.setCondition(opt_condition); |
| return break_point.number(); |
| } |
| @@ -799,6 +820,15 @@ Debug.setScriptBreakPointByName = function(script_name, |
| } |
| +Debug.setScriptBreakPointByRegExp = function(script_regexp, |
| + opt_line, opt_column, |
| + opt_condition, opt_groupId) { |
| + return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptRegExp, |
| + script_regexp, opt_line, opt_column, |
| + opt_condition, opt_groupId); |
| +} |
| + |
| + |
| Debug.enableScriptBreakPoint = function(break_point_number) { |
| var script_break_point = this.findScriptBreakPoint(break_point_number, false); |
| script_break_point.enable(); |
| @@ -1549,12 +1579,7 @@ DebugCommandProcessor.prototype.setBreakPointRequest_ = |
| response.failed('Missing argument "type" or "target"'); |
| return; |
| } |
| - if (type != 'function' && type != 'handle' && |
| - type != 'script' && type != 'scriptId') { |
| - response.failed('Illegal type "' + type + '"'); |
| - return; |
| - } |
| - |
| + |
| // Either function or script break point. |
| var break_point_number; |
| if (type == 'function') { |
| @@ -1598,9 +1623,16 @@ DebugCommandProcessor.prototype.setBreakPointRequest_ = |
| break_point_number = |
| Debug.setScriptBreakPointByName(target, line, column, condition, |
| groupId); |
| - } else { // type == 'scriptId. |
| + } else if (type == 'scriptId') { |
| break_point_number = |
| Debug.setScriptBreakPointById(target, line, column, condition, groupId); |
| + } else if (type == 'scriptRegExp') { |
| + break_point_number = |
| + Debug.setScriptBreakPointByRegExp(target, line, column, condition, |
| + groupId); |
| + } else { |
| + response.failed('Illegal type "' + type + '"'); |
| + return; |
| } |
| // Set additional break point properties. |
| @@ -1621,9 +1653,14 @@ DebugCommandProcessor.prototype.setBreakPointRequest_ = |
| if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { |
| response.body.type = 'scriptId'; |
| response.body.script_id = break_point.script_id(); |
| - } else { |
| + } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) { |
| response.body.type = 'scriptName'; |
| response.body.script_name = break_point.script_name(); |
| + } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) { |
| + response.body.type = 'scriptRegExp'; |
| + response.body.script_regexp = break_point.script_regexp_object().source; |
| + } else { |
| + throw new Error("Unexpected breakpoint type: " + break_point.type()); |
|
Søren Thygesen Gjesse
2011/06/21 08:04:40
Maybe this message should start with "Internal err
Peter Rybin
2011/06/21 19:18:30
Good point.
Done.
|
| } |
| response.body.line = break_point.line(); |
| response.body.column = break_point.column(); |
| @@ -1753,9 +1790,14 @@ DebugCommandProcessor.prototype.listBreakpointsRequest_ = function(request, resp |
| if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { |
| description.type = 'scriptId'; |
| description.script_id = break_point.script_id(); |
| - } else { |
| + } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) { |
| description.type = 'scriptName'; |
| description.script_name = break_point.script_name(); |
| + } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) { |
| + description.type = 'scriptRegExp'; |
| + description.script_regexp = break_point.script_regexp_object().source; |
| + } else { |
| + throw new Error("Unexpected breakpoint type: " + break_point.type()); |
|
Søren Thygesen Gjesse
2011/06/21 08:04:40
Ditto.
Peter Rybin
2011/06/21 19:18:30
Done.
|
| } |
| array.push(description); |
| } |