| OLD | NEW |
| 1 // Copyright 2011 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 isolate->clear_pending_exception(); | 765 isolate->clear_pending_exception(); |
| 766 return false; | 766 return false; |
| 767 } | 767 } |
| 768 | 768 |
| 769 // Execute the shared function in the debugger context. | 769 // Execute the shared function in the debugger context. |
| 770 Handle<Context> context = isolate->global_context(); | 770 Handle<Context> context = isolate->global_context(); |
| 771 bool caught_exception; | 771 bool caught_exception; |
| 772 Handle<JSFunction> function = | 772 Handle<JSFunction> function = |
| 773 factory->NewFunctionFromSharedFunctionInfo(function_info, context); | 773 factory->NewFunctionFromSharedFunctionInfo(function_info, context); |
| 774 | 774 |
| 775 Execution::TryCall(function, Handle<Object>(context->global()), | 775 Handle<Object> exception = |
| 776 0, NULL, &caught_exception); | 776 Execution::TryCall(function, Handle<Object>(context->global()), |
| 777 0, NULL, &caught_exception); |
| 777 | 778 |
| 778 // Check for caught exceptions. | 779 // Check for caught exceptions. |
| 779 if (caught_exception) { | 780 if (caught_exception) { |
| 781 ASSERT(!isolate->has_pending_exception()); |
| 782 MessageLocation computed_location; |
| 783 isolate->ComputeLocation(&computed_location); |
| 780 Handle<Object> message = MessageHandler::MakeMessageObject( | 784 Handle<Object> message = MessageHandler::MakeMessageObject( |
| 781 "error_loading_debugger", NULL, Vector<Handle<Object> >::empty(), | 785 "error_loading_debugger", &computed_location, |
| 782 Handle<String>(), Handle<JSArray>()); | 786 Vector<Handle<Object> >::empty(), Handle<String>(), Handle<JSArray>()); |
| 787 ASSERT(!isolate->has_pending_exception()); |
| 788 isolate->set_pending_exception(*exception); |
| 783 MessageHandler::ReportMessage(Isolate::Current(), NULL, message); | 789 MessageHandler::ReportMessage(Isolate::Current(), NULL, message); |
| 790 isolate->clear_pending_exception(); |
| 784 return false; | 791 return false; |
| 785 } | 792 } |
| 786 | 793 |
| 787 // Mark this script as native and return successfully. | 794 // Mark this script as native and return successfully. |
| 788 Handle<Script> script(Script::cast(function->shared()->script())); | 795 Handle<Script> script(Script::cast(function->shared()->script())); |
| 789 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 796 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
| 790 return true; | 797 return true; |
| 791 } | 798 } |
| 792 | 799 |
| 793 | 800 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 811 | 818 |
| 812 // Create the debugger context. | 819 // Create the debugger context. |
| 813 HandleScope scope(isolate_); | 820 HandleScope scope(isolate_); |
| 814 Handle<Context> context = | 821 Handle<Context> context = |
| 815 isolate_->bootstrapper()->CreateEnvironment( | 822 isolate_->bootstrapper()->CreateEnvironment( |
| 816 isolate_, | 823 isolate_, |
| 817 Handle<Object>::null(), | 824 Handle<Object>::null(), |
| 818 v8::Handle<ObjectTemplate>(), | 825 v8::Handle<ObjectTemplate>(), |
| 819 NULL); | 826 NULL); |
| 820 | 827 |
| 828 // Fail if no context could be created. |
| 829 if (context.is_null()) return false; |
| 830 |
| 821 // Use the debugger context. | 831 // Use the debugger context. |
| 822 SaveContext save(isolate_); | 832 SaveContext save(isolate_); |
| 823 isolate_->set_context(*context); | 833 isolate_->set_context(*context); |
| 824 | 834 |
| 825 // Expose the builtins object in the debugger context. | 835 // Expose the builtins object in the debugger context. |
| 826 Handle<String> key = isolate_->factory()->LookupAsciiSymbol("builtins"); | 836 Handle<String> key = isolate_->factory()->LookupAsciiSymbol("builtins"); |
| 827 Handle<GlobalObject> global = Handle<GlobalObject>(context->global()); | 837 Handle<GlobalObject> global = Handle<GlobalObject>(context->global()); |
| 828 RETURN_IF_EMPTY_HANDLE_VALUE( | 838 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 829 isolate_, | 839 isolate_, |
| 830 JSReceiver::SetProperty(global, key, Handle<Object>(global->builtins()), | 840 JSReceiver::SetProperty(global, key, Handle<Object>(global->builtins()), |
| (...skipping 2376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3207 | 3217 |
| 3208 | 3218 |
| 3209 EnterDebugger::~EnterDebugger() { | 3219 EnterDebugger::~EnterDebugger() { |
| 3210 ASSERT(Isolate::Current() == isolate_); | 3220 ASSERT(Isolate::Current() == isolate_); |
| 3211 Debug* debug = isolate_->debug(); | 3221 Debug* debug = isolate_->debug(); |
| 3212 | 3222 |
| 3213 // Restore to the previous break state. | 3223 // Restore to the previous break state. |
| 3214 debug->SetBreak(break_frame_id_, break_id_); | 3224 debug->SetBreak(break_frame_id_, break_id_); |
| 3215 | 3225 |
| 3216 // Check for leaving the debugger. | 3226 // Check for leaving the debugger. |
| 3217 if (prev_ == NULL) { | 3227 if (!load_failed_ && prev_ == NULL) { |
| 3218 // Clear mirror cache when leaving the debugger. Skip this if there is a | 3228 // Clear mirror cache when leaving the debugger. Skip this if there is a |
| 3219 // pending exception as clearing the mirror cache calls back into | 3229 // pending exception as clearing the mirror cache calls back into |
| 3220 // JavaScript. This can happen if the v8::Debug::Call is used in which | 3230 // JavaScript. This can happen if the v8::Debug::Call is used in which |
| 3221 // case the exception should end up in the calling code. | 3231 // case the exception should end up in the calling code. |
| 3222 if (!isolate_->has_pending_exception()) { | 3232 if (!isolate_->has_pending_exception()) { |
| 3223 // Try to avoid any pending debug break breaking in the clear mirror | 3233 // Try to avoid any pending debug break breaking in the clear mirror |
| 3224 // cache JavaScript code. | 3234 // cache JavaScript code. |
| 3225 if (isolate_->stack_guard()->IsDebugBreak()) { | 3235 if (isolate_->stack_guard()->IsDebugBreak()) { |
| 3226 debug->set_interrupts_pending(DEBUGBREAK); | 3236 debug->set_interrupts_pending(DEBUGBREAK); |
| 3227 isolate_->stack_guard()->Continue(DEBUGBREAK); | 3237 isolate_->stack_guard()->Continue(DEBUGBREAK); |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3554 { | 3564 { |
| 3555 Locker locker; | 3565 Locker locker; |
| 3556 Isolate::Current()->debugger()->CallMessageDispatchHandler(); | 3566 Isolate::Current()->debugger()->CallMessageDispatchHandler(); |
| 3557 } | 3567 } |
| 3558 } | 3568 } |
| 3559 } | 3569 } |
| 3560 | 3570 |
| 3561 #endif // ENABLE_DEBUGGER_SUPPORT | 3571 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3562 | 3572 |
| 3563 } } // namespace v8::internal | 3573 } } // namespace v8::internal |
| OLD | NEW |