Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: src/api.cc

Issue 8909: Added some missing initialization checks to the debugger API.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/test-debug.cc » ('j') | test/cctest/test-debug.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2782 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 } 2793 }
2794 i::Handle<i::Object> result(error); 2794 i::Handle<i::Object> result(error);
2795 return Utils::ToLocal(result); 2795 return Utils::ToLocal(result);
2796 } 2796 }
2797 2797
2798 2798
2799 // --- D e b u g S u p p o r t --- 2799 // --- D e b u g S u p p o r t ---
2800 2800
2801 2801
2802 bool Debug::AddDebugEventListener(DebugEventCallback that, Handle<Value> data) { 2802 bool Debug::AddDebugEventListener(DebugEventCallback that, Handle<Value> data) {
2803 EnsureInitialized("v8::V8::AddDebugEventListener()"); 2803 EnsureInitialized("v8::Debug::AddDebugEventListener()");
2804 ON_BAILOUT("v8::V8::AddDebugEventListener()", return false); 2804 ON_BAILOUT("v8::Debug::AddDebugEventListener()", return false);
2805 HandleScope scope; 2805 HandleScope scope;
2806 NeanderArray listeners(i::Factory::debug_event_listeners()); 2806 NeanderArray listeners(i::Factory::debug_event_listeners());
2807 NeanderObject obj(2); 2807 NeanderObject obj(2);
2808 obj.set(0, *i::Factory::NewProxy(FUNCTION_ADDR(that))); 2808 obj.set(0, *i::Factory::NewProxy(FUNCTION_ADDR(that)));
2809 obj.set(1, data.IsEmpty() ? 2809 obj.set(1, data.IsEmpty() ?
2810 i::Heap::undefined_value() : 2810 i::Heap::undefined_value() :
2811 *Utils::OpenHandle(*data)); 2811 *Utils::OpenHandle(*data));
2812 listeners.add(obj.value()); 2812 listeners.add(obj.value());
2813 i::Debugger::UpdateActiveDebugger(); 2813 i::Debugger::UpdateActiveDebugger();
2814 return true; 2814 return true;
2815 } 2815 }
2816 2816
2817 2817
2818 bool Debug::AddDebugEventListener(v8::Handle<v8::Function> that, 2818 bool Debug::AddDebugEventListener(v8::Handle<v8::Function> that,
2819 Handle<Value> data) { 2819 Handle<Value> data) {
2820 ON_BAILOUT("v8::V8::AddDebugEventListener()", return false); 2820 ON_BAILOUT("v8::Debug::AddDebugEventListener()", return false);
2821 HandleScope scope; 2821 HandleScope scope;
2822 NeanderArray listeners(i::Factory::debug_event_listeners()); 2822 NeanderArray listeners(i::Factory::debug_event_listeners());
2823 NeanderObject obj(2); 2823 NeanderObject obj(2);
2824 obj.set(0, *Utils::OpenHandle(*that)); 2824 obj.set(0, *Utils::OpenHandle(*that));
2825 obj.set(1, data.IsEmpty() ? 2825 obj.set(1, data.IsEmpty() ?
2826 i::Heap::undefined_value() : 2826 i::Heap::undefined_value() :
2827 *Utils::OpenHandle(*data)); 2827 *Utils::OpenHandle(*data));
2828 listeners.add(obj.value()); 2828 listeners.add(obj.value());
2829 i::Debugger::UpdateActiveDebugger(); 2829 i::Debugger::UpdateActiveDebugger();
2830 return true; 2830 return true;
2831 } 2831 }
2832 2832
2833 2833
2834 void Debug::RemoveDebugEventListener(DebugEventCallback that) { 2834 void Debug::RemoveDebugEventListener(DebugEventCallback that) {
2835 EnsureInitialized("v8::V8::RemoveDebugEventListener()"); 2835 EnsureInitialized("v8::Debug::RemoveDebugEventListener()");
2836 ON_BAILOUT("v8::V8::RemoveDebugEventListener()", return); 2836 ON_BAILOUT("v8::Debug::RemoveDebugEventListener()", return);
2837 HandleScope scope; 2837 HandleScope scope;
2838 NeanderArray listeners(i::Factory::debug_event_listeners()); 2838 NeanderArray listeners(i::Factory::debug_event_listeners());
2839 for (int i = 0; i < listeners.length(); i++) { 2839 for (int i = 0; i < listeners.length(); i++) {
2840 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones 2840 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones
2841 2841
2842 NeanderObject listener(i::JSObject::cast(listeners.get(i))); 2842 NeanderObject listener(i::JSObject::cast(listeners.get(i)));
2843 // When removing a C debug event listener only consider proxy objects. 2843 // When removing a C debug event listener only consider proxy objects.
2844 if (listener.get(0)->IsProxy()) { 2844 if (listener.get(0)->IsProxy()) {
2845 i::Handle<i::Proxy> callback_obj(i::Proxy::cast(listener.get(0))); 2845 i::Handle<i::Proxy> callback_obj(i::Proxy::cast(listener.get(0)));
2846 if (callback_obj->proxy() == FUNCTION_ADDR(that)) { 2846 if (callback_obj->proxy() == FUNCTION_ADDR(that)) {
2847 listeners.set(i, i::Heap::undefined_value()); 2847 listeners.set(i, i::Heap::undefined_value());
2848 } 2848 }
2849 } 2849 }
2850 } 2850 }
2851 i::Debugger::UpdateActiveDebugger(); 2851 i::Debugger::UpdateActiveDebugger();
2852 } 2852 }
2853 2853
2854 2854
2855 void Debug::RemoveDebugEventListener(v8::Handle<v8::Function> that) { 2855 void Debug::RemoveDebugEventListener(v8::Handle<v8::Function> that) {
2856 ON_BAILOUT("v8::V8::RemoveDebugEventListener()", return); 2856 ON_BAILOUT("v8::Debug::RemoveDebugEventListener()", return);
2857 HandleScope scope; 2857 HandleScope scope;
2858 NeanderArray listeners(i::Factory::debug_event_listeners()); 2858 NeanderArray listeners(i::Factory::debug_event_listeners());
2859 for (int i = 0; i < listeners.length(); i++) { 2859 for (int i = 0; i < listeners.length(); i++) {
2860 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones 2860 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones
2861 2861
2862 NeanderObject listener(i::JSObject::cast(listeners.get(i))); 2862 NeanderObject listener(i::JSObject::cast(listeners.get(i)));
2863 // When removing a JavaScript debug event listener only consider JavaScript 2863 // When removing a JavaScript debug event listener only consider JavaScript
2864 // function objects. 2864 // function objects.
2865 if (listener.get(0)->IsJSFunction()) { 2865 if (listener.get(0)->IsJSFunction()) {
2866 i::JSFunction* callback = i::JSFunction::cast(listener.get(0)); 2866 i::JSFunction* callback = i::JSFunction::cast(listener.get(0));
2867 i::Handle<i::JSFunction> callback_fun(callback); 2867 i::Handle<i::JSFunction> callback_fun(callback);
2868 if (callback_fun.is_identical_to(Utils::OpenHandle(*that))) { 2868 if (callback_fun.is_identical_to(Utils::OpenHandle(*that))) {
2869 listeners.set(i, i::Heap::undefined_value()); 2869 listeners.set(i, i::Heap::undefined_value());
2870 } 2870 }
2871 } 2871 }
2872 } 2872 }
2873 i::Debugger::UpdateActiveDebugger(); 2873 i::Debugger::UpdateActiveDebugger();
2874 } 2874 }
2875 2875
2876 2876
2877 void Debug::DebugBreak() { 2877 void Debug::DebugBreak() {
2878 if (!i::V8::HasBeenSetup()) return;
2878 i::StackGuard::DebugBreak(); 2879 i::StackGuard::DebugBreak();
2879 } 2880 }
2880 2881
2881 2882
2882 void Debug::SetMessageHandler(v8::DebugMessageHandler handler, void* data) { 2883 void Debug::SetMessageHandler(v8::DebugMessageHandler handler, void* data) {
2884 EnsureInitialized("v8::Debug::SetMessageHandler");
2883 i::Debugger::SetMessageHandler(handler, data); 2885 i::Debugger::SetMessageHandler(handler, data);
2884 } 2886 }
2885 2887
2886 2888
2887 void Debug::SendCommand(const uint16_t* command, int length) { 2889 void Debug::SendCommand(const uint16_t* command, int length) {
2890 if (!i::V8::HasBeenSetup()) return;
Kasper Lund 2008/10/30 10:09:34 Does the command sender expect an answer? If so, t
Søren Thygesen Gjesse 2008/10/30 10:27:02 All command responses are send through a callback
2888 i::Debugger::ProcessCommand(i::Vector<const uint16_t>(command, length)); 2891 i::Debugger::ProcessCommand(i::Vector<const uint16_t>(command, length));
2889 } 2892 }
2890 2893
2891 2894
2892 namespace internal { 2895 namespace internal {
2893 2896
2894 2897
2895 HandleScopeImplementer* HandleScopeImplementer::instance() { 2898 HandleScopeImplementer* HandleScopeImplementer::instance() {
2896 return &thread_local; 2899 return &thread_local;
2897 } 2900 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2963 reinterpret_cast<HandleScopeImplementer*>(storage); 2966 reinterpret_cast<HandleScopeImplementer*>(storage);
2964 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); 2967 List<void**>* blocks_of_archived_thread = thread_local->Blocks();
2965 ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = 2968 ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread =
2966 &thread_local->handle_scope_data_; 2969 &thread_local->handle_scope_data_;
2967 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); 2970 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread);
2968 2971
2969 return storage + ArchiveSpacePerThread(); 2972 return storage + ArchiveSpacePerThread();
2970 } 2973 }
2971 2974
2972 } } // namespace v8::internal 2975 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-debug.cc » ('j') | test/cctest/test-debug.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698