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 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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->native_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()), | 771 Execution::TryCall(function, Handle<Object>(context->global_object()), |
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()); | 832 Handle<GlobalObject> global = Handle<GlobalObject>(context->global_object()); |
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()->GetPropertyNoExceptionThrown( | 1098 debug_context()->global_object()->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(); | 2302 return IsLoaded() && global == debug_context()->global_object(); |
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(Isolate::Current()->global()->GetPropertyNoExceptionThrown( | 2314 Handle<Object> fun( |
| 2315 Isolate::Current()->global_object()->GetPropertyNoExceptionThrown( |
2315 *function_name)); | 2316 *function_name)); |
2316 ASSERT(fun->IsJSFunction()); | 2317 ASSERT(fun->IsJSFunction()); |
2317 bool caught_exception; | 2318 bool caught_exception; |
2318 Execution::TryCall(Handle<JSFunction>::cast(fun), | 2319 Execution::TryCall(Handle<JSFunction>::cast(fun), |
2319 Handle<JSObject>(Debug::debug_context()->global()), | 2320 Handle<JSObject>(Debug::debug_context()->global_object()), |
2320 0, NULL, &caught_exception); | 2321 0, NULL, &caught_exception); |
2321 } | 2322 } |
2322 | 2323 |
2323 | 2324 |
2324 void Debug::CreateScriptCache() { | 2325 void Debug::CreateScriptCache() { |
2325 Heap* heap = isolate_->heap(); | 2326 Heap* heap = isolate_->heap(); |
2326 HandleScope scope(isolate_); | 2327 HandleScope scope(isolate_); |
2327 | 2328 |
2328 // Perform two GCs to get rid of all unreferenced scripts. The first GC gets | 2329 // Perform two GCs to get rid of all unreferenced scripts. The first GC gets |
2329 // rid of all the cached script wrappers and the second gets rid of the | 2330 // 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... |
2431 Handle<Object> Debugger::MakeJSObject(Vector<const char> constructor_name, | 2432 Handle<Object> Debugger::MakeJSObject(Vector<const char> constructor_name, |
2432 int argc, | 2433 int argc, |
2433 Handle<Object> argv[], | 2434 Handle<Object> argv[], |
2434 bool* caught_exception) { | 2435 bool* caught_exception) { |
2435 ASSERT(isolate_->context() == *isolate_->debug()->debug_context()); | 2436 ASSERT(isolate_->context() == *isolate_->debug()->debug_context()); |
2436 | 2437 |
2437 // Create the execution state object. | 2438 // Create the execution state object. |
2438 Handle<String> constructor_str = | 2439 Handle<String> constructor_str = |
2439 isolate_->factory()->LookupSymbol(constructor_name); | 2440 isolate_->factory()->LookupSymbol(constructor_name); |
2440 Handle<Object> constructor( | 2441 Handle<Object> constructor( |
2441 isolate_->global()->GetPropertyNoExceptionThrown(*constructor_str)); | 2442 isolate_->global_object()->GetPropertyNoExceptionThrown( |
| 2443 *constructor_str)); |
2442 ASSERT(constructor->IsJSFunction()); | 2444 ASSERT(constructor->IsJSFunction()); |
2443 if (!constructor->IsJSFunction()) { | 2445 if (!constructor->IsJSFunction()) { |
2444 *caught_exception = true; | 2446 *caught_exception = true; |
2445 return isolate_->factory()->undefined_value(); | 2447 return isolate_->factory()->undefined_value(); |
2446 } | 2448 } |
2447 Handle<Object> js_object = Execution::TryCall( | 2449 Handle<Object> js_object = Execution::TryCall( |
2448 Handle<JSFunction>::cast(constructor), | 2450 Handle<JSFunction>::cast(constructor), |
2449 Handle<JSObject>(isolate_->debug()->debug_context()->global()), | 2451 Handle<JSObject>(isolate_->debug()->debug_context()->global_object()), |
2450 argc, | 2452 argc, |
2451 argv, | 2453 argv, |
2452 caught_exception); | 2454 caught_exception); |
2453 return js_object; | 2455 return js_object; |
2454 } | 2456 } |
2455 | 2457 |
2456 | 2458 |
2457 Handle<Object> Debugger::MakeExecutionState(bool* caught_exception) { | 2459 Handle<Object> Debugger::MakeExecutionState(bool* caught_exception) { |
2458 // Create the execution state object. | 2460 // Create the execution state object. |
2459 Handle<Object> break_id = isolate_->factory()->NewNumberFromInt( | 2461 Handle<Object> break_id = isolate_->factory()->NewNumberFromInt( |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2661 EnterDebugger debugger; | 2663 EnterDebugger debugger; |
2662 if (debugger.FailedToEnter()) return; | 2664 if (debugger.FailedToEnter()) return; |
2663 | 2665 |
2664 // If debugging there might be script break points registered for this | 2666 // If debugging there might be script break points registered for this |
2665 // script. Make sure that these break points are set. | 2667 // script. Make sure that these break points are set. |
2666 | 2668 |
2667 // Get the function UpdateScriptBreakPoints (defined in debug-debugger.js). | 2669 // Get the function UpdateScriptBreakPoints (defined in debug-debugger.js). |
2668 Handle<String> update_script_break_points_symbol = | 2670 Handle<String> update_script_break_points_symbol = |
2669 isolate_->factory()->LookupAsciiSymbol("UpdateScriptBreakPoints"); | 2671 isolate_->factory()->LookupAsciiSymbol("UpdateScriptBreakPoints"); |
2670 Handle<Object> update_script_break_points = | 2672 Handle<Object> update_script_break_points = |
2671 Handle<Object>(debug->debug_context()->global()-> | 2673 Handle<Object>(debug->debug_context()->global_object()-> |
2672 GetPropertyNoExceptionThrown(*update_script_break_points_symbol)); | 2674 GetPropertyNoExceptionThrown(*update_script_break_points_symbol)); |
2673 if (!update_script_break_points->IsJSFunction()) { | 2675 if (!update_script_break_points->IsJSFunction()) { |
2674 return; | 2676 return; |
2675 } | 2677 } |
2676 ASSERT(update_script_break_points->IsJSFunction()); | 2678 ASSERT(update_script_break_points->IsJSFunction()); |
2677 | 2679 |
2678 // Wrap the script object in a proper JS object before passing it | 2680 // Wrap the script object in a proper JS object before passing it |
2679 // to JavaScript. | 2681 // to JavaScript. |
2680 Handle<JSValue> wrapper = GetScriptWrapper(script); | 2682 Handle<JSValue> wrapper = GetScriptWrapper(script); |
2681 | 2683 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2817 ASSERT(event_listener_->IsJSFunction()); | 2819 ASSERT(event_listener_->IsJSFunction()); |
2818 Handle<JSFunction> fun(Handle<JSFunction>::cast(event_listener_)); | 2820 Handle<JSFunction> fun(Handle<JSFunction>::cast(event_listener_)); |
2819 | 2821 |
2820 // Invoke the JavaScript debug event listener. | 2822 // Invoke the JavaScript debug event listener. |
2821 Handle<Object> argv[] = { Handle<Object>(Smi::FromInt(event)), | 2823 Handle<Object> argv[] = { Handle<Object>(Smi::FromInt(event)), |
2822 exec_state, | 2824 exec_state, |
2823 event_data, | 2825 event_data, |
2824 event_listener_data_ }; | 2826 event_listener_data_ }; |
2825 bool caught_exception; | 2827 bool caught_exception; |
2826 Execution::TryCall(fun, | 2828 Execution::TryCall(fun, |
2827 isolate_->global(), | 2829 isolate_->global_object(), |
2828 ARRAY_SIZE(argv), | 2830 ARRAY_SIZE(argv), |
2829 argv, | 2831 argv, |
2830 &caught_exception); | 2832 &caught_exception); |
2831 // Silently ignore exceptions from debug event listeners. | 2833 // Silently ignore exceptions from debug event listeners. |
2832 } | 2834 } |
2833 | 2835 |
2834 | 2836 |
2835 Handle<Context> Debugger::GetDebugContext() { | 2837 Handle<Context> Debugger::GetDebugContext() { |
2836 never_unload_debugger_ = true; | 2838 never_unload_debugger_ = true; |
2837 EnterDebugger debugger; | 2839 EnterDebugger debugger; |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3653 { | 3655 { |
3654 Locker locker; | 3656 Locker locker; |
3655 Isolate::Current()->debugger()->CallMessageDispatchHandler(); | 3657 Isolate::Current()->debugger()->CallMessageDispatchHandler(); |
3656 } | 3658 } |
3657 } | 3659 } |
3658 } | 3660 } |
3659 | 3661 |
3660 #endif // ENABLE_DEBUGGER_SUPPORT | 3662 #endif // ENABLE_DEBUGGER_SUPPORT |
3661 | 3663 |
3662 } } // namespace v8::internal | 3664 } } // namespace v8::internal |
OLD | NEW |