| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 static Handle<Code> ComputeCallDebugPrepareStepIn(int argc, Code::Kind kind) { | 72 static Handle<Code> ComputeCallDebugPrepareStepIn(int argc, Code::Kind kind) { |
| 73 CALL_HEAP_FUNCTION( | 73 CALL_HEAP_FUNCTION( |
| 74 Isolate::Current()->stub_cache()->ComputeCallDebugPrepareStepIn( | 74 Isolate::Current()->stub_cache()->ComputeCallDebugPrepareStepIn( |
| 75 argc, kind), | 75 argc, kind), |
| 76 Code); | 76 Code); |
| 77 } | 77 } |
| 78 | 78 |
| 79 | 79 |
| 80 static v8::Handle<v8::Context> GetDebugEventContext() { | 80 static v8::Handle<v8::Context> GetDebugEventContext() { |
| 81 Handle<Context> context = Debug::debugger_entry()->GetContext(); | 81 Handle<Context> context = Debug::debugger_entry()->GetContext(); |
| 82 // Top::context() may have been NULL when "script collected" event occured. | 82 // Isolate::context() may have been NULL when "script collected" event |
| 83 // occured. |
| 83 if (*context == NULL) { | 84 if (*context == NULL) { |
| 84 return v8::Local<v8::Context>(); | 85 return v8::Local<v8::Context>(); |
| 85 } | 86 } |
| 86 Handle<Context> global_context(context->global_context()); | 87 Handle<Context> global_context(context->global_context()); |
| 87 return v8::Utils::ToLocal(global_context); | 88 return v8::Utils::ToLocal(global_context); |
| 88 } | 89 } |
| 89 | 90 |
| 90 | 91 |
| 91 BreakLocationIterator::BreakLocationIterator(Handle<DebugInfo> debug_info, | 92 BreakLocationIterator::BreakLocationIterator(Handle<DebugInfo> debug_info, |
| 92 BreakLocatorType type) { | 93 BreakLocatorType type) { |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 Handle<SharedFunctionInfo> function_info; | 732 Handle<SharedFunctionInfo> function_info; |
| 732 function_info = Compiler::Compile(source_code, | 733 function_info = Compiler::Compile(source_code, |
| 733 script_name, | 734 script_name, |
| 734 0, 0, NULL, NULL, | 735 0, 0, NULL, NULL, |
| 735 Handle<String>::null(), | 736 Handle<String>::null(), |
| 736 NATIVES_CODE); | 737 NATIVES_CODE); |
| 737 FLAG_allow_natives_syntax = allow_natives_syntax; | 738 FLAG_allow_natives_syntax = allow_natives_syntax; |
| 738 | 739 |
| 739 // Silently ignore stack overflows during compilation. | 740 // Silently ignore stack overflows during compilation. |
| 740 if (function_info.is_null()) { | 741 if (function_info.is_null()) { |
| 741 ASSERT(Top::has_pending_exception()); | 742 ASSERT(Isolate::Current()->has_pending_exception()); |
| 742 Top::clear_pending_exception(); | 743 Isolate::Current()->clear_pending_exception(); |
| 743 return false; | 744 return false; |
| 744 } | 745 } |
| 745 | 746 |
| 746 // Execute the shared function in the debugger context. | 747 // Execute the shared function in the debugger context. |
| 747 Handle<Context> context = Top::global_context(); | 748 Handle<Context> context = Isolate::Current()->global_context(); |
| 748 bool caught_exception = false; | 749 bool caught_exception = false; |
| 749 Handle<JSFunction> function = | 750 Handle<JSFunction> function = |
| 750 Factory::NewFunctionFromSharedFunctionInfo(function_info, context); | 751 Factory::NewFunctionFromSharedFunctionInfo(function_info, context); |
| 751 Handle<Object> result = | 752 Handle<Object> result = |
| 752 Execution::TryCall(function, Handle<Object>(context->global()), | 753 Execution::TryCall(function, Handle<Object>(context->global()), |
| 753 0, NULL, &caught_exception); | 754 0, NULL, &caught_exception); |
| 754 | 755 |
| 755 // Check for caught exceptions. | 756 // Check for caught exceptions. |
| 756 if (caught_exception) { | 757 if (caught_exception) { |
| 757 Handle<Object> message = MessageHandler::MakeMessageObject( | 758 Handle<Object> message = MessageHandler::MakeMessageObject( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 786 // Create the debugger context. | 787 // Create the debugger context. |
| 787 HandleScope scope; | 788 HandleScope scope; |
| 788 Handle<Context> context = | 789 Handle<Context> context = |
| 789 Isolate::Current()->bootstrapper()->CreateEnvironment( | 790 Isolate::Current()->bootstrapper()->CreateEnvironment( |
| 790 Handle<Object>::null(), | 791 Handle<Object>::null(), |
| 791 v8::Handle<ObjectTemplate>(), | 792 v8::Handle<ObjectTemplate>(), |
| 792 NULL); | 793 NULL); |
| 793 | 794 |
| 794 // Use the debugger context. | 795 // Use the debugger context. |
| 795 SaveContext save; | 796 SaveContext save; |
| 796 Top::set_context(*context); | 797 Isolate::Current()->set_context(*context); |
| 797 | 798 |
| 798 // Expose the builtins object in the debugger context. | 799 // Expose the builtins object in the debugger context. |
| 799 Handle<String> key = Factory::LookupAsciiSymbol("builtins"); | 800 Handle<String> key = Factory::LookupAsciiSymbol("builtins"); |
| 800 Handle<GlobalObject> global = Handle<GlobalObject>(context->global()); | 801 Handle<GlobalObject> global = Handle<GlobalObject>(context->global()); |
| 801 SetProperty(global, key, Handle<Object>(global->builtins()), NONE); | 802 SetProperty(global, key, Handle<Object>(global->builtins()), NONE); |
| 802 | 803 |
| 803 // Compile the JavaScript for the debugger in the debugger context. | 804 // Compile the JavaScript for the debugger in the debugger context. |
| 804 Debugger::set_compiling_natives(true); | 805 Debugger::set_compiling_natives(true); |
| 805 bool caught_exception = | 806 bool caught_exception = |
| 806 !CompileDebuggerScript(Natives::GetIndex("mirror")) || | 807 !CompileDebuggerScript(Natives::GetIndex("mirror")) || |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 Handle<Object> break_id = Factory::NewNumberFromInt(Debug::break_id()); | 999 Handle<Object> break_id = Factory::NewNumberFromInt(Debug::break_id()); |
| 999 | 1000 |
| 1000 // Call HandleBreakPointx. | 1001 // Call HandleBreakPointx. |
| 1001 bool caught_exception = false; | 1002 bool caught_exception = false; |
| 1002 const int argc = 2; | 1003 const int argc = 2; |
| 1003 Object** argv[argc] = { | 1004 Object** argv[argc] = { |
| 1004 break_id.location(), | 1005 break_id.location(), |
| 1005 reinterpret_cast<Object**>(break_point_object.location()) | 1006 reinterpret_cast<Object**>(break_point_object.location()) |
| 1006 }; | 1007 }; |
| 1007 Handle<Object> result = Execution::TryCall(check_break_point, | 1008 Handle<Object> result = Execution::TryCall(check_break_point, |
| 1008 Top::builtins(), argc, argv, | 1009 Isolate::Current()->builtins(), |
| 1009 &caught_exception); | 1010 argc, argv, &caught_exception); |
| 1010 | 1011 |
| 1011 // If exception or non boolean result handle as not triggered | 1012 // If exception or non boolean result handle as not triggered |
| 1012 if (caught_exception || !result->IsBoolean()) { | 1013 if (caught_exception || !result->IsBoolean()) { |
| 1013 return false; | 1014 return false; |
| 1014 } | 1015 } |
| 1015 | 1016 |
| 1016 // Return whether the break point is triggered. | 1017 // Return whether the break point is triggered. |
| 1017 return *result == HEAP->true_value(); | 1018 return *result == HEAP->true_value(); |
| 1018 } | 1019 } |
| 1019 | 1020 |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1760 } | 1761 } |
| 1761 | 1762 |
| 1762 | 1763 |
| 1763 bool Debug::IsDebugGlobal(GlobalObject* global) { | 1764 bool Debug::IsDebugGlobal(GlobalObject* global) { |
| 1764 return IsLoaded() && global == Debug::debug_context()->global(); | 1765 return IsLoaded() && global == Debug::debug_context()->global(); |
| 1765 } | 1766 } |
| 1766 | 1767 |
| 1767 | 1768 |
| 1768 void Debug::ClearMirrorCache() { | 1769 void Debug::ClearMirrorCache() { |
| 1769 HandleScope scope; | 1770 HandleScope scope; |
| 1770 ASSERT(Top::context() == *Debug::debug_context()); | 1771 ASSERT(Isolate::Current()->context() == *Debug::debug_context()); |
| 1771 | 1772 |
| 1772 // Clear the mirror cache. | 1773 // Clear the mirror cache. |
| 1773 Handle<String> function_name = | 1774 Handle<String> function_name = |
| 1774 Factory::LookupSymbol(CStrVector("ClearMirrorCache")); | 1775 Factory::LookupSymbol(CStrVector("ClearMirrorCache")); |
| 1775 Handle<Object> fun(Top::global()->GetProperty(*function_name)); | 1776 Handle<Object> fun(Isolate::Current()->global()->GetProperty(*function_name)); |
| 1776 ASSERT(fun->IsJSFunction()); | 1777 ASSERT(fun->IsJSFunction()); |
| 1777 bool caught_exception; | 1778 bool caught_exception; |
| 1778 Handle<Object> js_object = Execution::TryCall( | 1779 Handle<Object> js_object = Execution::TryCall( |
| 1779 Handle<JSFunction>::cast(fun), | 1780 Handle<JSFunction>::cast(fun), |
| 1780 Handle<JSObject>(Debug::debug_context()->global()), | 1781 Handle<JSObject>(Debug::debug_context()->global()), |
| 1781 0, NULL, &caught_exception); | 1782 0, NULL, &caught_exception); |
| 1782 } | 1783 } |
| 1783 | 1784 |
| 1784 | 1785 |
| 1785 void Debug::CreateScriptCache() { | 1786 void Debug::CreateScriptCache() { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 MessageDispatchHelperThread* Debugger::message_dispatch_helper_thread_ = NULL; | 1868 MessageDispatchHelperThread* Debugger::message_dispatch_helper_thread_ = NULL; |
| 1868 int Debugger::host_dispatch_micros_ = 100 * 1000; | 1869 int Debugger::host_dispatch_micros_ = 100 * 1000; |
| 1869 DebuggerAgent* Debugger::agent_ = NULL; | 1870 DebuggerAgent* Debugger::agent_ = NULL; |
| 1870 LockingCommandMessageQueue Debugger::command_queue_(kQueueInitialSize); | 1871 LockingCommandMessageQueue Debugger::command_queue_(kQueueInitialSize); |
| 1871 Semaphore* Debugger::command_received_ = OS::CreateSemaphore(0); | 1872 Semaphore* Debugger::command_received_ = OS::CreateSemaphore(0); |
| 1872 | 1873 |
| 1873 | 1874 |
| 1874 Handle<Object> Debugger::MakeJSObject(Vector<const char> constructor_name, | 1875 Handle<Object> Debugger::MakeJSObject(Vector<const char> constructor_name, |
| 1875 int argc, Object*** argv, | 1876 int argc, Object*** argv, |
| 1876 bool* caught_exception) { | 1877 bool* caught_exception) { |
| 1877 ASSERT(Top::context() == *Debug::debug_context()); | 1878 ASSERT(Isolate::Current()->context() == *Debug::debug_context()); |
| 1878 | 1879 |
| 1879 // Create the execution state object. | 1880 // Create the execution state object. |
| 1880 Handle<String> constructor_str = Factory::LookupSymbol(constructor_name); | 1881 Handle<String> constructor_str = Factory::LookupSymbol(constructor_name); |
| 1881 Handle<Object> constructor(Top::global()->GetProperty(*constructor_str)); | 1882 Handle<Object> constructor( |
| 1883 Isolate::Current()->global()->GetProperty(*constructor_str)); |
| 1882 ASSERT(constructor->IsJSFunction()); | 1884 ASSERT(constructor->IsJSFunction()); |
| 1883 if (!constructor->IsJSFunction()) { | 1885 if (!constructor->IsJSFunction()) { |
| 1884 *caught_exception = true; | 1886 *caught_exception = true; |
| 1885 return Factory::undefined_value(); | 1887 return Factory::undefined_value(); |
| 1886 } | 1888 } |
| 1887 Handle<Object> js_object = Execution::TryCall( | 1889 Handle<Object> js_object = Execution::TryCall( |
| 1888 Handle<JSFunction>::cast(constructor), | 1890 Handle<JSFunction>::cast(constructor), |
| 1889 Handle<JSObject>(Debug::debug_context()->global()), argc, argv, | 1891 Handle<JSObject>(Debug::debug_context()->global()), argc, argv, |
| 1890 caught_exception); | 1892 caught_exception); |
| 1891 return js_object; | 1893 return js_object; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2015 ProcessDebugEvent(v8::Exception, Handle<JSObject>::cast(event_data), false); | 2017 ProcessDebugEvent(v8::Exception, Handle<JSObject>::cast(event_data), false); |
| 2016 // Return to continue execution from where the exception was thrown. | 2018 // Return to continue execution from where the exception was thrown. |
| 2017 } | 2019 } |
| 2018 | 2020 |
| 2019 | 2021 |
| 2020 void Debugger::OnDebugBreak(Handle<Object> break_points_hit, | 2022 void Debugger::OnDebugBreak(Handle<Object> break_points_hit, |
| 2021 bool auto_continue) { | 2023 bool auto_continue) { |
| 2022 HandleScope scope; | 2024 HandleScope scope; |
| 2023 | 2025 |
| 2024 // Debugger has already been entered by caller. | 2026 // Debugger has already been entered by caller. |
| 2025 ASSERT(Top::context() == *Debug::debug_context()); | 2027 ASSERT(Isolate::Current()->context() == *Debug::debug_context()); |
| 2026 | 2028 |
| 2027 // Bail out if there is no listener for this event | 2029 // Bail out if there is no listener for this event |
| 2028 if (!Debugger::EventActive(v8::Break)) return; | 2030 if (!Debugger::EventActive(v8::Break)) return; |
| 2029 | 2031 |
| 2030 // Debugger must be entered in advance. | 2032 // Debugger must be entered in advance. |
| 2031 ASSERT(Top::context() == *Debug::debug_context()); | 2033 ASSERT(Isolate::Current()->context() == *Debug::debug_context()); |
| 2032 | 2034 |
| 2033 // Create the event data object. | 2035 // Create the event data object. |
| 2034 bool caught_exception = false; | 2036 bool caught_exception = false; |
| 2035 Handle<Object> exec_state = MakeExecutionState(&caught_exception); | 2037 Handle<Object> exec_state = MakeExecutionState(&caught_exception); |
| 2036 Handle<Object> event_data; | 2038 Handle<Object> event_data; |
| 2037 if (!caught_exception) { | 2039 if (!caught_exception) { |
| 2038 event_data = MakeBreakEvent(exec_state, break_points_hit, | 2040 event_data = MakeBreakEvent(exec_state, break_points_hit, |
| 2039 &caught_exception); | 2041 &caught_exception); |
| 2040 } | 2042 } |
| 2041 // Bail out and don't call debugger if exception. | 2043 // Bail out and don't call debugger if exception. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2113 // Wrap the script object in a proper JS object before passing it | 2115 // Wrap the script object in a proper JS object before passing it |
| 2114 // to JavaScript. | 2116 // to JavaScript. |
| 2115 Handle<JSValue> wrapper = GetScriptWrapper(script); | 2117 Handle<JSValue> wrapper = GetScriptWrapper(script); |
| 2116 | 2118 |
| 2117 // Call UpdateScriptBreakPoints expect no exceptions. | 2119 // Call UpdateScriptBreakPoints expect no exceptions. |
| 2118 bool caught_exception = false; | 2120 bool caught_exception = false; |
| 2119 const int argc = 1; | 2121 const int argc = 1; |
| 2120 Object** argv[argc] = { reinterpret_cast<Object**>(wrapper.location()) }; | 2122 Object** argv[argc] = { reinterpret_cast<Object**>(wrapper.location()) }; |
| 2121 Handle<Object> result = Execution::TryCall( | 2123 Handle<Object> result = Execution::TryCall( |
| 2122 Handle<JSFunction>::cast(update_script_break_points), | 2124 Handle<JSFunction>::cast(update_script_break_points), |
| 2123 Top::builtins(), argc, argv, | 2125 Isolate::Current()->builtins(), argc, argv, |
| 2124 &caught_exception); | 2126 &caught_exception); |
| 2125 if (caught_exception) { | 2127 if (caught_exception) { |
| 2126 return; | 2128 return; |
| 2127 } | 2129 } |
| 2128 // Bail out based on state or if there is no listener for this event | 2130 // Bail out based on state or if there is no listener for this event |
| 2129 if (in_debugger && (after_compile_flags & SEND_WHEN_DEBUGGING) == 0) return; | 2131 if (in_debugger && (after_compile_flags & SEND_WHEN_DEBUGGING) == 0) return; |
| 2130 if (!Debugger::EventActive(v8::AfterCompile)) return; | 2132 if (!Debugger::EventActive(v8::AfterCompile)) return; |
| 2131 | 2133 |
| 2132 // Create the compile state object. | 2134 // Create the compile state object. |
| 2133 Handle<Object> event_data = MakeCompileEvent(script, | 2135 Handle<Object> event_data = MakeCompileEvent(script, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2212 // JavaScript debug event listener. | 2214 // JavaScript debug event listener. |
| 2213 ASSERT(event_listener_->IsJSFunction()); | 2215 ASSERT(event_listener_->IsJSFunction()); |
| 2214 Handle<JSFunction> fun(Handle<JSFunction>::cast(event_listener_)); | 2216 Handle<JSFunction> fun(Handle<JSFunction>::cast(event_listener_)); |
| 2215 | 2217 |
| 2216 // Invoke the JavaScript debug event listener. | 2218 // Invoke the JavaScript debug event listener. |
| 2217 const int argc = 4; | 2219 const int argc = 4; |
| 2218 Object** argv[argc] = { Handle<Object>(Smi::FromInt(event)).location(), | 2220 Object** argv[argc] = { Handle<Object>(Smi::FromInt(event)).location(), |
| 2219 exec_state.location(), | 2221 exec_state.location(), |
| 2220 Handle<Object>::cast(event_data).location(), | 2222 Handle<Object>::cast(event_data).location(), |
| 2221 event_listener_data_.location() }; | 2223 event_listener_data_.location() }; |
| 2222 Handle<Object> result = Execution::TryCall(fun, Top::global(), | 2224 Handle<Object> result = Execution::TryCall(fun, |
| 2225 Isolate::Current()->global(), |
| 2223 argc, argv, &caught_exception); | 2226 argc, argv, &caught_exception); |
| 2224 // Silently ignore exceptions from debug event listeners. | 2227 // Silently ignore exceptions from debug event listeners. |
| 2225 } | 2228 } |
| 2226 } | 2229 } |
| 2227 } | 2230 } |
| 2228 | 2231 |
| 2229 | 2232 |
| 2230 Handle<Context> Debugger::GetDebugContext() { | 2233 Handle<Context> Debugger::GetDebugContext() { |
| 2231 never_unload_debugger_ = true; | 2234 never_unload_debugger_ = true; |
| 2232 EnterDebugger debugger; | 2235 EnterDebugger debugger; |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2728 } | 2731 } |
| 2729 return scope.Close(v8::Utils::ToLocal(Handle<String>::cast(json))); | 2732 return scope.Close(v8::Utils::ToLocal(Handle<String>::cast(json))); |
| 2730 } else { | 2733 } else { |
| 2731 return v8::Utils::ToLocal(response_json_); | 2734 return v8::Utils::ToLocal(response_json_); |
| 2732 } | 2735 } |
| 2733 } | 2736 } |
| 2734 | 2737 |
| 2735 | 2738 |
| 2736 v8::Handle<v8::Context> MessageImpl::GetEventContext() const { | 2739 v8::Handle<v8::Context> MessageImpl::GetEventContext() const { |
| 2737 v8::Handle<v8::Context> context = GetDebugEventContext(); | 2740 v8::Handle<v8::Context> context = GetDebugEventContext(); |
| 2738 // Top::context() may be NULL when "script collected" event occures. | 2741 // Isolate::context() may be NULL when "script collected" event occures. |
| 2739 ASSERT(!context.IsEmpty() || event_ == v8::ScriptCollected); | 2742 ASSERT(!context.IsEmpty() || event_ == v8::ScriptCollected); |
| 2740 return GetDebugEventContext(); | 2743 return GetDebugEventContext(); |
| 2741 } | 2744 } |
| 2742 | 2745 |
| 2743 | 2746 |
| 2744 v8::Debug::ClientData* MessageImpl::GetClientData() const { | 2747 v8::Debug::ClientData* MessageImpl::GetClientData() const { |
| 2745 return client_data_; | 2748 return client_data_; |
| 2746 } | 2749 } |
| 2747 | 2750 |
| 2748 | 2751 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2928 { | 2931 { |
| 2929 Locker locker; | 2932 Locker locker; |
| 2930 Debugger::CallMessageDispatchHandler(); | 2933 Debugger::CallMessageDispatchHandler(); |
| 2931 } | 2934 } |
| 2932 } | 2935 } |
| 2933 } | 2936 } |
| 2934 | 2937 |
| 2935 #endif // ENABLE_DEBUGGER_SUPPORT | 2938 #endif // ENABLE_DEBUGGER_SUPPORT |
| 2936 | 2939 |
| 2937 } } // namespace v8::internal | 2940 } } // namespace v8::internal |
| OLD | NEW |