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

Side by Side Diff: src/debug/debug.cc

Issue 2758483002: [debugger] tuned StepNext and StepOut at return position (Closed)
Patch Set: Created 3 years, 9 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/debug/debug.h" 5 #include "src/debug/debug.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 isolate_->counters()->debug_feature_usage()->AddSample(feature); 379 isolate_->counters()->debug_feature_usage()->AddSample(feature);
380 bitfield_ |= mask; 380 bitfield_ |= mask;
381 } 381 }
382 382
383 383
384 // Threading support. 384 // Threading support.
385 void Debug::ThreadInit() { 385 void Debug::ThreadInit() {
386 thread_local_.break_count_ = 0; 386 thread_local_.break_count_ = 0;
387 thread_local_.break_id_ = 0; 387 thread_local_.break_id_ = 0;
388 thread_local_.break_frame_id_ = StackFrame::NO_ID; 388 thread_local_.break_frame_id_ = StackFrame::NO_ID;
389 thread_local_.last_step_frame_id_ = StackFrame::NO_ID;
389 thread_local_.last_step_action_ = StepNone; 390 thread_local_.last_step_action_ = StepNone;
390 thread_local_.last_statement_position_ = kNoSourcePosition; 391 thread_local_.last_statement_position_ = kNoSourcePosition;
391 thread_local_.last_frame_count_ = -1; 392 thread_local_.last_frame_count_ = -1;
392 thread_local_.target_frame_count_ = -1; 393 thread_local_.target_frame_count_ = -1;
393 thread_local_.return_value_ = Smi::kZero; 394 thread_local_.return_value_ = Smi::kZero;
394 thread_local_.async_task_count_ = 0; 395 thread_local_.async_task_count_ = 0;
395 clear_suspended_generator(); 396 clear_suspended_generator();
396 thread_local_.restart_fp_ = nullptr; 397 thread_local_.restart_fp_ = nullptr;
397 base::NoBarrier_Store(&thread_local_.current_debug_scope_, 398 base::NoBarrier_Store(&thread_local_.current_debug_scope_,
398 static_cast<base::AtomicWord>(0)); 399 static_cast<base::AtomicWord>(0));
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 if (CheckBreakPoint(break_point_object)) { 870 if (CheckBreakPoint(break_point_object)) {
870 break_points_hit->set(break_points_hit_count++, *break_point_object); 871 break_points_hit->set(break_points_hit_count++, *break_point_object);
871 } 872 }
872 } 873 }
873 if (break_points_hit_count == 0) return {}; 874 if (break_points_hit_count == 0) return {};
874 break_points_hit->Shrink(break_points_hit_count); 875 break_points_hit->Shrink(break_points_hit_count);
875 return break_points_hit; 876 return break_points_hit;
876 } 877 }
877 878
878 void Debug::PrepareStepIn(Handle<JSFunction> function) { 879 void Debug::PrepareStepIn(Handle<JSFunction> function) {
879 CHECK(last_step_action() >= StepIn); 880 CHECK(last_step_action() != StepNone);
880 if (ignore_events()) return; 881 if (ignore_events()) return;
881 if (in_debug_scope()) return; 882 if (in_debug_scope()) return;
882 if (break_disabled()) return; 883 if (break_disabled()) return;
884 if (last_step_action() == StepIn) {
885 FloodWithOneShot(Handle<SharedFunctionInfo>(function->shared(), isolate_));
886 }
887 if (thread_local_.last_step_frame_id_ == StackFrame::NO_ID) return;
888 if (last_step_action() == StepOut || last_step_action() == StepNext) {
889 int count = 0;
890 for (StackTraceFrameIterator it(isolate_); !it.done(); it.Advance()) {
891 if (it.frame()->id() == thread_local_.last_step_frame_id_) return;
892 ++count;
893 }
894 thread_local_.target_frame_count_ = count + 1;
895 }
883 FloodWithOneShot(Handle<SharedFunctionInfo>(function->shared(), isolate_)); 896 FloodWithOneShot(Handle<SharedFunctionInfo>(function->shared(), isolate_));
884 } 897 }
885 898
886 void Debug::PrepareStepInSuspendedGenerator() { 899 void Debug::PrepareStepInSuspendedGenerator() {
887 CHECK(has_suspended_generator()); 900 CHECK(has_suspended_generator());
888 if (ignore_events()) return; 901 if (ignore_events()) return;
889 if (in_debug_scope()) return; 902 if (in_debug_scope()) return;
890 if (break_disabled()) return; 903 if (break_disabled()) return;
891 thread_local_.last_step_action_ = StepIn; 904 thread_local_.last_step_action_ = StepIn;
892 UpdateHookOnFunctionCall(); 905 UpdateHookOnFunctionCall();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 if (frame_id == StackFrame::NO_ID) return; 996 if (frame_id == StackFrame::NO_ID) return;
984 997
985 feature_tracker()->Track(DebugFeatureTracker::kStepping); 998 feature_tracker()->Track(DebugFeatureTracker::kStepping);
986 999
987 thread_local_.last_step_action_ = step_action; 1000 thread_local_.last_step_action_ = step_action;
988 UpdateHookOnFunctionCall(); 1001 UpdateHookOnFunctionCall();
989 1002
990 StackTraceFrameIterator frames_it(isolate_, frame_id); 1003 StackTraceFrameIterator frames_it(isolate_, frame_id);
991 StandardFrame* frame = frames_it.frame(); 1004 StandardFrame* frame = frames_it.frame();
992 1005
1006 if (step_action == StepOut || step_action == StepNext) {
1007 thread_local_.last_step_frame_id_ = frame->id();
1008 }
1009
993 // Handle stepping in wasm functions via the wasm interpreter. 1010 // Handle stepping in wasm functions via the wasm interpreter.
994 if (frame->is_wasm()) { 1011 if (frame->is_wasm()) {
995 // If the top frame is compiled, we cannot step. 1012 // If the top frame is compiled, we cannot step.
996 if (frame->is_wasm_compiled()) return; 1013 if (frame->is_wasm_compiled()) return;
997 WasmInterpreterEntryFrame* wasm_frame = 1014 WasmInterpreterEntryFrame* wasm_frame =
998 WasmInterpreterEntryFrame::cast(frame); 1015 WasmInterpreterEntryFrame::cast(frame);
999 wasm_frame->wasm_instance()->debug_info()->PrepareStep(step_action); 1016 wasm_frame->wasm_instance()->debug_info()->PrepareStep(step_action);
1000 return; 1017 return;
1001 } 1018 }
1002 1019
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 } 1134 }
1118 return locations; 1135 return locations;
1119 } 1136 }
1120 1137
1121 void Debug::ClearStepping() { 1138 void Debug::ClearStepping() {
1122 // Clear the various stepping setup. 1139 // Clear the various stepping setup.
1123 ClearOneShot(); 1140 ClearOneShot();
1124 1141
1125 thread_local_.last_step_action_ = StepNone; 1142 thread_local_.last_step_action_ = StepNone;
1126 thread_local_.last_statement_position_ = kNoSourcePosition; 1143 thread_local_.last_statement_position_ = kNoSourcePosition;
1144 thread_local_.last_step_frame_id_ = StackFrame::NO_ID;
1127 thread_local_.last_frame_count_ = -1; 1145 thread_local_.last_frame_count_ = -1;
1128 thread_local_.target_frame_count_ = -1; 1146 thread_local_.target_frame_count_ = -1;
1129 UpdateHookOnFunctionCall(); 1147 UpdateHookOnFunctionCall();
1130 } 1148 }
1131 1149
1132 1150
1133 // Clears all the one-shot break points that are currently set. Normally this 1151 // Clears all the one-shot break points that are currently set. Normally this
1134 // function is called each time a break point is hit as one shot break points 1152 // function is called each time a break point is hit as one shot break points
1135 // are used to support stepping. 1153 // are used to support stepping.
1136 void Debug::ClearOneShot() { 1154 void Debug::ClearOneShot() {
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 } else if (is_loaded()) { 2120 } else if (is_loaded()) {
2103 isolate_->compilation_cache()->Enable(); 2121 isolate_->compilation_cache()->Enable();
2104 Unload(); 2122 Unload();
2105 } 2123 }
2106 is_active_ = is_active; 2124 is_active_ = is_active;
2107 isolate_->DebugStateUpdated(); 2125 isolate_->DebugStateUpdated();
2108 } 2126 }
2109 2127
2110 void Debug::UpdateHookOnFunctionCall() { 2128 void Debug::UpdateHookOnFunctionCall() {
2111 STATIC_ASSERT(LastStepAction == StepIn); 2129 STATIC_ASSERT(LastStepAction == StepIn);
2112 hook_on_function_call_ = thread_local_.last_step_action_ == StepIn || 2130 hook_on_function_call_ = thread_local_.last_step_action_ != StepNone ||
2113 isolate_->needs_side_effect_check(); 2131 isolate_->needs_side_effect_check();
2114 } 2132 }
2115 2133
2116 MaybeHandle<Object> Debug::Call(Handle<Object> fun, Handle<Object> data) { 2134 MaybeHandle<Object> Debug::Call(Handle<Object> fun, Handle<Object> data) {
2117 DebugScope debug_scope(this); 2135 DebugScope debug_scope(this);
2118 if (debug_scope.failed()) return isolate_->factory()->undefined_value(); 2136 if (debug_scope.failed()) return isolate_->factory()->undefined_value();
2119 2137
2120 // Create the execution state. 2138 // Create the execution state.
2121 Handle<Object> exec_state; 2139 Handle<Object> exec_state;
2122 if (!MakeExecutionState().ToHandle(&exec_state)) { 2140 if (!MakeExecutionState().ToHandle(&exec_state)) {
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 isolate_->Throw(*isolate_->factory()->NewEvalError( 2475 isolate_->Throw(*isolate_->factory()->NewEvalError(
2458 MessageTemplate::kNoSideEffectDebugEvaluate)); 2476 MessageTemplate::kNoSideEffectDebugEvaluate));
2459 } 2477 }
2460 isolate_->set_needs_side_effect_check(old_needs_side_effect_check_); 2478 isolate_->set_needs_side_effect_check(old_needs_side_effect_check_);
2461 isolate_->debug()->UpdateHookOnFunctionCall(); 2479 isolate_->debug()->UpdateHookOnFunctionCall();
2462 isolate_->debug()->side_effect_check_failed_ = false; 2480 isolate_->debug()->side_effect_check_failed_ = false;
2463 } 2481 }
2464 2482
2465 } // namespace internal 2483 } // namespace internal
2466 } // namespace v8 2484 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698