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

Side by Side Diff: src/debug.cc

Issue 264333007: Add OnCompileError handler and v8::CompileError debug event (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 6 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
« 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 2536 matching lines...) Expand 10 before | Expand all | Expand 10 after
2547 // Create the new exception event object. 2547 // Create the new exception event object.
2548 Handle<Object> argv[] = { isolate_->factory()->NewNumberFromInt(break_id()), 2548 Handle<Object> argv[] = { isolate_->factory()->NewNumberFromInt(break_id()),
2549 exception, 2549 exception,
2550 isolate_->factory()->ToBoolean(uncaught), 2550 isolate_->factory()->ToBoolean(uncaught),
2551 promise }; 2551 promise };
2552 return MakeJSObject("MakeExceptionEvent", ARRAY_SIZE(argv), argv); 2552 return MakeJSObject("MakeExceptionEvent", ARRAY_SIZE(argv), argv);
2553 } 2553 }
2554 2554
2555 2555
2556 MaybeHandle<Object> Debug::MakeCompileEvent(Handle<Script> script, 2556 MaybeHandle<Object> Debug::MakeCompileEvent(Handle<Script> script,
2557 bool before) { 2557 v8::DebugEvent type) {
2558 // Create the compile event object. 2558 // Create the compile event object.
2559 Handle<Object> script_wrapper = Script::GetWrapper(script); 2559 Handle<Object> script_wrapper = Script::GetWrapper(script);
2560 Handle<Object> argv[] = { script_wrapper, 2560 Handle<Object> argv[] = { script_wrapper,
2561 isolate_->factory()->ToBoolean(before) }; 2561 isolate_->factory()->NewNumberFromInt(type) };
2562 return MakeJSObject("MakeCompileEvent", ARRAY_SIZE(argv), argv); 2562 return MakeJSObject("MakeCompileEvent", ARRAY_SIZE(argv), argv);
2563 } 2563 }
2564 2564
2565 2565
2566 MaybeHandle<Object> Debug::MakeScriptCollectedEvent(int id) { 2566 MaybeHandle<Object> Debug::MakeScriptCollectedEvent(int id) {
2567 // Create the script collected event object. 2567 // Create the script collected event object.
2568 Handle<Object> id_object = Handle<Smi>(Smi::FromInt(id), isolate_); 2568 Handle<Object> id_object = Handle<Smi>(Smi::FromInt(id), isolate_);
2569 Handle<Object> argv[] = { id_object }; 2569 Handle<Object> argv[] = { id_object };
2570 return MakeJSObject("MakeScriptCollectedEvent", ARRAY_SIZE(argv), argv); 2570 return MakeJSObject("MakeScriptCollectedEvent", ARRAY_SIZE(argv), argv);
2571 } 2571 }
(...skipping 28 matching lines...) Expand all
2600 exception, uncaught, promise).ToHandle(&event_data)) { 2600 exception, uncaught, promise).ToHandle(&event_data)) {
2601 return; 2601 return;
2602 } 2602 }
2603 2603
2604 // Process debug event. 2604 // Process debug event.
2605 ProcessDebugEvent(v8::Exception, Handle<JSObject>::cast(event_data), false); 2605 ProcessDebugEvent(v8::Exception, Handle<JSObject>::cast(event_data), false);
2606 // Return to continue execution from where the exception was thrown. 2606 // Return to continue execution from where the exception was thrown.
2607 } 2607 }
2608 2608
2609 2609
2610 void Debug::OnCompileError(Handle<Script> script) {
2611 // No more to do if not debugging.
2612 if (in_debug_scope() || ignore_events()) return;
2613
2614 HandleScope scope(isolate_);
2615 DebugScope debug_scope(this);
2616 if (debug_scope.failed()) return;
2617
2618 // Create the compile state object.
2619 Handle<Object> event_data;
2620 // Bail out and don't call debugger if exception.
2621 if (!MakeCompileEvent(script, v8::CompileError).ToHandle(&event_data)) return;
2622
2623 // Process debug event.
2624 ProcessDebugEvent(v8::CompileError, Handle<JSObject>::cast(event_data), true);
2625 }
2626
2627
2610 void Debug::OnDebugBreak(Handle<Object> break_points_hit, 2628 void Debug::OnDebugBreak(Handle<Object> break_points_hit,
2611 bool auto_continue) { 2629 bool auto_continue) {
2612 // The caller provided for DebugScope. 2630 // The caller provided for DebugScope.
2613 AssertDebugContext(); 2631 AssertDebugContext();
2614 // Bail out if there is no listener for this event 2632 // Bail out if there is no listener for this event
2615 if (ignore_events()) return; 2633 if (ignore_events()) return;
2616 2634
2617 HandleScope scope(isolate_); 2635 HandleScope scope(isolate_);
2618 // Create the event data object. 2636 // Create the event data object.
2619 Handle<Object> event_data; 2637 Handle<Object> event_data;
(...skipping 10 matching lines...) Expand all
2630 void Debug::OnBeforeCompile(Handle<Script> script) { 2648 void Debug::OnBeforeCompile(Handle<Script> script) {
2631 if (in_debug_scope() || ignore_events()) return; 2649 if (in_debug_scope() || ignore_events()) return;
2632 2650
2633 HandleScope scope(isolate_); 2651 HandleScope scope(isolate_);
2634 DebugScope debug_scope(this); 2652 DebugScope debug_scope(this);
2635 if (debug_scope.failed()) return; 2653 if (debug_scope.failed()) return;
2636 2654
2637 // Create the event data object. 2655 // Create the event data object.
2638 Handle<Object> event_data; 2656 Handle<Object> event_data;
2639 // Bail out and don't call debugger if exception. 2657 // Bail out and don't call debugger if exception.
2640 if (!MakeCompileEvent(script, true).ToHandle(&event_data)) return; 2658 if (!MakeCompileEvent(script, v8::BeforeCompile).ToHandle(&event_data))
2659 return;
2641 2660
2642 // Process debug event. 2661 // Process debug event.
2643 ProcessDebugEvent(v8::BeforeCompile, 2662 ProcessDebugEvent(v8::BeforeCompile,
2644 Handle<JSObject>::cast(event_data), 2663 Handle<JSObject>::cast(event_data),
2645 true); 2664 true);
2646 } 2665 }
2647 2666
2648 2667
2649 // Handle debugger actions when a new script is compiled. 2668 // Handle debugger actions when a new script is compiled.
2650 void Debug::OnAfterCompile(Handle<Script> script, 2669 void Debug::OnAfterCompile(Handle<Script> script,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2689 ARRAY_SIZE(argv), 2708 ARRAY_SIZE(argv),
2690 argv).is_null()) { 2709 argv).is_null()) {
2691 return; 2710 return;
2692 } 2711 }
2693 // Bail out based on state or if there is no listener for this event 2712 // Bail out based on state or if there is no listener for this event
2694 if (was_in_scope && (after_compile_flags & SEND_WHEN_DEBUGGING) == 0) return; 2713 if (was_in_scope && (after_compile_flags & SEND_WHEN_DEBUGGING) == 0) return;
2695 2714
2696 // Create the compile state object. 2715 // Create the compile state object.
2697 Handle<Object> event_data; 2716 Handle<Object> event_data;
2698 // Bail out and don't call debugger if exception. 2717 // Bail out and don't call debugger if exception.
2699 if (!MakeCompileEvent(script, false).ToHandle(&event_data)) return; 2718 if (!MakeCompileEvent(script, v8::AfterCompile).ToHandle(&event_data)) return;
2700 2719
2701 // Process debug event. 2720 // Process debug event.
2702 ProcessDebugEvent(v8::AfterCompile, Handle<JSObject>::cast(event_data), true); 2721 ProcessDebugEvent(v8::AfterCompile, Handle<JSObject>::cast(event_data), true);
2703 } 2722 }
2704 2723
2705 2724
2706 void Debug::OnScriptCollected(int id) { 2725 void Debug::OnScriptCollected(int id) {
2707 if (in_debug_scope() || ignore_events()) return; 2726 if (in_debug_scope() || ignore_events()) return;
2708 2727
2709 HandleScope scope(isolate_); 2728 HandleScope scope(isolate_);
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
3382 logger_->DebugEvent("Put", message.text()); 3401 logger_->DebugEvent("Put", message.text());
3383 } 3402 }
3384 3403
3385 3404
3386 void LockingCommandMessageQueue::Clear() { 3405 void LockingCommandMessageQueue::Clear() {
3387 LockGuard<Mutex> lock_guard(&mutex_); 3406 LockGuard<Mutex> lock_guard(&mutex_);
3388 queue_.Clear(); 3407 queue_.Clear();
3389 } 3408 }
3390 3409
3391 } } // namespace v8::internal 3410 } } // 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