Commit 8349ee0c authored by yangguo's avatar yangguo Committed by Commit bot

[debugger] muting break positions should work for the entire statement.

A statement could have several break positions. The entire statement
should be considered muted if break points across all these break
positions evaluate to false.

R=verwaest@chromium.org
BUG=chromium:429167
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#33522}
parent cfaeb63b
......@@ -168,6 +168,18 @@ void BreakLocation::FromAddressSameStatement(Handle<DebugInfo> debug_info,
}
// Find all break locations with the given statement position.
void BreakLocation::AllForStatementPosition(Handle<DebugInfo> debug_info,
int statement_position,
List<BreakLocation>* result_out) {
for (Iterator it(debug_info, ALL_BREAK_LOCATIONS); !it.Done(); it.Next()) {
if (it.statement_position() == statement_position) {
result_out->Add(it.GetBreakLocation());
}
}
}
int BreakLocation::BreakIndexFromAddress(Handle<DebugInfo> debug_info,
Address pc) {
// Run through all break points to locate the one closest to the address.
......@@ -536,11 +548,11 @@ Handle<Object> Debug::CheckBreakPoints(BreakLocation* location,
bool Debug::IsMutedAtCurrentLocation(JavaScriptFrame* frame) {
// A break location is considered muted if the break location has break
// points, but their conditions all evaluate to false.
// Aside from not triggering a debug break event at the break location,
// we also do not trigger one for debugger statements, nor an exception event
// on exception at this location.
// A break location is considered muted if break locations on the current
// statement have at least one break point, and all of these break points
// evaluate to false. Aside from not triggering a debug break event at the
// break location, we also do not trigger one for debugger statements, nor
// an exception event on exception at this location.
Object* fun = frame->function();
if (!fun->IsJSFunction()) return false;
JSFunction* function = JSFunction::cast(fun);
......@@ -550,10 +562,19 @@ bool Debug::IsMutedAtCurrentLocation(JavaScriptFrame* frame) {
// Enter the debugger.
DebugScope debug_scope(this);
if (debug_scope.failed()) return false;
BreakLocation location = BreakLocation::FromFrame(debug_info, frame);
bool has_break_points;
Handle<Object> check_result = CheckBreakPoints(&location, &has_break_points);
return has_break_points && check_result->IsUndefined();
BreakLocation current_position = BreakLocation::FromFrame(debug_info, frame);
List<BreakLocation> break_locations;
BreakLocation::AllForStatementPosition(
debug_info, current_position.statement_position(), &break_locations);
bool has_break_points_at_all = false;
for (int i = 0; i < break_locations.length(); i++) {
bool has_break_points;
Handle<Object> check_result =
CheckBreakPoints(&break_locations[i], &has_break_points);
has_break_points_at_all |= has_break_points;
if (has_break_points && !check_result->IsUndefined()) return false;
}
return has_break_points_at_all;
}
......
......@@ -76,6 +76,10 @@ class BreakLocation {
static void FromAddressSameStatement(Handle<DebugInfo> debug_info, Address pc,
List<BreakLocation>* result_out);
static void AllForStatementPosition(Handle<DebugInfo> debug_info,
int statement_position,
List<BreakLocation>* result_out);
static BreakLocation FromPosition(Handle<DebugInfo> debug_info, int position,
BreakPositionAlignment alignment);
......
......@@ -33,6 +33,14 @@ function g(x) {
}
}
function h(x) {
var a = undefined;
try {
var x = a();
} catch (e) {
}
}
Debug.setListener(listener);
assertCount(0, 0);
......@@ -79,5 +87,13 @@ assertCount(8, 4);
g(0);
assertCount(8, 4);
h(0);
assertCount(8, 5);
Debug.setBreakPoint(h, 3, 0, "x > 0");
h(1);
assertCount(9, 6);
h(0);
assertCount(9, 6);
Debug.clearBreakOnException();
Debug.setListener(null);
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