# HG changeset patch # User John W. Eaton # Date 1280530771 14400 # Node ID 65bc065bec957208d59a204229131a39e1eb4ce5 # Parent 960065af9f0f7ebb9437d20a042798563f8d3d8f still more debugger fixes diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2010-07-30 John W. Eaton + + * debug.cc (Fdbstack): Improve display. + + * toplev.cc (octave_call_stack::do_goto_frame_relative): + Improve message. Don't display column number. + + * debug.cc (get_file_line): Don't allow eol to be less than bol. + (Fdbwhere): Improve message. Don't display column number. + (Fdbstack): Omit column number from display. + + * pt-eval.cc (tree_evaluator::visit_statement): Don't call + octave_call_stack::set_statement for commands issued while + debugging. + 2010-07-30 John W. Eaton * pt-bp.cc (tree_breakpoint::take_action): Only call diff --git a/src/debug.cc b/src/debug.cc --- a/src/debug.cc +++ b/src/debug.cc @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -152,7 +153,7 @@ size_t bol = offsets[line]; size_t eol = offsets[line+1]; - while (eol > 0 && (buf[eol-1] == '\n' || buf[eol-1] == '\r')) + while (eol > 0 && eol > bol && (buf[eol-1] == '\n' || buf[eol-1] == '\r')) eol--; retval = buf.substr (bol, eol - bol); @@ -594,7 +595,7 @@ for (bp_table::fname_line_map_iterator it = bp_list.begin (); it != bp_list.end (); it++) { - octave_stdout << "Breakpoint in " << it->first << " at line(s) "; + octave_stdout << "breakpoint in " << it->first << " at line(s) "; bp_table::intmap m = it->second; @@ -658,28 +659,13 @@ name = dbg_fcn->name (); } - octave_stdout << name << ":"; - - unwind_protect frame; + octave_stdout << "stopped in " << name << " at "; - frame.add_fcn (octave_call_stack::restore_frame, - octave_call_stack::current_frame ()); - - // Skip the frame assigned to the dbwhere function. - octave_call_stack::goto_frame_relative (0); - - int l = octave_call_stack::current_line (); + int l = octave_call_stack::caller_user_code_line (); if (l > 0) { - octave_stdout << " line " << l; - - int c = octave_call_stack::current_column (); - - if (c > 0) - octave_stdout << ", column " << c; - - octave_stdout << std::endl; + octave_stdout << " line " << l << std::endl; if (have_file) { @@ -690,7 +676,7 @@ } } else - octave_stdout << " (unknown line)\n"; + octave_stdout << " " << std::endl; } else error ("dbwhere: must be inside of a user function to use dbwhere\n"); @@ -894,24 +880,41 @@ if (nframes_to_display > 0) { - octave_stdout << "Stopped in:\n\n"; + octave_stdout << "stopped in:\n\n"; Cell names = stk.contents ("name"); + Cell files = stk.contents ("file"); Cell lines = stk.contents ("line"); - Cell columns = stk.contents ("column"); + + bool show_top_level = true; + + size_t max_name_len = 0; for (octave_idx_type i = 0; i < nframes_to_display; i++) { - octave_value name = names(i); - octave_value line = lines(i); - octave_value column = columns(i); + std::string name = names(i).string_value (); + + max_name_len = std::max (name.length (), max_name_len); + } - octave_stdout << (i == curr_frame ? "--> " : " ") - << name.string_value () - << " at line " << line.int_value () - << " column " << column.int_value () + for (octave_idx_type i = 0; i < nframes_to_display; i++) + { + std::string name = names(i).string_value (); + std::string file = files(i).string_value (); + int line = lines(i).int_value (); + + if (show_top_level && i == curr_frame) + show_top_level = false; + + octave_stdout << (i == curr_frame ? " --> " : " ") + << std::setw (max_name_len) << name + << " at line " << line + << " [" << file << "]" << std::endl; } + + if (show_top_level) + octave_stdout << " --> top level" << std::endl; } } else diff --git a/src/pt-eval.cc b/src/pt-eval.cc --- a/src/pt-eval.cc +++ b/src/pt-eval.cc @@ -684,7 +684,11 @@ { if (in_fcn_or_script_body) { - octave_call_stack::set_statement (&stmt); + // Skip commands issued at a debug> prompt to avoid disturbing + // the state of the program we are debugging. + + if (! Vdebugging) + octave_call_stack::set_statement (&stmt); if (Vecho_executing_commands & ECHO_FUNCTIONS) stmt.echo_code (); diff --git a/src/toplev.cc b/src/toplev.cc --- a/src/toplev.cc +++ b/src/toplev.cc @@ -404,8 +404,8 @@ int l = s ? s->line () : -1; int c = s ? s->column () : -1; - buf << f->name () << ": " << " line " << l - << ", column " << c << std::endl; + buf << "stopped in " << f->name () + << " at line " << l << std::endl; } else buf << "at top level" << std::endl;