Index: src/debug.cc |
diff --git a/src/debug.cc b/src/debug.cc |
index 95226c7fc81e32bf3ae624b556678bde26008ff0..6b5730c7509beeae755baae21bd9b66cfb460c49 100644 |
--- a/src/debug.cc |
+++ b/src/debug.cc |
@@ -211,14 +211,15 @@ void BreakLocationIterator::Next(int count) { |
} |
-// Find the break point closest to the supplied address. |
+// Find the break point at the supplied address, or the closest one before |
+// the address. |
void BreakLocationIterator::FindBreakLocationFromAddress(Address pc) { |
// Run through all break points to locate the one closest to the address. |
int closest_break_point = 0; |
int distance = kMaxInt; |
while (!Done()) { |
// Check if this break point is closer that what was previously found. |
- if (this->pc() < pc && pc - this->pc() < distance) { |
+ if (this->pc() <= pc && pc - this->pc() < distance) { |
closest_break_point = break_point(); |
distance = static_cast<int>(pc - this->pc()); |
// Check whether we can't get any closer. |
@@ -943,7 +944,9 @@ Object* Debug::Break(Arguments args) { |
// Find the break point where execution has stopped. |
BreakLocationIterator break_location_iterator(debug_info, |
ALL_BREAK_LOCATIONS); |
- break_location_iterator.FindBreakLocationFromAddress(frame->pc()); |
+ // pc points to the instruction after the current one, possibly a break |
+ // location as well. So the "- 1" to exclude it from the search. |
+ break_location_iterator.FindBreakLocationFromAddress(frame->pc() - 1); |
// Check whether step next reached a new statement. |
if (!StepNextContinue(&break_location_iterator, frame)) { |
@@ -1404,7 +1407,9 @@ void Debug::PrepareStep(StepAction step_action, int step_count) { |
// Find the break location where execution has stopped. |
BreakLocationIterator it(debug_info, ALL_BREAK_LOCATIONS); |
- it.FindBreakLocationFromAddress(frame->pc()); |
+ // pc points to the instruction after the current one, possibly a break |
+ // location as well. So the "- 1" to exclude it from the search. |
+ it.FindBreakLocationFromAddress(frame->pc() - 1); |
// Compute whether or not the target is a call target. |
bool is_load_or_store = false; |