26 #if defined (HAVE_CONFIG_H)
64 : m_ok (false), m_file (file), m_dir (), m_fcn (), m_class_name ()
70 std::size_t
len = fcn.length ();
71 if (
len >= 2 && fcn[
len-2] ==
'.' && fcn[
len-1] ==
'm')
72 fcn = fcn.substr (0,
len-2);
76 if (pos != std::string::npos && pos < dir.length () - 1)
78 if (dir[pos+1] ==
'@')
80 m_class_name = dir.substr (pos+1);
84 dir = dir.substr (0, pos);
99 std::string
file (
void)
const {
return m_file; }
100 std::string
dir (
void)
const {
return m_fcn; }
101 std::string
fcn (
void)
const {
return m_fcn; }
104 bool ok (
void)
const {
return m_ok; }
147 fail = (U.
numel () > 1);
153 else if (! W(0).iscell ())
157 Cell V = W(0).cell_value ();
158 for (
int i = 0; i <
V.numel (); i++)
167 error (
"dbstop: invalid 'errs' field");
174 fail = (U.
numel () > 1);
180 else if (! W(0).iscell ())
184 Cell V = W(0).cell_value ();
185 for (
int i = 0; i <
V.numel (); i++)
194 error (
"dbstop: invalid 'caught' field");
201 fail = (U.
numel () > 1);
207 else if (! W(0).iscell ())
211 Cell V = W(0).cell_value ();
212 for (
int i = 0; i <
V.numel (); i++)
221 error (
"dbstop: invalid 'warn' field");
233 const std::string& fname,
235 const std::string& condition,
252 for (
auto& lineno : retval)
260 const char *s = strchr (fname.c_str (),
'>');
262 m_bp_set.insert (fname.substr (0, s - fname.c_str ()));
281 if (cond.length () > 0)
288 error (
"dbstop: Cannot parse condition '%s'", cond.c_str ());
293 std::shared_ptr<tree_statement_list> stmt_list
298 "condition is not empty, but has nothing to evaluate");
301 if (stmt_list->length () == 1
302 && (stmt = stmt_list->front ())
307 error (
"dbstop: condition cannot be an assignment. "
308 "Did you mean '=='?");
311 error (
"dbstop: condition must be an expression");
341 std::string& fcn_name,
342 std::string& class_name,
346 int nargin = args.
length ();
351 if (nargin == 0 || ! args(0).is_string ())
355 bool seen_in =
false;
356 bool seen_at =
false;
357 bool seen_if =
false;
363 if (args(pos).is_string ())
365 std::string arg = args(pos).string_value ();
371 else if (arg ==
"at")
376 else if (arg ==
"if")
381 else if (atoi (args(pos).string_value ().c_str ()) > 0)
390 error (
"%s: '%s' missing argument", who,
392 ?
"in" : (tok ==
dbstop_at ?
"at" :
"if")));
398 fcn_name = args(pos).string_value ();
400 error (
"%s: Too many function names specified -- %s",
401 who, fcn_name.c_str ());
402 else if (seen_at || seen_if)
403 error (
"%s: function name must come before line number and 'if'",
411 error (
"%s: Only one 'at' clause is allowed -- %s",
412 who, args(pos).string_value ().c_str ());
414 error (
"%s: line number must come before 'if' clause\n", who);
418 error (
"%s: line number must come before 'if' clause\n", who);
421 std::string arg = args(pos).string_value ();
426 if (atoi (arg.c_str ()) == 0)
430 class_name = fcn_name;
443 error (
"%s: function name must come before line number "
449 for ( ; pos < nargin; pos++)
451 if (args(pos).is_string ())
453 int line = atoi (args(pos).string_value ().c_str ());
460 else if (args(pos).isnumeric ())
465 lines.
insert (
static_cast<int> (arg.
elem (j)));
468 error (
"%s: Invalid argument type %s",
469 who, args(pos).type_name ().c_str ());
477 for (; pos < nargin; pos++)
479 if (args(pos).is_string ())
480 cond +=
' ' + args(pos).string_value ();
482 error (
"%s: arguments to 'if' must all be strings", who);
485 cond = cond.substr (1);
489 std::string condition = args(pos).string_value ();
490 bool on_off = !
strcmp (who,
"dbstop");
495 if (condition ==
"error")
498 else if (condition ==
"warning")
501 else if (condition ==
"caught" && nargin > pos+1
502 && args(pos+1).string_value () ==
"error")
508 else if (condition ==
"interrupt")
512 else if (condition ==
"naninf")
514 #if defined (DBSTOP_NANINF)
515 Vdebug_on_naninf = on_off;
518 warning (
"%s: condition '%s' not yet supported",
519 who, condition.c_str ());
523 error (
"%s: invalid condition %s",
524 who, condition.c_str ());
558 if (condition ==
"error")
560 else if (condition ==
"warning")
562 else if (condition ==
"caught")
565 error (
"%s: internal error in set_stop_flag", who);
569 const std::string& condition,
571 int nargin,
int& pos,
bool on_off,
572 std::set<std::string>& id_list)
578 if (! args(pos).is_string () || nargin > pos+1)
579 error (
"%s: ID must be a single string", who);
582 id_list.insert (args(pos).string_value ());
587 id_list.erase (args(pos).string_value ());
588 if (id_list.empty ())
597 if (condition ==
"error")
611 int *end_line =
nullptr)
619 std::map<std::string, octave_value> subfcns = main_fcn->
subfunctions ();
620 for (
const auto& str_val_p : subfcns)
622 if (str_val_p.second.is_user_function ())
624 auto *dbg_subfcn = str_val_p.second.user_function_value ();
631 if (dbg_subfcn->ending_line () < earliest_end
632 && dbg_subfcn->ending_line () >= lineno
633 && dbg_subfcn->beginning_line () <= lineno)
635 earliest_end = dbg_subfcn->ending_line ();
641 if (dbg_subfcn->beginning_line () >= lineno && ! next_fcn)
642 next_fcn = dbg_subfcn;
651 if (e >= lineno && e < earliest_end)
663 if (end_line && earliest_end < *end_line)
664 *end_line = earliest_end;
672 const std::string& class_name,
674 const std::string& condition)
677 line_info.insert (line);
682 return result.empty () ? 0 : *(result.begin ());
689 const std::string& class_name,
691 const std::string& condition)
696 error (
"add_breakpoints_in_function: unable to find function '%s'\n",
703 for (
const auto& lineno : lines)
709 line_info.insert (lineno);
715 if (! ret_one.empty ())
717 int line = *(ret_one.begin ());
720 retval.insert (line);
732 const std::string& condition)
749 const std::string& condition)
764 const std::string& fname,
779 if (results.
length () > 0)
785 for (
const auto& lineno : lines)
800 retval = results.
length ();
810 line_info.insert (line);
824 retval = results.size ();
831 error (
"remove_breakpoints_from_function: unable to find function %s\n",
838 const std::list<std::string> subfcn_names
841 std::map<std::string, octave_value> subfcns
844 for (
const auto& subf_nm : subfcn_names)
846 const auto q = subfcns.find (subf_nm);
848 if (q != subfcns.end ())
892 error (
"remove_all_breakpoints_from_function: "
893 "unable to find function %s\n", fname.c_str ());
948 for (
auto it =
m_bp_set.cbegin (), it_next = it;
963 for (
int i = 0; i < slist.
length (); i++)
965 if (slist(i).string_value () == match)
967 retval = slist(i).string_value ();
981 std::set<std::string> tmp_bp_set =
m_bp_set;
983 for (
auto& bp_fname : tmp_bp_set)
985 if (fname_list.
empty ()
1000 if (! bkpts.empty ())
1001 retval[bp_fname] = bkpts;
1005 const std::list<std::string> subf_nm
1008 std::map<std::string, octave_value> subfcns
1011 for (
const auto& subfcn_nm : subf_nm)
1013 const auto q = subfcns.find (subfcn_nm);
1015 if (q != subfcns.end ())
1020 cmds = dbg_subfcn->
body ();
1023 std::list<bp_type> bkpts
1026 if (! bkpts.empty ())
1029 = bp_fname +
'>' + dbg_subfcn->
name ();
1031 retval[key] = bkpts;
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
static octave_user_code * find_fcn_by_line(octave_user_code *main_fcn, int lineno, int *end_line=nullptr)
std::string find_bkpt_list(octave_value_list slist, std::string match)
charNDArray max(char d, const charNDArray &m)
OCTARRAY_OVERRIDABLE_FUNC_API bool isempty(void) const
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel(void) const
Number of elements in the array.
OCTARRAY_API Array< T, Alloc > & insert(const Array< T, Alloc > &a, const Array< octave_idx_type > &idx)
Insert an array into another at a specified position.
OCTARRAY_OVERRIDABLE_FUNC_API T & elem(octave_idx_type n)
Size of the specified dimension.
Cell index(const octave_value_list &idx, bool resize_ok=false) const
OCTINTERP_API void statement_list(std::shared_ptr< tree_statement_list > &lst)
OCTINTERP_API void reset(void)
std::string file(void) const
bp_file_info(tree_evaluator &tw, const std::string &file)
std::string dir(void) const
std::string class_name(void) const
std::string fcn(void) const
bool condition_valid(const std::string &cond)
std::set< std::string > m_caught_that_stop
void process_id_list(const char *who, const std::string &condition, const octave_value_list &args, int nargin, int &pos, bool on_off, std::set< std::string > &id_list)
int remove_breakpoint_from_file(const std::string &file="", int line=1)
tree_evaluator & m_evaluator
fname_bp_map get_breakpoint_list(const octave_value_list &fname_list)
std::set< std::string > m_warnings_that_stop
int remove_breakpoints_from_file(const std::string &file="", const bp_lines &lines=bp_lines())
std::set< std::string > m_errors_that_stop
bp_lines remove_all_breakpoints_from_function(const std::string &fname, bool silent=false)
int remove_breakpoints_from_function(const std::string &fname="", const bp_lines &lines=bp_lines())
void dbstop_process_map_args(const octave_map &mv)
int add_breakpoint_in_function(const std::string &fname="", const std::string &class_name="", int line=1, const std::string &condition="")
void set_stop_flag(const char *who, const std::string &condition, bool on_off)
void dbclear_all_signals(void)
int add_breakpoint_in_file(const std::string &file="", int line=1, const std::string &condition="")
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="")
std::set< std::string > m_bp_set
int remove_breakpoint_from_function(const std::string &fname="", int line=1)
bool add_breakpoint_1(octave_user_code *fcn, const std::string &fname, const bp_lines &line, const std::string &condition, bp_lines &retval)
std::map< std::string, std::list< bp_type > > fname_bp_map
bp_lines add_breakpoints_in_file(const std::string &file="", const bp_lines &lines=bp_lines(), const std::string &condition="")
bp_lines remove_all_breakpoints_from_file(const std::string &file, bool silent=false)
int remove_breakpoint_1(octave_user_code *fcn, const std::string &, const bp_lines &lines)
octave_map stop_on_err_warn_status(bool to_screen)
void remove_all_breakpoints(void)
void parse_dbfunction_params(const char *who, const octave_value_list &args, std::string &fcn_name, std::string &class_name, bp_table::bp_lines &lines, std::string &cond)
Vector representing the dimensions (size) of an Array.
OCTINTERP_API octave_value debug_on_warning(const octave_value_list &args, int nargout)
OCTINTERP_API octave_value debug_on_caught(const octave_value_list &args, int nargout)
OCTINTERP_API octave_value debug_on_error(const octave_value_list &args, int nargout)
Provides threadsafe access to octave.
void update_breakpoint(bool insert, const std::string &file, int line, const std::string &cond="")
event_manager & get_event_manager(void)
error_system & get_error_system(void)
load_path & get_load_path(void)
bool contains_file_in_dir(const std::string &file_name, const std::string &dir_name)
virtual bool is_user_function(void) const
virtual octave_user_code * user_code_value(bool silent=false)
virtual std::string profiler_name(void) const
virtual std::list< std::string > subfunction_names(void) const
std::string name(void) const
bool isfield(const std::string &name) const
void assign(const std::string &k, const Cell &val)
const Cell & contents(const_iterator p) const
std::string fcn_file_name(void) const
octave::tree_statement_list * body(void)
virtual std::map< std::string, octave_value > subfunctions(void) const
octave_idx_type length(void) const
Array< octave_value > array_value(void) const
OCTINTERP_API int run(void)
void reset_debug_state(void)
octave_user_code * get_user_code(const std::string &fname="", const std::string &class_name="")
bool in_debug_repl(void) const
interpreter & get_interpreter(void)
virtual bool is_assignment_expression(void) const
octave_value_list list_breakpoints(void)
std::list< bp_type > breakpoints_and_conds(void)
void delete_breakpoint(int line)
bp_table::bp_lines remove_all_breakpoints(event_manager &evmgr, const std::string &file)
bp_table::bp_lines add_breakpoint(event_manager &evmgr, const std::string &file, const bp_table::bp_lines &lines, const std::string &condition)
bool is_expression(void) const
tree_expression * expression(void)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
OCTINTERP_API void print_usage(void)
void warning(const char *fmt,...)
void error(const char *fmt,...)
std::string dirname(const std::string &path)
std::string tail(const std::string &path)
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT F77_DBLE * V
std::complex< double > w(std::complex< double > z, double relerr=0)
OCTAVE_API bool strcmp(const T &str_a, const T &str_b)
Octave string utility functions.
static std::string dir_sep_chars
static string_vector make_absolute(const string_vector &sv)