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

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
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 2600 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 exception, uncaught, promise).ToHandle(&event_data)) { 2611 exception, uncaught, promise).ToHandle(&event_data)) {
2612 return; 2612 return;
2613 } 2613 }
2614 2614
2615 // Process debug event. 2615 // Process debug event.
2616 ProcessDebugEvent(v8::Exception, Handle<JSObject>::cast(event_data), false); 2616 ProcessDebugEvent(v8::Exception, Handle<JSObject>::cast(event_data), false);
2617 // Return to continue execution from where the exception was thrown. 2617 // Return to continue execution from where the exception was thrown.
2618 } 2618 }
2619 2619
2620 2620
2621 void Debug::OnCompileError(Handle<Script> script) {
2622 // No more to do if not debugging.
2623 if (in_debug_scope() || ignore_events()) return;
2624
2625 HandleScope scope(isolate_);
2626 DebugScope debug_scope(this);
2627 if (debug_scope.failed()) return;
2628
2629 // Create the compile state object.
2630 Handle<Object> event_data;
2631 // Bail out and don't call debugger if exception.
2632 if (!MakeCompileEvent(script, false).ToHandle(&event_data)) return;
2633
2634 // Process debug event.
2635 ProcessDebugEvent(v8::CompileError, Handle<JSObject>::cast(event_data), true);
2636 }
2637
2638
2621 void Debug::OnDebugBreak(Handle<Object> break_points_hit, 2639 void Debug::OnDebugBreak(Handle<Object> break_points_hit,
2622 bool auto_continue) { 2640 bool auto_continue) {
2623 // The caller provided for DebugScope. 2641 // The caller provided for DebugScope.
2624 AssertDebugContext(); 2642 AssertDebugContext();
2625 // Bail out if there is no listener for this event 2643 // Bail out if there is no listener for this event
2626 if (ignore_events()) return; 2644 if (ignore_events()) return;
2627 2645
2628 HandleScope scope(isolate_); 2646 HandleScope scope(isolate_);
2629 // Create the event data object. 2647 // Create the event data object.
2630 Handle<Object> event_data; 2648 Handle<Object> event_data;
(...skipping 20 matching lines...) Expand all
2651 if (!MakeCompileEvent(script, true).ToHandle(&event_data)) return; 2669 if (!MakeCompileEvent(script, true).ToHandle(&event_data)) return;
2652 2670
2653 // Process debug event. 2671 // Process debug event.
2654 ProcessDebugEvent(v8::BeforeCompile, 2672 ProcessDebugEvent(v8::BeforeCompile,
2655 Handle<JSObject>::cast(event_data), 2673 Handle<JSObject>::cast(event_data),
2656 true); 2674 true);
2657 } 2675 }
2658 2676
2659 2677
2660 // Handle debugger actions when a new script is compiled. 2678 // Handle debugger actions when a new script is compiled.
2661 void Debug::OnAfterCompile(Handle<Script> script, 2679 void Debug::OnAfterCompile(Handle<Script> script) {
2662 AfterCompileFlags after_compile_flags) {
2663 // Add the newly compiled script to the script cache. 2680 // Add the newly compiled script to the script cache.
2664 if (script_cache_ != NULL) script_cache_->Add(script); 2681 if (script_cache_ != NULL) script_cache_->Add(script);
2665 2682
2666 // No more to do if not debugging. 2683 // No more to do if not debugging.
2667 if (in_debug_scope() || ignore_events()) return; 2684 if (in_debug_scope() || ignore_events()) return;
2668 2685
2669 HandleScope scope(isolate_); 2686 HandleScope scope(isolate_);
2670 // Store whether in debugger before entering debugger.
2671 bool was_in_scope = in_debug_scope();
2672
2673 DebugScope debug_scope(this); 2687 DebugScope debug_scope(this);
2674 if (debug_scope.failed()) return; 2688 if (debug_scope.failed()) return;
2675 2689
2676 // If debugging there might be script break points registered for this 2690 // If debugging there might be script break points registered for this
2677 // script. Make sure that these break points are set. 2691 // script. Make sure that these break points are set.
2678 2692
2679 // Get the function UpdateScriptBreakPoints (defined in debug-debugger.js). 2693 // Get the function UpdateScriptBreakPoints (defined in debug-debugger.js).
2680 Handle<String> update_script_break_points_string = 2694 Handle<String> update_script_break_points_string =
2681 isolate_->factory()->InternalizeOneByteString( 2695 isolate_->factory()->InternalizeOneByteString(
2682 STATIC_ASCII_VECTOR("UpdateScriptBreakPoints")); 2696 STATIC_ASCII_VECTOR("UpdateScriptBreakPoints"));
(...skipping 11 matching lines...) Expand all
2694 Handle<Object> wrapper = Script::GetWrapper(script); 2708 Handle<Object> wrapper = Script::GetWrapper(script);
2695 2709
2696 // Call UpdateScriptBreakPoints expect no exceptions. 2710 // Call UpdateScriptBreakPoints expect no exceptions.
2697 Handle<Object> argv[] = { wrapper }; 2711 Handle<Object> argv[] = { wrapper };
2698 if (Execution::TryCall(Handle<JSFunction>::cast(update_script_break_points), 2712 if (Execution::TryCall(Handle<JSFunction>::cast(update_script_break_points),
2699 isolate_->js_builtins_object(), 2713 isolate_->js_builtins_object(),
2700 ARRAY_SIZE(argv), 2714 ARRAY_SIZE(argv),
2701 argv).is_null()) { 2715 argv).is_null()) {
2702 return; 2716 return;
2703 } 2717 }
2704 // Bail out based on state or if there is no listener for this event
2705 if (was_in_scope && (after_compile_flags & SEND_WHEN_DEBUGGING) == 0) return;
Yang 2014/06/11 14:33:37 Is it guaranteed that when this method is called f
2706 2718
2707 // Create the compile state object. 2719 // Create the compile state object.
2708 Handle<Object> event_data; 2720 Handle<Object> event_data;
2709 // Bail out and don't call debugger if exception. 2721 // Bail out and don't call debugger if exception.
2710 if (!MakeCompileEvent(script, false).ToHandle(&event_data)) return; 2722 if (!MakeCompileEvent(script, false).ToHandle(&event_data)) return;
2711 2723
2712 // Process debug event. 2724 // Process debug event.
2713 ProcessDebugEvent(v8::AfterCompile, Handle<JSObject>::cast(event_data), true); 2725 ProcessDebugEvent(v8::AfterCompile, Handle<JSObject>::cast(event_data), true);
2714 } 2726 }
2715 2727
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
3393 logger_->DebugEvent("Put", message.text()); 3405 logger_->DebugEvent("Put", message.text());
3394 } 3406 }
3395 3407
3396 3408
3397 void LockingCommandMessageQueue::Clear() { 3409 void LockingCommandMessageQueue::Clear() {
3398 LockGuard<Mutex> lock_guard(&mutex_); 3410 LockGuard<Mutex> lock_guard(&mutex_);
3399 queue_.Clear(); 3411 queue_.Clear();
3400 } 3412 }
3401 3413
3402 } } // namespace v8::internal 3414 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698