26#if defined (HAVE_CONFIG_H)
71 for (
const auto& lineno : lines)
72 retval(idx++) = lineno;
172 std::string symbol_name =
"";
173 std::string class_name =
"";
175 std::string condition =
"";
178 octave::tree_evaluator& tw = interp.get_evaluator ();
182 if (args.length() >= 1 && ! args(0).isstruct ())
186 class_name, lines, condition);
188 if (lines.size () == 0)
191 if (symbol_name !=
"")
198 else if (args.length () != 1)
220 error (
"dbstop: invalid 'bkpt' field");
229 error (
"dbstop: Cell array must contain fields 'name' and 'line'");
233 bool use_cond = mv.
isfield (
"cond");
237 std::string unconditional =
"";
240 lines.
insert (line(i).int_value ());
244 ? cond(i).string_value ()
252 tw.reset_debug_state ();
301 std::string symbol_name =
"";
302 std::string class_name =
"";
306 int nargin = args.length ();
308 octave::tree_evaluator& tw = interp.get_evaluator ();
315 if (nargin == 1 && symbol_name ==
"all")
322 if (symbol_name !=
"")
327 tw.reset_debug_state ();
332DEFMETHOD (dbstatus, interp, args, nargout,
377 int nargin = args.length ();
379 if (nargin != 0 && nargin != 1)
380 error (
"dbstatus: only zero or one arguments accepted\n");
384 std::string symbol_name;
386 octave::tree_evaluator& tw = interp.get_evaluator ();
392 if (! args(0).is_string ())
395 symbol_name = args(0).string_value ();
396 fcn_list(0) = symbol_name;
420 for (
auto& fnm_bp_p: bp_list)
422 std::list<octave::bp_type> m = fnm_bp_p.second;
427 int have_unconditional = 0;
428 for (
const auto& bp : m)
432 if (have_unconditional++)
437 if (have_unconditional)
439 const char *_s_ = (have_unconditional > 1) ?
"s" :
"";
440 octave_stdout <<
"breakpoint" << _s_ <<
" in " << fnm_bp_p.first
441 <<
" at line" << _s_ <<
' ';
443 for (
const auto& bp : m)
452 for (
const auto& bp : m)
456 <<
" at line " << bp.line
457 <<
" if " << bp.cond <<
"\n";
467 octave::help_system& help_sys = interp.get_help_system ();
476 for (
const auto& fnm_bp_p : bp_list)
477 count += fnm_bp_p.second.size ();
484 for (
const auto& fnm_bp_p : bp_list)
486 std::string filename = fnm_bp_p.first;
487 const char *sub_fun = strchr (filename.c_str (),
'>');
489 filename = filename.substr(0, sub_fun - filename.c_str ());
494 for (
const auto& bp : fnm_bp_p.second)
496 names(i) = fnm_bp_p.first;
504 retmap.
assign (
"name", names);
505 retmap.
assign (
"file", file);
506 retmap.
assign (
"line", line);
507 retmap.
assign (
"cond", cond);
562 octave::tree_evaluator& tw = interp.get_evaluator ();
575 os <<
"dbtype: unknown function " <<
name <<
"\n";
581 os <<
"dbtype: unable to open '" << ff <<
"' for reading!\n";
587 while (std::getline (fs, text) && line <= end)
590 os << line <<
"\t" << text <<
"\n";
628 octave::tree_evaluator& tw = interp.get_evaluator ();
630 switch (args.length ())
633 dbg_fcn = tw.get_user_code ();
636 error (
"dbtype: must be inside a user function to give no arguments to dbtype\n");
645 std::string arg = argv[1];
647 std::size_t ind = arg.find (
':');
649 if (ind != std::string::npos)
651 dbg_fcn = tw.get_user_code ();
655 std::string start_str = arg.substr (0, ind);
656 std::string end_str = arg.substr (ind + 1);
659 start = atoi (start_str.c_str ());
660 if (end_str ==
"end")
663 end = atoi (end_str.c_str ());
666 error (
"dbtype: start and end lines must be >= 1\n");
669 error (
"dbtype: start line must be less than end line\n");
677 int line = atoi (arg.c_str ());
681 dbg_fcn = tw.get_user_code (arg);
684 error (
"dbtype: function <%s> not found\n", arg.c_str ());
692 error (
"dbtype: start and end lines must be >= 1\n");
694 dbg_fcn = tw.get_user_code ();
706 dbg_fcn = tw.get_user_code (argv[1]);
709 error (
"dbtype: function <%s> not found\n", argv[1].c_str ());
711 std::string arg = argv[2];
713 std::size_t ind = arg.find (
':');
715 if (ind != std::string::npos)
717 std::string start_str = arg.substr (0, ind);
718 std::string end_str = arg.substr (ind + 1);
720 start = atoi (start_str.c_str ());
721 if (end_str ==
"end")
724 end = atoi (end_str.c_str ());
728 start = atoi (arg.c_str ());
733 error (
"dbtype: start and end lines must be >= 1\n");
736 error (
"dbtype: start line must be less than end line\n");
743 error (
"dbtype: expecting zero, one, or two arguments\n");
762 if (args.length () == 1)
770 n = atoi (s_arg.c_str ());
773 n = args(0).int_value ();
776 error (
"dblist: N must be a non-negative integer");
779 octave::tree_evaluator& tw = interp.get_evaluator ();
784 error (
"dblist: must be inside a user function to use dblist\n");
786 bool have_file =
true;
796 int l = tw.debug_user_code_line ();
816 octave_stdout <<
"dblist: unable to determine source code line"
825 int nargout, std::ostream& os)
827 int nargin = args.
length ();
838 if (nargin == 1 || nargin == 2)
851 if (s_arg ==
"-completenames")
854 n = atoi (s_arg.c_str ());
860 error (
"dbstack: N must be a non-negative integer");
867 octave::tree_evaluator& tw = interp.get_evaluator ();
878 os <<
"stopped in:\n\n";
884 bool show_top_level =
true;
886 std::size_t max_name_len = 0;
890 std::string
name = names(i).string_value ();
897 std::string
name = names(i).string_value ();
898 std::string file = files(i).string_value ();
899 int line = lines(i).int_value ();
901 if (show_top_level && i == curr_frame)
902 show_top_level =
false;
904 os << (i == curr_frame ?
" --> " :
" ")
905 << std::setw (max_name_len) <<
name
906 <<
" at line " << line
907 <<
" [" << file <<
']'
911 if (tw.at_top_level () && show_top_level)
912 os <<
" --> top level" << std::endl;
917 octave_map stk = tw.backtrace (curr_frame,
false);
926 curr_frame -= num_skip;
927 curr_frame = (curr_frame < 0 ? 0 : curr_frame + 1);
929 retval =
ovl (stk, curr_frame);
947DEFMETHOD (dbstack, interp, args, nargout,
991 const std::string& who)
1003 n = atoi (s_arg.c_str ());
1006 n = args(0).int_value ();
1012 octave::tree_evaluator& tw = interp.get_evaluator ();
1014 tw.dbupdown (n,
true);
1070 octave::tree_evaluator& tw = interp.get_evaluator ();
1072 if (! tw.in_debug_repl ())
1073 error (
"dbstep: can only be called in debug mode");
1075 int nargin = args.length ();
1085 = args(0).xstring_value (
"dbstep: input argument must be a string");
1089 else if (arg ==
"out")
1093 n = atoi (arg.c_str ());
1096 error (
"dbstep: invalid argument");
1104 tw.set_dbstep_flag (n);
1107 tw.reset_debug_state ();
1123 octave::tree_evaluator& tw = interp.get_evaluator ();
1125 if (! tw.in_debug_repl ())
1126 error (
"dbcont: can only be called in debug mode");
1128 if (args.length () != 0)
1146 octave::tree_evaluator& tw = interp.get_evaluator ();
1148 if (! tw.in_debug_repl ())
1149 error (
"dbquit: can only be called in debug mode");
1151 int nargin = args.length ();
1159 = args(0).xstring_value (
"dbquit: input argument must be a string");
1164 error (
"dbquit: unrecognized argument '%s'", arg.c_str ());
1179 if (args.length () != 0)
1182 octave::tree_evaluator& tw = interp.get_evaluator ();
1184 return ovl (tw.in_debug_repl ());
1187DEFMETHOD (__db_next_breakpoint_quiet__, interp, args, ,
1196 int nargin = args.length ();
1204 state = args(0).bool_value ();
1206 octave::tree_evaluator& tw = interp.get_evaluator ();
1208 tw.quiet_breakpoint_flag (
state);
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
octave_idx_type numel(void) const
Number of elements in the array.
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Cell & insert(const Cell &a, octave_idx_type r, octave_idx_type c)
Vector representing the dimensions (size) of an Array.
octave_map stop_on_err_warn_status(bool to_screen)
bp_lines add_breakpoints_in_function(const std::string &fname="", const std::string &class_name="", const bp_lines &lines=bp_lines(), const std::string &condition="")
fname_bp_map get_breakpoint_list(const octave_value_list &fname_list)
void dbstop_process_map_args(const octave_map &mv)
std::map< std::string, std::list< bp_type > > fname_bp_map
void dbclear_all_signals(void)
void parse_dbfunction_params(const char *who, const octave_value_list &args, std::string &func_name, std::string &class_name, bp_table::bp_lines &lines, std::string &cond)
void remove_all_breakpoints(void)
int remove_breakpoints_from_function(const std::string &fname="", const bp_lines &lines=bp_lines())
std::string name(void) const
Cell getfield(const std::string &key) const
const Cell & contents(const_iterator p) const
bool isfield(const std::string &name) const
void delete_elements(const octave::idx_vector &i)
void setfield(const std::string &key, const Cell &val)
octave_idx_type numel(void) const
void assign(const std::string &k, const Cell &val)
const_iterator begin(void) const
const_iterator end(void) const
std::string fcn_file_name(void) const
std::string get_code_line(std::size_t line)
octave_idx_type length(void) const
int int_value(bool req_int=false, bool frc_str_conv=false) const
bool is_string(void) const
Cell cell_value(void) const
std::string string_value(bool force=false) const
static octave_value_list do_dbstack(octave::interpreter &interp, const octave_value_list &args, int nargout, std::ostream &os)
static OCTAVE_NAMESPACE_BEGIN octave_value bp_lines_to_ov(const octave::bp_table::bp_lines &lines)
void show_octave_dbstack(void)
static void do_dbtype(std::ostream &os, const std::string &name, int start, int end)
static void do_dbupdown(octave::interpreter &interp, const octave_value_list &args, const std::string &who)
OCTINTERP_API void print_usage(void)
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
#define DEFALIAS(alias, name)
Macro to define an alias for another existing function name.
void error(const char *fmt,...)
void err_wrong_type_arg(const char *name, const char *s)
octave::idx_vector idx_vector
F77_RET_T const F77_DBLE const F77_DBLE * f
std::ifstream ifstream(const std::string &filename, const std::ios::openmode mode)
std::string canonicalize_file_name(const std::string &name)
static uint32_t state[624]
interpreter & __get_interpreter__(const std::string &who)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
std::string fcn_file_in_path(const std::string &name)