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> |
| 8 |
7 #include "src/api.h" | 9 #include "src/api.h" |
8 #include "src/arguments.h" | 10 #include "src/arguments.h" |
9 #include "src/bootstrapper.h" | 11 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 12 #include "src/code-stubs.h" |
11 #include "src/codegen.h" | 13 #include "src/codegen.h" |
12 #include "src/compilation-cache.h" | 14 #include "src/compilation-cache.h" |
13 #include "src/compiler.h" | 15 #include "src/compiler.h" |
14 #include "src/deoptimizer.h" | 16 #include "src/deoptimizer.h" |
15 #include "src/execution.h" | 17 #include "src/execution.h" |
16 #include "src/frames-inl.h" | 18 #include "src/frames-inl.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 236 |
235 BreakLocation BreakLocation::BytecodeArrayIterator::GetBreakLocation() { | 237 BreakLocation BreakLocation::BytecodeArrayIterator::GetBreakLocation() { |
236 return BreakLocation(debug_info_, GetDebugBreakType(), code_offset(), | 238 return BreakLocation(debug_info_, GetDebugBreakType(), code_offset(), |
237 position(), statement_position()); | 239 position(), statement_position()); |
238 } | 240 } |
239 | 241 |
240 // Find the break point at the supplied address, or the closest one before | 242 // Find the break point at the supplied address, or the closest one before |
241 // the address. | 243 // the address. |
242 BreakLocation BreakLocation::FromCodeOffset(Handle<DebugInfo> debug_info, | 244 BreakLocation BreakLocation::FromCodeOffset(Handle<DebugInfo> debug_info, |
243 int offset) { | 245 int offset) { |
244 base::SmartPointer<Iterator> it(GetIterator(debug_info)); | 246 std::unique_ptr<Iterator> it(GetIterator(debug_info)); |
245 it->SkipTo(BreakIndexFromCodeOffset(debug_info, offset)); | 247 it->SkipTo(BreakIndexFromCodeOffset(debug_info, offset)); |
246 return it->GetBreakLocation(); | 248 return it->GetBreakLocation(); |
247 } | 249 } |
248 | 250 |
249 BreakLocation BreakLocation::FromFrame(Handle<DebugInfo> debug_info, | 251 BreakLocation BreakLocation::FromFrame(Handle<DebugInfo> debug_info, |
250 JavaScriptFrame* frame) { | 252 JavaScriptFrame* frame) { |
251 int code_offset = FrameSummary::GetFirst(frame).code_offset(); | 253 int code_offset = FrameSummary::GetFirst(frame).code_offset(); |
252 int call_offset = | 254 int call_offset = |
253 CallOffsetFromCodeOffset(code_offset, frame->is_interpreted()); | 255 CallOffsetFromCodeOffset(code_offset, frame->is_interpreted()); |
254 return FromCodeOffset(debug_info, call_offset); | 256 return FromCodeOffset(debug_info, call_offset); |
255 } | 257 } |
256 | 258 |
257 void BreakLocation::AllForStatementPosition(Handle<DebugInfo> debug_info, | 259 void BreakLocation::AllForStatementPosition(Handle<DebugInfo> debug_info, |
258 int statement_position, | 260 int statement_position, |
259 List<BreakLocation>* result_out) { | 261 List<BreakLocation>* result_out) { |
260 for (base::SmartPointer<Iterator> it(GetIterator(debug_info)); !it->Done(); | 262 for (std::unique_ptr<Iterator> it(GetIterator(debug_info)); !it->Done(); |
261 it->Next()) { | 263 it->Next()) { |
262 if (it->statement_position() == statement_position) { | 264 if (it->statement_position() == statement_position) { |
263 result_out->Add(it->GetBreakLocation()); | 265 result_out->Add(it->GetBreakLocation()); |
264 } | 266 } |
265 } | 267 } |
266 } | 268 } |
267 | 269 |
268 int BreakLocation::BreakIndexFromCodeOffset(Handle<DebugInfo> debug_info, | 270 int BreakLocation::BreakIndexFromCodeOffset(Handle<DebugInfo> debug_info, |
269 int offset) { | 271 int offset) { |
270 // Run through all break points to locate the one closest to the address. | 272 // Run through all break points to locate the one closest to the address. |
271 int closest_break = 0; | 273 int closest_break = 0; |
272 int distance = kMaxInt; | 274 int distance = kMaxInt; |
273 DCHECK(0 <= offset && offset < debug_info->abstract_code()->Size()); | 275 DCHECK(0 <= offset && offset < debug_info->abstract_code()->Size()); |
274 for (base::SmartPointer<Iterator> it(GetIterator(debug_info)); !it->Done(); | 276 for (std::unique_ptr<Iterator> it(GetIterator(debug_info)); !it->Done(); |
275 it->Next()) { | 277 it->Next()) { |
276 // Check if this break point is closer that what was previously found. | 278 // Check if this break point is closer that what was previously found. |
277 if (it->code_offset() <= offset && offset - it->code_offset() < distance) { | 279 if (it->code_offset() <= offset && offset - it->code_offset() < distance) { |
278 closest_break = it->break_index(); | 280 closest_break = it->break_index(); |
279 distance = offset - it->code_offset(); | 281 distance = offset - it->code_offset(); |
280 // Check whether we can't get any closer. | 282 // Check whether we can't get any closer. |
281 if (distance == 0) break; | 283 if (distance == 0) break; |
282 } | 284 } |
283 } | 285 } |
284 return closest_break; | 286 return closest_break; |
285 } | 287 } |
286 | 288 |
287 | 289 |
288 BreakLocation BreakLocation::FromPosition(Handle<DebugInfo> debug_info, | 290 BreakLocation BreakLocation::FromPosition(Handle<DebugInfo> debug_info, |
289 int position, | 291 int position, |
290 BreakPositionAlignment alignment) { | 292 BreakPositionAlignment alignment) { |
291 // Run through all break points to locate the one closest to the source | 293 // Run through all break points to locate the one closest to the source |
292 // position. | 294 // position. |
293 int distance = kMaxInt; | 295 int distance = kMaxInt; |
294 base::SmartPointer<Iterator> it(GetIterator(debug_info)); | 296 std::unique_ptr<Iterator> it(GetIterator(debug_info)); |
295 BreakLocation closest_break = it->GetBreakLocation(); | 297 BreakLocation closest_break = it->GetBreakLocation(); |
296 while (!it->Done()) { | 298 while (!it->Done()) { |
297 int next_position; | 299 int next_position; |
298 if (alignment == STATEMENT_ALIGNED) { | 300 if (alignment == STATEMENT_ALIGNED) { |
299 next_position = it->statement_position(); | 301 next_position = it->statement_position(); |
300 } else { | 302 } else { |
301 DCHECK(alignment == BREAK_POSITION_ALIGNED); | 303 DCHECK(alignment == BREAK_POSITION_ALIGNED); |
302 next_position = it->position(); | 304 next_position = it->position(); |
303 } | 305 } |
304 if (position <= next_position && next_position - position < distance) { | 306 if (position <= next_position && next_position - position < distance) { |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 } | 846 } |
845 } | 847 } |
846 | 848 |
847 | 849 |
848 // Clear out all the debug break code. This is ONLY supposed to be used when | 850 // Clear out all the debug break code. This is ONLY supposed to be used when |
849 // shutting down the debugger as it will leave the break point information in | 851 // shutting down the debugger as it will leave the break point information in |
850 // DebugInfo even though the code is patched back to the non break point state. | 852 // DebugInfo even though the code is patched back to the non break point state. |
851 void Debug::ClearAllBreakPoints() { | 853 void Debug::ClearAllBreakPoints() { |
852 for (DebugInfoListNode* node = debug_info_list_; node != NULL; | 854 for (DebugInfoListNode* node = debug_info_list_; node != NULL; |
853 node = node->next()) { | 855 node = node->next()) { |
854 for (base::SmartPointer<BreakLocation::Iterator> it( | 856 for (std::unique_ptr<BreakLocation::Iterator> it( |
855 BreakLocation::GetIterator(node->debug_info())); | 857 BreakLocation::GetIterator(node->debug_info())); |
856 !it->Done(); it->Next()) { | 858 !it->Done(); it->Next()) { |
857 it->GetBreakLocation().ClearDebugBreak(); | 859 it->GetBreakLocation().ClearDebugBreak(); |
858 } | 860 } |
859 } | 861 } |
860 // Remove all debug info. | 862 // Remove all debug info. |
861 while (debug_info_list_ != NULL) { | 863 while (debug_info_list_ != NULL) { |
862 RemoveDebugInfoAndClearFromShared(debug_info_list_->debug_info()); | 864 RemoveDebugInfoAndClearFromShared(debug_info_list_->debug_info()); |
863 } | 865 } |
864 } | 866 } |
(...skipping 13 matching lines...) Expand all Loading... |
878 } | 880 } |
879 // Make sure the function is compiled and has set up the debug info. | 881 // Make sure the function is compiled and has set up the debug info. |
880 Handle<SharedFunctionInfo> shared(function->shared()); | 882 Handle<SharedFunctionInfo> shared(function->shared()); |
881 if (!EnsureDebugInfo(shared, function)) { | 883 if (!EnsureDebugInfo(shared, function)) { |
882 // Return if we failed to retrieve the debug info. | 884 // Return if we failed to retrieve the debug info. |
883 return; | 885 return; |
884 } | 886 } |
885 | 887 |
886 // Flood the function with break points. | 888 // Flood the function with break points. |
887 Handle<DebugInfo> debug_info(shared->GetDebugInfo()); | 889 Handle<DebugInfo> debug_info(shared->GetDebugInfo()); |
888 for (base::SmartPointer<BreakLocation::Iterator> it( | 890 for (std::unique_ptr<BreakLocation::Iterator> it( |
889 BreakLocation::GetIterator(debug_info, type)); | 891 BreakLocation::GetIterator(debug_info, type)); |
890 !it->Done(); it->Next()) { | 892 !it->Done(); it->Next()) { |
891 it->GetBreakLocation().SetOneShot(); | 893 it->GetBreakLocation().SetOneShot(); |
892 } | 894 } |
893 } | 895 } |
894 | 896 |
895 | 897 |
896 void Debug::ChangeBreakOnException(ExceptionBreakType type, bool enable) { | 898 void Debug::ChangeBreakOnException(ExceptionBreakType type, bool enable) { |
897 if (type == BreakUncaughtException) { | 899 if (type == BreakUncaughtException) { |
898 break_on_uncaught_exception_ = enable; | 900 break_on_uncaught_exception_ = enable; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 | 1122 |
1121 // 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 |
1122 // 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 |
1123 // are used to support stepping. | 1125 // are used to support stepping. |
1124 void Debug::ClearOneShot() { | 1126 void Debug::ClearOneShot() { |
1125 // The current implementation just runs through all the breakpoints. When the | 1127 // The current implementation just runs through all the breakpoints. When the |
1126 // 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 |
1127 // removed from the list. | 1129 // removed from the list. |
1128 for (DebugInfoListNode* node = debug_info_list_; node != NULL; | 1130 for (DebugInfoListNode* node = debug_info_list_; node != NULL; |
1129 node = node->next()) { | 1131 node = node->next()) { |
1130 for (base::SmartPointer<BreakLocation::Iterator> it( | 1132 for (std::unique_ptr<BreakLocation::Iterator> it( |
1131 BreakLocation::GetIterator(node->debug_info())); | 1133 BreakLocation::GetIterator(node->debug_info())); |
1132 !it->Done(); it->Next()) { | 1134 !it->Done(); it->Next()) { |
1133 it->GetBreakLocation().ClearOneShot(); | 1135 it->GetBreakLocation().ClearOneShot(); |
1134 } | 1136 } |
1135 } | 1137 } |
1136 } | 1138 } |
1137 | 1139 |
1138 | 1140 |
1139 bool MatchingCodeTargets(Code* target1, Code* target2) { | 1141 bool MatchingCodeTargets(Code* target1, Code* target2) { |
1140 if (target1 == target2) return true; | 1142 if (target1 == target2) return true; |
(...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2572 } | 2574 } |
2573 | 2575 |
2574 | 2576 |
2575 void LockingCommandMessageQueue::Clear() { | 2577 void LockingCommandMessageQueue::Clear() { |
2576 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2578 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
2577 queue_.Clear(); | 2579 queue_.Clear(); |
2578 } | 2580 } |
2579 | 2581 |
2580 } // namespace internal | 2582 } // namespace internal |
2581 } // namespace v8 | 2583 } // namespace v8 |
OLD | NEW |