26 #if defined (HAVE_CONFIG_H)
90 fail = (U.
numel () > 1);
96 else if (! W(0).iscell ())
100 Cell V = W(0).cell_value ();
101 for (
int i = 0; i <
V.numel (); i++)
110 error (
"dbstop: invalid 'errs' field");
117 fail = (U.
numel () > 1);
123 else if (! W(0).iscell ())
127 Cell V = W(0).cell_value ();
128 for (
int i = 0; i <
V.numel (); i++)
137 error (
"dbstop: invalid 'caught' field");
144 fail = (U.
numel () > 1);
150 else if (! W(0).iscell ())
154 Cell V = W(0).cell_value ();
155 for (
int i = 0; i <
V.numel (); i++)
164 error (
"dbstop: invalid 'warn' field");
176 const std::string& fname,
178 const std::string& condition,
195 for (
auto& idx_line_p :
retval)
197 if (idx_line_p.second != 0)
203 const char *s = strchr (fname.c_str (),
'>');
205 m_bp_set.insert (fname.substr (0, s - fname.c_str ()));
224 if (cond.length () > 0)
231 error (
"dbstop: Cannot parse condition '%s'", cond.c_str ());
236 std::shared_ptr<tree_statement_list> stmt_list
241 "condition is not empty, but has nothing to evaluate");
244 if (stmt_list->length () == 1
245 && (stmt = stmt_list->front ())
250 error (
"dbstop: condition cannot be an assignment. "
251 "Did you mean '=='?");
254 error (
"dbstop: condition must be an expression");
284 std::string& func_name,
285 std::string& class_name,
289 int nargin = args.
length ();
295 if (nargin == 0 || ! args(0).is_string ())
299 bool seen_in =
false;
300 bool seen_at =
false;
301 bool seen_if =
false;
307 if (args(pos).is_string ())
309 std::string arg = args(pos).string_value ();
315 else if (arg ==
"at")
320 else if (arg ==
"if")
325 else if (atoi (args(pos).string_value ().c_str ()) > 0)
334 error (
"%s: '%s' missing argument", who,
336 ?
"in" : (tok ==
dbstop_at ?
"at" :
"if")));
342 func_name = args(pos).string_value ();
344 error (
"%s: Too many function names specified -- %s",
345 who, func_name.c_str ());
346 else if (seen_at || seen_if)
347 error (
"%s: function name must come before line number and 'if'",
355 error (
"%s: Only one 'at' clause is allowed -- %s",
356 who, args(pos).string_value ().c_str ());
358 error (
"%s: line number must come before 'if' clause\n", who);
362 error (
"%s: line number must come before 'if' clause\n", who);
365 std::string arg = args(pos).string_value ();
370 if (atoi (arg.c_str ()) == 0)
374 class_name = func_name;
387 error (
"%s: function name must come before line number "
393 for ( ; pos < nargin; pos++)
395 if (args(pos).is_string ())
397 int line = atoi (args(pos).string_value ().c_str ());
400 lines[list_idx++] =
line;
404 else if (args(pos).isnumeric ())
409 lines[list_idx++] =
static_cast<int> (arg.
elem (j));
412 error (
"%s: Invalid argument type %s",
413 who, args(pos).type_name ().c_str ());
421 for (; pos < nargin; pos++)
423 if (args(pos).is_string ())
424 cond +=
' ' + args(pos).string_value ();
426 error (
"%s: arguments to 'if' must all be strings", who);
429 cond = cond.substr (1);
433 std::string condition = args(pos).string_value ();
434 bool on_off = !
strcmp (who,
"dbstop");
439 if (condition ==
"error")
442 else if (condition ==
"warning")
445 else if (condition ==
"caught" && nargin > pos+1
446 && args(pos+1).string_value () ==
"error")
452 else if (condition ==
"interrupt")
456 else if (condition ==
"naninf")
458 #if defined (DBSTOP_NANINF)
459 Vdebug_on_naninf = on_off;
462 warning (
"%s: condition '%s' not yet supported",
463 who, condition.c_str ());
467 error (
"%s: invalid condition %s",
468 who, condition.c_str ());
502 if (condition ==
"error")
504 else if (condition ==
"warning")
506 else if (condition ==
"caught")
509 error (
"%s: internal error in set_stop_flag", who);
513 const std::string& condition,
515 int nargin,
int& pos,
bool on_off,
516 std::set<std::string>& id_list)
522 if (! args(pos).is_string () || nargin > pos+1)
523 error (
"%s: ID must be a single string", who);
526 id_list.insert (args(pos).string_value ());
531 id_list.erase (args(pos).string_value ());
532 if (id_list.empty ())
541 if (condition ==
"error")
555 int *end_line =
nullptr)
563 std::map<std::string, octave_value> subfcns = main_fcn->
subfunctions ();
564 for (
const auto& str_val_p : subfcns)
566 if (str_val_p.second.is_user_function ())
568 auto *dbg_subfcn = str_val_p.second.user_function_value ();
575 if (dbg_subfcn->ending_line () < earliest_end
576 && dbg_subfcn->ending_line () >= lineno
577 && dbg_subfcn->beginning_line () <= lineno)
579 earliest_end = dbg_subfcn->ending_line ();
585 if (dbg_subfcn->beginning_line () >= lineno && ! next_fcn)
586 next_fcn = dbg_subfcn;
595 if (e >= lineno && e < earliest_end)
607 if (end_line && earliest_end < *end_line)
608 *end_line = earliest_end;
616 const std::string& class_name,
618 const std::string& condition)
623 error (
"add_breakpoint: unable to find function '%s'\n", fname.c_str ());
631 for (
int i = 0; i <
len; i++)
635 if (
m !=
line.end ())
637 int lineno =
m->second;
647 retval.
insert (std::pair<int,int> (i, ret_one.find (i)->second));
657 const std::string& fname,
672 if (results.
length () > 0)
680 for (
int i = 0; i <
len; i++)
684 if (p !=
line.end ())
686 int lineno = p->second;
725 error (
"remove_breakpoint: unable to find function %s\n",
732 const std::list<std::string> subfcn_names
735 std::map<std::string, octave_value> subfcns
738 for (
const auto& subf_nm : subfcn_names)
740 const auto q = subfcns.find (subf_nm);
742 if (q != subfcns.end ())
786 error (
"remove_all_breakpoint_in_file: "
787 "unable to find function %s\n", fname.c_str ());
798 for (
auto it =
m_bp_set.cbegin (), it_next = it;
813 for (
int i = 0; i < slist.
length (); i++)
815 if (slist(i).string_value () == match)
817 retval = slist(i).string_value ();
831 std::set<std::string> tmp_bp_set =
m_bp_set;
833 for (
auto& bp_fname : tmp_bp_set)
835 if (fname_list.
empty ()
850 if (! bkpts.empty ())
855 const std::list<std::string> subf_nm
858 std::map<std::string, octave_value> subfcns
861 for (
const auto& subfcn_nm : subf_nm)
863 const auto q = subfcns.find (subfcn_nm);
865 if (q != subfcns.end ())
870 cmds = dbg_subfcn->
body ();
873 std::list<bp_type> bkpts
876 if (! bkpts.empty ())
879 = bp_fname +
'>' + dbg_subfcn->
name ();
charNDArray max(char d, const charNDArray &m)
Array< T > & insert(const Array< T > &a, const Array< octave_idx_type > &idx)
Insert an array into another at a specified position.
void assign(const idx_vector &i, const Array< T > &rhs, const T &rfv)
Indexed assignment (always with resize & fill).
octave_idx_type numel(void) const
Number of elements in the array.
T & elem(octave_idx_type n)
Size of the specified dimension.
size_type size(const size_type d) const
Size of the specified dimension.
bool isempty(void) const
Size of the specified dimension.
Cell index(const octave_value_list &idx, bool resize_ok=false) const
Vector representing the dimensions (size) of an Array.
void statement_list(std::shared_ptr< tree_statement_list > &lst)
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)
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)
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)
std::set< std::string > m_warnings_that_stop
std::set< std::string > m_errors_that_stop
intmap add_breakpoint(const std::string &fname="", const std::string &class_name="", const intmap &lines=intmap(), const std::string &condition="")
bool condition_valid(const std::string &cond)
intmap::const_iterator const_intmap_iterator
bool add_breakpoint_1(octave_user_code *fcn, const std::string &fname, const intmap &line, const std::string &condition, intmap &retval)
void remove_all_breakpoints(void)
int remove_breakpoint_1(octave_user_code *fcn, const std::string &, const intmap &lines)
std::set< std::string > m_caught_that_stop
std::set< std::string > m_bp_set
void set_stop_flag(const char *who, const std::string &condition, bool on_off)
std::map< int, int > intmap
intmap remove_all_breakpoints_in_file(const std::string &fname, bool silent=false)
tree_evaluator & m_evaluator
octave_value debug_on_error(const octave_value_list &args, int nargout)
octave_value debug_on_caught(const octave_value_list &args, int nargout)
octave_value debug_on_warning(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="")
error_system & get_error_system(void)
event_manager & get_event_manager(void)
octave_user_code * get_user_code(const std::string &fname="", const std::string &class_name="")
bool in_debug_repl(void) const
void reset_debug_state(void)
interpreter & get_interpreter(void)
virtual bool is_assignment_expression(void) const
void delete_breakpoint(int line)
octave_value_list list_breakpoints(void)
bp_table::intmap remove_all_breakpoints(event_manager &evmgr, const std::string &file)
std::list< bp_type > breakpoints_and_conds(void)
bp_table::intmap add_breakpoint(event_manager &evmgr, const std::string &file, const bp_table::intmap &line, const std::string &condition)
bool is_expression(void) const
tree_expression * expression(void)
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
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 void print_usage(void)
void warning(const char *fmt,...)
void error(const char *fmt,...)
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)
bool strcmp(const T &str_a, const T &str_b)
True if strings are the same.
tree_evaluator & __get_evaluator__(const std::string &who)
octave_user_code * get_user_code(const std::string &fname)
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)
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