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

Side by Side Diff: src/debug.cc

Issue 728103008: Fix disabling all break points from within the debug event callback. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments Created 6 years, 1 month 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') | test/mjsunit/regress/regress-crbug-432493.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 22 matching lines...) Expand all
33 event_listener_data_(Handle<Object>()), 33 event_listener_data_(Handle<Object>()),
34 message_handler_(NULL), 34 message_handler_(NULL),
35 command_received_(0), 35 command_received_(0),
36 command_queue_(isolate->logger(), kQueueInitialSize), 36 command_queue_(isolate->logger(), kQueueInitialSize),
37 event_command_queue_(isolate->logger(), kQueueInitialSize), 37 event_command_queue_(isolate->logger(), kQueueInitialSize),
38 is_active_(false), 38 is_active_(false),
39 is_suppressed_(false), 39 is_suppressed_(false),
40 live_edit_enabled_(true), // TODO(yangguo): set to false by default. 40 live_edit_enabled_(true), // TODO(yangguo): set to false by default.
41 has_break_points_(false), 41 has_break_points_(false),
42 break_disabled_(false), 42 break_disabled_(false),
43 in_debug_event_listener_(false),
43 break_on_exception_(false), 44 break_on_exception_(false),
44 break_on_uncaught_exception_(false), 45 break_on_uncaught_exception_(false),
45 script_cache_(NULL), 46 script_cache_(NULL),
46 debug_info_list_(NULL), 47 debug_info_list_(NULL),
47 isolate_(isolate) { 48 isolate_(isolate) {
48 ThreadInit(); 49 ThreadInit();
49 } 50 }
50 51
51 52
52 static v8::Handle<v8::Context> GetDebugEventContext(Isolate* isolate) { 53 static v8::Handle<v8::Context> GetDebugEventContext(Isolate* isolate) {
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 866
866 void Debug::Break(Arguments args, JavaScriptFrame* frame) { 867 void Debug::Break(Arguments args, JavaScriptFrame* frame) {
867 Heap* heap = isolate_->heap(); 868 Heap* heap = isolate_->heap();
868 HandleScope scope(isolate_); 869 HandleScope scope(isolate_);
869 DCHECK(args.length() == 0); 870 DCHECK(args.length() == 0);
870 871
871 // Initialize LiveEdit. 872 // Initialize LiveEdit.
872 LiveEdit::InitializeThreadLocal(this); 873 LiveEdit::InitializeThreadLocal(this);
873 874
874 // Just continue if breaks are disabled or debugger cannot be loaded. 875 // Just continue if breaks are disabled or debugger cannot be loaded.
875 if (break_disabled_) return; 876 if (break_disabled()) return;
876 877
877 // Enter the debugger. 878 // Enter the debugger.
878 DebugScope debug_scope(this); 879 DebugScope debug_scope(this);
879 if (debug_scope.failed()) return; 880 if (debug_scope.failed()) return;
880 881
881 // Postpone interrupt during breakpoint processing. 882 // Postpone interrupt during breakpoint processing.
882 PostponeInterruptsScope postpone(isolate_); 883 PostponeInterruptsScope postpone(isolate_);
883 884
884 // Get the debug info (create it if it does not exist). 885 // Get the debug info (create it if it does not exist).
885 Handle<SharedFunctionInfo> shared = 886 Handle<SharedFunctionInfo> shared =
(...skipping 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after
2805 command.Dispose(); 2806 command.Dispose();
2806 } 2807 }
2807 } 2808 }
2808 } 2809 }
2809 2810
2810 2811
2811 void Debug::CallEventCallback(v8::DebugEvent event, 2812 void Debug::CallEventCallback(v8::DebugEvent event,
2812 Handle<Object> exec_state, 2813 Handle<Object> exec_state,
2813 Handle<Object> event_data, 2814 Handle<Object> event_data,
2814 v8::Debug::ClientData* client_data) { 2815 v8::Debug::ClientData* client_data) {
2815 DisableBreak no_break(this, true); 2816 bool previous = in_debug_event_listener_;
2817 in_debug_event_listener_ = true;
2816 if (event_listener_->IsForeign()) { 2818 if (event_listener_->IsForeign()) {
2817 // Invoke the C debug event listener. 2819 // Invoke the C debug event listener.
2818 v8::Debug::EventCallback callback = 2820 v8::Debug::EventCallback callback =
2819 FUNCTION_CAST<v8::Debug::EventCallback>( 2821 FUNCTION_CAST<v8::Debug::EventCallback>(
2820 Handle<Foreign>::cast(event_listener_)->foreign_address()); 2822 Handle<Foreign>::cast(event_listener_)->foreign_address());
2821 EventDetailsImpl event_details(event, 2823 EventDetailsImpl event_details(event,
2822 Handle<JSObject>::cast(exec_state), 2824 Handle<JSObject>::cast(exec_state),
2823 Handle<JSObject>::cast(event_data), 2825 Handle<JSObject>::cast(event_data),
2824 event_listener_data_, 2826 event_listener_data_,
2825 client_data); 2827 client_data);
2826 callback(event_details); 2828 callback(event_details);
2827 DCHECK(!isolate_->has_scheduled_exception()); 2829 DCHECK(!isolate_->has_scheduled_exception());
2828 } else { 2830 } else {
2829 // Invoke the JavaScript debug event listener. 2831 // Invoke the JavaScript debug event listener.
2830 DCHECK(event_listener_->IsJSFunction()); 2832 DCHECK(event_listener_->IsJSFunction());
2831 Handle<Object> argv[] = { Handle<Object>(Smi::FromInt(event), isolate_), 2833 Handle<Object> argv[] = { Handle<Object>(Smi::FromInt(event), isolate_),
2832 exec_state, 2834 exec_state,
2833 event_data, 2835 event_data,
2834 event_listener_data_ }; 2836 event_listener_data_ };
2835 Handle<JSReceiver> global(isolate_->global_proxy()); 2837 Handle<JSReceiver> global(isolate_->global_proxy());
2836 Execution::TryCall(Handle<JSFunction>::cast(event_listener_), 2838 Execution::TryCall(Handle<JSFunction>::cast(event_listener_),
2837 global, arraysize(argv), argv); 2839 global, arraysize(argv), argv);
2838 } 2840 }
2841 in_debug_event_listener_ = previous;
2839 } 2842 }
2840 2843
2841 2844
2842 Handle<Context> Debug::GetDebugContext() { 2845 Handle<Context> Debug::GetDebugContext() {
2843 DebugScope debug_scope(this); 2846 DebugScope debug_scope(this);
2844 // The global handle may be destroyed soon after. Return it reboxed. 2847 // The global handle may be destroyed soon after. Return it reboxed.
2845 return handle(*debug_context(), isolate_); 2848 return handle(*debug_context(), isolate_);
2846 } 2849 }
2847 2850
2848 2851
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
3082 Handle<Object>(debug_context()->global_proxy(), isolate_), 3085 Handle<Object>(debug_context()->global_proxy(), isolate_),
3083 arraysize(argv), 3086 arraysize(argv),
3084 argv); 3087 argv);
3085 } 3088 }
3086 3089
3087 3090
3088 void Debug::HandleDebugBreak() { 3091 void Debug::HandleDebugBreak() {
3089 // Ignore debug break during bootstrapping. 3092 // Ignore debug break during bootstrapping.
3090 if (isolate_->bootstrapper()->IsActive()) return; 3093 if (isolate_->bootstrapper()->IsActive()) return;
3091 // Just continue if breaks are disabled. 3094 // Just continue if breaks are disabled.
3092 if (break_disabled_) return; 3095 if (break_disabled()) return;
3093 // Ignore debug break if debugger is not active. 3096 // Ignore debug break if debugger is not active.
3094 if (!is_active()) return; 3097 if (!is_active()) return;
3095 3098
3096 StackLimitCheck check(isolate_); 3099 StackLimitCheck check(isolate_);
3097 if (check.HasOverflowed()) return; 3100 if (check.HasOverflowed()) return;
3098 3101
3099 { JavaScriptFrameIterator it(isolate_); 3102 { JavaScriptFrameIterator it(isolate_);
3100 DCHECK(!it.done()); 3103 DCHECK(!it.done());
3101 Object* fun = it.frame()->function(); 3104 Object* fun = it.frame()->function();
3102 if (fun && fun->IsJSFunction()) { 3105 if (fun && fun->IsJSFunction()) {
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
3436 logger_->DebugEvent("Put", message.text()); 3439 logger_->DebugEvent("Put", message.text());
3437 } 3440 }
3438 3441
3439 3442
3440 void LockingCommandMessageQueue::Clear() { 3443 void LockingCommandMessageQueue::Clear() {
3441 base::LockGuard<base::Mutex> lock_guard(&mutex_); 3444 base::LockGuard<base::Mutex> lock_guard(&mutex_);
3442 queue_.Clear(); 3445 queue_.Clear();
3443 } 3446 }
3444 3447
3445 } } // namespace v8::internal 3448 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.h ('k') | test/mjsunit/regress/regress-crbug-432493.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698