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 "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "api.h" | 7 #include "api.h" |
8 #include "arguments.h" | 8 #include "arguments.h" |
9 #include "bootstrapper.h" | 9 #include "bootstrapper.h" |
10 #include "code-stubs.h" | 10 #include "code-stubs.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 Debug::Debug(Isolate* isolate) | 33 Debug::Debug(Isolate* isolate) |
34 : has_break_points_(false), | 34 : has_break_points_(false), |
35 script_cache_(NULL), | 35 script_cache_(NULL), |
36 debug_info_list_(NULL), | 36 debug_info_list_(NULL), |
37 disable_break_(false), | 37 disable_break_(false), |
38 break_on_exception_(false), | 38 break_on_exception_(false), |
39 break_on_uncaught_exception_(false), | 39 break_on_uncaught_exception_(false), |
40 promise_catch_handlers_(0), | 40 promise_catch_handlers_(0), |
41 promise_getters_(0), | 41 promise_getters_(0), |
42 debug_break_return_(NULL), | |
43 debug_break_slot_(NULL), | |
44 isolate_(isolate) { | 42 isolate_(isolate) { |
45 memset(registers_, 0, sizeof(JSCallerSavedBuffer)); | 43 memset(registers_, 0, sizeof(JSCallerSavedBuffer)); |
| 44 ThreadInit(); |
46 } | 45 } |
47 | 46 |
48 | 47 |
49 Debug::~Debug() { | 48 Debug::~Debug() { |
50 } | 49 } |
51 | 50 |
52 | 51 |
53 static void PrintLn(v8::Local<v8::Value> value) { | 52 static void PrintLn(v8::Local<v8::Value> value) { |
54 v8::Local<v8::String> s = value->ToString(); | 53 v8::Local<v8::String> s = value->ToString(); |
55 ScopedVector<char> data(s->Utf8Length() + 1); | 54 ScopedVector<char> data(s->Utf8Length() + 1); |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 HashMap::Entry* entry = script_cache->Lookup(key, hash, false); | 657 HashMap::Entry* entry = script_cache->Lookup(key, hash, false); |
659 Object** location = reinterpret_cast<Object**>(entry->value); | 658 Object** location = reinterpret_cast<Object**>(entry->value); |
660 script_cache->Remove(key, hash); | 659 script_cache->Remove(key, hash); |
661 script_cache->collected_scripts_.Add(id); | 660 script_cache->collected_scripts_.Add(id); |
662 | 661 |
663 // Clear the weak handle. | 662 // Clear the weak handle. |
664 GlobalHandles::Destroy(location); | 663 GlobalHandles::Destroy(location); |
665 } | 664 } |
666 | 665 |
667 | 666 |
668 void Debug::SetUp(bool create_heap_objects) { | |
669 ThreadInit(); | |
670 if (create_heap_objects) { | |
671 // Get code to handle debug break on return. | |
672 debug_break_return_ = | |
673 isolate_->builtins()->builtin(Builtins::kReturn_DebugBreak); | |
674 ASSERT(debug_break_return_->IsCode()); | |
675 // Get code to handle debug break in debug break slots. | |
676 debug_break_slot_ = | |
677 isolate_->builtins()->builtin(Builtins::kSlot_DebugBreak); | |
678 ASSERT(debug_break_slot_->IsCode()); | |
679 } | |
680 } | |
681 | |
682 | |
683 void Debug::HandleWeakDebugInfo( | 667 void Debug::HandleWeakDebugInfo( |
684 const v8::WeakCallbackData<v8::Value, void>& data) { | 668 const v8::WeakCallbackData<v8::Value, void>& data) { |
685 Debug* debug = reinterpret_cast<Isolate*>(data.GetIsolate())->debug(); | 669 Debug* debug = reinterpret_cast<Isolate*>(data.GetIsolate())->debug(); |
686 DebugInfoListNode* node = | 670 DebugInfoListNode* node = |
687 reinterpret_cast<DebugInfoListNode*>(data.GetParameter()); | 671 reinterpret_cast<DebugInfoListNode*>(data.GetParameter()); |
688 // We need to clear all breakpoints associated with the function to restore | 672 // We need to clear all breakpoints associated with the function to restore |
689 // original code and avoid patching the code twice later because | 673 // original code and avoid patching the code twice later because |
690 // the function will live in the heap until next gc, and can be found by | 674 // the function will live in the heap until next gc, and can be found by |
691 // Debug::FindSharedFunctionInfoInScript. | 675 // Debug::FindSharedFunctionInfoInScript. |
692 BreakLocationIterator it(node->debug_info(), ALL_BREAK_LOCATIONS); | 676 BreakLocationIterator it(node->debug_info(), ALL_BREAK_LOCATIONS); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 } | 860 } |
877 | 861 |
878 | 862 |
879 // Set the flag indicating that preemption happened during debugging. | 863 // Set the flag indicating that preemption happened during debugging. |
880 void Debug::PreemptionWhileInDebugger() { | 864 void Debug::PreemptionWhileInDebugger() { |
881 ASSERT(InDebugger()); | 865 ASSERT(InDebugger()); |
882 Debug::set_interrupts_pending(PREEMPT); | 866 Debug::set_interrupts_pending(PREEMPT); |
883 } | 867 } |
884 | 868 |
885 | 869 |
886 void Debug::Iterate(ObjectVisitor* v) { | |
887 v->VisitPointer(BitCast<Object**>(&(debug_break_return_))); | |
888 v->VisitPointer(BitCast<Object**>(&(debug_break_slot_))); | |
889 } | |
890 | |
891 | |
892 Object* Debug::Break(Arguments args) { | 870 Object* Debug::Break(Arguments args) { |
893 Heap* heap = isolate_->heap(); | 871 Heap* heap = isolate_->heap(); |
894 HandleScope scope(isolate_); | 872 HandleScope scope(isolate_); |
895 ASSERT(args.length() == 0); | 873 ASSERT(args.length() == 0); |
896 | 874 |
897 thread_local_.frame_drop_mode_ = FRAMES_UNTOUCHED; | 875 thread_local_.frame_drop_mode_ = FRAMES_UNTOUCHED; |
898 | 876 |
899 // Get the top-most JavaScript frame. | 877 // Get the top-most JavaScript frame. |
900 JavaScriptFrameIterator it(isolate_); | 878 JavaScriptFrameIterator it(isolate_); |
901 JavaScriptFrame* frame = it.frame(); | 879 JavaScriptFrame* frame = it.frame(); |
(...skipping 2872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3774 already_signalled_ = false; | 3752 already_signalled_ = false; |
3775 } | 3753 } |
3776 { | 3754 { |
3777 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3755 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
3778 isolate_->debugger()->CallMessageDispatchHandler(); | 3756 isolate_->debugger()->CallMessageDispatchHandler(); |
3779 } | 3757 } |
3780 } | 3758 } |
3781 } | 3759 } |
3782 | 3760 |
3783 } } // namespace v8::internal | 3761 } } // namespace v8::internal |
OLD | NEW |