Add a flag that prevents v8 from relocating breakpoints across
line boundaries.
This patch should be squashed into --
cf3296721194eafb9bb07ee94026cfb5bcc5d092 [V8] Add flag to avoid
breakpoint relocation -- in the next V8 rebase as this code only
improves code in that patch
Change-Id: I4fefc08f18874f2fa26ffff64eefb11dc949ddfd
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
actual_position = position;
}
var actual_location = script.locationFromPosition(actual_position, true);
+ // Check for any relocation and compare it with the breakpoint_relocation flag
+ if (actual_location.line != line && !%AllowBreakPointRelocation()) {
+ %ClearBreakPoint(break_point);
+ return break_point;
+ }
break_point.actual_location = { line: actual_location.line,
column: actual_location.column,
script_id: script.id };
return Handle<DebugInfo>(DebugInfo::cast(shared->debug_info()));
}
-static bool ContainsLineBreak(String *string, int from, int to)
-{
- ASSERT(from >= 0);
- ASSERT(from <= to);
- const int end = (string->length() < to) ? string->length() : to;
- for (int pos = from; pos < end; ++pos) {
- if (string->Get(pos) == '\n')
- return true;
- }
- return false;
-}
void Debug::SetBreakPoint(Handle<SharedFunctionInfo> shared,
Handle<Object> break_point_object,
// Find the break point and change it.
BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS);
it.FindBreakLocationFromPosition(*source_position);
+ it.SetBreakPoint(break_point_object);
- bool acceptBreak = true;
- if (!FLAG_breakpoint_relocation) {
- if (String *sourceStr = String::cast(shared->GetSourceCode())) {
- acceptBreak = !ContainsLineBreak(sourceStr, *source_position, it.position());
- }
- }
-
- if (acceptBreak) {
- it.SetBreakPoint(break_point_object);
+ *source_position = it.position();
- *source_position = it.position();
-
- // At least one active break point now.
- ASSERT(debug_info->GetBreakPointCount() > 0);
- }
+ // At least one active break point now.
+ ASSERT(debug_info->GetBreakPointCount() > 0);
}
case ScopeIterator::ScopeTypeGlobal:
return Handle<JSObject>(CurrentContext()->global());
case ScopeIterator::ScopeTypeLocal: {
- Handle<SerializedScopeInfo> scope_info = nested_scope_chain_.last();
ASSERT(nested_scope_chain_.length() == 1);
// Materialize the content of the local scope into a JSObject.
return MaterializeLocalScope(isolate_, frame_, inlined_frame_index_);
}
+// Return the value of breakpoint_relocation flag
+RUNTIME_FUNCTION(MaybeObject*, Runtime_AllowBreakPointRelocation) {
+ return Smi::FromInt(FLAG_breakpoint_relocation);
+}
+
+
// Set a break point in a function
// args[0]: function
// args[1]: number: break source position (within the function source)
F(GetThreadDetails, 2, 1) \
F(SetDisableBreak, 1, 1) \
F(GetBreakLocations, 1, 1) \
+ F(AllowBreakPointRelocation, 0, 1) \
F(SetFunctionBreakPoint, 3, 1) \
F(SetScriptBreakPoint, 3, 1) \
F(ClearBreakPoint, 1, 1) \