Mercurial > octave
diff libinterp/corefcn/stack-frame.cc @ 27037:8408acb7ca4f
make dbup/dbdown work again (bug #56020)
Store call stack index in stack frame object to make iteration in call
stack possible given only a stack frame. Store current debug frame in
call stack and use that info to track stack location when at a debug
prompt. New class for managing debug info and the debug repl.
It should now be possible to enter the debugger recursively.
* stack-frame.h, stack-frame.cc (stack_frame::m_index): New data member.
(stack_frame::m_prev): Delete data member and all uses.
Update constructors for base and derived classes and change all uses.
(stack_frame::index): New function.
(display_stopped_in_message): New function.
* bp-table.cc: Eliminate use of Vdebugger. Don't set debug_mode directly.
* error.cc (maybe_enter_debugger, warning_1): Use
tree_evaluator::enter_debugger instead of input_system::keyboard to
enter debugger.
* call-stack.h, call-stack.cc (call_stack::goto_frame_relative):
Delete.
(call_stack::find_current_user_frame,
call_stack::find_current_user_frame,
call_stack::find_current_user_frame, call_stack::find_caller_frame):
New functions.
(call_stack::goto_caller_frame): Simplify by calling find_caller_frame
and dbupdown.
(class stack_trace_generator): Delete class and all uses.
(call_stack::current_user_code): Rename from caller_user_code and
eliminate nskip argument.
(call_stack::current_user_code_line):
Rename from caller_user_code_line.
(call_stack::current_user_code_column):
Rename from caller_user_code_column.
(call_stack::goto_frame, call_stack::dbupdown):
Use stack_frame::display_in_stopped_message.
(call_stack::backtrace_frames, call_stack::backtrace):
Make these functions work again. Eliminate nskip argument.
* debug.cc (Fdbstop, Fdbclear, Fdbstep):
Call tree_evaluator::reset_debug_state.
(Fdbstop, Fdbclear, Fdbstep, Fdbcont, Fdbquit, Fisdebugmode):
Move real work to evaluator, debugger, and call_stack classes.
(Fdbwhere): Use stack_frame::display_stopped_in_message.
* input.h, input.cc (Vdebugging): Delete variable and all uses.
(input_system::keyboard, execute_in_debugger_handler,
input_system::get_debutg_input): Delete. Move functionality to
new debugger class.
(Fkeyboard): Simplify.
(do_keyboard): Delete.
* pt-eval.h, pt-eval.cc (class debugger): New class for managing debugger.
(tree_evaluator::m_debug_frame): Rename from m_current_frame. Use
this variable to manage debugger location when making function calls
during debugging (for example, to dbup, dbdown, etc.).
(tree_evaluator::m_debugger_stack): New variable.
(tree_evaluator::reset_debug_state): Set m_debug_mode if we have
breakpoints, are stepping in the debugger, or executing in the
debugger repl.
(tree_evaluator::reset_debug_state): Don't set m_dbstep_flag here.
(tree_evaluator::enter_debugger): New function.
(tree_evaluator::do_breakpoint): Handle exiting from the debugger
object here. Maybe rejoin existing debugger instance.
(tree_evaluator::do_keyboard): Delete.
(bool tree_evaluator::in_debug_repl, bool
tree_evaluator::exit_debug_repl, bool tree_evaluator::exit_debug_repl,
bool tree_evaluator::abort_debug_repl, bool
tree_evaluator::abort_debug_repl): New functions.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 08 Apr 2019 00:36:33 +0000 |
parents | d9770844392e |
children | 61226b7bd6b9 |
line wrap: on
line diff
--- a/libinterp/corefcn/stack-frame.cc Mon Apr 08 09:22:39 2019 -0700 +++ b/libinterp/corefcn/stack-frame.cc Mon Apr 08 00:36:33 2019 +0000 @@ -478,6 +478,22 @@ accept (sc); } + void stack_frame::display_stopped_in_message (std::ostream& os) const + { + if (index () == 0) + os << "at top level" << std::endl; + else + { + os << "stopped in " << fcn_name (); + + int l = line (); + if (l > 0) + os << " at line " << line (); + + os << " [" << fcn_file_name () << "] " << std::endl; + } + } + void stack_frame::display (bool follow) const { std::ostream& os = octave_stdout; @@ -500,7 +516,7 @@ os << "line: " << m_line << std::endl; os << "column: " << m_column << std::endl; - os << "prev: " << m_prev << std::endl; + os << "index: " << m_index << std::endl; os << std::endl; @@ -543,9 +559,9 @@ script_stack_frame::script_stack_frame (call_stack& cs, octave_user_script *script, unwind_protect *up_frame, - size_t prev, + size_t index, stack_frame *static_link) - : stack_frame (cs, prev, static_link, get_access_link (static_link)), + : stack_frame (cs, index, static_link, get_access_link (static_link)), m_script (script), m_unwind_protect_frame (up_frame), m_lexical_frame_offsets (get_num_symbols (script), 1), m_value_offsets (get_num_symbols (script), 0)