GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
bp-table.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2001-2018 Ben Sapp
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_bp_table_h)
24 #define octave_bp_table_h 1
25 
26 #include "octave-config.h"
27 
28 #include <list>
29 #include <map>
30 #include <set>
31 #include <string>
32 
33 class octave_map;
34 class octave_user_code;
35 class octave_value_list;
36 
37 namespace octave
38 {
39  struct bp_type
40  {
41  int line;
43 
44  bp_type (int l, const std::string& c) : line (l), cond (c) { }
45  };
46 
47  // Interface to breakpoints.
48  class OCTINTERP_API bp_table
49  {
50  public:
51 
52  bp_table (void)
53  : m_bp_set (), m_errors_that_stop (), m_caught_that_stop (),
54  m_warnings_that_stop ()
55  { }
56 
57  ~bp_table (void) = default;
58 
59  // mapping from (FIXME: arbitrary index??) to line number of breakpoint
60  typedef std::map<int, int> intmap;
61 
62  typedef intmap::const_iterator const_intmap_iterator;
63  typedef intmap::iterator intmap_iterator;
64 
65  typedef std::map <std::string, intmap> fname_line_map;
66 
67  typedef fname_line_map::const_iterator const_fname_line_map_iterator;
68  typedef fname_line_map::iterator fname_line_map_iterator;
69 
70  typedef std::map <std::string, std::list<bp_type>> fname_bp_map;
71  typedef fname_bp_map::const_iterator const_fname_bp_map_iterator;
72  typedef fname_bp_map::iterator fname_bp_map_iterator;
73 
74  // Add a breakpoint at the nearest executable line.
75  intmap add_breakpoint (const std::string& fname = "",
76  const intmap& lines = intmap (),
77  const std::string& condition = "");
78 
79  // Remove a breakpoint from a line in file.
80  int remove_breakpoint (const std::string& fname = "",
81  const intmap& lines = intmap ());
82 
83  // Remove all the breakpoints in a specified file.
84  intmap remove_all_breakpoints_in_file (const std::string& fname,
85  bool silent = false);
86 
87  // Remove all the breakpoints registered with octave.
88  void remove_all_breakpoints (void);
89 
90  // Return all breakpoints. Each element of the map is a vector
91  // containing the breakpoints corresponding to a given function name.
92  fname_bp_map get_breakpoint_list (const octave_value_list& fname_list);
93 
94  bool have_breakpoints (void) { return (! m_bp_set.empty ()); }
95 
96  // Should we enter debugging for this particular error identifier?
97  bool debug_on_err (const std::string& id)
98  {
99  return (m_errors_that_stop.empty () || m_errors_that_stop.count (id));
100  }
101 
102  // Should we enter debugging for this particular identifier in a try/catch?
103  bool debug_on_caught (const std::string& id)
104  {
105  return (m_caught_that_stop.empty () || m_caught_that_stop.count (id));
106  }
107 
108  // Should we enter debugging for this particular warning identifier?
109  bool debug_on_warn (const std::string& id)
110  {
111  return (m_warnings_that_stop.empty () || m_warnings_that_stop.count (id));
112  }
113 
114  octave_map stop_on_err_warn_status (bool to_screen);
115 
116  void dbstop_process_map_args (const octave_map& mv);
117 
118  void dbclear_all_signals (void);
119 
120  bool condition_valid (const std::string& cond);
121 
122  void parse_dbfunction_params (const char *, const octave_value_list&,
124  std::string&);
125 
126  private:
127 
128  typedef std::set<std::string>::const_iterator const_bp_set_iterator;
129  typedef std::set<std::string>::iterator bp_set_iterator;
130 
131  // Set of function (.m file) names containing at least one breakpoint.
132  std::set<std::string> m_bp_set;
133 
134  // Set of error and warning message IDs that cause us to stop
135  // *if* Vdebug_on_error / Vdebug_on_caught / Vdebug_on_warning is set.
136  // Empty means stop on any error / caught error / warning.
137  std::set<std::string> m_errors_that_stop;
138  std::set<std::string> m_caught_that_stop;
139  std::set<std::string> m_warnings_that_stop;
140 
141  bool add_breakpoint_1 (octave_user_code *fcn, const std::string& fname,
142  const intmap& line, const std::string& condition,
143  intmap& retval);
144 
145  int remove_breakpoint_1 (octave_user_code *fcn, const std::string&,
146  const intmap& lines);
147 
148  intmap remove_all_breakpoints_in_file_1 (octave_user_code *fcn,
149  const std::string& fname);
150  };
151 
152  extern octave_user_code * get_user_code (const std::string& fname = "");
153 }
154 
155 #endif
std::set< std::string > m_warnings_that_stop
Definition: bp-table.h:139
octave_user_code * get_user_code(const std::string &fname)
Definition: bp-table.cc:936
fname
Definition: load-save.cc:767
bool debug_on_warn(const std::string &id)
Definition: bp-table.h:109
fname_line_map::iterator fname_line_map_iterator
Definition: bp-table.h:68
intmap::const_iterator const_intmap_iterator
Definition: bp-table.h:62
std::map< std::string, std::list< bp_type > > fname_bp_map
Definition: bp-table.h:70
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
fname_line_map::const_iterator const_fname_line_map_iterator
Definition: bp-table.h:67
std::set< std::string >::iterator bp_set_iterator
Definition: bp-table.h:129
std::set< std::string > m_caught_that_stop
Definition: bp-table.h:138
octave_function * fcn
Definition: ov-class.cc:1754
std::set< std::string > m_errors_that_stop
Definition: bp-table.h:137
std::set< std::string > m_bp_set
Definition: bp-table.h:132
std::string cond
Definition: bp-table.h:42
bp_type(int l, const std::string &c)
Definition: bp-table.h:44
bool have_breakpoints(void)
Definition: bp-table.h:94
bool debug_on_err(const std::string &id)
Definition: bp-table.h:97
octave_value retval
Definition: data.cc:6246
bool debug_on_caught(const std::string &id)
Definition: bp-table.h:103
intmap::iterator intmap_iterator
Definition: bp-table.h:63
std::map< int, int > intmap
Definition: bp-table.h:60
bp_table(void)
Definition: bp-table.h:52
fname_bp_map::const_iterator const_fname_bp_map_iterator
Definition: bp-table.h:71
std::map< std::string, intmap > fname_line_map
Definition: bp-table.h:65
fname_bp_map::iterator fname_bp_map_iterator
Definition: bp-table.h:72
std::set< std::string >::const_iterator const_bp_set_iterator
Definition: bp-table.h:128
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
Definition: utils.cc:888