annotate libinterp/parse-tree/bp-table.cc @ 25438:cb1606f78f6b

prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible Using <iostream> brings with it a static initializer for the std::cin, std::cout, and std::cerr streams. In most cases they are not needed and should be avoided if possible. Files affected: build-aux/mk-opts.pl libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp libinterp/corefcn/__dsearchn__.cc libinterp/corefcn/c-file-ptr-stream.cc libinterp/corefcn/c-file-ptr-stream.h libinterp/corefcn/daspk.cc libinterp/corefcn/dasrt.cc libinterp/corefcn/dassl.cc libinterp/corefcn/defaults.cc libinterp/corefcn/defun.cc libinterp/corefcn/file-io.cc libinterp/corefcn/ft-text-renderer.cc libinterp/corefcn/gl-render.cc libinterp/corefcn/help.cc libinterp/corefcn/ls-ascii-helper.cc libinterp/corefcn/ls-hdf5.cc libinterp/corefcn/ls-hdf5.h libinterp/corefcn/ls-mat-ascii.cc libinterp/corefcn/ls-mat4.cc libinterp/corefcn/ls-mat5.cc libinterp/corefcn/ls-oct-binary.cc libinterp/corefcn/ls-oct-text.cc libinterp/corefcn/lsode.cc libinterp/corefcn/oct-iostrm.cc libinterp/corefcn/oct-procbuf.cc libinterp/corefcn/oct-stdstrm.h libinterp/corefcn/procstream.cc libinterp/corefcn/procstream.h libinterp/corefcn/quad.cc libinterp/corefcn/symscope.h libinterp/corefcn/symtab.h libinterp/corefcn/toplev.cc libinterp/corefcn/urlwrite.cc libinterp/corefcn/utils.cc libinterp/corefcn/zfstream.cc libinterp/dldfcn/__ode15__.cc libinterp/dldfcn/convhulln.cc libinterp/octave-value/ov-base-diag.cc libinterp/octave-value/ov-base-int.cc libinterp/octave-value/ov-base-mat.cc libinterp/octave-value/ov-base-scalar.cc libinterp/octave-value/ov-base-sparse.cc libinterp/octave-value/ov-base.cc libinterp/octave-value/ov-bool-mat.cc libinterp/octave-value/ov-bool-sparse.cc libinterp/octave-value/ov-bool.cc libinterp/octave-value/ov-cell.cc libinterp/octave-value/ov-ch-mat.cc libinterp/octave-value/ov-class.cc libinterp/octave-value/ov-colon.cc libinterp/octave-value/ov-complex.cc libinterp/octave-value/ov-cs-list.cc libinterp/octave-value/ov-cx-mat.cc libinterp/octave-value/ov-cx-sparse.cc libinterp/octave-value/ov-fcn-handle.cc libinterp/octave-value/ov-fcn-inline.cc libinterp/octave-value/ov-float.cc libinterp/octave-value/ov-flt-complex.cc libinterp/octave-value/ov-flt-cx-mat.cc libinterp/octave-value/ov-flt-re-mat.cc libinterp/octave-value/ov-int16.cc libinterp/octave-value/ov-int32.cc libinterp/octave-value/ov-int64.cc libinterp/octave-value/ov-int8.cc libinterp/octave-value/ov-java.cc libinterp/octave-value/ov-range.cc libinterp/octave-value/ov-re-mat.cc libinterp/octave-value/ov-re-sparse.cc libinterp/octave-value/ov-scalar.cc libinterp/octave-value/ov-str-mat.cc libinterp/octave-value/ov-struct.cc libinterp/octave-value/ov-typeinfo.cc libinterp/octave-value/ov-uint16.cc libinterp/octave-value/ov-uint32.cc libinterp/octave-value/ov-uint64.cc libinterp/octave-value/ov-uint8.cc libinterp/octave.cc libinterp/parse-tree/bp-table.cc libinterp/parse-tree/lex.h libinterp/parse-tree/profiler.cc libinterp/parse-tree/pt-arg-list.cc libinterp/parse-tree/pt-array-list.cc libinterp/parse-tree/pt-assign.cc libinterp/parse-tree/pt-cell.cc libinterp/parse-tree/pt-const.cc libinterp/parse-tree/pt-eval.cc libinterp/parse-tree/pt-exp.cc libinterp/parse-tree/pt-fcn-handle.cc libinterp/parse-tree/pt-jit.cc libinterp/parse-tree/pt-pr-code.cc libinterp/parse-tree/pt-tm-const.cc libinterp/parse-tree/pt.cc liboctave/array/Array.cc liboctave/array/CColVector.cc liboctave/array/CDiagMatrix.cc liboctave/array/CMatrix.cc liboctave/array/CNDArray.cc liboctave/array/CRowVector.cc liboctave/array/CSparse.cc liboctave/array/DiagArray2.cc liboctave/array/MArray.cc liboctave/array/Range.cc liboctave/array/Sparse.cc liboctave/array/boolMatrix.cc liboctave/array/boolSparse.cc liboctave/array/chMatrix.cc liboctave/array/dColVector.cc liboctave/array/dDiagMatrix.cc liboctave/array/dMatrix.cc liboctave/array/dNDArray.cc liboctave/array/dRowVector.cc liboctave/array/dSparse.cc liboctave/array/fCColVector.cc liboctave/array/fCDiagMatrix.cc liboctave/array/fCMatrix.cc liboctave/array/fCNDArray.cc liboctave/array/fCRowVector.cc liboctave/array/fColVector.cc liboctave/array/fDiagMatrix.cc liboctave/array/fMatrix.cc liboctave/array/fNDArray.cc liboctave/array/fRowVector.cc liboctave/array/idx-vector.cc liboctave/numeric/CollocWt.cc liboctave/numeric/eigs-base.cc liboctave/system/file-ops.cc liboctave/system/oct-time.cc liboctave/util/cmd-hist.cc liboctave/util/data-conv.cc liboctave/util/data-conv.h liboctave/util/file-info.cc liboctave/util/lo-utils.cc liboctave/util/lo-utils.h liboctave/util/quit.cc liboctave/util/str-vec.cc liboctave/util/url-transfer.cc liboctave/util/url-transfer.h
author John W. Eaton <jwe@octave.org>
date Thu, 07 Jun 2018 10:11:54 -0400
parents ef2b9d4abf4a
children 143007dad864
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
25054
6652d3823428 maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 24738
diff changeset
3 Copyright (C) 2001-2018 Ben Sapp
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 Copyright (C) 2007-2009 John Swensen
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 This file is part of Octave.
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24286
diff changeset
8 Octave is free software: you can redistribute it and/or modify it
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24286
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 (at your option) any later version.
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 WITHOUT ANY WARRANTY; without even the implied warranty of
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 GNU General Public License for more details.
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24286
diff changeset
20 <https://www.gnu.org/licenses/>.
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 */
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 #if defined (HAVE_CONFIG_H)
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 # include "config.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #endif
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27
23824
061a343089be Miscellaneous cleanups of C++11 std::string code.
Rik <rik@octave.org>
parents: 23807
diff changeset
28 #include <algorithm>
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include <limits>
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include <list>
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include <map>
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <set>
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include <string>
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include "file-ops.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include "bp-table.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include "defun-int.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #include "call-stack.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #include "error.h"
25347
af3319d86a5f eliminate some global references to interpreter internals
John W. Eaton <jwe@octave.org>
parents: 25343
diff changeset
41 #include "interpreter.h"
23553
14723784b9f2 don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
42 #include "interpreter-private.h"
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #include "oct-map.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 #include "octave-link.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 #include "ov-usr-fcn.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 #include "ov.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 #include "ovl.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 #include "pager.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 #include "parse.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 #include "pt-eval.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 #include "pt-exp.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 #include "pt-stmt.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 #include "sighandlers.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 #include "symtab.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
56 namespace octave
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 {
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
58 // Clear all reasons to stop, other than breakpoints.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
59
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
60 void bp_table::dbclear_all_signals (void)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
61 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
62 Vdebug_on_error = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
63 bp_table::m_errors_that_stop.clear ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
64
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
65 Vdebug_on_caught = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
66 bp_table::m_caught_that_stop.clear ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
67
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
68 Vdebug_on_warning = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
69 bp_table::m_warnings_that_stop.clear ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
70
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
71 Vdebug_on_interrupt = false;
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
72 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
73
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
74 // Process the "warn", "errs", "caught" and "intr" fields for a call of
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
75 // "dbstop (p)".
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
77 void bp_table::dbstop_process_map_args (const octave_map& mv)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
78 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
79 // process errs
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
80 // why so many levels of indirection needed?
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
81 bool fail = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
82 Cell U = mv.contents ("errs");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
83 if (U.numel () != 1)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
84 fail = (U.numel () > 1);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
85 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
86 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
87 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
88 if (W.isempty () || W(0).isempty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
89 Vdebug_on_error = 1; // like "dbstop if error" with no identifier
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
90 else if (! W(0).iscell ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
91 fail = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
92 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
93 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
94 Cell V = W(0).cell_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
95 for (int i = 0; i < V.numel (); i++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
96 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
97 m_errors_that_stop.insert (V(i).string_value ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
98 Vdebug_on_error = 1;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
99 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
100 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
101 }
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
102
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
103 if (fail)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
104 error ("dbstop: invalid 'errs' field");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
105
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
106 // process caught
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
107 // why so many levels of indirection needed?
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
108 fail = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
109 U = mv.contents ("caught");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
110 if (U.numel () != 1)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
111 fail = (U.numel () > 1);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
112 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
113 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
114 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
115 if (W.isempty () || W(0).isempty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
116 Vdebug_on_caught = 1; // like "dbstop if caught error" with no ID
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
117 else if (! W(0).iscell ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
118 fail = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
119 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
120 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
121 Cell V = W(0).cell_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
122 for (int i = 0; i < V.numel (); i++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
123 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
124 m_caught_that_stop.insert (V(i).string_value ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
125 Vdebug_on_caught = 1;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
126 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
127 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
128 }
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
129
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
130 if (fail)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
131 error ("dbstop: invalid 'caught' field");
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
132
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
133 // process warn
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
134 // why so many levels of indirection needed?
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
135 fail = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
136 U = mv.contents ("warn");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
137 if (U.numel () != 1)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
138 fail = (U.numel () > 1);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
139 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
140 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
141 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
142 if (W.isempty () || W(0).isempty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
143 Vdebug_on_warning = 1; // like "dbstop if warning" with no identifier
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
144 else if (! W(0).iscell ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
145 fail = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
146 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
147 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
148 Cell V = W(0).cell_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
149 for (int i = 0; i < V.numel (); i++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
150 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
151 m_warnings_that_stop.insert (V(i).string_value ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
152 Vdebug_on_warning = 1;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
153 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
154 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
155 }
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
156
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
157 if (fail)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
158 error ("dbstop: invalid 'warn' field");
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
160 // process interrupt
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
161 if (mv.isfield ("intr"))
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
162 Vdebug_on_interrupt = 1;
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
163 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
164
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
165 // Insert a breakpoint in function fcn at line within file fname,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
166 // to stop only when condition is true.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
167 // Record in m_bp_set that fname contains a breakpoint.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
168
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
169 bool bp_table::add_breakpoint_1 (octave_user_code *fcn,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
170 const std::string& fname,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
171 const bp_table::intmap& line,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
172 const std::string& condition,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
173 bp_table::intmap& retval)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
174 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
175 bool found = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
176
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
177 tree_statement_list *cmds = fcn->body ();
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
178
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
179 std::string file = fcn->fcn_file_name ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
180
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
181 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
182 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
183 retval = cmds->add_breakpoint (file, line, condition);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
184
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
185 for (auto& idx_line_p : retval)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
186 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
187 if (idx_line_p.second != 0)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
188 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
189 // Normalize to store only the file name.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
190 // Otherwise, there can be an entry for both
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
191 // file>subfunction and file, which causes a crash on
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
192 // dbclear all
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
193 const char *s = strchr (fname.c_str (), '>');
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
194 if (s)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
195 m_bp_set.insert (fname.substr (0, s - fname.c_str ()));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
196 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
197 m_bp_set.insert (fname);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
198 found = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
199 break;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
200 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
201 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
202 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
203
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
204 return found;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
205 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
206
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
207 // Cursory check that cond is a valid condition to use for a breakpoint.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
208 // Currently allows conditions with side-effects, like 'y+=10' and 'y++';
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
209 // it is odd that the former is not flagged by "is_assignment_expression".
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
210 // Throws an exception if not valid.
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
211
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
212 bool bp_table::condition_valid (const std::string& cond)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
213 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
214 if (cond.length () > 0)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
215 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
216 parser parser (cond + " ;"); // ; to reject partial expr like "y=="
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
217 parser.reset ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
218 int parse_status = parser.run ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
219 if (parse_status)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
220 error ("dbstop: Cannot parse condition '%s'", cond.c_str ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
221 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
222 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
223 tree_statement *stmt = nullptr;
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
224 if (! parser.m_stmt_list)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
225 error ("dbstop: "
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
226 "condition is not empty, but has nothing to evaluate");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
227 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
228 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
229 if (parser.m_stmt_list->length () == 1
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
230 && (stmt = parser.m_stmt_list->front ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
231 && stmt->is_expression ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
232 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
233 tree_expression *expr = stmt->expression ();
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
234 if (expr->is_assignment_expression ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
235 error ("dbstop: condition cannot be an assignment. "
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
236 "Did you mean '=='?");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
237 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
238 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
239 error ("dbstop: condition must be an expression");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
240 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
241 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
242 }
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
243
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
244 return true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
245 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
246
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
247 enum dbstop_args
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
248 {
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
249 dbstop_in,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
250 dbstop_at,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
251 dbstop_if,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
252 dbstop_none
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
253 };
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
254
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
255 // Parse parameters (args) of dbstop and dbclear commands.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
256 // For dbstop, who=="dbstop"; for dbclear, who=="dbclear".
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
257 // The syntax is: dbstop [[in] symbol] [[at] line [line [...]]] [if condition]
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
258 // where the form of condition depends on whether or not a file or line has
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
259 // been seen.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
260 // Also execute "if [error|warning|interrupt|naninf]" clauses.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
261
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
262 void bp_table::parse_dbfunction_params (const char *who,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
263 const octave_value_list& args,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
264 std::string& symbol_name,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
265 bp_table::intmap& lines,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
266 std::string& cond)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
267 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
268 int nargin = args.length ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
269 int list_idx = 0;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
270 symbol_name = "";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
271 lines = bp_table::intmap ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
272
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
273 if (nargin == 0 || ! args(0).is_string ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
274 print_usage (who);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
275
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
276 // elements already processed
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
277 bool seen_in = false, seen_at = false, seen_if = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
278 int pos = 0;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
279 dbstop_args tok = dbstop_none;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
280 while (pos < nargin)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
281 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
282 // allow "in" and "at" to be implicit
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
283 if (args(pos).is_string ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
284 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
285 std::string arg = args(pos).string_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
286 if (arg == "in")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
287 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
288 tok = dbstop_in;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
289 pos++;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
290 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
291 else if (arg == "at")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
292 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
293 tok = dbstop_at;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
294 pos++;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
295 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
296 else if (arg == "if")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
297 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
298 tok = dbstop_if;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
299 pos++;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
300 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
301 else if (atoi (args(pos).string_value ().c_str ()) > 0)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
302 tok = dbstop_at;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
303 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
304 tok = dbstop_in;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
305 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
306 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
307 tok = dbstop_at;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
308
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
309 if (pos >= nargin)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
310 error ("%s: '%s' missing argument", who,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
311 (tok == dbstop_in
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
312 ? "in" : (tok == dbstop_at ? "at" : "if")));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
313
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
314 // process the actual arguments
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
315 switch (tok)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
316 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
317 case dbstop_in:
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
318 symbol_name = args(pos).string_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
319 if (seen_in)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
320 error ("%s: Too many function names specified -- %s",
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
321 who, symbol_name.c_str ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
322 else if (seen_at || seen_if)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
323 error ("%s: function name must come before line number and 'if'",
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
324 who);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
325 seen_in = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
326 pos++;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
327 break;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
328
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
329 case dbstop_at:
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
330 if (seen_at)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
331 error ("%s: Only one 'at' clause is allowed -- %s",
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
332 who, args(pos).string_value ().c_str ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
333 else if (seen_if)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
334 error ("%s: line number must come before 'if' clause\n");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
335 seen_at = true;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
336
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
337 if (! seen_in)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
338 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
339 // It was a line number. Get function name from debugger.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
340 if (Vdebugging)
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25347
diff changeset
341 symbol_name = m_evaluator.get_user_code ()->profiler_name ();
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
342 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
343 error ("%s: function name must come before line number "
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
344 "and 'if'", who);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
345 seen_in = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
346 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
347 else if (seen_if)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
348 error ("%s: line number must come before 'if' clause\n");
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
349
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
350 // Read a list of line numbers (or arrays thereof)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
351 for ( ; pos < nargin; pos++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
352 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
353 if (args(pos).is_string ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
354 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
355 int line = atoi (args(pos).string_value ().c_str ());
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
356
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
357 if (line > 0)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
358 lines[list_idx++] = line;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
359 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
360 break; // may be "if"
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
361 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
362 else if (args(pos).isnumeric ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
363 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
364 const NDArray arg = args(pos).array_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
365
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
366 for (octave_idx_type j = 0; j < arg.numel (); j++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
367 lines[list_idx++] = static_cast<int> (arg.elem (j));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
368 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
369 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
370 error ("%s: Invalid argument type %s",
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
371 args(pos).type_name ().c_str ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
372 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
373 break;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
374
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
375 case dbstop_if:
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
376 if (seen_in) // conditional breakpoint
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
377 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
378 cond = ""; // remaining arguments form condition
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
379 for (; pos < nargin; pos++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
380 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
381 if (args(pos).is_string ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
382 cond += ' ' + args(pos).string_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
383 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
384 error ("%s: arguments to 'if' must all be strings", who);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
385 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
386
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
387 cond = cond.substr (1); // omit initial space
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
388 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
389 else // stop on event (error, warning, interrupt, NaN/inf)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
390 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
391 std::string condition = args(pos).string_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
392 int on_off = ! strcmp(who, "dbstop");
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
393
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
394 // list of error/warning IDs to update
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
395 std::set<std::string> *id_list = nullptr;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
396 bool *stop_flag = nullptr; // Vdebug_on_... flag
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
397
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
398 if (condition == "error")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
399 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
400 id_list = &m_errors_that_stop;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
401 stop_flag = &Vdebug_on_error;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
402 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
403 else if (condition == "warning")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
404 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
405 id_list = &m_warnings_that_stop;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
406 stop_flag = &Vdebug_on_warning;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
407 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
408 else if (condition == "caught" && nargin > pos+1
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
409 && args(pos+1).string_value () == "error")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
410 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
411 id_list = &m_caught_that_stop;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
412 stop_flag = &Vdebug_on_caught;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
413 pos++;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
414 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
415 else if (condition == "interrupt")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
416 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
417 Vdebug_on_interrupt = on_off;
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
418 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
419 else if (condition == "naninf")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
420 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
421 #if defined (DBSTOP_NANINF)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
422 Vdebug_on_naninf = on_off;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
423 enable_fpe (on_off);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
424 #else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
425 warning ("%s: condition '%s' not yet supported",
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
426 who, condition.c_str ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
427 #endif
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
428 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
429 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
430 error ("%s: invalid condition %s",
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
431 who, condition.c_str ());
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
432
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
433 // process ID list for "dbstop if error <error_ID>" etc
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
434 if (id_list)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
435 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
436 pos++;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
437 if (pos < nargin) // only affect a single error ID
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
438 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
439 if (! args(pos).is_string () || nargin > pos+1)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
440 error ("%s: ID must be a single string", who);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
441 else if (on_off == 1)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
442 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
443 id_list->insert (args(pos).string_value ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
444 *stop_flag = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
445 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
446 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
447 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
448 id_list->erase (args(pos).string_value ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
449 if (id_list->empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
450 *stop_flag = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
451 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
452 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
453 else // unqualified. Turn all on or off
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
454 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
455 id_list->clear ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
456 *stop_flag = on_off;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
457 if (stop_flag == &Vdebug_on_error)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
458 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
459 // Matlab stops on both.
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
460 Vdebug_on_interrupt = on_off;
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
461 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
462 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
463 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
464
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
465 pos = nargin;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
466 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
467 break;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
468
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
469 default: // dbstop_none should never occur
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
470 break;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
471 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
472 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
473 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
474
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
475 /*
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
476 %!test
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
477 %! dbclear all; # Clear out breakpoints before test
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
478 %! dbstop help;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
479 %! dbstop in ls;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
480 %! dbstop help at 100;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
481 %! dbstop in ls 100;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
482 %! dbstop help 201 if a==5;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
483 %! dbstop if error Octave:undefined-function;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
484 %! s = dbstatus;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
485 %! dbclear all;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
486 %! assert ({s.bkpt(:).name}, {"help", "help", "help>do_contents", "ls", "ls"});
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
487 %! assert ([s.bkpt(:).line], [48, 100, 201, 58, 100]);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
488 %! assert (s.errs, {"Octave:undefined-function"});
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
489 */
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
490
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
491 // Return the sub/nested/main function of MAIN_FCN that contains
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
492 // line number LINENO of the source file.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
493 // If END_LINE != 0, *END_LINE is set to last line of the returned function.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
494
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
495 static octave_user_code * find_fcn_by_line (octave_user_code *main_fcn,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
496 int lineno, int *end_line = nullptr)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
497 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
498 octave_user_code *retval = nullptr;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
499 octave_user_code *next_fcn = nullptr; // 1st function starting after lineno
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
500
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
501 // Find innermost nested (or parent) function containing lineno.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
502 int earliest_end = std::numeric_limits<int>::max ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
503
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
504 std::map<std::string, octave_value> subfcns = main_fcn->subfunctions ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
505 for (const auto& str_val_p : subfcns)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
506 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
507 if (str_val_p.second.is_user_function ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
508 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
509 auto *dbg_subfcn = str_val_p.second.user_function_value ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
510
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
511 // Check if lineno is within dbg_subfcn.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
512 // FIXME: we could break when beginning_line() > lineno,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
513 // but that makes the code "fragile"
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
514 // if the order of walking subfcns changes,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
515 // for a minor speed improvement in non-critical code.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
516 if (dbg_subfcn->ending_line () < earliest_end
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
517 && dbg_subfcn->ending_line () >= lineno
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
518 && dbg_subfcn->beginning_line () <= lineno)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
519 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
520 earliest_end = dbg_subfcn->ending_line ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
521 retval = find_fcn_by_line (dbg_subfcn, lineno, &earliest_end);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
522 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
523
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
524 // Find the first fcn starting after lineno.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
525 // This is used if line is not inside any function.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
526 if (dbg_subfcn->beginning_line () >= lineno && ! next_fcn)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
527 next_fcn = dbg_subfcn;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
528 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
529 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
530
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
531 // The breakpoint is either in the subfunction found above,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
532 // or in the main function, which we check now.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
533 if (main_fcn->is_user_function ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
534 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
535 int e = dynamic_cast<octave_user_function *> (main_fcn)->ending_line ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
536 if (e >= lineno && e < earliest_end)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
537 retval = main_fcn;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
538
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
539 if (! retval)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
540 retval = next_fcn;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
541 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
542 else // main_fcn is a script.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
543 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
544 if (! retval)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
545 retval = main_fcn;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
546 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
547
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
548 if (end_line && earliest_end < *end_line)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
549 *end_line = earliest_end;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
550
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
551 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
552 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
553
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
554 // Given file name fname, find the subfunction at line and create
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
555 // a breakpoint there. Put the system into debug_mode.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
556 bp_table::intmap bp_table::add_breakpoint (const std::string& fname,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
557 const bp_table::intmap& line,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
558 const std::string& condition)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
559 {
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25347
diff changeset
560 octave_user_code *main_fcn = m_evaluator.get_user_code (fname);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
561
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
562 if (! main_fcn)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
563 error ("add_breakpoint: unable to find function '%s'\n", fname.c_str ());
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
564
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
565 condition_valid (condition); // Throw error if condition not valid.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
566
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
567 intmap retval;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
568
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
569 octave_idx_type len = line.size ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
570
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
571 for (int i = 0; i < len; i++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
572 {
25342
416856765a55 be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
573 const_intmap_iterator m = line.find (i);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
574
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
575 if (m != line.end ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
576 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
577 int lineno = m->second;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
578
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
579 octave_user_code *dbg_fcn = find_fcn_by_line (main_fcn, lineno);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
580
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
581 // We've found the right (sub)function. Now insert the breakpoint.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
582 // We insert all breakpoints.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
583 // If multiple are in the same function, we insert multiple times.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
584 intmap ret_one;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
585 if (dbg_fcn
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
586 && add_breakpoint_1 (dbg_fcn, fname, line, condition, ret_one))
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
587 retval.insert (std::pair<int,int> (i, ret_one.find (i)->second));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
588 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
589 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
590
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25360
diff changeset
591 m_evaluator.debug_mode (bp_table::have_breakpoints () || Vdebugging);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
592
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
593 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
594 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
595
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
596 int bp_table::remove_breakpoint_1 (octave_user_code *fcn,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
597 const std::string& fname,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
598 const bp_table::intmap& line)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
599 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
600 int retval = 0;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
601
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
602 std::string file = fcn->fcn_file_name ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
603
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
604 tree_statement_list *cmds = fcn->body ();
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
605
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
606 // FIXME: move the operation on cmds to the tree_statement_list class?
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
607
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
608 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
609 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
610 octave_value_list results = cmds->list_breakpoints ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
611
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
612 if (results.length () > 0)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
613 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
614 octave_idx_type len = line.size ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
615
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
616 for (int i = 0; i < len; i++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
617 {
25342
416856765a55 be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
618 const_intmap_iterator p = line.find (i);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
619
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
620 if (p != line.end ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
621 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
622 int lineno = p->second;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
623
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
624 cmds->delete_breakpoint (lineno);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
625
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
626 if (! file.empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
627 octave_link::update_breakpoint (false, file, lineno);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
628 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
629 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
630
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
631 results = cmds->list_breakpoints ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
632
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25336
diff changeset
633 auto it = m_bp_set.find (fname);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
634 if (results.empty () && it != m_bp_set.end ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
635 m_bp_set.erase (it);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
636 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
637
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
638 retval = results.length ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
639 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
640
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
641 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
642 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
643
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
644 int bp_table::remove_breakpoint (const std::string& fname,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
645 const bp_table::intmap& line)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
646 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
647 int retval = 0;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
648
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
649 octave_idx_type len = line.size ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
650
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
651 if (len == 0)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
652 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
653 intmap results = remove_all_breakpoints_in_file (fname);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
654 retval = results.size ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
655 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
656 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
657 {
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25347
diff changeset
658 octave_user_code *dbg_fcn = m_evaluator.get_user_code (fname);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
659
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
660 if (! dbg_fcn)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
661 error ("remove_breakpoint: unable to find function %s\n",
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
662 fname.c_str ());
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
663
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
664 retval = remove_breakpoint_1 (dbg_fcn, fname, line);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
665
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
666 // Search subfunctions in the order they appear in the file.
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
667
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
668 const std::list<std::string> subfcn_names
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
669 = dbg_fcn->subfunction_names ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
670
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
671 std::map<std::string, octave_value> subfcns
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
672 = dbg_fcn->subfunctions ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
673
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
674 for (const auto& subf_nm : subfcn_names)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
675 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
676 const auto q = subfcns.find (subf_nm);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
677
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
678 if (q != subfcns.end ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
679 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
680 octave_user_code *dbg_subfcn = q->second.user_code_value ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
681
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
682 retval += remove_breakpoint_1 (dbg_subfcn, fname, line);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
683 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
684 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
685 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
686
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25360
diff changeset
687 m_evaluator.debug_mode (bp_table::have_breakpoints () || Vdebugging);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
688
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
689 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
690 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
691
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
692 // Remove all breakpoints from a file, including those in subfunctions.
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
693
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
694 bp_table::intmap
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
695 bp_table::remove_all_breakpoints_in_file (const std::string& fname,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
696 bool silent)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
697 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
698 intmap retval;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
699
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25347
diff changeset
700 octave_user_code *dbg_fcn = m_evaluator.get_user_code (fname);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
701
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
702 if (dbg_fcn)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
703 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
704 std::string file = dbg_fcn->fcn_file_name ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
705
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
706 tree_statement_list *cmds = dbg_fcn->body ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
707
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
708 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
709 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
710 retval = cmds->remove_all_breakpoints (file);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
711
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25336
diff changeset
712 auto it = m_bp_set.find (fname);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
713 if (it != m_bp_set.end ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
714 m_bp_set.erase (it);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
715 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
716 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
717 else if (! silent)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
718 error ("remove_all_breakpoint_in_file: "
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
719 "unable to find function %s\n", fname.c_str ());
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
720
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25360
diff changeset
721 m_evaluator.debug_mode (bp_table::have_breakpoints () || Vdebugging);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
722
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
723 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
724 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
725
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
726 void bp_table::remove_all_breakpoints (void)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
727 {
25342
416856765a55 be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
728 // Odd loop structure required because delete will invalidate
416856765a55 be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
729 // m_bp_set iterators.
25343
4d7790d9793f use cbegin, crbegin, cend, and crend and auto decls where possible
John W. Eaton <jwe@octave.org>
parents: 25342
diff changeset
730 for (auto it = m_bp_set.cbegin (), it_next = it;
4d7790d9793f use cbegin, crbegin, cend, and crend and auto decls where possible
John W. Eaton <jwe@octave.org>
parents: 25342
diff changeset
731 it != m_bp_set.cend ();
25342
416856765a55 be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
732 it = it_next)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
733 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
734 ++it_next;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
735 remove_all_breakpoints_in_file (*it);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
736 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
737
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25360
diff changeset
738 m_evaluator.debug_mode (bp_table::have_breakpoints () || Vdebugging);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
739 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
740
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
741 std::string find_bkpt_list (octave_value_list slist, std::string match)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
742 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
743 std::string retval;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
744
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
745 for (int i = 0; i < slist.length (); i++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
746 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
747 if (slist(i).string_value () == match)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
748 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
749 retval = slist(i).string_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
750 break;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
751 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
752 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
753
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
754 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
755 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
756
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
757 bp_table::fname_bp_map
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
758 bp_table::get_breakpoint_list (const octave_value_list& fname_list)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
759 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
760 fname_bp_map retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
761
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
762 // make copy since changes may invalidate iters of m_bp_set.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
763 std::set<std::string> tmp_bp_set = m_bp_set;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
764
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
765 for (auto& bp_fname : tmp_bp_set)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
766 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
767 if (fname_list.empty ()
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
768 || find_bkpt_list (fname_list, bp_fname) != "")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
769 {
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25347
diff changeset
770 octave_user_code *dbg_fcn = m_evaluator.get_user_code (bp_fname);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
771
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
772 if (dbg_fcn)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
773 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
774 tree_statement_list *cmds = dbg_fcn->body ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
775
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
776 // FIXME: move the operation on cmds to the
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
777 // tree_statement_list class?
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
778 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
779 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
780 std::list<bp_type> bkpts = cmds->breakpoints_and_conds ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
781
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
782 if (! bkpts.empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
783 retval[bp_fname] = bkpts;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
784 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
785
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
786 // look for breakpoints in subfunctions
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
787 const std::list<std::string> subf_nm
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
788 = dbg_fcn->subfunction_names ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
789
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
790 std::map<std::string, octave_value> subfcns
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
791 = dbg_fcn->subfunctions ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
792
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
793 for (const auto& subfcn_nm : subf_nm)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
794 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
795 const auto q = subfcns.find (subfcn_nm);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
796
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
797 if (q != subfcns.end ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
798 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
799 octave_user_code *dbg_subfcn
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
800 = q->second.user_code_value ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
801
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
802 cmds = dbg_subfcn->body ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
803 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
804 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
805 std::list<bp_type> bkpts
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
806 = cmds->breakpoints_and_conds ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
807
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
808 if (! bkpts.empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
809 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
810 std::string key
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
811 = bp_fname + '>' + dbg_subfcn->name ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
812
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
813 retval[key] = bkpts;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
814 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
815 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
816 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
817 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
818 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
819 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
820 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
821
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
822 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
823 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
824
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
825 // Report the status of "dbstop if error ..." and "dbstop if warning ..."
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
826 // If to_screen is true, the output goes to octave_stdout; otherwise it is
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
827 // returned.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
828 // If dbstop if error is true but no explicit IDs are specified, the return
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
829 // value will have an empty field called "errs". If IDs are specified, the
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
830 // "errs" field will have a row per ID. If dbstop if error is false, there
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
831 // is no "errs" field. The "warn" field is set similarly by dbstop if warning
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
832
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
833 octave_map bp_table::stop_on_err_warn_status (bool to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
834 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
835 octave_map retval;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
836
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
837 // print dbstop if error information
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
838 if (Vdebug_on_error)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
839 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
840 if (m_errors_that_stop.empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
841 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
842 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
843 octave_stdout << "stop if error\n";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
844 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
845 retval.assign ("errs", octave_value(""));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
846 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
847 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
848 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
849 Cell errs (dim_vector (bp_table::m_errors_that_stop.size (), 1));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
850 int i = 0;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
851
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
852 for (const auto& e : m_errors_that_stop)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
853 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
854 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
855 octave_stdout << "stop if error " << e << "\n";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
856 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
857 errs(i++) = e;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
858 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
859 if (! to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
860 retval.assign ("errs", octave_value (errs));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
861 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
862 }
24286
6bfb96ab73cb * bp-table.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 24279
diff changeset
863
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
864 // print dbstop if caught error information
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
865 if (Vdebug_on_caught)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
866 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
867 if (m_caught_that_stop.empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
868 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
869 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
870 octave_stdout << "stop if caught error\n";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
871 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
872 retval.assign ("caught", octave_value(""));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
873 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
874 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
875 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
876 Cell errs (dim_vector (m_caught_that_stop.size (), 1));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
877 int i = 0;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
878
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
879 for (const auto& e : m_caught_that_stop)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
880 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
881 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
882 octave_stdout << "stop if caught error " << e << "\n";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
883 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
884 errs(i++) = e;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
885 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
886 if (! to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
887 retval.assign ("caught", octave_value (errs));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
888 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
889 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
890
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
891 // print dbstop if warning information
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
892 if (Vdebug_on_warning)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
893 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
894 if (m_warnings_that_stop.empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
895 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
896 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
897 octave_stdout << "stop if warning\n";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
898 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
899 retval.assign ("warn", octave_value(""));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
900 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
901 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
902 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
903 Cell warn (dim_vector (m_warnings_that_stop.size (), 1));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
904 int i = 0;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
905
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
906 for (const auto& w : m_warnings_that_stop)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
907 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
908 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
909 octave_stdout << "stop if warning " << w << "\n";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
910 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
911 warn(i++) = w;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
912 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
913 if (! to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
914 retval.assign ("warn", octave_value (warn));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
915 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
916 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
917
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
918 // print dbstop if interrupt information
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
919 if (Vdebug_on_interrupt)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
920 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
921 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
922 octave_stdout << "stop if interrupt\n";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
923 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
924 retval.assign ("intr", octave_value ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
925 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
926
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
927 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
928 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
929
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
930 octave_user_code *
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
931 get_user_code (const std::string& fname)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
932 {
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25347
diff changeset
933 tree_evaluator& tw = __get_evaluator__ ("get_user_code");
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
934
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25347
diff changeset
935 return tw.get_user_code (fname);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
936 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
937 }