Chromium Code Reviews| Index: src/debug-debugger.js |
| diff --git a/src/debug-debugger.js b/src/debug-debugger.js |
| index 908fcd2120ffa8cafe61fb959a8fa007aeadd855..19627109458b47df90176488d03226f4b91f790d 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 }; |
|
Søren Thygesen Gjesse
2011/06/06 09:03:43
I guess that we do need an additional type here ev
Peter Rybin
2011/06/16 11:02:20
(I take it as "we do NOT need")
Actually on the c
|
| function ScriptTypeFlag(type) { |
| return (1 << type); |
| @@ -255,6 +256,8 @@ 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 if (type == Debug.ScriptBreakPointType.ScriptRegexp) { |
| + this.script_regexp_ = new RegExp(script_id_or_name); |
| } else { // type == Debug.ScriptBreakPointType.ScriptName |
| this.script_name_ = script_id_or_name; |
| } |
| @@ -309,6 +312,11 @@ ScriptBreakPoint.prototype.script_name = function() { |
| }; |
| +ScriptBreakPoint.prototype.script_regexp = function() { |
| + return this.script_regexp_; |
| +}; |
| + |
| + |
| ScriptBreakPoint.prototype.line = function() { |
| return this.line_; |
| }; |
| @@ -384,10 +392,16 @@ 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 { |
| + if (!(script.line_offset <= this.line_ && |
| + this.line_ < script.line_offset + script.lineCount())) { |
| + return false; |
| + } |
| + if (this.type_ == Debug.ScriptBreakPointType.ScriptRegexp) { |
| + return this.script_regexp_.test(script.nameOrSourceURL()); |
| + } else { // this.type_ == Debug.ScriptBreakPointType.ScriptName |
| + return this.script_name_ == script.nameOrSourceURL(); |
| + } |
| } |
| }; |
| @@ -799,6 +813,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(); |
| @@ -1550,7 +1573,7 @@ DebugCommandProcessor.prototype.setBreakPointRequest_ = |
| return; |
| } |
| if (type != 'function' && type != 'handle' && |
| - type != 'script' && type != 'scriptId') { |
| + type != 'script' && type != 'scriptId' && type != 'scriptRegexp') { |
| response.failed('Illegal type "' + type + '"'); |
| return; |
| } |
| @@ -1598,6 +1621,10 @@ DebugCommandProcessor.prototype.setBreakPointRequest_ = |
| break_point_number = |
| Debug.setScriptBreakPointByName(target, line, column, condition, |
| groupId); |
| + } else if (type == 'scriptRegexp') { |
|
Søren Thygesen Gjesse
2011/06/06 09:03:43
Can't we combine 'script' and 'scriptRegexp' here,
Peter Rybin
2011/06/16 11:02:20
I'd like to keep exact name and regexp separate. I
|
| + break_point_number = |
| + Debug.setScriptBreakPointByRegexp(target, line, column, condition, |
| + groupId); |
| } else { // type == 'scriptId. |
| break_point_number = |
| Debug.setScriptBreakPointById(target, line, column, condition, groupId); |
| @@ -1621,6 +1648,9 @@ DebugCommandProcessor.prototype.setBreakPointRequest_ = |
| if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { |
| response.body.type = 'scriptId'; |
| response.body.script_id = break_point.script_id(); |
| + } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegexp) { |
| + response.body.type = 'scriptRegexp'; |
| + response.body.script_regexp = break_point.script_regexp().source(); |
| } else { |
| response.body.type = 'scriptName'; |
| response.body.script_name = break_point.script_name(); |
| @@ -1753,6 +1783,9 @@ DebugCommandProcessor.prototype.listBreakpointsRequest_ = function(request, resp |
| if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { |
| description.type = 'scriptId'; |
| description.script_id = break_point.script_id(); |
| + } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegexp) { |
| + description.type = 'scriptRegexp'; |
| + description.script_name = break_point.script_regexp().source(); |
| } else { |
| description.type = 'scriptName'; |
| description.script_name = break_point.script_name(); |