OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 Isolate* isolate = Isolate::Current(); | 90 Isolate* isolate = Isolate::Current(); |
91 return isolate->stub_cache()->ComputeCallDebugPrepareStepIn(argc, kind); | 91 return isolate->stub_cache()->ComputeCallDebugPrepareStepIn(argc, kind); |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 static v8::Handle<v8::Context> GetDebugEventContext(Isolate* isolate) { | 95 static v8::Handle<v8::Context> GetDebugEventContext(Isolate* isolate) { |
96 Handle<Context> context = isolate->debug()->debugger_entry()->GetContext(); | 96 Handle<Context> context = isolate->debug()->debugger_entry()->GetContext(); |
97 // Isolate::context() may have been NULL when "script collected" event | 97 // Isolate::context() may have been NULL when "script collected" event |
98 // occured. | 98 // occured. |
99 if (context.is_null()) return v8::Local<v8::Context>(); | 99 if (context.is_null()) return v8::Local<v8::Context>(); |
100 Handle<Context> native_context(context->native_context()); | 100 Handle<Context> global_context(context->global_context()); |
101 return v8::Utils::ToLocal(native_context); | 101 return v8::Utils::ToLocal(global_context); |
102 } | 102 } |
103 | 103 |
104 | 104 |
105 BreakLocationIterator::BreakLocationIterator(Handle<DebugInfo> debug_info, | 105 BreakLocationIterator::BreakLocationIterator(Handle<DebugInfo> debug_info, |
106 BreakLocatorType type) { | 106 BreakLocatorType type) { |
107 debug_info_ = debug_info; | 107 debug_info_ = debug_info; |
108 type_ = type; | 108 type_ = type; |
109 reloc_iterator_ = NULL; | 109 reloc_iterator_ = NULL; |
110 reloc_iterator_original_ = NULL; | 110 reloc_iterator_original_ = NULL; |
111 Reset(); // Initialize the rest of the member variables. | 111 Reset(); // Initialize the rest of the member variables. |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 NATIVES_CODE); | 755 NATIVES_CODE); |
756 | 756 |
757 // Silently ignore stack overflows during compilation. | 757 // Silently ignore stack overflows during compilation. |
758 if (function_info.is_null()) { | 758 if (function_info.is_null()) { |
759 ASSERT(isolate->has_pending_exception()); | 759 ASSERT(isolate->has_pending_exception()); |
760 isolate->clear_pending_exception(); | 760 isolate->clear_pending_exception(); |
761 return false; | 761 return false; |
762 } | 762 } |
763 | 763 |
764 // Execute the shared function in the debugger context. | 764 // Execute the shared function in the debugger context. |
765 Handle<Context> context = isolate->native_context(); | 765 Handle<Context> context = isolate->global_context(); |
766 bool caught_exception; | 766 bool caught_exception; |
767 Handle<JSFunction> function = | 767 Handle<JSFunction> function = |
768 factory->NewFunctionFromSharedFunctionInfo(function_info, context); | 768 factory->NewFunctionFromSharedFunctionInfo(function_info, context); |
769 | 769 |
770 Handle<Object> exception = | 770 Handle<Object> exception = |
771 Execution::TryCall(function, Handle<Object>(context->global_object()), | 771 Execution::TryCall(function, Handle<Object>(context->global()), |
772 0, NULL, &caught_exception); | 772 0, NULL, &caught_exception); |
773 | 773 |
774 // Check for caught exceptions. | 774 // Check for caught exceptions. |
775 if (caught_exception) { | 775 if (caught_exception) { |
776 ASSERT(!isolate->has_pending_exception()); | 776 ASSERT(!isolate->has_pending_exception()); |
777 MessageLocation computed_location; | 777 MessageLocation computed_location; |
778 isolate->ComputeLocation(&computed_location); | 778 isolate->ComputeLocation(&computed_location); |
779 Handle<Object> message = MessageHandler::MakeMessageObject( | 779 Handle<Object> message = MessageHandler::MakeMessageObject( |
780 "error_loading_debugger", &computed_location, | 780 "error_loading_debugger", &computed_location, |
781 Vector<Handle<Object> >::empty(), Handle<String>(), Handle<JSArray>()); | 781 Vector<Handle<Object> >::empty(), Handle<String>(), Handle<JSArray>()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 | 822 |
823 // Fail if no context could be created. | 823 // Fail if no context could be created. |
824 if (context.is_null()) return false; | 824 if (context.is_null()) return false; |
825 | 825 |
826 // Use the debugger context. | 826 // Use the debugger context. |
827 SaveContext save(isolate_); | 827 SaveContext save(isolate_); |
828 isolate_->set_context(*context); | 828 isolate_->set_context(*context); |
829 | 829 |
830 // Expose the builtins object in the debugger context. | 830 // Expose the builtins object in the debugger context. |
831 Handle<String> key = isolate_->factory()->LookupAsciiSymbol("builtins"); | 831 Handle<String> key = isolate_->factory()->LookupAsciiSymbol("builtins"); |
832 Handle<GlobalObject> global = Handle<GlobalObject>(context->global_object()); | 832 Handle<GlobalObject> global = Handle<GlobalObject>(context->global()); |
833 RETURN_IF_EMPTY_HANDLE_VALUE( | 833 RETURN_IF_EMPTY_HANDLE_VALUE( |
834 isolate_, | 834 isolate_, |
835 JSReceiver::SetProperty(global, key, Handle<Object>(global->builtins()), | 835 JSReceiver::SetProperty(global, key, Handle<Object>(global->builtins()), |
836 NONE, kNonStrictMode), | 836 NONE, kNonStrictMode), |
837 false); | 837 false); |
838 | 838 |
839 // Compile the JavaScript for the debugger in the debugger context. | 839 // Compile the JavaScript for the debugger in the debugger context. |
840 debugger->set_compiling_natives(true); | 840 debugger->set_compiling_natives(true); |
841 bool caught_exception = | 841 bool caught_exception = |
842 !CompileDebuggerScript(Natives::GetIndex("mirror")) || | 842 !CompileDebuggerScript(Natives::GetIndex("mirror")) || |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 HandleScope scope(isolate_); | 1088 HandleScope scope(isolate_); |
1089 | 1089 |
1090 // Ignore check if break point object is not a JSObject. | 1090 // Ignore check if break point object is not a JSObject. |
1091 if (!break_point_object->IsJSObject()) return true; | 1091 if (!break_point_object->IsJSObject()) return true; |
1092 | 1092 |
1093 // Get the function IsBreakPointTriggered (defined in debug-debugger.js). | 1093 // Get the function IsBreakPointTriggered (defined in debug-debugger.js). |
1094 Handle<String> is_break_point_triggered_symbol = | 1094 Handle<String> is_break_point_triggered_symbol = |
1095 factory->LookupAsciiSymbol("IsBreakPointTriggered"); | 1095 factory->LookupAsciiSymbol("IsBreakPointTriggered"); |
1096 Handle<JSFunction> check_break_point = | 1096 Handle<JSFunction> check_break_point = |
1097 Handle<JSFunction>(JSFunction::cast( | 1097 Handle<JSFunction>(JSFunction::cast( |
1098 debug_context()->global_object()->GetPropertyNoExceptionThrown( | 1098 debug_context()->global()->GetPropertyNoExceptionThrown( |
1099 *is_break_point_triggered_symbol))); | 1099 *is_break_point_triggered_symbol))); |
1100 | 1100 |
1101 // Get the break id as an object. | 1101 // Get the break id as an object. |
1102 Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id()); | 1102 Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id()); |
1103 | 1103 |
1104 // Call HandleBreakPointx. | 1104 // Call HandleBreakPointx. |
1105 bool caught_exception; | 1105 bool caught_exception; |
1106 Handle<Object> argv[] = { break_id, break_point_object }; | 1106 Handle<Object> argv[] = { break_id, break_point_object }; |
1107 Handle<Object> result = Execution::TryCall(check_break_point, | 1107 Handle<Object> result = Execution::TryCall(check_break_point, |
1108 isolate_->js_builtins_object(), | 1108 isolate_->js_builtins_object(), |
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2292 | 2292 |
2293 | 2293 |
2294 const int Debug::FramePaddingLayout::kInitialSize = 1; | 2294 const int Debug::FramePaddingLayout::kInitialSize = 1; |
2295 | 2295 |
2296 | 2296 |
2297 // Any even value bigger than kInitialSize as needed for stack scanning. | 2297 // Any even value bigger than kInitialSize as needed for stack scanning. |
2298 const int Debug::FramePaddingLayout::kPaddingValue = kInitialSize + 1; | 2298 const int Debug::FramePaddingLayout::kPaddingValue = kInitialSize + 1; |
2299 | 2299 |
2300 | 2300 |
2301 bool Debug::IsDebugGlobal(GlobalObject* global) { | 2301 bool Debug::IsDebugGlobal(GlobalObject* global) { |
2302 return IsLoaded() && global == debug_context()->global_object(); | 2302 return IsLoaded() && global == debug_context()->global(); |
2303 } | 2303 } |
2304 | 2304 |
2305 | 2305 |
2306 void Debug::ClearMirrorCache() { | 2306 void Debug::ClearMirrorCache() { |
2307 PostponeInterruptsScope postpone(isolate_); | 2307 PostponeInterruptsScope postpone(isolate_); |
2308 HandleScope scope(isolate_); | 2308 HandleScope scope(isolate_); |
2309 ASSERT(isolate_->context() == *Debug::debug_context()); | 2309 ASSERT(isolate_->context() == *Debug::debug_context()); |
2310 | 2310 |
2311 // Clear the mirror cache. | 2311 // Clear the mirror cache. |
2312 Handle<String> function_name = | 2312 Handle<String> function_name = |
2313 isolate_->factory()->LookupSymbol(CStrVector("ClearMirrorCache")); | 2313 isolate_->factory()->LookupSymbol(CStrVector("ClearMirrorCache")); |
2314 Handle<Object> fun( | 2314 Handle<Object> fun(Isolate::Current()->global()->GetPropertyNoExceptionThrown( |
2315 Isolate::Current()->global_object()->GetPropertyNoExceptionThrown( | |
2316 *function_name)); | 2315 *function_name)); |
2317 ASSERT(fun->IsJSFunction()); | 2316 ASSERT(fun->IsJSFunction()); |
2318 bool caught_exception; | 2317 bool caught_exception; |
2319 Execution::TryCall(Handle<JSFunction>::cast(fun), | 2318 Execution::TryCall(Handle<JSFunction>::cast(fun), |
2320 Handle<JSObject>(Debug::debug_context()->global_object()), | 2319 Handle<JSObject>(Debug::debug_context()->global()), |
2321 0, NULL, &caught_exception); | 2320 0, NULL, &caught_exception); |
2322 } | 2321 } |
2323 | 2322 |
2324 | 2323 |
2325 void Debug::CreateScriptCache() { | 2324 void Debug::CreateScriptCache() { |
2326 Heap* heap = isolate_->heap(); | 2325 Heap* heap = isolate_->heap(); |
2327 HandleScope scope(isolate_); | 2326 HandleScope scope(isolate_); |
2328 | 2327 |
2329 // Perform two GCs to get rid of all unreferenced scripts. The first GC gets | 2328 // Perform two GCs to get rid of all unreferenced scripts. The first GC gets |
2330 // rid of all the cached script wrappers and the second gets rid of the | 2329 // rid of all the cached script wrappers and the second gets rid of the |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2432 Handle<Object> Debugger::MakeJSObject(Vector<const char> constructor_name, | 2431 Handle<Object> Debugger::MakeJSObject(Vector<const char> constructor_name, |
2433 int argc, | 2432 int argc, |
2434 Handle<Object> argv[], | 2433 Handle<Object> argv[], |
2435 bool* caught_exception) { | 2434 bool* caught_exception) { |
2436 ASSERT(isolate_->context() == *isolate_->debug()->debug_context()); | 2435 ASSERT(isolate_->context() == *isolate_->debug()->debug_context()); |
2437 | 2436 |
2438 // Create the execution state object. | 2437 // Create the execution state object. |
2439 Handle<String> constructor_str = | 2438 Handle<String> constructor_str = |
2440 isolate_->factory()->LookupSymbol(constructor_name); | 2439 isolate_->factory()->LookupSymbol(constructor_name); |
2441 Handle<Object> constructor( | 2440 Handle<Object> constructor( |
2442 isolate_->global_object()->GetPropertyNoExceptionThrown( | 2441 isolate_->global()->GetPropertyNoExceptionThrown(*constructor_str)); |
2443 *constructor_str)); | |
2444 ASSERT(constructor->IsJSFunction()); | 2442 ASSERT(constructor->IsJSFunction()); |
2445 if (!constructor->IsJSFunction()) { | 2443 if (!constructor->IsJSFunction()) { |
2446 *caught_exception = true; | 2444 *caught_exception = true; |
2447 return isolate_->factory()->undefined_value(); | 2445 return isolate_->factory()->undefined_value(); |
2448 } | 2446 } |
2449 Handle<Object> js_object = Execution::TryCall( | 2447 Handle<Object> js_object = Execution::TryCall( |
2450 Handle<JSFunction>::cast(constructor), | 2448 Handle<JSFunction>::cast(constructor), |
2451 Handle<JSObject>(isolate_->debug()->debug_context()->global_object()), | 2449 Handle<JSObject>(isolate_->debug()->debug_context()->global()), |
2452 argc, | 2450 argc, |
2453 argv, | 2451 argv, |
2454 caught_exception); | 2452 caught_exception); |
2455 return js_object; | 2453 return js_object; |
2456 } | 2454 } |
2457 | 2455 |
2458 | 2456 |
2459 Handle<Object> Debugger::MakeExecutionState(bool* caught_exception) { | 2457 Handle<Object> Debugger::MakeExecutionState(bool* caught_exception) { |
2460 // Create the execution state object. | 2458 // Create the execution state object. |
2461 Handle<Object> break_id = isolate_->factory()->NewNumberFromInt( | 2459 Handle<Object> break_id = isolate_->factory()->NewNumberFromInt( |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2663 EnterDebugger debugger; | 2661 EnterDebugger debugger; |
2664 if (debugger.FailedToEnter()) return; | 2662 if (debugger.FailedToEnter()) return; |
2665 | 2663 |
2666 // If debugging there might be script break points registered for this | 2664 // If debugging there might be script break points registered for this |
2667 // script. Make sure that these break points are set. | 2665 // script. Make sure that these break points are set. |
2668 | 2666 |
2669 // Get the function UpdateScriptBreakPoints (defined in debug-debugger.js). | 2667 // Get the function UpdateScriptBreakPoints (defined in debug-debugger.js). |
2670 Handle<String> update_script_break_points_symbol = | 2668 Handle<String> update_script_break_points_symbol = |
2671 isolate_->factory()->LookupAsciiSymbol("UpdateScriptBreakPoints"); | 2669 isolate_->factory()->LookupAsciiSymbol("UpdateScriptBreakPoints"); |
2672 Handle<Object> update_script_break_points = | 2670 Handle<Object> update_script_break_points = |
2673 Handle<Object>(debug->debug_context()->global_object()-> | 2671 Handle<Object>(debug->debug_context()->global()-> |
2674 GetPropertyNoExceptionThrown(*update_script_break_points_symbol)); | 2672 GetPropertyNoExceptionThrown(*update_script_break_points_symbol)); |
2675 if (!update_script_break_points->IsJSFunction()) { | 2673 if (!update_script_break_points->IsJSFunction()) { |
2676 return; | 2674 return; |
2677 } | 2675 } |
2678 ASSERT(update_script_break_points->IsJSFunction()); | 2676 ASSERT(update_script_break_points->IsJSFunction()); |
2679 | 2677 |
2680 // Wrap the script object in a proper JS object before passing it | 2678 // Wrap the script object in a proper JS object before passing it |
2681 // to JavaScript. | 2679 // to JavaScript. |
2682 Handle<JSValue> wrapper = GetScriptWrapper(script); | 2680 Handle<JSValue> wrapper = GetScriptWrapper(script); |
2683 | 2681 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2819 ASSERT(event_listener_->IsJSFunction()); | 2817 ASSERT(event_listener_->IsJSFunction()); |
2820 Handle<JSFunction> fun(Handle<JSFunction>::cast(event_listener_)); | 2818 Handle<JSFunction> fun(Handle<JSFunction>::cast(event_listener_)); |
2821 | 2819 |
2822 // Invoke the JavaScript debug event listener. | 2820 // Invoke the JavaScript debug event listener. |
2823 Handle<Object> argv[] = { Handle<Object>(Smi::FromInt(event)), | 2821 Handle<Object> argv[] = { Handle<Object>(Smi::FromInt(event)), |
2824 exec_state, | 2822 exec_state, |
2825 event_data, | 2823 event_data, |
2826 event_listener_data_ }; | 2824 event_listener_data_ }; |
2827 bool caught_exception; | 2825 bool caught_exception; |
2828 Execution::TryCall(fun, | 2826 Execution::TryCall(fun, |
2829 isolate_->global_object(), | 2827 isolate_->global(), |
2830 ARRAY_SIZE(argv), | 2828 ARRAY_SIZE(argv), |
2831 argv, | 2829 argv, |
2832 &caught_exception); | 2830 &caught_exception); |
2833 // Silently ignore exceptions from debug event listeners. | 2831 // Silently ignore exceptions from debug event listeners. |
2834 } | 2832 } |
2835 | 2833 |
2836 | 2834 |
2837 Handle<Context> Debugger::GetDebugContext() { | 2835 Handle<Context> Debugger::GetDebugContext() { |
2838 never_unload_debugger_ = true; | 2836 never_unload_debugger_ = true; |
2839 EnterDebugger debugger; | 2837 EnterDebugger debugger; |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3655 { | 3653 { |
3656 Locker locker; | 3654 Locker locker; |
3657 Isolate::Current()->debugger()->CallMessageDispatchHandler(); | 3655 Isolate::Current()->debugger()->CallMessageDispatchHandler(); |
3658 } | 3656 } |
3659 } | 3657 } |
3660 } | 3658 } |
3661 | 3659 |
3662 #endif // ENABLE_DEBUGGER_SUPPORT | 3660 #endif // ENABLE_DEBUGGER_SUPPORT |
3663 | 3661 |
3664 } } // namespace v8::internal | 3662 } } // namespace v8::internal |
OLD | NEW |