|
1 |
| -// Copyright 2011 the V8 project authors. All rights reserved. |
| 1 | +// Copyright 2012 the V8 project authors. All rights reserved. |
2 | 2 | // Redistribution and use in source and binary forms, with or without
|
3 | 3 | // modification, are permitted provided that the following conditions are
|
4 | 4 | // met:
|
@@ -767,15 +767,22 @@ bool Debug::CompileDebuggerScript(int index) {
|
767 | 767 | Handle<JSFunction> function =
|
768 | 768 | factory->NewFunctionFromSharedFunctionInfo(function_info, context);
|
769 | 769 |
|
770 |
| - Execution::TryCall(function, Handle<Object>(context->global()), |
771 |
| - 0, NULL, &caught_exception); |
| 770 | + Handle<Object> exception = |
| 771 | + Execution::TryCall(function, Handle<Object>(context->global()), |
| 772 | + 0, NULL, &caught_exception); |
772 | 773 |
|
773 | 774 | // Check for caught exceptions.
|
774 | 775 | if (caught_exception) {
|
| 776 | + ASSERT(!isolate->has_pending_exception()); |
| 777 | + MessageLocation computed_location; |
| 778 | + isolate->ComputeLocation(&computed_location); |
775 | 779 | Handle<Object> message = MessageHandler::MakeMessageObject(
|
776 |
| - "error_loading_debugger", NULL, Vector<Handle<Object> >::empty(), |
777 |
| - Handle<String>(), Handle<JSArray>()); |
| 780 | + "error_loading_debugger", &computed_location, |
| 781 | + Vector<Handle<Object> >::empty(), Handle<String>(), Handle<JSArray>()); |
| 782 | + ASSERT(!isolate->has_pending_exception()); |
| 783 | + isolate->set_pending_exception(*exception); |
778 | 784 | MessageHandler::ReportMessage(Isolate::Current(), NULL, message);
|
| 785 | + isolate->clear_pending_exception(); |
779 | 786 | return false;
|
780 | 787 | }
|
781 | 788 |
|
@@ -813,6 +820,9 @@ bool Debug::Load() {
|
813 | 820 | v8::Handle<ObjectTemplate>(),
|
814 | 821 | NULL);
|
815 | 822 |
|
| 823 | + // Fail if no context could be created. |
| 824 | + if (context.is_null()) return false; |
| 825 | + |
816 | 826 | // Use the debugger context.
|
817 | 827 | SaveContext save(isolate_);
|
818 | 828 | isolate_->set_context(*context);
|
@@ -3239,7 +3249,7 @@ EnterDebugger::~EnterDebugger() {
|
3239 | 3249 | debug->SetBreak(break_frame_id_, break_id_);
|
3240 | 3250 |
|
3241 | 3251 | // Check for leaving the debugger.
|
3242 |
| - if (prev_ == NULL) { |
| 3252 | + if (!load_failed_ && prev_ == NULL) { |
3243 | 3253 | // Clear mirror cache when leaving the debugger. Skip this if there is a
|
3244 | 3254 | // pending exception as clearing the mirror cache calls back into
|
3245 | 3255 | // JavaScript. This can happen if the v8::Debug::Call is used in which
|
|
0 commit comments