@@ -9,6 +9,8 @@ pub struct Stepper {
99 active : bool ,
1010 step_mode : StepMode ,
1111 pause_next : bool ,
12+ last_pause_triple : Option < ( usize , usize , StepMode ) > ,
13+ pause_repeat_count : usize ,
1214}
1315
1416impl Stepper {
@@ -17,6 +19,8 @@ impl Stepper {
1719 active : false ,
1820 step_mode : StepMode :: StepInto ,
1921 pause_next : false ,
22+ last_pause_triple : None ,
23+ pause_repeat_count : 0 ,
2024 }
2125 }
2226
@@ -41,13 +45,42 @@ impl Stepper {
4145 self . step_mode
4246 }
4347
48+ pub fn pause_repeat_count ( & self ) -> usize {
49+ self . pause_repeat_count
50+ }
51+
52+ pub fn reset_pause_count ( & mut self ) {
53+ self . pause_repeat_count = 0 ;
54+ }
55+
56+ fn track_pause ( & mut self , debug_state : & DebugState ) {
57+ if let Some ( inst) = debug_state. current_instruction ( ) {
58+ let current_triple = (
59+ inst. offset ,
60+ debug_state. instruction_pointer ( ) . call_stack_depth ( ) ,
61+ self . step_mode ,
62+ ) ;
63+
64+ if self . last_pause_triple == Some ( current_triple) {
65+ self . pause_repeat_count += 1 ;
66+ } else {
67+ self . last_pause_triple = Some ( current_triple) ;
68+ self . pause_repeat_count = 0 ;
69+ }
70+ }
71+ }
72+
4473 pub fn step_into ( & mut self , debug_state : & mut DebugState ) -> bool {
4574 if !self . active {
4675 return false ;
4776 }
4877 self . step_mode = StepMode :: StepInto ;
4978 debug_state. start_instruction_stepping ( StepMode :: StepInto ) ;
50- debug_state. next_instruction ( ) . is_some ( )
79+ let stepped = debug_state. next_instruction ( ) . is_some ( ) ;
80+ if stepped {
81+ self . track_pause ( debug_state) ;
82+ }
83+ stepped
5184 }
5285
5386 pub fn step_over ( & mut self , debug_state : & mut DebugState ) -> bool {
@@ -56,7 +89,11 @@ impl Stepper {
5689 }
5790 self . step_mode = StepMode :: StepOver ;
5891 debug_state. start_instruction_stepping ( StepMode :: StepOver ) ;
59- self . advance_to_depth ( debug_state, false )
92+ let stepped = self . advance_to_depth ( debug_state, false ) ;
93+ if stepped {
94+ self . track_pause ( debug_state) ;
95+ }
96+ stepped
6097 }
6198
6299 /// Step over to the next distinct source line within the same call frame.
@@ -96,6 +133,7 @@ impl Stepper {
96133 } ;
97134
98135 if is_different_line {
136+ self . track_pause ( debug_state) ;
99137 return true ;
100138 }
101139 }
@@ -109,7 +147,11 @@ impl Stepper {
109147 }
110148 self . step_mode = StepMode :: StepOut ;
111149 debug_state. start_instruction_stepping ( StepMode :: StepOut ) ;
112- self . advance_to_depth ( debug_state, true )
150+ let stepped = self . advance_to_depth ( debug_state, true ) ;
151+ if stepped {
152+ self . track_pause ( debug_state) ;
153+ }
154+ stepped
113155 }
114156
115157 pub fn step_block ( & mut self , debug_state : & mut DebugState ) -> bool {
@@ -118,14 +160,22 @@ impl Stepper {
118160 }
119161 self . step_mode = StepMode :: StepBlock ;
120162 debug_state. start_instruction_stepping ( StepMode :: StepBlock ) ;
121- self . find_next_control_flow ( debug_state)
163+ let stepped = self . find_next_control_flow ( debug_state) ;
164+ if stepped {
165+ self . track_pause ( debug_state) ;
166+ }
167+ stepped
122168 }
123169
124170 pub fn step_back ( & mut self , debug_state : & mut DebugState ) -> bool {
125171 if !self . active {
126172 return false ;
127173 }
128- debug_state. previous_instruction ( ) . is_some ( )
174+ let stepped = debug_state. previous_instruction ( ) . is_some ( ) ;
175+ if stepped {
176+ self . track_pause ( debug_state) ;
177+ }
178+ stepped
129179 }
130180
131181 pub fn continue_execution ( & mut self , debug_state : & mut DebugState ) {
@@ -155,6 +205,7 @@ impl Stepper {
155205 return false ;
156206 }
157207 if self . should_pause ( instruction, debug_state) {
208+ self . track_pause ( debug_state) ;
158209 self . pause_next = false ;
159210 return true ;
160211 }
@@ -164,6 +215,8 @@ impl Stepper {
164215 pub fn reset ( & mut self ) {
165216 self . active = false ;
166217 self . pause_next = false ;
218+ self . last_pause_triple = None ;
219+ self . pause_repeat_count = 0 ;
167220 }
168221
169222 fn advance_to_depth ( & self , debug_state : & mut DebugState , strictly_lower : bool ) -> bool {
0 commit comments