26 #if defined (HAVE_CONFIG_H)
69 for (
size_t i = 0; i <
line.size (); i++)
75 int lineno = p->second;
177 std::string symbol_name =
"";
178 std::string class_name =
"";
180 std::string condition =
"";
187 if (args.length() >= 1 && ! args(0).isstruct ())
191 class_name, lines, condition);
193 if (lines.size () == 0)
196 if (symbol_name !=
"")
203 else if (args.length () != 1)
226 error (
"dbstop: invalid 'bkpt' field");
237 error (
"dbstop: Cell array must contain fields 'name' and 'line'");
242 bool use_cond = mv.
isfield (
"cond");
246 std::string unconditional =
"";
249 lines [0] =
line(i).double_value ();
252 ? cond(i).string_value ()
309 std::string symbol_name =
"";
310 std::string class_name =
"";
314 int nargin = args.length ();
322 if (nargin == 1 && symbol_name ==
"all")
329 if (symbol_name !=
"")
339 DEFMETHOD (dbstatus, interp, args, nargout,
384 int nargin = args.length ();
386 if (nargin != 0 && nargin != 1)
387 error (
"dbstatus: only zero or one arguments accepted\n");
391 std::string symbol_name;
399 if (! args(0).is_string ())
402 symbol_name = args(0).string_value ();
403 fcn_list(0) = symbol_name;
427 for (
auto& fnm_bp_p: bp_list)
429 std::list<octave::bp_type>
m = fnm_bp_p.second;
434 int have_unconditional = 0;
435 for (
const auto& bp :
m)
439 if (have_unconditional++)
444 if (have_unconditional)
446 const char *_s_ = (have_unconditional > 1) ?
"s" :
"";
447 octave_stdout <<
"breakpoint" << _s_ <<
" in " << fnm_bp_p.first
448 <<
" at line" << _s_ <<
' ';
450 for (
const auto& bp :
m)
459 for (
const auto& bp :
m)
463 <<
" at line " << bp.line
464 <<
" if " << bp.cond <<
"\n";
483 for (
const auto& fnm_bp_p : bp_list)
484 count += fnm_bp_p.second.
size ();
491 for (
const auto& fnm_bp_p : bp_list)
493 std::string filename = fnm_bp_p.first;
494 const char *sub_fun = strchr (filename.c_str (),
'>');
496 filename = filename.substr(0, sub_fun - filename.c_str ());
501 for (
const auto& bp : fnm_bp_p.second)
503 names(i) = fnm_bp_p.first;
511 retmap.
assign (
"name", names);
512 retmap.
assign (
"file", file);
514 retmap.
assign (
"cond", cond);
582 os <<
"dbtype: unknown function " <<
name <<
"\n";
588 os <<
"dbtype: unable to open '" << ff <<
"' for reading!\n";
594 while (std::getline (fs,
text) &&
line <= end)
637 switch (args.length ())
643 error (
"dbtype: must be inside a user function to give no arguments to dbtype\n");
652 std::string arg = argv[1];
654 size_t ind = arg.find (
':');
656 if (ind != std::string::npos)
662 std::string start_str = arg.substr (0, ind);
663 std::string end_str = arg.substr (ind + 1);
666 start = atoi (start_str.c_str ());
667 if (end_str ==
"end")
670 end = atoi (end_str.c_str ());
673 error (
"dbtype: start and end lines must be >= 1\n");
676 error (
"dbtype: start line must be less than end line\n");
684 int line = atoi (arg.c_str ());
691 error (
"dbtype: function <%s> not found\n", arg.c_str ());
699 error (
"dbtype: start and end lines must be >= 1\n");
716 error (
"dbtype: function <%s> not found\n", argv[1].c_str ());
718 std::string arg = argv[2];
720 size_t ind = arg.find (
':');
722 if (ind != std::string::npos)
724 std::string start_str = arg.substr (0, ind);
725 std::string end_str = arg.substr (ind + 1);
727 start = atoi (start_str.c_str ());
728 if (end_str ==
"end")
731 end = atoi (end_str.c_str ());
735 start = atoi (arg.c_str ());
740 error (
"dbtype: start and end lines must be >= 1\n");
743 error (
"dbtype: start line must be less than end line\n");
750 error (
"dbtype: expecting zero, one, or two arguments\n");
769 if (args.length () == 1)
777 n = atoi (s_arg.c_str ());
780 n = args(0).int_value ();
783 error (
"dblist: N must be a non-negative integer");
791 error (
"dblist: must be inside a user function to use dblist\n");
793 bool have_file =
true;
823 octave_stdout <<
"dblist: unable to determine source code line"
832 int nargout, std::ostream& os)
834 int nargin = args.
length ();
847 if (nargin == 1 || nargin == 2)
860 if (s_arg ==
"-completenames")
863 n = atoi (s_arg.c_str ());
869 error (
"dbstack: N must be a non-negative integer");
887 os <<
"stopped in:\n\n";
893 bool show_top_level =
true;
895 size_t max_name_len = 0;
899 std::string
name = names(i).string_value ();
906 std::string
name = names(i).string_value ();
907 std::string file = files(i).string_value ();
908 int line = lines(i).int_value ();
910 if (show_top_level && i == curr_frame)
911 show_top_level =
false;
913 os << (i == curr_frame ?
" --> " :
" ")
914 << std::setw (max_name_len) <<
name
915 <<
" at line " <<
line
916 <<
" [" << file <<
']'
921 os <<
" --> top level" << std::endl;
951 DEFMETHOD (dbstack, interp, args, nargout,
1000 const std::string& who)
1012 n = atoi (s_arg.c_str ());
1015 n = args(0).int_value ();
1082 error (
"dbstep: can only be called in debug mode");
1084 int nargin = args.length ();
1094 = args(0).xstring_value (
"dbstep: input argument must be a string");
1098 else if (arg ==
"out")
1102 n = atoi (arg.c_str ());
1105 error (
"dbstep: invalid argument");
1135 error (
"dbcont: can only be called in debug mode");
1137 if (args.length () != 0)
1158 error (
"dbquit: can only be called in debug mode");
1160 int nargin = args.length ();
1168 = args(0).xstring_value (
"dbquit: input argument must be a string");
1173 error (
"dbquit: unrecognized argument '%s'", arg.c_str ());
1188 if (args.length () != 0)
1196 DEFMETHOD (__db_next_breakpoint_quiet__, interp, args, ,
1205 int nargin = args.length ();
1213 state = args(0).bool_value ();
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type numel(void) const
Number of elements in the array.
size_type size(const size_type d) const
Size of the specified dimension.
Vector representing the dimensions (size) of an Array.
void parse_dbfunction_params(const char *who, const octave_value_list &args, std::string &func_name, std::string &class_name, bp_table::intmap &lines, std::string &cond)
octave_map stop_on_err_warn_status(bool to_screen)
fname_bp_map get_breakpoint_list(const octave_value_list &fname_list)
int remove_breakpoint(const std::string &fname="", const intmap &lines=intmap())
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)
intmap add_breakpoint(const std::string &fname="", const std::string &class_name="", const intmap &lines=intmap(), const std::string &condition="")
intmap::const_iterator const_intmap_iterator
void remove_all_breakpoints(void)
std::map< int, int > intmap
std::string which(const std::string &name) const
tree_evaluator & get_evaluator(void)
octave_user_code * get_user_code(const std::string &fname="", const std::string &class_name="")
bool at_top_level(void) const
int debug_user_code_line(void) const
bool in_debug_repl(void) const
bool quiet_breakpoint_flag(void) const
bp_table & get_bp_table(void)
void dbquit(bool all=false)
void set_dbstep_flag(int step)
void dbupdown(int n, bool verbose=false)
void reset_debug_state(void)
void debug_where(std::ostream &os) const
octave_map backtrace(octave_idx_type &curr_user_frame, bool print_subfn=true) const
std::string name(void) const
Cell getfield(const std::string &key) const
bool isfield(const std::string &name) const
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
const Cell & contents(const_iterator p) const
std::string get_code_line(size_t line)
std::string fcn_file_name(void) const
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_value intmap_to_ov(const octave::bp_table::intmap &line)
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)
F77_RET_T const F77_DBLE const F77_DBLE * f
std::string canonicalize_file_name(const std::string &name)
std::ifstream ifstream(const std::string &filename, const std::ios::openmode mode)
static uint32_t state[624]
interpreter & __get_interpreter__(const std::string &who)
std::string fcn_file_in_path(const std::string &name)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value::octave_value(const Array< char > &chm, char type) return retval
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.