comparison libinterp/parse-tree/pt-eval.cc @ 15574:d20cbfec6df7

Fix off-by-1 error when executing 'dbstep N' * pt-eval.cc(do_breakpoint): Decrement dbstep_flag only after it has been determined that 'dbstep N' is being run and N > 1 and it is not the end of the frame.
author Rik <rik@octave.org>
date Thu, 01 Nov 2012 11:42:21 -0700
parents 72868cae7624
children 5f37c24350db
comparison
equal deleted inserted replaced
15572:859c8bf6d134 15574:d20cbfec6df7
1134 tree_evaluator::do_breakpoint (bool is_breakpoint, 1134 tree_evaluator::do_breakpoint (bool is_breakpoint,
1135 bool is_end_of_fcn_or_script) const 1135 bool is_end_of_fcn_or_script) const
1136 { 1136 {
1137 bool break_on_this_statement = false; 1137 bool break_on_this_statement = false;
1138 1138
1139 // Don't decrement break flag unless we are in the same frame as we 1139 if (octave_debug_on_interrupt_state)
1140 // were when we saw the "dbstep N" command. 1140 {
1141 1141 break_on_this_statement = true;
1142 if (dbstep_flag > 1) 1142
1143 octave_debug_on_interrupt_state = false;
1144
1145 current_frame = octave_call_stack::current_frame ();
1146 }
1147 else if (is_breakpoint)
1148 {
1149 break_on_this_statement = true;
1150
1151 dbstep_flag = 0;
1152
1153 current_frame = octave_call_stack::current_frame ();
1154 }
1155 else if (dbstep_flag > 0)
1143 { 1156 {
1144 if (octave_call_stack::current_frame () == current_frame) 1157 if (octave_call_stack::current_frame () == current_frame)
1145 { 1158 {
1146 // Don't allow dbstep N to step past end of current frame. 1159 if (dbstep_flag == 1 || is_end_of_fcn_or_script)
1147 1160 {
1148 if (is_end_of_fcn_or_script) 1161 // We get here if we are doing a "dbstep" or a "dbstep N" and the
1149 dbstep_flag = 1; 1162 // count has reached 1 so that we must stop and return to debug
1163 // prompt. Alternatively, "dbstep N" has been used but the end
1164 // of the frame has been reached so we stop at the last line and
1165 // return to prompt.
1166
1167 break_on_this_statement = true;
1168
1169 dbstep_flag = 0;
1170 }
1150 else 1171 else
1151 dbstep_flag--; 1172 {
1152 } 1173 // Executing "dbstep N". Decrease N by one and continue executing.
1153 } 1174
1154 1175 dbstep_flag--;
1155 if (octave_debug_on_interrupt_state) 1176 }
1156 { 1177
1157 break_on_this_statement = true;
1158
1159 octave_debug_on_interrupt_state = false;
1160
1161 current_frame = octave_call_stack::current_frame ();
1162 }
1163 else if (is_breakpoint)
1164 {
1165 break_on_this_statement = true;
1166
1167 dbstep_flag = 0;
1168
1169 current_frame = octave_call_stack::current_frame ();
1170 }
1171 else if (dbstep_flag == 1)
1172 {
1173 if (octave_call_stack::current_frame () == current_frame)
1174 {
1175 // We get here if we are doing a "dbstep" or a "dbstep N"
1176 // and the count has reached 1 and we are in the current
1177 // debugging frame.
1178
1179 break_on_this_statement = true;
1180
1181 dbstep_flag = 0;
1182 } 1178 }
1183 } 1179 }
1184 else if (dbstep_flag == -1) 1180 else if (dbstep_flag == -1)
1185 { 1181 {
1186 // We get here if we are doing a "dbstep in". 1182 // We get here if we are doing a "dbstep in".