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 #ifndef V8_DEBUG_H_ | 5 #ifndef V8_DEBUG_H_ |
6 #define V8_DEBUG_H_ | 6 #define V8_DEBUG_H_ |
7 | 7 |
8 #include "allocation.h" | 8 #include "allocation.h" |
9 #include "arguments.h" | 9 #include "arguments.h" |
10 #include "assembler.h" | 10 #include "assembler.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 205 |
206 // This class contains the debugger support. The main purpose is to handle | 206 // This class contains the debugger support. The main purpose is to handle |
207 // setting break points in the code. | 207 // setting break points in the code. |
208 // | 208 // |
209 // This class controls the debug info for all functions which currently have | 209 // This class controls the debug info for all functions which currently have |
210 // active breakpoints in them. This debug info is held in the heap root object | 210 // active breakpoints in them. This debug info is held in the heap root object |
211 // debug_info which is a FixedArray. Each entry in this list is of class | 211 // debug_info which is a FixedArray. Each entry in this list is of class |
212 // DebugInfo. | 212 // DebugInfo. |
213 class Debug { | 213 class Debug { |
214 public: | 214 public: |
215 void SetUp(bool create_heap_objects); | |
216 bool Load(); | 215 bool Load(); |
217 void Unload(); | 216 void Unload(); |
218 bool IsLoaded() { return !debug_context_.is_null(); } | 217 bool IsLoaded() { return !debug_context_.is_null(); } |
219 bool InDebugger() { return thread_local_.debugger_entry_ != NULL; } | 218 bool InDebugger() { return thread_local_.debugger_entry_ != NULL; } |
220 void PreemptionWhileInDebugger(); | 219 void PreemptionWhileInDebugger(); |
221 void Iterate(ObjectVisitor* v); | |
222 | 220 |
223 Object* Break(Arguments args); | 221 Object* Break(Arguments args); |
224 void SetBreakPoint(Handle<JSFunction> function, | 222 void SetBreakPoint(Handle<JSFunction> function, |
225 Handle<Object> break_point_object, | 223 Handle<Object> break_point_object, |
226 int* source_position); | 224 int* source_position); |
227 bool SetBreakPointForScript(Handle<Script> script, | 225 bool SetBreakPointForScript(Handle<Script> script, |
228 Handle<Object> break_point_object, | 226 Handle<Object> break_point_object, |
229 int* source_position, | 227 int* source_position, |
230 BreakPositionAlignment alignment); | 228 BreakPositionAlignment alignment); |
231 void ClearBreakPoint(Handle<Object> break_point_object); | 229 void ClearBreakPoint(Handle<Object> break_point_object); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 } | 338 } |
341 | 339 |
342 // Getters for the current exception break state. | 340 // Getters for the current exception break state. |
343 bool break_on_exception() { return break_on_exception_; } | 341 bool break_on_exception() { return break_on_exception_; } |
344 bool break_on_uncaught_exception() { | 342 bool break_on_uncaught_exception() { |
345 return break_on_uncaught_exception_; | 343 return break_on_uncaught_exception_; |
346 } | 344 } |
347 | 345 |
348 enum AddressId { | 346 enum AddressId { |
349 k_after_break_target_address, | 347 k_after_break_target_address, |
350 k_debug_break_return_address, | |
351 k_debug_break_slot_address, | |
352 k_restarter_frame_function_pointer | 348 k_restarter_frame_function_pointer |
353 }; | 349 }; |
354 | 350 |
355 // Support for setting the address to jump to when returning from break point. | 351 // Support for setting the address to jump to when returning from break point. |
356 Address* after_break_target_address() { | 352 Address* after_break_target_address() { |
357 return reinterpret_cast<Address*>(&thread_local_.after_break_target_); | 353 return reinterpret_cast<Address*>(&thread_local_.after_break_target_); |
358 } | 354 } |
359 Address* restarter_frame_function_pointer_address() { | 355 Address* restarter_frame_function_pointer_address() { |
360 Object*** address = &thread_local_.restarter_frame_function_pointer_; | 356 Object*** address = &thread_local_.restarter_frame_function_pointer_; |
361 return reinterpret_cast<Address*>(address); | 357 return reinterpret_cast<Address*>(address); |
362 } | 358 } |
363 | 359 |
364 // Support for saving/restoring registers when handling debug break calls. | 360 // Support for saving/restoring registers when handling debug break calls. |
365 Object** register_address(int r) { | 361 Object** register_address(int r) { |
366 return ®isters_[r]; | 362 return ®isters_[r]; |
367 } | 363 } |
368 | 364 |
369 // Access to the debug break on return code. | |
370 Code* debug_break_return() { return debug_break_return_; } | |
371 Code** debug_break_return_address() { | |
372 return &debug_break_return_; | |
373 } | |
374 | |
375 // Access to the debug break in debug break slot code. | |
376 Code* debug_break_slot() { return debug_break_slot_; } | |
377 Code** debug_break_slot_address() { | |
378 return &debug_break_slot_; | |
379 } | |
380 | |
381 static const int kEstimatedNofDebugInfoEntries = 16; | 365 static const int kEstimatedNofDebugInfoEntries = 16; |
382 static const int kEstimatedNofBreakPointsInFunction = 16; | 366 static const int kEstimatedNofBreakPointsInFunction = 16; |
383 | 367 |
384 // Passed to MakeWeak. | 368 // Passed to MakeWeak. |
385 static void HandleWeakDebugInfo( | 369 static void HandleWeakDebugInfo( |
386 const v8::WeakCallbackData<v8::Value, void>& data); | 370 const v8::WeakCallbackData<v8::Value, void>& data); |
387 | 371 |
388 friend class Debugger; | 372 friend class Debugger; |
389 friend Handle<FixedArray> GetDebuggedFunctions(); // In test-debug.cc | 373 friend Handle<FixedArray> GetDebuggedFunctions(); // In test-debug.cc |
390 friend void CheckDebuggerUnloaded(bool check_functions); // In test-debug.cc | 374 friend void CheckDebuggerUnloaded(bool check_functions); // In test-debug.cc |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 // of the pointer to function being restarted. Otherwise (most of the time) | 587 // of the pointer to function being restarted. Otherwise (most of the time) |
604 // stores NULL. This pointer is used with 'step in' implementation. | 588 // stores NULL. This pointer is used with 'step in' implementation. |
605 Object** restarter_frame_function_pointer_; | 589 Object** restarter_frame_function_pointer_; |
606 }; | 590 }; |
607 | 591 |
608 // Storage location for registers when handling debug break calls | 592 // Storage location for registers when handling debug break calls |
609 JSCallerSavedBuffer registers_; | 593 JSCallerSavedBuffer registers_; |
610 ThreadLocal thread_local_; | 594 ThreadLocal thread_local_; |
611 void ThreadInit(); | 595 void ThreadInit(); |
612 | 596 |
613 // Code to call for handling debug break on return. | |
614 Code* debug_break_return_; | |
615 | |
616 // Code to call for handling debug break in debug break slots. | |
617 Code* debug_break_slot_; | |
618 | |
619 Isolate* isolate_; | 597 Isolate* isolate_; |
620 | 598 |
621 friend class Isolate; | 599 friend class Isolate; |
622 | 600 |
623 DISALLOW_COPY_AND_ASSIGN(Debug); | 601 DISALLOW_COPY_AND_ASSIGN(Debug); |
624 }; | 602 }; |
625 | 603 |
626 | 604 |
627 DECLARE_RUNTIME_FUNCTION(Debug_Break); | 605 DECLARE_RUNTIME_FUNCTION(Debug_Break); |
628 | 606 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 // Debug_Address encapsulates the Address pointers used in generating debug | 967 // Debug_Address encapsulates the Address pointers used in generating debug |
990 // code. | 968 // code. |
991 class Debug_Address { | 969 class Debug_Address { |
992 public: | 970 public: |
993 explicit Debug_Address(Debug::AddressId id) : id_(id) { } | 971 explicit Debug_Address(Debug::AddressId id) : id_(id) { } |
994 | 972 |
995 static Debug_Address AfterBreakTarget() { | 973 static Debug_Address AfterBreakTarget() { |
996 return Debug_Address(Debug::k_after_break_target_address); | 974 return Debug_Address(Debug::k_after_break_target_address); |
997 } | 975 } |
998 | 976 |
999 static Debug_Address DebugBreakReturn() { | |
1000 return Debug_Address(Debug::k_debug_break_return_address); | |
1001 } | |
1002 | |
1003 static Debug_Address RestarterFrameFunctionPointer() { | 977 static Debug_Address RestarterFrameFunctionPointer() { |
1004 return Debug_Address(Debug::k_restarter_frame_function_pointer); | 978 return Debug_Address(Debug::k_restarter_frame_function_pointer); |
1005 } | 979 } |
1006 | 980 |
1007 Address address(Isolate* isolate) const { | 981 Address address(Isolate* isolate) const { |
1008 Debug* debug = isolate->debug(); | 982 Debug* debug = isolate->debug(); |
1009 switch (id_) { | 983 switch (id_) { |
1010 case Debug::k_after_break_target_address: | 984 case Debug::k_after_break_target_address: |
1011 return reinterpret_cast<Address>(debug->after_break_target_address()); | 985 return reinterpret_cast<Address>(debug->after_break_target_address()); |
1012 case Debug::k_debug_break_return_address: | |
1013 return reinterpret_cast<Address>(debug->debug_break_return_address()); | |
1014 case Debug::k_debug_break_slot_address: | |
1015 return reinterpret_cast<Address>(debug->debug_break_slot_address()); | |
1016 case Debug::k_restarter_frame_function_pointer: | 986 case Debug::k_restarter_frame_function_pointer: |
1017 return reinterpret_cast<Address>( | 987 return reinterpret_cast<Address>( |
1018 debug->restarter_frame_function_pointer_address()); | 988 debug->restarter_frame_function_pointer_address()); |
1019 default: | 989 default: |
1020 UNREACHABLE(); | 990 UNREACHABLE(); |
1021 return NULL; | 991 return NULL; |
1022 } | 992 } |
1023 } | 993 } |
1024 | 994 |
1025 private: | 995 private: |
(...skipping 19 matching lines...) Expand all Loading... |
1045 Mutex mutex_; | 1015 Mutex mutex_; |
1046 bool already_signalled_; | 1016 bool already_signalled_; |
1047 | 1017 |
1048 DISALLOW_COPY_AND_ASSIGN(MessageDispatchHelperThread); | 1018 DISALLOW_COPY_AND_ASSIGN(MessageDispatchHelperThread); |
1049 }; | 1019 }; |
1050 | 1020 |
1051 | 1021 |
1052 } } // namespace v8::internal | 1022 } } // namespace v8::internal |
1053 | 1023 |
1054 #endif // V8_DEBUG_H_ | 1024 #endif // V8_DEBUG_H_ |
OLD | NEW |