Index: src/debug.cc |
diff --git a/src/debug.cc b/src/debug.cc |
index 5d26ba2b139e36fc8704678c4b2c1919b74447a8..de44ff5e3ec6f84004d8a52d29dc3634c72b3aa4 100644 |
--- a/src/debug.cc |
+++ b/src/debug.cc |
@@ -235,17 +235,24 @@ void BreakLocationIterator::FindBreakLocationFromAddress(Address pc) { |
// Find the break point closest to the supplied source position. |
-void BreakLocationIterator::FindBreakLocationFromPosition(int position) { |
+void BreakLocationIterator::FindBreakLocationFromPosition(int position, |
+ bool statement_alighned) { |
Yang
2013/06/25 11:32:00
Change variable name to "statement_aligned".
Sugg
Peter.Rybin
2013/06/27 14:07:29
I'm fine with this idea. I did JavaScript part as
|
// Run through all break points to locate the one closest to the source |
// position. |
int closest_break_point = 0; |
int distance = kMaxInt; |
+ |
while (!Done()) { |
+ int next_position; |
+ if (statement_alighned) { |
Yang
2013/06/25 11:32:00
You could use a ternary operator to simplify this
Peter.Rybin
2013/06/27 14:07:29
I guess with enum I should do switch? Or is it too
|
+ next_position = this->statement_position(); |
+ } else { |
+ next_position = this->position(); |
+ } |
// Check if this break point is closer that what was previously found. |
- if (position <= statement_position() && |
- statement_position() - position < distance) { |
+ if (position <= next_position && next_position - position < distance) { |
closest_break_point = break_point(); |
- distance = statement_position() - position; |
+ distance = next_position - position; |
// Check whether we can't get any closer. |
if (distance == 0) break; |
} |
@@ -1176,7 +1183,7 @@ void Debug::SetBreakPoint(Handle<JSFunction> function, |
// Find the break point and change it. |
BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS); |
- it.FindBreakLocationFromPosition(*source_position); |
+ it.FindBreakLocationFromPosition(*source_position, true); |
it.SetBreakPoint(break_point_object); |
*source_position = it.position(); |
@@ -1188,7 +1195,8 @@ void Debug::SetBreakPoint(Handle<JSFunction> function, |
bool Debug::SetBreakPointForScript(Handle<Script> script, |
Handle<Object> break_point_object, |
- int* source_position) { |
+ int* source_position, |
+ bool statement_alighned) { |
Yang
2013/06/25 11:32:00
Ditto.
Peter.Rybin
2013/06/27 14:07:29
Done.
|
HandleScope scope(isolate_); |
PrepareForBreakPoints(); |
@@ -1219,7 +1227,7 @@ bool Debug::SetBreakPointForScript(Handle<Script> script, |
// Find the break point and change it. |
BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS); |
- it.FindBreakLocationFromPosition(position); |
+ it.FindBreakLocationFromPosition(position, statement_alighned); |
it.SetBreakPoint(break_point_object); |
*source_position = it.position() + shared->start_position(); |