Fix very strange bug in FindBreakLocationFromAddress algorithm

R=yangguo@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15014 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
peter.rybin@gmail.com 2013-06-07 16:48:22 +00:00
parent d7431f2c6e
commit 5dde44e431
2 changed files with 12 additions and 5 deletions

View File

@ -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;

View File

@ -11229,7 +11229,9 @@ class ScopeIterator {
// 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);
if (break_location_iterator.IsExit()) {
// We are within the return sequence. At the momemt it is not possible to
// get a source position which is consistent with the current scope chain.