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

Side by Side Diff: src/debug.cc

Issue 357603005: Introduce debug events for promises. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase and addressed comments Created 6 years, 5 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
« no previous file with comments | « src/debug.h ('k') | src/debug-debugger.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 2526 matching lines...) Expand 10 before | Expand all | Expand 10 after
2537 MaybeHandle<Object> Debug::MakeCompileEvent(Handle<Script> script, 2537 MaybeHandle<Object> Debug::MakeCompileEvent(Handle<Script> script,
2538 v8::DebugEvent type) { 2538 v8::DebugEvent type) {
2539 // Create the compile event object. 2539 // Create the compile event object.
2540 Handle<Object> script_wrapper = Script::GetWrapper(script); 2540 Handle<Object> script_wrapper = Script::GetWrapper(script);
2541 Handle<Object> argv[] = { script_wrapper, 2541 Handle<Object> argv[] = { script_wrapper,
2542 isolate_->factory()->NewNumberFromInt(type) }; 2542 isolate_->factory()->NewNumberFromInt(type) };
2543 return MakeJSObject("MakeCompileEvent", ARRAY_SIZE(argv), argv); 2543 return MakeJSObject("MakeCompileEvent", ARRAY_SIZE(argv), argv);
2544 } 2544 }
2545 2545
2546 2546
2547 MaybeHandle<Object> Debug::MakePromiseEvent(Handle<JSObject> event_data) {
2548 // Create the promise event object.
2549 Handle<Object> argv[] = { event_data };
2550 return MakeJSObject("MakePromiseEvent", ARRAY_SIZE(argv), argv);
2551 }
2552
2553
2547 void Debug::OnException(Handle<Object> exception, bool uncaught) { 2554 void Debug::OnException(Handle<Object> exception, bool uncaught) {
2548 if (in_debug_scope() || ignore_events()) return; 2555 if (in_debug_scope() || ignore_events()) return;
2549 2556
2550 HandleScope scope(isolate_); 2557 HandleScope scope(isolate_);
2551 Handle<Object> promise = GetPromiseForUncaughtException(); 2558 Handle<Object> promise = GetPromiseForUncaughtException();
2552 uncaught |= !promise->IsUndefined(); 2559 uncaught |= !promise->IsUndefined();
2553 2560
2554 // Bail out if exception breaks are not active 2561 // Bail out if exception breaks are not active
2555 if (uncaught) { 2562 if (uncaught) {
2556 // Uncaught exceptions are reported by either flags. 2563 // Uncaught exceptions are reported by either flags.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 // Create the compile state object. 2689 // Create the compile state object.
2683 Handle<Object> event_data; 2690 Handle<Object> event_data;
2684 // Bail out and don't call debugger if exception. 2691 // Bail out and don't call debugger if exception.
2685 if (!MakeCompileEvent(script, v8::AfterCompile).ToHandle(&event_data)) return; 2692 if (!MakeCompileEvent(script, v8::AfterCompile).ToHandle(&event_data)) return;
2686 2693
2687 // Process debug event. 2694 // Process debug event.
2688 ProcessDebugEvent(v8::AfterCompile, Handle<JSObject>::cast(event_data), true); 2695 ProcessDebugEvent(v8::AfterCompile, Handle<JSObject>::cast(event_data), true);
2689 } 2696 }
2690 2697
2691 2698
2699 void Debug::OnPromiseEvent(Handle<JSObject> data) {
2700 if (in_debug_scope() || ignore_events()) return;
2701
2702 HandleScope scope(isolate_);
2703 DebugScope debug_scope(this);
2704 if (debug_scope.failed()) return;
2705
2706 // Create the script collected state object.
2707 Handle<Object> event_data;
2708 // Bail out and don't call debugger if exception.
2709 if (!MakePromiseEvent(data).ToHandle(&event_data)) return;
2710
2711 // Process debug event.
2712 ProcessDebugEvent(v8::PromiseEvent,
2713 Handle<JSObject>::cast(event_data),
2714 true);
2715 }
2716
2717
2692 void Debug::ProcessDebugEvent(v8::DebugEvent event, 2718 void Debug::ProcessDebugEvent(v8::DebugEvent event,
2693 Handle<JSObject> event_data, 2719 Handle<JSObject> event_data,
2694 bool auto_continue) { 2720 bool auto_continue) {
2695 HandleScope scope(isolate_); 2721 HandleScope scope(isolate_);
2696 2722
2697 // Create the execution state. 2723 // Create the execution state.
2698 Handle<Object> exec_state; 2724 Handle<Object> exec_state;
2699 // Bail out and don't call debugger if exception. 2725 // Bail out and don't call debugger if exception.
2700 if (!MakeExecutionState().ToHandle(&exec_state)) return; 2726 if (!MakeExecutionState().ToHandle(&exec_state)) return;
2701 2727
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
3344 logger_->DebugEvent("Put", message.text()); 3370 logger_->DebugEvent("Put", message.text());
3345 } 3371 }
3346 3372
3347 3373
3348 void LockingCommandMessageQueue::Clear() { 3374 void LockingCommandMessageQueue::Clear() {
3349 LockGuard<Mutex> lock_guard(&mutex_); 3375 LockGuard<Mutex> lock_guard(&mutex_);
3350 queue_.Clear(); 3376 queue_.Clear();
3351 } 3377 }
3352 3378
3353 } } // namespace v8::internal 3379 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.h ('k') | src/debug-debugger.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698