24 #if defined (HAVE_CONFIG_H) 67 for (
size_t i = 0;
i <
line.size ();
i++)
73 int lineno =
p->second;
83 DEFUN (dbstop, args, ,
181 if (args.length() >= 1 && ! args(0).isstruct ())
187 if (lines.size () == 0)
190 if (symbol_name !=
"")
196 else if (args.length () != 1)
219 error (
"dbstop: invalid 'bkpt' field");
230 error (
"dbstop: Cell array must contain fields 'name' and 'line'");
235 bool use_cond = mv.
isfield (
"cond");
242 lines [0] =
line(
i).double_value ();
245 ? cond(
i).string_value ()
255 DEFUN (dbclear, args, ,
303 int nargin = args.length ();
309 if (
nargin == 1 && symbol_name ==
"all")
316 if (symbol_name !=
"")
368 int nargin = args.length ();
371 error (
"dbstatus: only zero or one arguments accepted\n");
381 if (! args(0).is_string ())
384 symbol_name = args(0).string_value ();
385 fcn_list(0) = symbol_name;
409 for (
auto& fnm_bp_p: bp_list)
411 std::list<octave::bp_type> m = fnm_bp_p.second;
416 int have_unconditional = 0;
417 for (
const auto& bp : m)
421 if (have_unconditional++)
426 if (have_unconditional)
428 const char *_s_ = (have_unconditional > 1) ?
"s" :
"";
429 octave_stdout <<
"breakpoint" << _s_ <<
" in " << fnm_bp_p.first
430 <<
" at line" << _s_ <<
' ';
432 for (
const auto& bp : m)
441 for (
const auto& bp : m)
445 <<
" at line " << bp.line
446 <<
" if " << bp.cond <<
"\n";
465 for (
const auto& fnm_bp_p : bp_list)
466 count += fnm_bp_p.second.
size ();
473 for (
const auto& fnm_bp_p : bp_list)
476 const char *sub_fun = strchr (
filename.c_str (),
'>');
483 for (
const auto& bp : fnm_bp_p.second)
485 names(
i) = fnm_bp_p.first;
496 retmap.
assign (
"cond", cond);
506 outer.assign (
"bkpt",
Cell (retmap));
561 if (! file_name.empty ())
585 os <<
"dbtype: unknown function " <<
name <<
"\n";
588 std::ifstream
fs (ff.c_str (), std::ios::in);
591 os <<
"dbtype: unable to open '" << ff <<
"' for reading!\n";
597 while (std::getline (
fs,
text) &&
line <= end)
610 DEFUN (dbtype, args, ,
638 switch (args.length ())
644 error (
"dbtype: must be inside a user function to give no arguments to dbtype\n");
655 size_t ind =
arg.find (
':');
657 if (
ind != std::string::npos)
667 start = atoi (start_str.c_str ());
668 if (end_str ==
"end")
671 end = atoi (end_str.c_str ());
674 error (
"dbtype: start and end lines must be >= 1\n");
677 error (
"dbtype: start line must be less than end line\n");
685 int line = atoi (
arg.c_str ());
692 error (
"dbtype: function <%s> not found\n",
arg.c_str ());
700 error (
"dbtype: start and end lines must be >= 1\n");
717 error (
"dbtype: function <%s> not found\n",
argv[1].c_str ());
721 size_t ind =
arg.find (
':');
723 if (
ind != std::string::npos)
728 start = atoi (start_str.c_str ());
729 if (end_str ==
"end")
732 end = atoi (end_str.c_str ());
741 error (
"dbtype: start and end lines must be >= 1\n");
744 error (
"dbtype: start line must be less than end line\n");
751 error (
"dbtype: expecting zero, one, or two arguments\n");
770 if (args.length () == 1)
778 n = atoi (s_arg.c_str ());
781 n = args(0).int_value ();
784 error (
"dblist: N must be a non-negative integer");
790 error (
"dblist: must be inside a user function to use dblist\n");
792 bool have_file =
true;
824 octave_stdout <<
"dblist: unable to determine source code line" 861 if (s_arg ==
"-completenames")
864 n = atoi (s_arg.c_str ());
870 error (
"dbstack: N must be a non-negative integer");
884 if (nframes_to_display > 0)
888 os <<
"stopped in:\n\n";
894 bool show_top_level =
true;
896 size_t max_name_len = 0;
909 int line = lines(
i).int_value ();
911 if (show_top_level &&
i == curr_frame)
912 show_top_level =
false;
914 os << (
i == curr_frame ?
" --> " :
" ")
915 << std::setw (max_name_len) <<
name 916 <<
" at line " <<
line 917 <<
" [" <<
file <<
']' 922 os <<
" --> top level" << std::endl;
929 retval =
ovl (stk, curr_frame < 0 ? 1 : curr_frame + 1);
941 show_octave_dbstack (
void)
1008 n = atoi (s_arg.c_str ());
1011 n = args(0).int_value ();
1020 error (
"%s: invalid stack frame", who.c_str ());
1033 do_dbupdown (interp, args,
"dbup");
1048 do_dbupdown (interp, args,
"dbdown");
1053 DEFUN (dbstep, args, ,
1077 error (
"dbstep: can only be called in debug mode");
1086 std::string arg = args(0).xstring_value (
"dbstep: input argument must be a string");
1095 else if (
arg ==
"out")
1104 int n = atoi (
arg.c_str ());
1107 error (
"dbstep: invalid argument");
1128 DEFUN (dbcont, args, ,
1136 error (
"dbcont: can only be called in debug mode");
1149 DEFUN (dbquit, args, ,
1158 error (
"dbquit: can only be called in debug mode");
1170 throw octave::interrupt_exception ();
1175 DEFUN (isdebugmode, args, ,
1188 DEFUN (__db_next_breakpoint_quiet__, args, ,
1205 state = args(0).bool_value ();
scalar structure containing the one value The second produces an empty struct array with one field and no values since being passed an empty cell array of struct array values When the value is a cell array containing a single entry this becomes a scalar struct with that single entry as the value of the field That single entry happens to be an empty cell array Finally if the value is a non scalar cell array then ode isstruct
For example cd octave end example noindent changes the current working directory to file
int int_value(bool req_int=false, bool frc_str_conv=false) const
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
std::string canonicalize_file_name(const std::string &name)
interpreter & __get_interpreter__(const std::string &who)
octave_user_code * get_user_code(const std::string &fname)
std::string string_value(bool force=false) const
void assign(const std::string &k, const Cell &val)
int debug_user_code_line(void) const
OCTINTERP_API void print_usage(void)
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
OCTINTERP_API std::string fcn_file_in_path(const std::string &)
octave_map backtrace(size_t nskip, octave_idx_type &curr_user_frame, bool print_subfn=true) const
std::string get_code_line(size_t line)
bool goto_frame_relative(int n, bool verbose=false)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
intmap::const_iterator const_intmap_iterator
void error(const char *fmt,...)
static void reset_debug_state(void)
const_iterator end(void) const
std::map< std::string, std::list< bp_type > > fname_bp_map
intmap add_breakpoint(const std::string &fname="", const intmap &lines=intmap(), const std::string &condition="")
int remove_breakpoint(const std::string &fname="", const intmap &lines=intmap())
virtual std::string fcn_file_name(void) const
static octave_value intmap_to_ov(const octave::bp_table::intmap &line)
static bool quiet_breakpoint_flag
octave_value resize(const dim_vector &dv, bool fill=false) const
void dbclear_all_signals(void)
#define DEFALIAS(alias, name)
Macro to define an alias for another existing function name.
Cell getfield(const std::string &key) const
bool isfield(const std::string &name) const
nd deftypefn *std::string name
void parse_dbfunction_params(const char *, const octave_value_list &, std::string &, bp_table::intmap &, std::string &)
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
const Cell & contents(const_iterator p) const
std::map< int, int > intmap
octave_map stop_on_err_warn_status(bool to_screen)
octave_idx_type numel(void) const
void err_wrong_type_arg(const char *name, const char *s)
static uint32_t state[624]
octave::unwind_protect frame
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
void dbstop_process_map_args(const octave_map &mv)
charNDArray max(char d, const charNDArray &m)
OCTAVE_EXPORT octave_value_list the first data row corresponds to an index of zero The a spreadsheet style form such as the file is read until end of file is reached The such as text
fname_bp_map get_breakpoint_list(const octave_value_list &fname_list)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
std::string which(const std::string &name) const
otherwise an error message is printed The permission mask is a UNIX concept used when creating new objects on a file system such as files
bp_table & __get_bp_table__(const std::string &who)
void remove_all_breakpoints(void)
octave_idx_type length(void) const
call_stack & get_call_stack(void)
octave::sys::file_stat fs(filename)
bool is_string(void) const
octave_fields::const_iterator const_iterator
octave_idx_type numel(void) const
Number of elements in the array.
Vector representing the dimensions (size) of an Array.
const_iterator begin(void) const
std::string name(void) const
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Cell cell_value(void) const
charNDArray min(char d, const charNDArray &m)