Mercurial > octave
annotate libinterp/parse-tree/bp-table.cc @ 23807:336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Better performance when string constructor isn't required.
* Figure.cc, __init_qt__.cc, files-dock-widget.cc, file-editor-tab.cc,
file-editor.cc, octave-qscintilla.cc, main-window.cc, octave-dock-widget.cc,
octave-qt-link.cc, parser.cc, webinfo.cc, resource-manager.cc,
settings-dialog.cc, workspace-view.cc, __magick_read__.cc, balance.cc,
debug.cc, dynamic-ld.cc, ft-text-renderer.cc, gl-render.cc, gl2ps-print.cc,
graphics.cc, hook-fcn.h, input.cc, load-path.cc, load-save.cc, ls-hdf5.cc,
oct-hist.cc, oct-stream.cc, pager.cc, pr-output.cc, qz.cc, symtab.cc, symtab.h,
tril.cc, __delaunayn__.cc, __init_fltk__.cc, __voronoi__.cc, audioread.cc,
ccolamd.cc, colamd.cc, convhulln.cc, ov-base-int.cc, ov-base-mat.cc,
ov-base-scalar.cc, ov-base.cc, ov-bool-mat.cc, ov-cell.cc, ov-class.cc,
ov-classdef.cc, ov-colon.cc, ov-complex.cc, ov-cx-mat.cc, ov-fcn-handle.cc,
ov-fcn-inline.cc, ov-fcn.h, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-java.cc,
ov-oncleanup.cc, ov-range.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-str-mat.cc,
ov-struct.cc, ov-usr-fcn.cc, ov.cc, octave.cc, bp-table.cc, jit-ir.cc,
jit-ir.h, jit-typeinfo.cc, pt-funcall.cc, pt-idx.cc, pt-pr-code.cc, pt.h,
Array.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc,
Range.cc, boolSparse.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc,
dRowVector.cc, dSparse.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc,
fCRowVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc,
idx-vector.cc, intNDArray.cc, CollocWt.cc, DASPK.cc, DASRT.cc, DASSL.cc,
LSODE.cc, oct-time.cc, cmd-hist.cc, kpse.cc, lo-array-errwarn.cc, lo-regexp.cc,
lo-utils.cc, str-vec.cc, url-transfer.cc, main-cli.cc, main-gui.cc,
mkoctfile.in.cc:
Replace 1-character string literals "c" with the character literal 'c'.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 28 Jul 2017 15:40:00 -0700 |
parents | 980f39c3ab90 |
children | 061a343089be |
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 |
23221
debe0c7dcefc
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23170
diff
changeset
|
3 Copyright (C) 2001-2017 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 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 Octave is free software; you can redistribute it and/or modify it |
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 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 the Free Software Foundation; either version 3 of the License, or |
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 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 <http://www.gnu.org/licenses/>. |
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 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #include <fstream> |
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> |
23170
b3f2645803fe
Add headers needed on MacOS to avoid "implicit instantiation of undefined
Mike Miller <mtmiller@octave.org>
parents:
23158
diff
changeset
|
34 #include <sstream> |
b3f2645803fe
Add headers needed on MacOS to avoid "implicit instantiation of undefined
Mike Miller <mtmiller@octave.org>
parents:
23158
diff
changeset
|
35 #include <iostream> |
23137
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 "file-ops.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "singleton-cleanup.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 #include "bp-table.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 #include "defun-int.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 #include "call-stack.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 #include "error.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 #include "input.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
45 #include "interpreter-private.h" |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 #include "oct-map.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 #include "octave-link.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 #include "ov-usr-fcn.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 #include "ov.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 #include "ovl.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 #include "pager.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 #include "parse.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 #include "pt-eval.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 #include "pt-exp.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 #include "pt-stmt.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 #include "sighandlers.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 #include "symtab.h" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 // Initialize the singleton object |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
60 bp_table *bp_table::instance = nullptr; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 std::set<std::string> bp_table::errors_that_stop; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 std::set<std::string> bp_table::caught_that_stop; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 std::set<std::string> bp_table::warnings_that_stop; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 // Return a pointer to the user-defined function FNAME. If FNAME is |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 // empty, search backward for the first user-defined function in the |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 // current call stack. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 octave_user_code * |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 get_user_code (const std::string& fname) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
73 octave_user_code *dbg_fcn = nullptr; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 if (fname.empty ()) |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
76 { |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
77 octave::call_stack& cs = octave::__get_call_stack__ ("get_user_code"); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
78 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
79 dbg_fcn = cs.debug_user_code (); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
80 } |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 std::string name = fname; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 if (octave::sys::file_ops::dir_sep_char () != '/' && name[0] == '@') |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 int len = name.length () - 1; // -1: can't have trailing '/' |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 for (int i = 2; i < len; i++) // 2: can't have @/method |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 if (name[i] == '/') |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 name[i] = octave::sys::file_ops::dir_sep_char (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 size_t name_len = name.length (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 if (! name.empty () && name_len > 2 && name.substr (name_len-2) == ".m") |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 name = name.substr (0, name_len-2); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
98 octave::symbol_table& symtab = octave::__get_symbol_table__ ("get_user_code"); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23586
diff
changeset
|
99 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23586
diff
changeset
|
100 octave_value fcn = symtab.find_function (name); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 if (fcn.is_defined () && fcn.is_user_code ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 dbg_fcn = fcn.user_code_value (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 return dbg_fcn; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 // Return true if there is a valid breakpoint table, false otherwise. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 // If no table exists, one is created; false is only returned if this fails. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 bool |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
112 bp_table::instance_ok (void) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
114 if (! instance) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 instance = new bp_table (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 if (instance) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 singleton_cleanup_list::add (cleanup_instance); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
121 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 if (! instance) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 error ("unable to create breakpoint table!"); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
124 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 return true; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 // Clear all reasons to stop, other than breakpoints |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 void |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 bp_table::dbclear_all_signals (void) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 Vdebug_on_error = false; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 bp_table::errors_that_stop.clear (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 Vdebug_on_caught = false; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 bp_table::caught_that_stop.clear (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 Vdebug_on_warning = false; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 bp_table::warnings_that_stop.clear (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 octave::Vdebug_on_interrupt = false; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
142 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
144 // Process the "warn", "errs", "caught" and "intr" fields for a call of |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
145 // "dbstop (p)". |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 void |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
147 bp_table::dbstop_process_map_args (const octave_map& mv) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
148 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 // process errs |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 // why so many levels of indirection needed? |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 bool fail = false; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
152 Cell U = mv.contents ("errs"); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
153 if (U.numel () != 1) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 fail = (U.numel () > 1); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0)); |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
158 if (W.isempty () || W(0).isempty ()) |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 Vdebug_on_error = 1; // like "dbstop if error" with no identifier |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23553
diff
changeset
|
160 else if (! W(0).iscell ()) |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 fail = true; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
162 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
163 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 Cell V = W(0).cell_value (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 for (int i = 0; i < V.numel (); i++) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
166 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 errors_that_stop.insert (V(i).string_value ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 Vdebug_on_error = 1; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
170 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 if (fail) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
173 error ("dbstop: invalid 'errs' field"); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
174 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
175 // process caught |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
176 // why so many levels of indirection needed? |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 fail = false; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 U = mv.contents ("caught"); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
179 if (U.numel () != 1) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 fail = (U.numel () > 1); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
181 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
182 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0)); |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
184 if (W.isempty () || W(0).isempty ()) |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
185 Vdebug_on_caught = 1; // like "dbstop if caught error" with no ID |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23553
diff
changeset
|
186 else if (! W(0).iscell ()) |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
187 fail = true; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
188 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 Cell V = W(0).cell_value (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
191 for (int i = 0; i < V.numel (); i++) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
193 caught_that_stop.insert (V(i).string_value ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 Vdebug_on_caught = 1; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
195 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
197 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
198 if (fail) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 error ("dbstop: invalid 'caught' field"); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
200 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 // process warn |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
202 // why so many levels of indirection needed? |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 fail = false; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
204 U = mv.contents ("warn"); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 if (U.numel () != 1) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 fail = (U.numel () > 1); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
207 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0)); |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
210 if (W.isempty () || W(0).isempty ()) |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 Vdebug_on_warning = 1; // like "dbstop if warning" with no identifier |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23553
diff
changeset
|
212 else if (! W(0).iscell ()) |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 fail = true; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
214 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
215 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 Cell V = W(0).cell_value (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 for (int i = 0; i < V.numel (); i++) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 warnings_that_stop.insert (V(i).string_value ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 Vdebug_on_warning = 1; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
221 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
224 if (fail) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
225 error ("dbstop: invalid 'warn' field"); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
226 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
227 // process interrupt |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
228 if (mv.isfield ("intr")) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
229 octave::Vdebug_on_interrupt = 1; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
230 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
231 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 // Insert a breakpoint in function fcn at line within file fname, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
233 // to stop only when condition is true. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 // Record in bp_set that fname contains a breakpoint. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
235 bool |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
236 bp_table::do_add_breakpoint_1 (octave_user_code *fcn, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 const std::string& fname, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
238 const bp_table::intmap& line, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
239 const std::string& condition, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 bp_table::intmap& retval) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
241 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 bool found = false; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 octave::tree_statement_list *cmds = fcn->body (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 std::string file = fcn->fcn_file_name (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
248 if (cmds) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
249 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 retval = cmds->add_breakpoint (file, line, condition); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
251 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
252 for (auto& idx_line_p : retval) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
253 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
254 if (idx_line_p.second != 0) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 // Normalize to store only the file name. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
257 // Otherwise, there can be an entry for both file>subfunction and |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
258 // file, which causes a crash on dbclear all |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 const char *s = strchr (fname.c_str (), Vfilemarker); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
260 if (s) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 bp_set.insert (fname.substr (0, s - fname.c_str ())); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
263 bp_set.insert (fname); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
264 found = true; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
265 break; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
266 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
267 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
268 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
269 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
270 return found; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
271 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
272 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
273 // Cursory check that cond is a valid condition to use for a breakpoint. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
274 // Currently allows conditions with side-effects, like 'y+=10' and 'y++'; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
275 // it is odd that the former is not flagged by "is_assignment_expression". |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
276 // Throws an exception if not valid. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
277 bool |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
278 bp_table::condition_valid (const std::string& cond) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
279 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
280 if (cond.length () > 0) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 octave::parser parser (cond + " ;"); // ; to reject partial expr like "y==" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
283 parser.reset (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
284 int parse_status = parser.run (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
285 if (parse_status) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
286 error ("dbstop: Cannot parse condition '%s'", cond.c_str ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
287 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
288 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
289 octave::tree_statement *stmt = nullptr; |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
290 if (! parser.m_stmt_list) |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
291 error ("dbstop: " |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
292 "condition is not empty, but has nothing to evaluate"); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
293 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
294 { |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
295 if (parser.m_stmt_list->length () == 1 |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
296 && (stmt = parser.m_stmt_list->front ()) |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
297 && stmt->is_expression ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
298 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
299 octave::tree_expression *expr = stmt->expression (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
300 if (expr->is_assignment_expression ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
301 error ("dbstop: condition cannot be an assignment. " |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
302 "Did you mean '=='?"); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
303 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
305 error ("dbstop: condition must be an expression"); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
306 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
307 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
308 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
309 return true; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
310 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
311 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
312 enum |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
313 dbstop_args {dbstop_in, dbstop_at, dbstop_if, dbstop_none}; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
314 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
315 // Parse parameters (args) of dbstop and dbclear commands. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
316 // For dbstop, who=="dbstop"; for dbclear, who=="dbclear". |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
317 // The syntax is: dbstop [[in] symbol] [[at] line [line [...]]] [if condition] |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
318 // where the form of condition depends on whether or not a file or line has |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
319 // been seen. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
320 // Also execute "if [error|warning|interrupt|naninf]" clauses. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
321 void |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
322 bp_table::parse_dbfunction_params (const char *who, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
323 const octave_value_list& args, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
324 std::string& symbol_name, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
325 bp_table::intmap& lines, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
326 std::string& cond) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
328 int nargin = args.length (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
329 int list_idx = 0; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
330 symbol_name = ""; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
331 lines = bp_table::intmap (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
332 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
333 if (nargin == 0 || ! args(0).is_string ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
334 print_usage (who); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
335 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
336 // elements already processed |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
337 bool seen_in = false, seen_at = false, seen_if = false; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
338 int pos = 0; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
339 dbstop_args tok = dbstop_none; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
340 while (pos < nargin) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
341 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
342 // allow "in" and "at" to be implicit |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
343 if (args(pos).is_string ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
344 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
345 std::string arg = args(pos).string_value (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
346 if (arg == "in") |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
347 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
348 tok = dbstop_in; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
349 pos++; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
350 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
351 else if (arg == "at") |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
352 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
353 tok = dbstop_at; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
354 pos++; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
355 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
356 else if (arg == "if") |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
357 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
358 tok = dbstop_if; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
359 pos++; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
360 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
361 else if (atoi (args(pos).string_value ().c_str ()) > 0) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
362 tok = dbstop_at; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
363 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
364 tok = dbstop_in; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
365 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
366 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
367 tok = dbstop_at; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
368 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
369 if (pos >= nargin) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
370 error ("%s: '%s' missing argument", who, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
371 (tok == dbstop_in |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
372 ? "in" : (tok == dbstop_at ? "at" : "if"))); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
373 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
374 // process the actual arguments |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
375 switch (tok) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
376 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
377 case dbstop_in: |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
378 symbol_name = args(pos).string_value (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
379 if (seen_in) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
380 error ("%s: Too many function names specified -- %s", |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
381 who, symbol_name.c_str ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
382 else if (seen_at || seen_if) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
383 error ("%s: function name must come before line number and 'if'", |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
384 who); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
385 seen_in = true; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
386 pos++; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
387 break; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
388 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
389 case dbstop_at: |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
390 if (seen_at) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
391 error ("%s: Only one 'at' clause is allowed -- %s", |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
392 who, args(pos).string_value ().c_str ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
393 else if (seen_if) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
394 error ("%s: line number must come before 'if' clause\n"); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
395 seen_at = true; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
396 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
397 if (! seen_in) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
398 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
399 // It was a line number. Get function name from debugger. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
400 if (Vdebugging) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
401 symbol_name = get_user_code ()->profiler_name (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
402 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
403 error ("%s: function name must come before line number " |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
404 "and 'if'", who); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
405 seen_in = true; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
406 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
407 else if (seen_if) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
408 error ("%s: line number must come before 'if' clause\n"); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
409 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
410 // Read a list of line numbers (or arrays thereof) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
411 for ( ; pos < nargin; pos++) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
412 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
413 if (args(pos).is_string ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
414 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
415 int line = atoi (args(pos).string_value ().c_str ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
416 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
417 if (line > 0) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
418 lines[list_idx++] = line; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
419 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
420 break; // may be "if" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
421 } |
23586
f6c5db0a02e7
maint: Deprecate is_numeric_type and replace with isnumeric.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
422 else if (args(pos).isnumeric ()) |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
423 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
424 const NDArray arg = args(pos).array_value (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
425 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
426 for (octave_idx_type j = 0; j < arg.numel (); j++) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
427 lines[list_idx++] = static_cast<int> (arg.elem (j)); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
428 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
429 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
430 error ("%s: Invalid argument type %s", |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
431 args(pos).type_name ().c_str ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
432 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
433 break; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
434 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
435 case dbstop_if: |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
436 if (seen_in) // conditional breakpoint |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
437 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
438 cond = ""; // remaining arguments form condition |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
439 for (; pos < nargin; pos++) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
440 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
441 if (args(pos).is_string ()) |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
442 cond = cond + ' ' + args(pos).string_value (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
443 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
444 error ("%s: arguments to 'if' must all be strings", who); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
445 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
446 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
447 cond = cond.substr (1); // omit initial space |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
448 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
449 else // stop on event (error, warning, interrupt, NaN/inf) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
450 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
451 std::string condition = args(pos).string_value (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
452 int on_off = ! strcmp(who, "dbstop"); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
453 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
454 // list of error/warning IDs to update |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
455 std::set<std::string> *id_list = nullptr; |
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
456 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
|
457 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
458 if (condition == "error") |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
459 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
460 id_list = &bp_table::errors_that_stop; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
461 stop_flag = &Vdebug_on_error; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
462 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
463 else if (condition == "warning") |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
464 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
465 id_list = &bp_table::warnings_that_stop; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
466 stop_flag = &Vdebug_on_warning; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
467 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
468 else if (condition == "caught" && nargin > pos+1 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
469 && args(pos+1).string_value () == "error") |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
470 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
471 id_list = &bp_table::caught_that_stop; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
472 stop_flag = &Vdebug_on_caught; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
473 pos++; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
474 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
475 else if (condition == "interrupt") |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
476 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
477 octave::Vdebug_on_interrupt = on_off; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
478 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
479 else if (condition == "naninf") |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
480 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
481 #if defined (DBSTOP_NANINF) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
482 Vdebug_on_naninf = on_off; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
483 enable_fpe (on_off); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
484 #else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
485 warning ("%s: condition '%s' not yet supported", |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
486 who, condition.c_str ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
487 #endif |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
488 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
489 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
490 error ("%s: invalid condition %s", |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
491 who, condition.c_str ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
492 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
493 // process ID list for "dbstop if error <error_ID>" etc |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
494 if (id_list != nullptr) |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
495 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
496 pos++; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
497 if (pos < nargin) // only affect a single error ID |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
498 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
499 if (! args(pos).is_string () || nargin > pos+1) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
500 error ("%s: ID must be a single string", who); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
501 else if (on_off == 1) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
502 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
503 id_list->insert (args(pos).string_value ()); |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
504 *stop_flag = true; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
505 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
506 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
507 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
508 id_list->erase (args(pos).string_value ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
509 if (id_list->empty ()) |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
510 *stop_flag = false; |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
511 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
512 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
513 else // unqualified. Turn all on or off |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
514 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
515 id_list->clear (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
516 *stop_flag = on_off; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
517 if (stop_flag == &Vdebug_on_error) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
518 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
519 // Matlab stops on both. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
520 octave::Vdebug_on_interrupt = on_off; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
521 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
522 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
523 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
524 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
525 pos = nargin; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
526 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
527 break; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
528 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
529 default: // dbstop_none should never occur |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
530 break; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
531 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
532 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
533 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
534 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
535 /* |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
536 %!test |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
537 %! dbclear all; # Clear out breakpoints before test |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
538 %! dbstop help; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 %! dbstop in ls; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
540 %! dbstop help at 100; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
541 %! dbstop in ls 100; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
542 %! dbstop help 201 if a==5; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
543 %! dbstop if error Octave:undefined-function; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
544 %! s = dbstatus; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
545 %! dbclear all; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
546 %! assert ({s.bkpt(:).name}, {"help", "help", "help>do_contents", "ls", "ls"}); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
547 %! assert ([s.bkpt(:).line], [48, 100, 201, 58, 100]); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
548 %! assert (s.errs, {"Octave:undefined-function"}); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
549 */ |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
550 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
551 // Return the sub/nested/main function of MAIN_FCN that contains |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
552 // line number LINENO of the source file. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
553 // If END_LINE != 0, *END_LINE is set to last line of the returned function. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
554 static octave_user_code* |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
555 find_fcn_by_line (octave_user_code *main_fcn, int lineno, int *end_line = nullptr) |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
556 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
557 octave_user_code *retval = nullptr; |
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23447
diff
changeset
|
558 octave_user_code *next_fcn = nullptr; // 1st function starting after lineno |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
559 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
560 // Find innermost nested (or parent) function containing lineno. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
561 int earliest_end = std::numeric_limits<int>::max (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
562 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
563 std::map<std::string, octave_value> subfcns = main_fcn->subfunctions (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
564 for (const auto& str_val_p : subfcns) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
565 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
566 if (str_val_p.second.is_user_function ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
567 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
568 auto *dbg_subfcn = str_val_p.second.user_function_value (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
569 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
570 // Check if lineno is within dbg_subfcn. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
571 // FIXME: we could break when beginning_line() > lineno, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
572 // but that makes the code "fragile" |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
573 // if the order of walking subfcns changes, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
574 // for a minor speed improvement in non-critical code. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
575 if (dbg_subfcn->ending_line () < earliest_end |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
576 && dbg_subfcn->ending_line () >= lineno |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
577 && dbg_subfcn->beginning_line () <= lineno) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
578 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
579 earliest_end = dbg_subfcn->ending_line (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
580 retval = find_fcn_by_line (dbg_subfcn, lineno, &earliest_end); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
581 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
582 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
583 // Find the first fcn starting after lineno. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
584 // This is used if line is not inside any function. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
585 if (dbg_subfcn->beginning_line () >= lineno && ! next_fcn) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
586 next_fcn = dbg_subfcn; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
587 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
588 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
589 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
590 // The breakpoint is either in the subfunction found above, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
591 // or in the main function, which we check now. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
592 if (main_fcn->is_user_function ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
593 { |
23447
db1fdf4384dd
maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents:
23221
diff
changeset
|
594 int e = dynamic_cast<octave_user_function *> (main_fcn)->ending_line (); |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
595 if (e >= lineno && e < earliest_end) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
596 retval = main_fcn; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
597 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
598 if (! retval) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
599 retval = next_fcn; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
600 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
601 else // main_fcn is a script. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
602 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
603 if (! retval) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
604 retval = main_fcn; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
605 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
606 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23728
diff
changeset
|
607 if (end_line != nullptr && earliest_end < *end_line) |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
608 *end_line = earliest_end; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
609 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
610 return retval; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
611 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
612 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
613 // Given file name fname, find the subfunction at line and create |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
614 // a breakpoint there. Put the system into debug_mode. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
615 bp_table::intmap |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
616 bp_table::do_add_breakpoint (const std::string& fname, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
617 const bp_table::intmap& line, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
618 const std::string& condition) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
619 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
620 octave_user_code *main_fcn = get_user_code (fname); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
621 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
622 if (! main_fcn) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
623 error ("add_breakpoint: unable to find function '%s'\n", fname.c_str ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
624 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
625 condition_valid (condition); // Throw error if condition not valid. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
626 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
627 intmap retval; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
628 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
629 octave_idx_type len = line.size (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
630 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
631 for (int i = 0; i < len; i++) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
632 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
633 const_intmap_iterator m = line.find (i); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
634 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
635 if (m != line.end ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
636 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
637 int lineno = m->second; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
638 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
639 octave_user_code *dbg_fcn = find_fcn_by_line (main_fcn, lineno); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
640 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
641 // We've found the right (sub)function. Now insert the breakpoint. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
642 // We insert all breakpoints. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
643 // If multiple are in the same function, we insert multiple times. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
644 intmap ret_one; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
645 if (dbg_fcn |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
646 && do_add_breakpoint_1 (dbg_fcn, fname, line, condition, ret_one)) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
647 retval.insert (std::pair<int,int> (i, ret_one.find (i)->second)); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
648 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
649 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
650 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
651 octave::tree_evaluator::debug_mode = bp_table::have_breakpoints () |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
652 || Vdebugging; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
653 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
654 return retval; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
655 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
656 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
657 int |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
658 bp_table::do_remove_breakpoint_1 (octave_user_code *fcn, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
659 const std::string& fname, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
660 const bp_table::intmap& line) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
661 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
662 int retval = 0; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
663 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
664 std::string file = fcn->fcn_file_name (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
665 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
666 octave::tree_statement_list *cmds = fcn->body (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
667 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
668 // FIXME: move the operation on cmds to the tree_statement_list class? |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
669 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
670 if (cmds) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
671 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
672 octave_value_list results = cmds->list_breakpoints (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
673 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
674 if (results.length () > 0) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
675 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
676 octave_idx_type len = line.size (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
677 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
678 for (int i = 0; i < len; i++) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
679 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
680 const_intmap_iterator p = line.find (i); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
681 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
682 if (p != line.end ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
683 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
684 int lineno = p->second; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
685 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
686 cmds->delete_breakpoint (lineno); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
687 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
688 if (! file.empty ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
689 octave_link::update_breakpoint (false, file, lineno); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
690 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
691 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
692 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
693 results = cmds->list_breakpoints (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
694 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
695 bp_set_iterator it = bp_set.find (fname); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
696 if (results.empty () && it != bp_set.end ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
697 bp_set.erase (it); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
698 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
699 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
700 retval = results.length (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
701 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
702 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
703 return retval; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
704 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
705 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
706 int |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
707 bp_table::do_remove_breakpoint (const std::string& fname, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
708 const bp_table::intmap& line) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
709 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
710 int retval = 0; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
711 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
712 octave_idx_type len = line.size (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
713 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
714 if (len == 0) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
715 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
716 intmap results = remove_all_breakpoints_in_file (fname); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
717 retval = results.size (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
718 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
719 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
720 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
721 octave_user_code *dbg_fcn = get_user_code (fname); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
722 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
723 if (! dbg_fcn) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
724 error ("remove_breakpoint: unable to find function %s\n", |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
725 fname.c_str ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
726 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
727 retval = do_remove_breakpoint_1 (dbg_fcn, fname, line); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
728 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
729 // Search subfunctions in the order they appear in the file. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
730 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
731 const std::list<std::string> subfcn_names |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
732 = dbg_fcn->subfunction_names (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
733 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
734 std::map<std::string, octave_value> subfcns |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
735 = dbg_fcn->subfunctions (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
736 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
737 for (const auto& subf_nm : subfcn_names) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
738 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
739 const auto q = subfcns.find (subf_nm); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
740 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
741 if (q != subfcns.end ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
742 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
743 octave_user_code *dbg_subfcn = q->second.user_code_value (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
744 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
745 retval += do_remove_breakpoint_1 (dbg_subfcn, fname, line); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
746 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
747 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
748 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
749 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
750 octave::tree_evaluator::debug_mode = bp_table::have_breakpoints () |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
751 || Vdebugging; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
752 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
753 return retval; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
754 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
755 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
756 // Remove all breakpoints from a file, including those in subfunctions |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
757 bp_table::intmap |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
758 bp_table::do_remove_all_breakpoints_in_file (const std::string& fname, |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
759 bool silent) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
760 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
761 intmap retval; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
762 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
763 octave_user_code *dbg_fcn = get_user_code (fname); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
764 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
765 if (dbg_fcn) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
766 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
767 std::string file = dbg_fcn->fcn_file_name (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
768 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
769 octave::tree_statement_list *cmds = dbg_fcn->body (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
770 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
771 if (cmds) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
772 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
773 retval = cmds->remove_all_breakpoints (file); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
774 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
775 bp_set_iterator it = bp_set.find (fname); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
776 if (it != bp_set.end ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
777 bp_set.erase (it); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
778 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
779 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
780 else if (! silent) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
781 error ("remove_all_breakpoint_in_file: " |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
782 "unable to find function %s\n", fname.c_str ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
783 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
784 octave::tree_evaluator::debug_mode = bp_table::have_breakpoints () |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
785 || Vdebugging; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
786 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
787 return retval; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
788 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
789 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
790 void |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
791 bp_table::do_remove_all_breakpoints (void) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
792 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
793 // Odd loop structure required because delete will invalidate bp_set iterators |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
794 for (const_bp_set_iterator it=bp_set.begin (), it_next=it; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
795 it != bp_set.end (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
796 it=it_next) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
797 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
798 ++it_next; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
799 remove_all_breakpoints_in_file (*it); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
800 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
801 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
802 octave::tree_evaluator::debug_mode = bp_table::have_breakpoints () |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
803 || Vdebugging; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
804 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
805 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
806 std::string |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
807 do_find_bkpt_list (octave_value_list slist, std::string match) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
808 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
809 std::string retval; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
810 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
811 for (int i = 0; i < slist.length (); i++) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
812 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
813 if (slist(i).string_value () == match) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
814 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
815 retval = slist(i).string_value (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
816 break; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
817 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
818 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
819 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
820 return retval; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
821 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
822 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
823 bp_table::fname_bp_map |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
824 bp_table::do_get_breakpoint_list (const octave_value_list& fname_list) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
825 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
826 fname_bp_map retval; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
827 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
828 // make copy since changes may invalidate iters of bp_set. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
829 std::set<std::string> tmp_bp_set = bp_set; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
830 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
831 for (auto& bp_fname : tmp_bp_set) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
832 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
833 if (fname_list.empty () |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
834 || do_find_bkpt_list (fname_list, bp_fname) != "") |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
835 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
836 octave_user_code *f = get_user_code (bp_fname); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
837 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
838 if (f) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
839 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
840 octave::tree_statement_list *cmds = f->body (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
841 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
842 // FIXME: move the operation on cmds to the |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
843 // tree_statement_list class? |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
844 if (cmds) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
845 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
846 std::list<bp_type> bkpts = cmds->breakpoints_and_conds (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
847 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
848 if (! bkpts.empty ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
849 retval[bp_fname] = bkpts; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
850 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
851 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
852 // look for breakpoints in subfunctions |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
853 const std::list<std::string> subf_nm = f->subfunction_names (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
854 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
855 std::map<std::string, octave_value> subf = f->subfunctions (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
856 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
857 for (const auto& subfcn_nm : subf_nm) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
858 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
859 const auto q = subf.find (subfcn_nm); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
860 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
861 if (q != subf.end ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
862 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
863 octave_user_code *ff = q->second.user_code_value (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
864 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
865 cmds = ff->body (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
866 if (cmds) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
867 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
868 std::list<bp_type> bkpts |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
869 = cmds->breakpoints_and_conds (); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
870 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
871 if (! bkpts.empty ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
872 retval[bp_fname + Vfilemarker + ff->name ()] = bkpts; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
873 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
874 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
875 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
876 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
877 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
878 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
879 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
880 return retval; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
881 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
882 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
883 // Report the status of "dbstop if error ..." and "dbstop if warning ..." |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
884 // If to_screen is true, the output goes to octave_stdout; otherwise it is |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
885 // returned. |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
886 // If dbstop if error is true but no explicit IDs are specified, the return |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
887 // value will have an empty field called "errs". If IDs are specified, the |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
888 // "errs" field will have a row per ID. If dbstop if error is false, there |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
889 // is no "errs" field. The "warn" field is set similarly by dbstop if warning |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
890 octave_map |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
891 bp_table::stop_on_err_warn_status (bool to_screen) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
892 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
893 octave_map retval; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
894 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
895 // print dbstop if error information |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
896 if (Vdebug_on_error) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
897 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
898 if (errors_that_stop.empty ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
899 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
900 if (to_screen) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
901 octave_stdout << "stop if error\n"; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
902 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
903 retval.assign ("errs", octave_value("")); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
904 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
905 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
906 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
907 Cell errs (dim_vector (bp_table::errors_that_stop.size (), 1)); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
908 int i = 0; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
909 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
910 for (const auto& e : errors_that_stop) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
911 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
912 if (to_screen) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
913 octave_stdout << "stop if error " << e << "\n"; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
914 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
915 errs(i++) = e; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
916 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
917 if (! to_screen) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
918 retval.assign ("errs", octave_value (errs)); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
919 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
920 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
921 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
922 // print dbstop if caught error information |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
923 if (Vdebug_on_caught) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
924 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
925 if (caught_that_stop.empty ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
926 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
927 if (to_screen) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
928 octave_stdout << "stop if caught error\n"; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
929 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
930 retval.assign ("caught", octave_value("")); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
931 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
932 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
933 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
934 Cell errs (dim_vector (caught_that_stop.size (), 1)); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
935 int i = 0; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
936 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
937 for (const auto& e : caught_that_stop) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
938 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
939 if (to_screen) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
940 octave_stdout << "stop if caught error " << e << "\n"; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
941 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
942 errs(i++) = e; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
943 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
944 if (! to_screen) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
945 retval.assign ("caught", octave_value (errs)); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
946 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
947 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
948 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
949 // print dbstop if warning information |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
950 if (Vdebug_on_warning) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
951 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
952 if (warnings_that_stop.empty ()) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
953 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
954 if (to_screen) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
955 octave_stdout << "stop if warning\n"; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
956 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
957 retval.assign ("warn", octave_value("")); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
958 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
959 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
960 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
961 Cell warn (dim_vector (warnings_that_stop.size (), 1)); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
962 int i = 0; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
963 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
964 for (const auto& w : warnings_that_stop) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
965 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
966 if (to_screen) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
967 octave_stdout << "stop if warning " << w << "\n"; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
968 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
969 warn(i++) = w; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
970 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
971 if (! to_screen) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
972 retval.assign ("warn", octave_value (warn)); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
973 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
974 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
975 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
976 // print dbstop if interrupt information |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
977 if (octave::Vdebug_on_interrupt) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
978 { |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
979 if (to_screen) |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
980 octave_stdout << "stop if interrupt\n"; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
981 else |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
982 retval.assign ("intr", octave_value ()); |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
983 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
984 |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
985 return retval; |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
986 } |
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
987 |