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 } |
339 | 346 |
340 void BreakLocation::SetOneShot() { | 347 void BreakLocation::SetOneShot() { |
341 // Debugger statement always calls debugger. No need to modify it. | 348 // Debugger statement always calls debugger. No need to modify it. |
342 if (IsDebuggerStatement()) return; | 349 if (IsDebuggerStatement()) return; |
343 | 350 |
344 // If there is a real break point here no more to do. | 351 // If there is a real break point here no more to do. |
345 if (HasBreakPoint()) { | 352 if (HasBreakPoint()) { |
346 DCHECK(IsDebugBreak()); | 353 DCHECK(IsDebugBreak()); |
347 return; | 354 return; |
348 } | 355 } |
349 | 356 |
350 // Patch code with debug break. | 357 // Patch code with debug break. |
351 SetDebugBreak(); | 358 SetDebugBreak(); |
352 } | 359 } |
353 | 360 |
354 | 361 |
355 void BreakLocation::ClearOneShot() { | 362 void BreakLocation::ClearOneShot() { |
356 // Debugger statement always calls debugger. No need to modify it. | 363 // Debugger statement always calls debugger. No need to modify it. |
357 if (IsDebuggerStatement()) return; | 364 if (IsDebuggerStatement()) return; |
358 | 365 |
359 // If there is a real break point here no more to do. | |
360 if (HasBreakPoint()) { | |
361 DCHECK(IsDebugBreak()); | |
362 return; | |
363 } | |
364 | |
365 // Patch code removing debug break. | 366 // Patch code removing debug break. |
366 ClearDebugBreak(); | 367 ClearDebugBreak(); |
367 DCHECK(!IsDebugBreak()); | 368 DCHECK(!IsDebugBreak()); |
368 } | 369 } |
369 | 370 |
370 | 371 |
371 void BreakLocation::SetDebugBreak() { | 372 void BreakLocation::SetDebugBreak() { |
372 // Debugger statement always calls debugger. No need to modify it. | 373 // Debugger statement always calls debugger. No need to modify it. |
373 if (IsDebuggerStatement()) return; | 374 if (IsDebuggerStatement()) return; |
374 | 375 |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 } | 1121 } |
1121 | 1122 |
1122 | 1123 |
1123 // Clears all the one-shot break points that are currently set. Normally this | 1124 // Clears all the one-shot break points that are currently set. Normally this |
1124 // function is called each time a break point is hit as one shot break points | 1125 // function is called each time a break point is hit as one shot break points |
1125 // are used to support stepping. | 1126 // are used to support stepping. |
1126 void Debug::ClearOneShot() { | 1127 void Debug::ClearOneShot() { |
1127 // The current implementation just runs through all the breakpoints. When the | 1128 // The current implementation just runs through all the breakpoints. When the |
1128 // last break point for a function is removed that function is automatically | 1129 // last break point for a function is removed that function is automatically |
1129 // removed from the list. | 1130 // removed from the list. |
| 1131 DisallowHeapAllocation no_gc; |
1130 for (DebugInfoListNode* node = debug_info_list_; node != NULL; | 1132 for (DebugInfoListNode* node = debug_info_list_; node != NULL; |
1131 node = node->next()) { | 1133 node = node->next()) { |
| 1134 Handle<DebugInfo> debug_info = node->debug_info(); |
1132 for (std::unique_ptr<BreakLocation::Iterator> it( | 1135 for (std::unique_ptr<BreakLocation::Iterator> it( |
1133 BreakLocation::GetIterator(node->debug_info())); | 1136 BreakLocation::GetIterator(debug_info)); |
1134 !it->Done(); it->Next()) { | 1137 !it->Done(); it->Next()) { |
1135 it->GetBreakLocation().ClearOneShot(); | 1138 it->GetBreakLocation().ClearOneShot(); |
1136 } | 1139 } |
| 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 } |
1137 } | 1153 } |
1138 } | 1154 } |
1139 | 1155 |
1140 | 1156 |
1141 bool MatchingCodeTargets(Code* target1, Code* target2) { | 1157 bool MatchingCodeTargets(Code* target1, Code* target2) { |
1142 if (target1 == target2) return true; | 1158 if (target1 == target2) return true; |
1143 if (target1->kind() != target2->kind()) return false; | 1159 if (target1->kind() != target2->kind()) return false; |
1144 return target1->is_handler() || target1->is_inline_cache_stub(); | 1160 return target1->is_handler() || target1->is_inline_cache_stub(); |
1145 } | 1161 } |
1146 | 1162 |
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2577 } | 2593 } |
2578 | 2594 |
2579 | 2595 |
2580 void LockingCommandMessageQueue::Clear() { | 2596 void LockingCommandMessageQueue::Clear() { |
2581 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2597 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
2582 queue_.Clear(); | 2598 queue_.Clear(); |
2583 } | 2599 } |
2584 | 2600 |
2585 } // namespace internal | 2601 } // namespace internal |
2586 } // namespace v8 | 2602 } // namespace v8 |
OLD | NEW |