Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: src/debug.cc

Issue 15737023: Fix very strange bug in FindBreakLocationFromAddress algorithm (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: new comments Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 204
205 205
206 void BreakLocationIterator::Next(int count) { 206 void BreakLocationIterator::Next(int count) {
207 while (count > 0) { 207 while (count > 0) {
208 Next(); 208 Next();
209 count--; 209 count--;
210 } 210 }
211 } 211 }
212 212
213 213
214 // Find the break point closest to the supplied address. 214 // Find the break point at the supplied address, or the closest one before
215 // the address.
215 void BreakLocationIterator::FindBreakLocationFromAddress(Address pc) { 216 void BreakLocationIterator::FindBreakLocationFromAddress(Address pc) {
216 // Run through all break points to locate the one closest to the address. 217 // Run through all break points to locate the one closest to the address.
217 int closest_break_point = 0; 218 int closest_break_point = 0;
218 int distance = kMaxInt; 219 int distance = kMaxInt;
219 while (!Done()) { 220 while (!Done()) {
220 // Check if this break point is closer that what was previously found. 221 // Check if this break point is closer that what was previously found.
221 if (this->pc() < pc && pc - this->pc() < distance) { 222 if (this->pc() <= pc && pc - this->pc() < distance) {
222 closest_break_point = break_point(); 223 closest_break_point = break_point();
223 distance = static_cast<int>(pc - this->pc()); 224 distance = static_cast<int>(pc - this->pc());
224 // Check whether we can't get any closer. 225 // Check whether we can't get any closer.
225 if (distance == 0) break; 226 if (distance == 0) break;
226 } 227 }
227 Next(); 228 Next();
228 } 229 }
229 230
230 // Move to the break point found. 231 // Move to the break point found.
231 Reset(); 232 Reset();
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 PostponeInterruptsScope postpone(isolate_); 937 PostponeInterruptsScope postpone(isolate_);
937 938
938 // Get the debug info (create it if it does not exist). 939 // Get the debug info (create it if it does not exist).
939 Handle<SharedFunctionInfo> shared = 940 Handle<SharedFunctionInfo> shared =
940 Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared()); 941 Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared());
941 Handle<DebugInfo> debug_info = GetDebugInfo(shared); 942 Handle<DebugInfo> debug_info = GetDebugInfo(shared);
942 943
943 // Find the break point where execution has stopped. 944 // Find the break point where execution has stopped.
944 BreakLocationIterator break_location_iterator(debug_info, 945 BreakLocationIterator break_location_iterator(debug_info,
945 ALL_BREAK_LOCATIONS); 946 ALL_BREAK_LOCATIONS);
946 break_location_iterator.FindBreakLocationFromAddress(frame->pc()); 947 // pc points to the instruction after the current one, possibly a break
948 // location as well. So the "- 1" to exclude it from the search.
949 break_location_iterator.FindBreakLocationFromAddress(frame->pc() - 1);
947 950
948 // Check whether step next reached a new statement. 951 // Check whether step next reached a new statement.
949 if (!StepNextContinue(&break_location_iterator, frame)) { 952 if (!StepNextContinue(&break_location_iterator, frame)) {
950 // Decrease steps left if performing multiple steps. 953 // Decrease steps left if performing multiple steps.
951 if (thread_local_.step_count_ > 0) { 954 if (thread_local_.step_count_ > 0) {
952 thread_local_.step_count_--; 955 thread_local_.step_count_--;
953 } 956 }
954 } 957 }
955 958
956 // If there is one or more real break points check whether any of these are 959 // If there is one or more real break points check whether any of these are
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 Handle<JSFunction> function(JSFunction::cast(frame->function())); 1400 Handle<JSFunction> function(JSFunction::cast(frame->function()));
1398 Handle<SharedFunctionInfo> shared(function->shared()); 1401 Handle<SharedFunctionInfo> shared(function->shared());
1399 if (!EnsureDebugInfo(shared, function)) { 1402 if (!EnsureDebugInfo(shared, function)) {
1400 // Return if ensuring debug info failed. 1403 // Return if ensuring debug info failed.
1401 return; 1404 return;
1402 } 1405 }
1403 Handle<DebugInfo> debug_info = GetDebugInfo(shared); 1406 Handle<DebugInfo> debug_info = GetDebugInfo(shared);
1404 1407
1405 // Find the break location where execution has stopped. 1408 // Find the break location where execution has stopped.
1406 BreakLocationIterator it(debug_info, ALL_BREAK_LOCATIONS); 1409 BreakLocationIterator it(debug_info, ALL_BREAK_LOCATIONS);
1407 it.FindBreakLocationFromAddress(frame->pc()); 1410 // pc points to the instruction after the current one, possibly a break
1411 // location as well. So the "- 1" to exclude it from the search.
1412 it.FindBreakLocationFromAddress(frame->pc() - 1);
1408 1413
1409 // Compute whether or not the target is a call target. 1414 // Compute whether or not the target is a call target.
1410 bool is_load_or_store = false; 1415 bool is_load_or_store = false;
1411 bool is_inline_cache_stub = false; 1416 bool is_inline_cache_stub = false;
1412 bool is_at_restarted_function = false; 1417 bool is_at_restarted_function = false;
1413 Handle<Code> call_function_stub; 1418 Handle<Code> call_function_stub;
1414 1419
1415 if (thread_local_.restarter_frame_function_pointer_ == NULL) { 1420 if (thread_local_.restarter_frame_function_pointer_ == NULL) {
1416 if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) { 1421 if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) {
1417 bool is_call_target = false; 1422 bool is_call_target = false;
(...skipping 2380 matching lines...) Expand 10 before | Expand all | Expand 10 after
3798 { 3803 {
3799 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); 3804 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_));
3800 isolate_->debugger()->CallMessageDispatchHandler(); 3805 isolate_->debugger()->CallMessageDispatchHandler();
3801 } 3806 }
3802 } 3807 }
3803 } 3808 }
3804 3809
3805 #endif // ENABLE_DEBUGGER_SUPPORT 3810 #endif // ENABLE_DEBUGGER_SUPPORT
3806 3811
3807 } } // namespace v8::internal 3812 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698