Commit 808981a2 authored by yangguo's avatar yangguo Committed by Commit bot

[debugger] reapply break points after clearing one shots.

On the debug info, we have a list of existing break points.  When we
step in the debugger, we flood the function with one-shot break points.
Afterwards, we clear these one-shots by clearing all break locations.

Previously, while clearing break locations, we would skip ones that have
actual break points. Now we clear all break locations, and then reapply
break points. This is necessary for the next step, when we encode break
point info by source position, and not code offset. Encoding by code
offset would mean that break points are dependent on the code kind we
use.

R=jgruber@chromium.org
BUG=v8:5265

Review-Url: https://codereview.chromium.org/2221333002
Cr-Commit-Position: refs/heads/master@{#38492}
parent 78727d43
......@@ -336,6 +336,13 @@ void BreakLocation::ClearBreakPoint(Handle<Object> break_point_object) {
}
}
void BreakLocation::ReapplyBreakPoint() {
// We indeed have a break point here to re-apply.
DCHECK(HasBreakPoint());
// The break point is currently not applied to code.
DCHECK(!IsDebugBreak());
SetDebugBreak();
}
void BreakLocation::SetOneShot() {
// Debugger statement always calls debugger. No need to modify it.
......@@ -356,12 +363,6 @@ void BreakLocation::ClearOneShot() {
// Debugger statement always calls debugger. No need to modify it.
if (IsDebuggerStatement()) return;
// If there is a real break point here no more to do.
if (HasBreakPoint()) {
DCHECK(IsDebugBreak());
return;
}
// Patch code removing debug break.
ClearDebugBreak();
DCHECK(!IsDebugBreak());
......@@ -1127,13 +1128,28 @@ void Debug::ClearOneShot() {
// The current implementation just runs through all the breakpoints. When the
// last break point for a function is removed that function is automatically
// removed from the list.
DisallowHeapAllocation no_gc;
for (DebugInfoListNode* node = debug_info_list_; node != NULL;
node = node->next()) {
Handle<DebugInfo> debug_info = node->debug_info();
for (std::unique_ptr<BreakLocation::Iterator> it(
BreakLocation::GetIterator(node->debug_info()));
BreakLocation::GetIterator(debug_info));
!it->Done(); it->Next()) {
it->GetBreakLocation().ClearOneShot();
}
// Re-apply break points after having cleared everything.
if (debug_info->break_points()->IsUndefined(isolate_)) continue;
FixedArray* break_points = debug_info->break_points();
for (int i = 0; i < break_points->length(); i++) {
if (break_points->get(i)->IsUndefined(isolate_)) continue;
BreakPointInfo* break_point_info =
BreakPointInfo::cast(break_points->get(i));
if (break_point_info->GetBreakPointCount() == 0) continue;
BreakLocation break_location = BreakLocation::FromPosition(
debug_info, break_point_info->source_position(),
BREAK_POSITION_ALIGNED);
break_location.ReapplyBreakPoint();
}
}
}
......
......@@ -97,6 +97,7 @@ class BreakLocation {
void SetBreakPoint(Handle<Object> break_point_object);
void ClearBreakPoint(Handle<Object> break_point_object);
void ReapplyBreakPoint();
void SetOneShot();
void ClearOneShot();
......
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