Mercurial > hg > octave-terminal
changeset 15575: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 | 859c8bf6d134 |
children | 5f37c24350db |
files | libinterp/parse-tree/pt-eval.cc |
diffstat | 1 files changed, 18 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-eval.cc +++ b/libinterp/parse-tree/pt-eval.cc @@ -1136,22 +1136,6 @@ { bool break_on_this_statement = false; - // Don't decrement break flag unless we are in the same frame as we - // were when we saw the "dbstep N" command. - - if (dbstep_flag > 1) - { - if (octave_call_stack::current_frame () == current_frame) - { - // Don't allow dbstep N to step past end of current frame. - - if (is_end_of_fcn_or_script) - dbstep_flag = 1; - else - dbstep_flag--; - } - } - if (octave_debug_on_interrupt_state) { break_on_this_statement = true; @@ -1168,17 +1152,29 @@ current_frame = octave_call_stack::current_frame (); } - else if (dbstep_flag == 1) + else if (dbstep_flag > 0) { if (octave_call_stack::current_frame () == current_frame) { - // We get here if we are doing a "dbstep" or a "dbstep N" - // and the count has reached 1 and we are in the current - // debugging frame. + if (dbstep_flag == 1 || is_end_of_fcn_or_script) + { + // We get here if we are doing a "dbstep" or a "dbstep N" and the + // count has reached 1 so that we must stop and return to debug + // prompt. Alternatively, "dbstep N" has been used but the end + // of the frame has been reached so we stop at the last line and + // return to prompt. + + break_on_this_statement = true; - break_on_this_statement = true; + dbstep_flag = 0; + } + else + { + // Executing "dbstep N". Decrease N by one and continue executing. - dbstep_flag = 0; + dbstep_flag--; + } + } } else if (dbstep_flag == -1)