| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/debug/debug.h" | 5 #include "src/debug/debug.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 void BreakLocation::ClearBreakPoint(Handle<Object> break_point_object) { | 329 void BreakLocation::ClearBreakPoint(Handle<Object> break_point_object) { |
| 330 // Clear the break point information. | 330 // Clear the break point information. |
| 331 DebugInfo::ClearBreakPoint(debug_info_, code_offset_, break_point_object); | 331 DebugInfo::ClearBreakPoint(debug_info_, code_offset_, break_point_object); |
| 332 // If there are no more break points here remove the debug break. | 332 // If there are no more break points here remove the debug break. |
| 333 if (!HasBreakPoint()) { | 333 if (!HasBreakPoint()) { |
| 334 ClearDebugBreak(); | 334 ClearDebugBreak(); |
| 335 DCHECK(!IsDebugBreak()); | 335 DCHECK(!IsDebugBreak()); |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 | 338 |
| 339 void BreakLocation::ReapplyBreakPoint() { | |
| 340 // We indeed have a break point here to re-apply. | |
| 341 DCHECK(HasBreakPoint()); | |
| 342 // The break point is currently not applied to code. | |
| 343 DCHECK(!IsDebugBreak()); | |
| 344 SetDebugBreak(); | |
| 345 } | |
| 346 | 339 |
| 347 void BreakLocation::SetOneShot() { | 340 void BreakLocation::SetOneShot() { |
| 348 // Debugger statement always calls debugger. No need to modify it. | 341 // Debugger statement always calls debugger. No need to modify it. |
| 349 if (IsDebuggerStatement()) return; | 342 if (IsDebuggerStatement()) return; |
| 350 | 343 |
| 351 // If there is a real break point here no more to do. | 344 // If there is a real break point here no more to do. |
| 352 if (HasBreakPoint()) { | 345 if (HasBreakPoint()) { |
| 353 DCHECK(IsDebugBreak()); | 346 DCHECK(IsDebugBreak()); |
| 354 return; | 347 return; |
| 355 } | 348 } |
| 356 | 349 |
| 357 // Patch code with debug break. | 350 // Patch code with debug break. |
| 358 SetDebugBreak(); | 351 SetDebugBreak(); |
| 359 } | 352 } |
| 360 | 353 |
| 361 | 354 |
| 362 void BreakLocation::ClearOneShot() { | 355 void BreakLocation::ClearOneShot() { |
| 363 // Debugger statement always calls debugger. No need to modify it. | 356 // Debugger statement always calls debugger. No need to modify it. |
| 364 if (IsDebuggerStatement()) return; | 357 if (IsDebuggerStatement()) return; |
| 365 | 358 |
| 359 // If there is a real break point here no more to do. |
| 360 if (HasBreakPoint()) { |
| 361 DCHECK(IsDebugBreak()); |
| 362 return; |
| 363 } |
| 364 |
| 366 // Patch code removing debug break. | 365 // Patch code removing debug break. |
| 367 ClearDebugBreak(); | 366 ClearDebugBreak(); |
| 368 DCHECK(!IsDebugBreak()); | 367 DCHECK(!IsDebugBreak()); |
| 369 } | 368 } |
| 370 | 369 |
| 371 | 370 |
| 372 void BreakLocation::SetDebugBreak() { | 371 void BreakLocation::SetDebugBreak() { |
| 373 // Debugger statement always calls debugger. No need to modify it. | 372 // Debugger statement always calls debugger. No need to modify it. |
| 374 if (IsDebuggerStatement()) return; | 373 if (IsDebuggerStatement()) return; |
| 375 | 374 |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 } | 1120 } |
| 1122 | 1121 |
| 1123 | 1122 |
| 1124 // Clears all the one-shot break points that are currently set. Normally this | 1123 // Clears all the one-shot break points that are currently set. Normally this |
| 1125 // function is called each time a break point is hit as one shot break points | 1124 // function is called each time a break point is hit as one shot break points |
| 1126 // are used to support stepping. | 1125 // are used to support stepping. |
| 1127 void Debug::ClearOneShot() { | 1126 void Debug::ClearOneShot() { |
| 1128 // The current implementation just runs through all the breakpoints. When the | 1127 // The current implementation just runs through all the breakpoints. When the |
| 1129 // last break point for a function is removed that function is automatically | 1128 // last break point for a function is removed that function is automatically |
| 1130 // removed from the list. | 1129 // removed from the list. |
| 1131 DisallowHeapAllocation no_gc; | |
| 1132 for (DebugInfoListNode* node = debug_info_list_; node != NULL; | 1130 for (DebugInfoListNode* node = debug_info_list_; node != NULL; |
| 1133 node = node->next()) { | 1131 node = node->next()) { |
| 1134 Handle<DebugInfo> debug_info = node->debug_info(); | |
| 1135 for (std::unique_ptr<BreakLocation::Iterator> it( | 1132 for (std::unique_ptr<BreakLocation::Iterator> it( |
| 1136 BreakLocation::GetIterator(debug_info)); | 1133 BreakLocation::GetIterator(node->debug_info())); |
| 1137 !it->Done(); it->Next()) { | 1134 !it->Done(); it->Next()) { |
| 1138 it->GetBreakLocation().ClearOneShot(); | 1135 it->GetBreakLocation().ClearOneShot(); |
| 1139 } | 1136 } |
| 1140 // Re-apply break points after having cleared everything. | |
| 1141 if (debug_info->break_points()->IsUndefined(isolate_)) continue; | |
| 1142 FixedArray* break_points = debug_info->break_points(); | |
| 1143 for (int i = 0; i < break_points->length(); i++) { | |
| 1144 if (break_points->get(i)->IsUndefined(isolate_)) continue; | |
| 1145 BreakPointInfo* break_point_info = | |
| 1146 BreakPointInfo::cast(break_points->get(i)); | |
| 1147 if (break_point_info->GetBreakPointCount() == 0) continue; | |
| 1148 BreakLocation break_location = BreakLocation::FromPosition( | |
| 1149 debug_info, break_point_info->source_position(), | |
| 1150 BREAK_POSITION_ALIGNED); | |
| 1151 break_location.ReapplyBreakPoint(); | |
| 1152 } | |
| 1153 } | 1137 } |
| 1154 } | 1138 } |
| 1155 | 1139 |
| 1156 | 1140 |
| 1157 bool MatchingCodeTargets(Code* target1, Code* target2) { | 1141 bool MatchingCodeTargets(Code* target1, Code* target2) { |
| 1158 if (target1 == target2) return true; | 1142 if (target1 == target2) return true; |
| 1159 if (target1->kind() != target2->kind()) return false; | 1143 if (target1->kind() != target2->kind()) return false; |
| 1160 return target1->is_handler() || target1->is_inline_cache_stub(); | 1144 return target1->is_handler() || target1->is_inline_cache_stub(); |
| 1161 } | 1145 } |
| 1162 | 1146 |
| (...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2593 } | 2577 } |
| 2594 | 2578 |
| 2595 | 2579 |
| 2596 void LockingCommandMessageQueue::Clear() { | 2580 void LockingCommandMessageQueue::Clear() { |
| 2597 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2581 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
| 2598 queue_.Clear(); | 2582 queue_.Clear(); |
| 2599 } | 2583 } |
| 2600 | 2584 |
| 2601 } // namespace internal | 2585 } // namespace internal |
| 2602 } // namespace v8 | 2586 } // namespace v8 |
| OLD | NEW |