Commit fe19b11e authored by yangguo's avatar yangguo Committed by Commit bot

[debugger] remove break point hit count and ignore count.

These features are not used by devtools and consequently not
exposed through the devtools protocol. They make the debugger
unnecessarily complex. If we decide that we need this, we should
implement this on a higher layer.

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/1607193003

Cr-Commit-Position: refs/heads/master@{#33436}
parent 2e481c15
......@@ -147,10 +147,8 @@ function BreakPoint(source_position, opt_script_break_point) {
} else {
this.number_ = next_break_point_number++;
}
this.hit_count_ = 0;
this.active_ = true;
this.condition_ = null;
this.ignoreCount_ = 0;
}
......@@ -169,11 +167,6 @@ BreakPoint.prototype.source_position = function() {
};
BreakPoint.prototype.hit_count = function() {
return this.hit_count_;
};
BreakPoint.prototype.active = function() {
if (this.script_break_point()) {
return this.script_break_point().active();
......@@ -190,11 +183,6 @@ BreakPoint.prototype.condition = function() {
};
BreakPoint.prototype.ignoreCount = function() {
return this.ignoreCount_;
};
BreakPoint.prototype.script_break_point = function() {
return this.script_break_point_;
};
......@@ -215,11 +203,6 @@ BreakPoint.prototype.setCondition = function(condition) {
};
BreakPoint.prototype.setIgnoreCount = function(ignoreCount) {
this.ignoreCount_ = ignoreCount;
};
BreakPoint.prototype.isTriggered = function(exec_state) {
// Break point not active - not triggered.
if (!this.active()) return false;
......@@ -239,18 +222,6 @@ BreakPoint.prototype.isTriggered = function(exec_state) {
}
}
// Update the hit count.
this.hit_count_++;
if (this.script_break_point_) {
this.script_break_point_.hit_count_++;
}
// If the break point has an ignore count it is not triggered.
if (this.ignoreCount_ > 0) {
this.ignoreCount_--;
return false;
}
// Break point triggered.
return true;
};
......@@ -283,10 +254,8 @@ function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
this.groupId_ = opt_groupId;
this.position_alignment_ = IS_UNDEFINED(opt_position_alignment)
? Debug.BreakPositionAlignment.Statement : opt_position_alignment;
this.hit_count_ = 0;
this.active_ = true;
this.condition_ = null;
this.ignoreCount_ = 0;
this.break_points_ = [];
}
......@@ -299,10 +268,8 @@ ScriptBreakPoint.prototype.cloneForOtherScript = function (other_script) {
copy.number_ = next_break_point_number++;
script_break_points.push(copy);
copy.hit_count_ = this.hit_count_;
copy.active_ = this.active_;
copy.condition_ = this.condition_;
copy.ignoreCount_ = this.ignoreCount_;
return copy;
};
......@@ -362,11 +329,6 @@ ScriptBreakPoint.prototype.update_positions = function(line, column) {
};
ScriptBreakPoint.prototype.hit_count = function() {
return this.hit_count_;
};
ScriptBreakPoint.prototype.active = function() {
return this.active_;
};
......@@ -377,11 +339,6 @@ ScriptBreakPoint.prototype.condition = function() {
};
ScriptBreakPoint.prototype.ignoreCount = function() {
return this.ignoreCount_;
};
ScriptBreakPoint.prototype.enable = function() {
this.active_ = true;
};
......@@ -397,16 +354,6 @@ ScriptBreakPoint.prototype.setCondition = function(condition) {
};
ScriptBreakPoint.prototype.setIgnoreCount = function(ignoreCount) {
this.ignoreCount_ = ignoreCount;
// Set ignore count on all break points created from this script break point.
for (var i = 0; i < this.break_points_.length; i++) {
this.break_points_[i].setIgnoreCount(ignoreCount);
}
};
// Check whether a script matches this script break point. Currently this is
// only based on script name.
ScriptBreakPoint.prototype.matchesScript = function(script) {
......@@ -461,7 +408,6 @@ ScriptBreakPoint.prototype.set = function (script) {
// Create a break point object and set the break point.
var break_point = MakeBreakPoint(position, this);
break_point.setIgnoreCount(this.ignoreCount());
var actual_position = %SetScriptBreakPoint(script, position,
this.position_alignment_,
break_point);
......@@ -726,13 +672,6 @@ Debug.changeBreakPointCondition = function(break_point_number, condition) {
};
Debug.changeBreakPointIgnoreCount = function(break_point_number, ignoreCount) {
if (ignoreCount < 0) throw MakeError(kDebugger, 'Invalid argument');
var break_point = this.findBreakPoint(break_point_number, false);
break_point.setIgnoreCount(ignoreCount);
};
Debug.clearBreakPoint = function(break_point_number) {
var break_point = this.findBreakPoint(break_point_number, true);
if (break_point) {
......@@ -857,14 +796,6 @@ Debug.changeScriptBreakPointCondition = function(
};
Debug.changeScriptBreakPointIgnoreCount = function(
break_point_number, ignoreCount) {
if (ignoreCount < 0) throw MakeError(kDebugger, 'Invalid argument');
var script_break_point = this.findScriptBreakPoint(break_point_number, false);
script_break_point.setIgnoreCount(ignoreCount);
};
Debug.scriptBreakPoints = function() {
return script_break_points;
};
......@@ -1503,7 +1434,6 @@ DebugCommandProcessor.prototype.setBreakPointRequest_ =
var enabled = IS_UNDEFINED(request.arguments.enabled) ?
true : request.arguments.enabled;
var condition = request.arguments.condition;
var ignoreCount = request.arguments.ignoreCount;
var groupId = request.arguments.groupId;
// Check for legal arguments.
......@@ -1569,9 +1499,6 @@ DebugCommandProcessor.prototype.setBreakPointRequest_ =
// Set additional break point properties.
var break_point = Debug.findBreakPoint(break_point_number);
if (ignoreCount) {
Debug.changeBreakPointIgnoreCount(break_point_number, ignoreCount);
}
if (!enabled) {
Debug.disableBreakPoint(break_point_number);
}
......@@ -1617,7 +1544,6 @@ DebugCommandProcessor.prototype.changeBreakPointRequest_ = function(
var break_point = TO_NUMBER(request.arguments.breakpoint);
var enabled = request.arguments.enabled;
var condition = request.arguments.condition;
var ignoreCount = request.arguments.ignoreCount;
// Check for legal arguments.
if (!break_point) {
......@@ -1638,11 +1564,6 @@ DebugCommandProcessor.prototype.changeBreakPointRequest_ = function(
if (!IS_UNDEFINED(condition)) {
Debug.changeBreakPointCondition(break_point, condition);
}
// Change ignore count if supplied
if (!IS_UNDEFINED(ignoreCount)) {
Debug.changeBreakPointIgnoreCount(break_point, ignoreCount);
}
};
......@@ -1717,10 +1638,8 @@ DebugCommandProcessor.prototype.listBreakpointsRequest_ = function(
line: break_point.line(),
column: break_point.column(),
groupId: break_point.groupId(),
hit_count: break_point.hit_count(),
active: break_point.active(),
condition: break_point.condition(),
ignoreCount: break_point.ignoreCount(),
actual_locations: break_point.actual_locations()
};
......
......@@ -302,18 +302,6 @@ static void ChangeScriptBreakPointConditionFromJS(v8::Isolate* isolate,
}
static void ChangeScriptBreakPointIgnoreCountFromJS(v8::Isolate* isolate,
int break_point_number,
int ignoreCount) {
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
SNPrintF(buffer,
"debug.Debug.changeScriptBreakPointIgnoreCount(%d, %d)",
break_point_number, ignoreCount);
buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0';
CompileRunChecked(isolate, buffer.start());
}
// Change break on exception.
static void ChangeBreakOnException(bool caught, bool uncaught) {
v8::internal::Debug* debug = CcTest::i_isolate()->debug();
......@@ -1717,72 +1705,6 @@ TEST(ConditionalScriptBreakPoint) {
}
// Test ignore count on script break points.
TEST(ScriptBreakPointIgnoreCount) {
break_point_hit_count = 0;
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
v8::Debug::SetDebugEventListener(env->GetIsolate(),
DebugEventBreakPointHitCount);
v8::Local<v8::String> script = v8_str(env->GetIsolate(),
"function f() {\n"
" a = 0; // line 1\n"
"};");
// Compile the script and get function f.
v8::Local<v8::Context> context = env.context();
v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str(env->GetIsolate(), "test"));
v8::Script::Compile(context, script, &origin)
.ToLocalChecked()
->Run(context)
.ToLocalChecked();
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
env->Global()
->Get(context, v8_str(env->GetIsolate(), "f"))
.ToLocalChecked());
// Set script break point on line 1 (in function f).
int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0);
// Call f with different ignores on the script break point.
break_point_hit_count = 0;
ChangeScriptBreakPointIgnoreCountFromJS(env->GetIsolate(), sbp, 1);
f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(0, break_point_hit_count);
f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
CHECK_EQ(1, break_point_hit_count);
ChangeScriptBreakPointIgnoreCountFromJS(env->GetIsolate(), sbp, 5);
break_point_hit_count = 0;
for (int i = 0; i < 10; i++) {
f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
}
CHECK_EQ(5, break_point_hit_count);
// Reload the script and get f again checking that the ignore survives.
v8::Script::Compile(context, script, &origin)
.ToLocalChecked()
->Run(context)
.ToLocalChecked();
f = v8::Local<v8::Function>::Cast(
env->Global()
->Get(context, v8_str(env->GetIsolate(), "f"))
.ToLocalChecked());
break_point_hit_count = 0;
for (int i = 0; i < 10; i++) {
f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
}
CHECK_EQ(5, break_point_hit_count);
v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
CheckDebuggerUnloaded(env->GetIsolate());
}
// Test that script break points survive when a script is reloaded.
TEST(ScriptBreakPointReload) {
break_point_hit_count = 0;
......
......@@ -79,12 +79,6 @@ function listener(event, exec_state, event_data, data) {
testArguments(dcp, '{' + bp_str + ',"enabled":"false"}', true);
testArguments(dcp, '{' + bp_str + ',"condition":"1==2"}', true);
testArguments(dcp, '{' + bp_str + ',"condition":"false"}', true);
testArguments(dcp, '{' + bp_str + ',"ignoreCount":7}', true);
testArguments(dcp, '{' + bp_str + ',"ignoreCount":0}', true);
testArguments(
dcp,
'{' + bp_str + ',"enabled":"true","condition":"false","ignoreCount":0}',
true);
// Indicate that all was processed.
listenerComplete = true;
......
......@@ -53,7 +53,6 @@ break_point_hit_count = 0;
bp = Debug.setBreakPoint(f, 0, 0, '{{{');
f();
assertEquals(0, break_point_hit_count);
assertEquals(0, Debug.findBreakPoint(bp, false).hit_count());
Debug.clearBreakPoint(bp);
// Conditional breakpoint which evaluates to false.
......@@ -61,7 +60,6 @@ break_point_hit_count = 0;
bp = Debug.setBreakPoint(f, 0, 0, 'false');
f();
assertEquals(0, break_point_hit_count);
assertEquals(0, Debug.findBreakPoint(bp, false).hit_count());
Debug.clearBreakPoint(bp);
// Conditional breakpoint which evaluates to true.
......@@ -69,7 +67,6 @@ break_point_hit_count = 0;
bp = Debug.setBreakPoint(f, 0, 0, 'true');
f();
assertEquals(1, break_point_hit_count);
assertEquals(1, Debug.findBreakPoint(bp, false).hit_count());
Debug.clearBreakPoint(bp);
// Conditional breakpoint which different types of quotes.
......@@ -77,13 +74,11 @@ break_point_hit_count = 0;
bp = Debug.setBreakPoint(f, 0, 0, '"a" == "a"');
f();
assertEquals(1, break_point_hit_count);
assertEquals(1, Debug.findBreakPoint(bp, false).hit_count());
Debug.clearBreakPoint(bp);
break_point_hit_count = 0;
bp = Debug.setBreakPoint(f, 0, 0, "'a' == 'a'");
f();
assertEquals(1, break_point_hit_count);
assertEquals(1, Debug.findBreakPoint(bp, false).hit_count());
Debug.clearBreakPoint(bp);
// Changing condition.
......@@ -91,15 +86,12 @@ break_point_hit_count = 0;
bp = Debug.setBreakPoint(f, 0, 0, '"ab".indexOf("b") > 0');
f();
assertEquals(1, break_point_hit_count);
assertEquals(1, Debug.findBreakPoint(bp, false).hit_count());
Debug.changeBreakPointCondition(bp, 'Math.sin(Math.PI/2) > 1');
f();
assertEquals(1, break_point_hit_count);
assertEquals(1, Debug.findBreakPoint(bp, false).hit_count());
Debug.changeBreakPointCondition(bp, '1==1');
f();
assertEquals(2, break_point_hit_count);
assertEquals(2, Debug.findBreakPoint(bp, false).hit_count());
Debug.clearBreakPoint(bp);
// Conditional breakpoint which checks global variable.
......@@ -107,11 +99,9 @@ break_point_hit_count = 0;
bp = Debug.setBreakPoint(f, 0, 0, 'x==1');
f();
assertEquals(0, break_point_hit_count);
assertEquals(0, Debug.findBreakPoint(bp, false).hit_count());
x=1;
f();
assertEquals(1, break_point_hit_count);
assertEquals(1, Debug.findBreakPoint(bp, false).hit_count());
Debug.clearBreakPoint(bp);
// Conditional breakpoint which checks global variable.
......@@ -121,7 +111,6 @@ for (var i = 0; i < 10; i++) {
g();
}
assertEquals(5, break_point_hit_count);
assertEquals(5, Debug.findBreakPoint(bp, false).hit_count());
Debug.clearBreakPoint(bp);
// Conditional breakpoint which checks a parameter.
......@@ -131,7 +120,6 @@ for (var i = 0; i < 10; i++) {
g();
}
assertEquals(5, break_point_hit_count);
assertEquals(5, Debug.findBreakPoint(bp, false).hit_count());
Debug.clearBreakPoint(bp);
// Conditional breakpoint which checks a local variable.
......@@ -141,7 +129,6 @@ for (var i = 0; i < 10; i++) {
g();
}
assertEquals(5, break_point_hit_count);
assertEquals(5, Debug.findBreakPoint(bp, false).hit_count());
Debug.clearBreakPoint(bp);
// Multiple conditional breakpoint which the same condition.
......@@ -152,8 +139,6 @@ for (var i = 0; i < 10; i++) {
g();
}
assertEquals(5, break_point_hit_count);
assertEquals(5, Debug.findBreakPoint(bp1, false).hit_count());
assertEquals(5, Debug.findBreakPoint(bp2, false).hit_count());
Debug.clearBreakPoint(bp1);
Debug.clearBreakPoint(bp2);
......@@ -165,7 +150,5 @@ for (var i = 0; i < 10; i++) {
g();
}
assertEquals(10, break_point_hit_count);
assertEquals(5, Debug.findBreakPoint(bp1, false).hit_count());
assertEquals(5, Debug.findBreakPoint(bp2, false).hit_count());
Debug.clearBreakPoint(bp1);
Debug.clearBreakPoint(bp2);
// Copyright 2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
// Simple debug event handler which just counts the number of break points hit.
var break_point_hit_count;
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
break_point_hit_count++;
}
};
// Add the debug event listener.
Debug.setListener(listener);
// Test function.
function f() {};
// This tests ignore of break points including the case with several
// break points in the same location.
break_point_hit_count = 0;
// Set a breakpoint in f.
bp1 = Debug.setBreakPoint(f);
// Try ignore count of 1.
Debug.changeBreakPointIgnoreCount(bp1, 1);
f();
assertEquals(0, break_point_hit_count);
f();
assertEquals(1, break_point_hit_count);
// Set another breakpoint in f at the same place.
bp2 = Debug.setBreakPoint(f);
f();
assertEquals(2, break_point_hit_count);
// Set different ignore counts.
Debug.changeBreakPointIgnoreCount(bp1, 2);
Debug.changeBreakPointIgnoreCount(bp2, 4);
f();
assertEquals(2, break_point_hit_count);
f();
assertEquals(2, break_point_hit_count);
f();
assertEquals(3, break_point_hit_count);
f();
assertEquals(4, break_point_hit_count);
// Set different ignore counts (opposite).
Debug.changeBreakPointIgnoreCount(bp1, 4);
Debug.changeBreakPointIgnoreCount(bp2, 2);
f();
assertEquals(4, break_point_hit_count);
f();
assertEquals(4, break_point_hit_count);
f();
assertEquals(5, break_point_hit_count);
f();
assertEquals(6, break_point_hit_count);
......@@ -88,7 +88,6 @@ function listener(event, exec_state, event_data, data) {
testArguments(dcp, '{"type":"function","target":1}', false);
testArguments(dcp, '{"type":"function","target":"f","line":-1}', false);
testArguments(dcp, '{"type":"function","target":"f","column":-1}', false);
testArguments(dcp, '{"type":"function","target":"f","ignoreCount":-1}', false);
testArguments(dcp, '{"type":"handle","target":"-1"}', false);
mirror = debug.MakeMirror(o);
testArguments(dcp, '{"type":"handle","target":' + mirror.handle() + '}', false);
......@@ -101,7 +100,6 @@ function listener(event, exec_state, event_data, data) {
testArguments(dcp, '{"type":"function","target":"f","condition":"i == 1"}', true, false);
testArguments(dcp, '{"type":"function","target":"f","enabled":true}', true, false);
testArguments(dcp, '{"type":"function","target":"f","enabled":false}', true, false);
testArguments(dcp, '{"type":"function","target":"f","ignoreCount":7}', true, false);
testArguments(dcp, '{"type":"script","target":"test"}', true, true);
testArguments(dcp, '{"type":"script","target":"test"}', true, true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment