Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: src/debug.cc

Issue 249503002: Trigger debug event on not yet caught exception in promises. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: always use original exception Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2610 matching lines...) Expand 10 before | Expand all | Expand 10 after
2621 MaybeHandle<Object> Debugger::MakeBreakEvent(Handle<Object> break_points_hit) { 2621 MaybeHandle<Object> Debugger::MakeBreakEvent(Handle<Object> break_points_hit) {
2622 Handle<Object> exec_state; 2622 Handle<Object> exec_state;
2623 if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>(); 2623 if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>();
2624 // Create the new break event object. 2624 // Create the new break event object.
2625 Handle<Object> argv[] = { exec_state, break_points_hit }; 2625 Handle<Object> argv[] = { exec_state, break_points_hit };
2626 return MakeJSObject(CStrVector("MakeBreakEvent"), ARRAY_SIZE(argv), argv); 2626 return MakeJSObject(CStrVector("MakeBreakEvent"), ARRAY_SIZE(argv), argv);
2627 } 2627 }
2628 2628
2629 2629
2630 MaybeHandle<Object> Debugger::MakeExceptionEvent(Handle<Object> exception, 2630 MaybeHandle<Object> Debugger::MakeExceptionEvent(Handle<Object> exception,
2631 bool uncaught) { 2631 bool uncaught,
2632 Handle<Object> promise) {
2632 Handle<Object> exec_state; 2633 Handle<Object> exec_state;
2633 if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>(); 2634 if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>();
2634 // Create the new exception event object. 2635 // Create the new exception event object.
2635 Handle<Object> argv[] = { exec_state, 2636 Handle<Object> argv[] = { exec_state,
2636 exception, 2637 exception,
2637 isolate_->factory()->ToBoolean(uncaught) }; 2638 isolate_->factory()->ToBoolean(uncaught),
2639 promise };
2638 return MakeJSObject(CStrVector("MakeExceptionEvent"), ARRAY_SIZE(argv), argv); 2640 return MakeJSObject(CStrVector("MakeExceptionEvent"), ARRAY_SIZE(argv), argv);
2639 } 2641 }
2640 2642
2641 2643
2642 MaybeHandle<Object> Debugger::MakeCompileEvent(Handle<Script> script, 2644 MaybeHandle<Object> Debugger::MakeCompileEvent(Handle<Script> script,
2643 bool before) { 2645 bool before) {
2644 Handle<Object> exec_state; 2646 Handle<Object> exec_state;
2645 if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>(); 2647 if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>();
2646 // Create the compile event object. 2648 // Create the compile event object.
2647 Handle<Object> script_wrapper = Script::GetWrapper(script); 2649 Handle<Object> script_wrapper = Script::GetWrapper(script);
2648 Handle<Object> argv[] = { exec_state, 2650 Handle<Object> argv[] = { exec_state,
2649 script_wrapper, 2651 script_wrapper,
2650 isolate_->factory()->ToBoolean(before) }; 2652 isolate_->factory()->ToBoolean(before) };
2651 return MakeJSObject(CStrVector("MakeCompileEvent"), ARRAY_SIZE(argv), argv); 2653 return MakeJSObject(CStrVector("MakeCompileEvent"), ARRAY_SIZE(argv), argv);
2652 } 2654 }
2653 2655
2654 2656
2655 MaybeHandle<Object> Debugger::MakeScriptCollectedEvent(int id) { 2657 MaybeHandle<Object> Debugger::MakeScriptCollectedEvent(int id) {
2656 Handle<Object> exec_state; 2658 Handle<Object> exec_state;
2657 if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>(); 2659 if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>();
2658 // Create the script collected event object. 2660 // Create the script collected event object.
2659 Handle<Object> id_object = Handle<Smi>(Smi::FromInt(id), isolate_); 2661 Handle<Object> id_object = Handle<Smi>(Smi::FromInt(id), isolate_);
2660 Handle<Object> argv[] = { exec_state, id_object }; 2662 Handle<Object> argv[] = { exec_state, id_object };
2661 2663
2662 return MakeJSObject( 2664 return MakeJSObject(
2663 CStrVector("MakeScriptCollectedEvent"), ARRAY_SIZE(argv), argv); 2665 CStrVector("MakeScriptCollectedEvent"), ARRAY_SIZE(argv), argv);
2664 } 2666 }
2665 2667
2666 2668
2667 void Debugger::OnException(Handle<Object> exception, bool uncaught) { 2669 void Debugger::OnException(Handle<Object> exception,
2670 bool uncaught,
2671 Handle<Object> promise) {
2668 HandleScope scope(isolate_); 2672 HandleScope scope(isolate_);
2669 Debug* debug = isolate_->debug(); 2673 Debug* debug = isolate_->debug();
2670 2674
2671 // Bail out based on state or if there is no listener for this event 2675 // Bail out based on state or if there is no listener for this event
2672 if (debug->InDebugger()) return; 2676 if (debug->InDebugger()) return;
2673 if (!Debugger::EventActive(v8::Exception)) return; 2677 if (!Debugger::EventActive(v8::Exception)) return;
2674 2678
2675 // Bail out if exception breaks are not active 2679 // Bail out if exception breaks are not active
2676 if (uncaught) { 2680 if (uncaught) {
2677 // Uncaught exceptions are reported by either flags. 2681 // Uncaught exceptions are reported by either flags.
2678 if (!(debug->break_on_uncaught_exception() || 2682 if (!(debug->break_on_uncaught_exception() ||
2679 debug->break_on_exception())) return; 2683 debug->break_on_exception())) return;
2680 } else { 2684 } else {
2681 // Caught exceptions are reported is activated. 2685 // Caught exceptions are reported is activated.
2682 if (!debug->break_on_exception()) return; 2686 if (!debug->break_on_exception()) return;
2683 } 2687 }
2684 2688
2685 // Enter the debugger. 2689 // Enter the debugger.
2686 EnterDebugger debugger(isolate_); 2690 EnterDebugger debugger(isolate_);
2687 if (debugger.FailedToEnter()) return; 2691 if (debugger.FailedToEnter()) return;
2688 2692
2689 // Clear all current stepping setup. 2693 // Clear all current stepping setup.
2690 debug->ClearStepping(); 2694 debug->ClearStepping();
2695
2696 // Determine event;
2697 DebugEvent event = promise->IsUndefined()
2698 ? v8::Exception : v8::UncaughtExceptionInPromise;
2699
2691 // Create the event data object. 2700 // Create the event data object.
2692 Handle<Object> event_data; 2701 Handle<Object> event_data;
2693 // Bail out and don't call debugger if exception. 2702 // Bail out and don't call debugger if exception.
2694 if (!MakeExceptionEvent(exception, uncaught).ToHandle(&event_data)) return; 2703 if (!MakeExceptionEvent(
2704 exception, uncaught, promise).ToHandle(&event_data)) {
2705 return;
2706 }
2695 2707
2696 // Process debug event. 2708 // Process debug event.
2697 ProcessDebugEvent(v8::Exception, Handle<JSObject>::cast(event_data), false); 2709 ProcessDebugEvent(event, Handle<JSObject>::cast(event_data), false);
2698 // Return to continue execution from where the exception was thrown. 2710 // Return to continue execution from where the exception was thrown.
2699 } 2711 }
2700 2712
2701 2713
2702 void Debugger::OnDebugBreak(Handle<Object> break_points_hit, 2714 void Debugger::OnDebugBreak(Handle<Object> break_points_hit,
2703 bool auto_continue) { 2715 bool auto_continue) {
2704 HandleScope scope(isolate_); 2716 HandleScope scope(isolate_);
2705 2717
2706 // Debugger has already been entered by caller. 2718 // Debugger has already been entered by caller.
2707 ASSERT(isolate_->context() == *isolate_->debug()->debug_context()); 2719 ASSERT(isolate_->context() == *isolate_->debug()->debug_context());
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
3736 { 3748 {
3737 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); 3749 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_));
3738 isolate_->debugger()->CallMessageDispatchHandler(); 3750 isolate_->debugger()->CallMessageDispatchHandler();
3739 } 3751 }
3740 } 3752 }
3741 } 3753 }
3742 3754
3743 #endif // ENABLE_DEBUGGER_SUPPORT 3755 #endif // ENABLE_DEBUGGER_SUPPORT
3744 3756
3745 } } // namespace v8::internal 3757 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.h ('k') | src/debug-debugger.js » ('j') | src/debug-debugger.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698