annotate libinterp/parse-tree/bp-table.cc @ 30564:796f54d4ddbf stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021. In all .txi and .texi files except gpl.txi and gpl.texi in the doc/liboctave and doc/interpreter directories, change the copyright to "Octave Project Developers", the same as used for other source files. Update copyright notices for 2022 (not done since 2019). For gpl.txi and gpl.texi, change the copyright notice to be "Free Software Foundation, Inc." and leave the date at 2007 only because this file only contains the text of the GPL, not anything created by the Octave Project Developers. Add Paul Thomas to contributors.in.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Dec 2021 18:22:40 -0500
parents b36e83cdbf05
children 83f9f8bda883 41101f2facdc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29688
diff changeset
3 // Copyright (C) 2001-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #if defined (HAVE_CONFIG_H)
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 # include "config.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #endif
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
23824
061a343089be Miscellaneous cleanups of C++11 std::string code.
Rik <rik@octave.org>
parents: 23807
diff changeset
30 #include <algorithm>
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include <limits>
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <list>
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include <map>
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #include <set>
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include <string>
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"
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
38 #include "oct-env.h"
23137
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 "error.h"
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
43 #include "event-manager.h"
25347
af3319d86a5f eliminate some global references to interpreter internals
John W. Eaton <jwe@octave.org>
parents: 25343
diff changeset
44 #include "interpreter.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 "ov-usr-fcn.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 #include "ov.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 #include "ovl.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 #include "pager.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 #include "parse.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 #include "pt-eval.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 #include "pt-exp.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 #include "pt-stmt.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 #include "sighandlers.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
57 namespace octave
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 {
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
59 class bp_file_info
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
60 {
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
61 public:
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
62
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
63 bp_file_info (tree_evaluator& tw, const std::string& file)
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
64 : m_ok (false), m_file (file), m_dir (), m_fcn (), m_class_name ()
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
65 {
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
66 std::string abs_file = sys::env::make_absolute (file);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
67
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
68 std::string dir = sys::file_ops::dirname (abs_file);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
69 std::string fcn = sys::file_ops::tail (abs_file);
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29458
diff changeset
70 std::size_t len = fcn.length ();
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
71 if (len >= 2 && fcn[len-2] == '.' && fcn[len-1] == 'm')
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
72 fcn = fcn.substr (0, len-2);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
73
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29458
diff changeset
74 std::size_t pos = dir.rfind (sys::file_ops::dir_sep_chars ());
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
75
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
76 if (pos != std::string::npos && pos < dir.length () - 1)
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
77 {
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
78 if (dir[pos+1] == '@')
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
79 {
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
80 m_class_name = dir.substr (pos+1);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
81
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
82 fcn = sys::file_ops::concat (m_class_name, fcn);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
83
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
84 dir = dir.substr (0, pos);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
85 }
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
86 }
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
87
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
88 m_dir = dir;
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
89 m_fcn = fcn;
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
90
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
91 interpreter& interp = tw.get_interpreter ();
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
92
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
93 load_path& lp = interp.get_load_path ();
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
94
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
95 if (lp.contains_file_in_dir (m_file, m_dir))
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
96 m_ok = true;
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
97 }
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
98
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
99 std::string file (void) const { return m_file; }
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
100 std::string dir (void) const { return m_fcn; }
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
101 std::string fcn (void) const { return m_fcn; }
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
102 std::string class_name (void) const { return m_class_name; }
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
103
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
104 bool ok (void) const { return m_ok; }
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
105
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
106 private:
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
107
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
108 bool m_ok;
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
109 std::string m_file;
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
110 std::string m_dir;
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
111 std::string m_fcn;
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
112 std::string m_class_name;
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
113 };
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
114
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
115 // Clear all reasons to stop, other than breakpoints.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
116
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
117 void bp_table::dbclear_all_signals (void)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
118 {
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
119 interpreter& interp = m_evaluator.get_interpreter ();
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
120 error_system& es = interp.get_error_system ();
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
121
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
122 es.debug_on_error (false);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
123 bp_table::m_errors_that_stop.clear ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
124
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
125 es.debug_on_caught (false);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
126 bp_table::m_caught_that_stop.clear ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
127
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
128 es.debug_on_warning (false);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
129 bp_table::m_warnings_that_stop.clear ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
130
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
131 Vdebug_on_interrupt = false;
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
132 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
133
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
134 // Process the "warn", "errs", "caught" and "intr" fields for a call of
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
135 // "dbstop (p)".
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
137 void bp_table::dbstop_process_map_args (const octave_map& mv)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
138 {
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
139 interpreter& interp = m_evaluator.get_interpreter ();
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
140 error_system& es = interp.get_error_system ();
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
141
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
142 // process errs
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
143 // why so many levels of indirection needed?
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
144 bool fail = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
145 Cell U = mv.contents ("errs");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
146 if (U.numel () != 1)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
147 fail = (U.numel () > 1);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
148 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
149 {
29688
b36e83cdbf05 ensure idx_vector(int) constructor is defined (bug #60531)
John W. Eaton <jwe@octave.org>
parents: 29572
diff changeset
150 Array<octave_value> W = U.index (0);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
151 if (W.isempty () || W(0).isempty ())
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
152 es.debug_on_error (true); // like "dbstop if error" with no identifier
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
153 else if (! W(0).iscell ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
154 fail = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
155 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
156 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
157 Cell V = W(0).cell_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
158 for (int i = 0; i < V.numel (); i++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
159 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
160 m_errors_that_stop.insert (V(i).string_value ());
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
161 es.debug_on_error (true);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
162 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
163 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
164 }
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
165
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
166 if (fail)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
167 error ("dbstop: invalid 'errs' field");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
168
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
169 // process caught
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
170 // why so many levels of indirection needed?
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
171 fail = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
172 U = mv.contents ("caught");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
173 if (U.numel () != 1)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
174 fail = (U.numel () > 1);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
175 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
176 {
29688
b36e83cdbf05 ensure idx_vector(int) constructor is defined (bug #60531)
John W. Eaton <jwe@octave.org>
parents: 29572
diff changeset
177 Array<octave_value> W = U.index (0);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
178 if (W.isempty () || W(0).isempty ())
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
179 es.debug_on_caught (true); // like "dbstop if caught error" with no ID
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
180 else if (! W(0).iscell ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
181 fail = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
182 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
183 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
184 Cell V = W(0).cell_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
185 for (int i = 0; i < V.numel (); i++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
186 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
187 m_caught_that_stop.insert (V(i).string_value ());
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
188 es.debug_on_caught (true);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
189 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
190 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
191 }
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
192
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
193 if (fail)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
194 error ("dbstop: invalid 'caught' field");
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
195
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
196 // process warn
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
197 // why so many levels of indirection needed?
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
198 fail = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
199 U = mv.contents ("warn");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
200 if (U.numel () != 1)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
201 fail = (U.numel () > 1);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
202 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
203 {
29688
b36e83cdbf05 ensure idx_vector(int) constructor is defined (bug #60531)
John W. Eaton <jwe@octave.org>
parents: 29572
diff changeset
204 Array<octave_value> W = U.index (0);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
205 if (W.isempty () || W(0).isempty ())
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
206 es.debug_on_warning (true); // like "dbstop if warning" with no identifier
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
207 else if (! W(0).iscell ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
208 fail = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
209 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
210 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
211 Cell V = W(0).cell_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
212 for (int i = 0; i < V.numel (); i++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
213 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
214 m_warnings_that_stop.insert (V(i).string_value ());
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
215 es.debug_on_warning (true);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
216 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
217 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
218 }
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
219
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
220 if (fail)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
221 error ("dbstop: invalid 'warn' field");
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
222
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
223 // process interrupt
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
224 if (mv.isfield ("intr"))
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
225 Vdebug_on_interrupt = true;
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
226 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
227
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
228 // Insert a breakpoint in function fcn at line within file fname,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
229 // to stop only when condition is true.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
230 // Record in m_bp_set that fname contains a breakpoint.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
231
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
232 bool bp_table::add_breakpoint_1 (octave_user_code *fcn,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
233 const std::string& fname,
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
234 const bp_table::bp_lines& line,
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
235 const std::string& condition,
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
236 bp_table::bp_lines& retval)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
237 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
238 bool found = false;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
239
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
240 tree_statement_list *cmds = fcn->body ();
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
241
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
242 std::string file = fcn->fcn_file_name ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
243
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
244 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
245 {
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27185
diff changeset
246 interpreter& interp = m_evaluator.get_interpreter ();
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27185
diff changeset
247
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
248 event_manager& evmgr = interp.get_event_manager ();
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27185
diff changeset
249
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
250 retval = cmds->add_breakpoint (evmgr, file, line, condition);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
251
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
252 for (auto& lineno : retval)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
253 {
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
254 if (lineno != 0)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
255 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
256 // Normalize to store only the file name.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
257 // Otherwise, there can be an entry for both
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
258 // file>subfunction and file, which causes a crash on
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
259 // dbclear all
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
260 const char *s = strchr (fname.c_str (), '>');
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
261 if (s)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
262 m_bp_set.insert (fname.substr (0, s - fname.c_str ()));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
263 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
264 m_bp_set.insert (fname);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
265 found = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
266 break;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
267 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
268 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
269 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
270
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
271 return found;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
272 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
273
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
274 // Cursory check that cond is a valid condition to use for a breakpoint.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
275 // Currently allows conditions with side-effects, like 'y+=10' and 'y++';
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
276 // it is odd that the former is not flagged by "is_assignment_expression".
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
277 // Throws an exception if not valid.
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
278
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
279 bool bp_table::condition_valid (const std::string& cond)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
280 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
281 if (cond.length () > 0)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
282 {
25441
143007dad864 store reference instead of pointer to interpreter in lexer
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
283 // ; to reject partial expr like "y=="
143007dad864 store reference instead of pointer to interpreter in lexer
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
284 parser parser (cond + " ;", m_evaluator.get_interpreter ());
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
285 parser.reset ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
286 int parse_status = parser.run ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
287 if (parse_status)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
288 error ("dbstop: Cannot parse condition '%s'", cond.c_str ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
289 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
290 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
291 tree_statement *stmt = nullptr;
27504
7a31b25e3252 use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
292
7a31b25e3252 use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
293 std::shared_ptr<tree_statement_list> stmt_list
7a31b25e3252 use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
294 = parser.statement_list ();
7a31b25e3252 use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
295
7a31b25e3252 use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
296 if (! stmt_list)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
297 error ("dbstop: "
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
298 "condition is not empty, but has nothing to evaluate");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
299 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
300 {
27504
7a31b25e3252 use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
301 if (stmt_list->length () == 1
7a31b25e3252 use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
302 && (stmt = stmt_list->front ())
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
303 && stmt->is_expression ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
304 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
305 tree_expression *expr = stmt->expression ();
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
306 if (expr->is_assignment_expression ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
307 error ("dbstop: condition cannot be an assignment. "
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
308 "Did you mean '=='?");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
309 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
310 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
311 error ("dbstop: condition must be an expression");
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
312 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
313 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
314 }
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
315
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
316 return true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
317 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
318
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
319 enum dbstop_args
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
320 {
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
321 dbstop_in,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
322 dbstop_at,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
323 dbstop_if,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
324 dbstop_none
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
325 };
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
326
27971
ec769a7ab9fb fix more spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
327 // FIXME: This function probably needs to be completely overhauled to
26954
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
328 // correctly parse the full syntax of the dbstop command and properly
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
329 // reject incorrect forms.
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
330
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
331 // Parse parameters (args) of dbstop and dbclear commands.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
332 // For dbstop, who=="dbstop"; for dbclear, who=="dbclear".
26954
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
333 // The syntax is: dbstop [[in] symbol] [[at] [method | line [line [...]]]] [if condition]
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
334 // where the form of condition depends on whether or not a file or line has
26954
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
335 // been seen. IF symbol and method are specified, then symbol should
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
336 // be a class name. Otherwise it should be a function name.
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
337 // Also execute "if [error|warning|interrupt|naninf]" clauses.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
338
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
339 void bp_table::parse_dbfunction_params (const char *who,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
340 const octave_value_list& args,
26954
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
341 std::string& func_name,
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
342 std::string& class_name,
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
343 bp_table::bp_lines& lines,
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
344 std::string& cond)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
345 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
346 int nargin = args.length ();
26954
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
347 func_name = "";
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
348 class_name = "";
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
349 lines = bp_table::bp_lines ();
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
350
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
351 if (nargin == 0 || ! args(0).is_string ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
352 print_usage (who);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
353
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
354 // elements already processed
26586
5fec5393a9c8 bp-table.cc: Don't declare and initialize multiple vars on one line.
Rik <rik@octave.org>
parents: 26376
diff changeset
355 bool seen_in = false;
5fec5393a9c8 bp-table.cc: Don't declare and initialize multiple vars on one line.
Rik <rik@octave.org>
parents: 26376
diff changeset
356 bool seen_at = false;
5fec5393a9c8 bp-table.cc: Don't declare and initialize multiple vars on one line.
Rik <rik@octave.org>
parents: 26376
diff changeset
357 bool seen_if = false;
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
358 int pos = 0;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
359 dbstop_args tok = dbstop_none;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
360 while (pos < nargin)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
361 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
362 // allow "in" and "at" to be implicit
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
363 if (args(pos).is_string ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
364 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
365 std::string arg = args(pos).string_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
366 if (arg == "in")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
367 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
368 tok = dbstop_in;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
369 pos++;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
370 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
371 else if (arg == "at")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
372 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
373 tok = dbstop_at;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
374 pos++;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
375 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
376 else if (arg == "if")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
377 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
378 tok = dbstop_if;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
379 pos++;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
380 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
381 else if (atoi (args(pos).string_value ().c_str ()) > 0)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
382 tok = dbstop_at;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
383 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
384 tok = dbstop_in;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
385 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
386 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
387 tok = dbstop_at;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
388
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
389 if (pos >= nargin)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
390 error ("%s: '%s' missing argument", who,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
391 (tok == dbstop_in
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
392 ? "in" : (tok == dbstop_at ? "at" : "if")));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
393
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
394 // process the actual arguments
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
395 switch (tok)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
396 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
397 case dbstop_in:
26954
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
398 func_name = args(pos).string_value ();
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
399 if (seen_in)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
400 error ("%s: Too many function names specified -- %s",
26954
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
401 who, func_name.c_str ());
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
402 else if (seen_at || seen_if)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
403 error ("%s: function name must come before line number and 'if'",
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
404 who);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
405 seen_in = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
406 pos++;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
407 break;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
408
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
409 case dbstop_at:
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
410 if (seen_at)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
411 error ("%s: Only one 'at' clause is allowed -- %s",
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
412 who, args(pos).string_value ().c_str ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
413 else if (seen_if)
26107
05dfcb24ef12 Supply missing arguments to variable length *printf functions (bug #55046).
Rik <rik@octave.org>
parents: 25441
diff changeset
414 error ("%s: line number must come before 'if' clause\n", who);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
415 seen_at = true;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
416
26954
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
417 if (seen_if)
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
418 error ("%s: line number must come before 'if' clause\n", who);
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
419 else if (seen_in)
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
420 {
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
421 std::string arg = args(pos).string_value ();
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
422
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
423 // FIXME: we really want to distinguish number
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
424 // vs. method name here.
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
425
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
426 if (atoi (arg.c_str ()) == 0)
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
427 {
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
428 // We have class and function names but already
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
429 // stored the class name in func_name.
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
430 class_name = func_name;
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
431 func_name = arg;
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
432 pos++;
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
433 break;
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
434 }
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
435
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
436 }
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
437 else
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
438 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
439 // It was a line number. Get function name from debugger.
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27000
diff changeset
440 if (m_evaluator.in_debug_repl ())
26954
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
441 func_name = m_evaluator.get_user_code ()->profiler_name ();
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
442 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
443 error ("%s: function name must come before line number "
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
444 "and 'if'", who);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
445 seen_in = true;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
446 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
447
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
448 // Read a list of line numbers (or arrays thereof)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
449 for ( ; pos < nargin; pos++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
450 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
451 if (args(pos).is_string ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
452 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
453 int line = atoi (args(pos).string_value ().c_str ());
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
454
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
455 if (line > 0)
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
456 lines.insert (line);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
457 else
26954
6e50f1fedeb5 dbstop: accept "at CLASS in METHOD" syntax (partial fix for bug #45404)
John W. Eaton <jwe@octave.org>
parents: 26586
diff changeset
458 break; // may be "if" or a method name
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
459 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
460 else if (args(pos).isnumeric ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
461 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
462 const NDArray arg = args(pos).array_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
463
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
464 for (octave_idx_type j = 0; j < arg.numel (); j++)
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
465 lines.insert (static_cast<int> (arg.elem (j)));
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
466 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
467 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
468 error ("%s: Invalid argument type %s",
26107
05dfcb24ef12 Supply missing arguments to variable length *printf functions (bug #55046).
Rik <rik@octave.org>
parents: 25441
diff changeset
469 who, args(pos).type_name ().c_str ());
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
470 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
471 break;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
472
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
473 case dbstop_if:
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
474 if (seen_in) // conditional breakpoint
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
475 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
476 cond = ""; // remaining arguments form condition
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
477 for (; pos < nargin; pos++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
478 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
479 if (args(pos).is_string ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
480 cond += ' ' + args(pos).string_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
481 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
482 error ("%s: arguments to 'if' must all be strings", who);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
483 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
484
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
485 cond = cond.substr (1); // omit initial space
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
486 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
487 else // stop on event (error, warning, interrupt, NaN/inf)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
488 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
489 std::string condition = args(pos).string_value ();
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
490 bool on_off = ! strcmp (who, "dbstop");
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
491
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
492 // FIXME: the following seems a bit messy in the way it
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
493 // duplicates checks on CONDITION.
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
494
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
495 if (condition == "error")
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
496 process_id_list (who, condition, args, nargin, pos, on_off,
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
497 m_errors_that_stop);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
498 else if (condition == "warning")
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
499 process_id_list (who, condition, args, nargin, pos, on_off,
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
500 m_warnings_that_stop);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
501 else if (condition == "caught" && nargin > pos+1
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
502 && args(pos+1).string_value () == "error")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
503 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
504 pos++;
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
505 process_id_list (who, condition, args, nargin, pos, on_off,
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
506 m_caught_that_stop);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
507 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
508 else if (condition == "interrupt")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
509 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
510 Vdebug_on_interrupt = on_off;
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
511 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
512 else if (condition == "naninf")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
513 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
514 #if defined (DBSTOP_NANINF)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
515 Vdebug_on_naninf = on_off;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
516 enable_fpe (on_off);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
517 #else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
518 warning ("%s: condition '%s' not yet supported",
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
519 who, condition.c_str ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
520 #endif
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
521 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
522 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
523 error ("%s: invalid condition %s",
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
524 who, condition.c_str ());
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
525
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
526 pos = nargin;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
527 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
528 break;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
529
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
530 default: // dbstop_none should never occur
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
531 break;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
532 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
533 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
534 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
535
27184
f7bf27159cf7 * bp-table.cc: Fix test.
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
536 /*
f7bf27159cf7 * bp-table.cc: Fix test.
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
537 %!test
f7bf27159cf7 * bp-table.cc: Fix test.
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
538 %! dbclear all; # Clear out breakpoints before test
f7bf27159cf7 * bp-table.cc: Fix test.
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
539 %! dbstop help;
f7bf27159cf7 * bp-table.cc: Fix test.
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
540 %! dbstop in ls;
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27913
diff changeset
541 %! dbstop help at 104;
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27913
diff changeset
542 %! dbstop in ls 102; ## 102 is a comment; code line is at 105
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27913
diff changeset
543 %! dbstop help 204 if a==5;
27184
f7bf27159cf7 * bp-table.cc: Fix test.
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
544 %! dbstop if error Octave:undefined-function;
f7bf27159cf7 * bp-table.cc: Fix test.
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
545 %! s = dbstatus;
f7bf27159cf7 * bp-table.cc: Fix test.
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
546 %! dbclear all;
f7bf27159cf7 * bp-table.cc: Fix test.
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
547 %! assert ({s.bkpt(:).name}, {"help", "help", "help>do_contents", "ls", "ls"});
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
548 %! assert ([s.bkpt(:).line], [55, 105, 207, 63, 102]);
27184
f7bf27159cf7 * bp-table.cc: Fix test.
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
549 %! assert (s.errs, {"Octave:undefined-function"});
f7bf27159cf7 * bp-table.cc: Fix test.
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
550 */
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
551
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
552 void bp_table::set_stop_flag (const char *who, const std::string& condition,
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
553 bool on_off)
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
554 {
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
555 interpreter& interp = m_evaluator.get_interpreter ();
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
556 error_system& es = interp.get_error_system ();
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
557
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
558 if (condition == "error")
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
559 es.debug_on_error (on_off);
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
560 else if (condition == "warning")
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
561 es.debug_on_warning (on_off);
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
562 else if (condition == "caught")
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
563 es.debug_on_caught (on_off);
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
564 else
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
565 error ("%s: internal error in set_stop_flag", who);
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
566 }
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
567
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
568 void bp_table::process_id_list (const char *who,
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
569 const std::string& condition,
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
570 const octave_value_list& args,
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
571 int nargin, int& pos, bool on_off,
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
572 std::set<std::string>& id_list)
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
573 {
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
574 pos++;
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
575
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
576 if (nargin > pos) // only affect a single error ID
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
577 {
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
578 if (! args(pos).is_string () || nargin > pos+1)
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
579 error ("%s: ID must be a single string", who);
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
580 else if (on_off)
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
581 {
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
582 id_list.insert (args(pos).string_value ());
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
583 set_stop_flag (who, condition, true);
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
584 }
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
585 else
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
586 {
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
587 id_list.erase (args(pos).string_value ());
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
588 if (id_list.empty ())
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
589 set_stop_flag (who, condition, false);
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
590 }
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
591 }
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
592 else // unqualified. Turn all on or off
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
593 {
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
594 id_list.clear ();
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
595 set_stop_flag (who, condition, on_off);
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
596
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
597 if (condition == "error")
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
598 {
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
599 // Matlab stops on both.
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
600 Vdebug_on_interrupt = on_off;
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
601 }
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
602 }
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
603 }
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
604
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
605 // Return the sub/nested/main function of MAIN_FCN that contains
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
606 // line number LINENO of the source file.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
607 // If END_LINE != 0, *END_LINE is set to last line of the returned function.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
608
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
609 static octave_user_code * find_fcn_by_line (octave_user_code *main_fcn,
27932
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27923
diff changeset
610 int lineno,
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27923
diff changeset
611 int *end_line = nullptr)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
612 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
613 octave_user_code *retval = nullptr;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
614 octave_user_code *next_fcn = nullptr; // 1st function starting after lineno
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
615
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
616 // Find innermost nested (or parent) function containing lineno.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
617 int earliest_end = std::numeric_limits<int>::max ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
618
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
619 std::map<std::string, octave_value> subfcns = main_fcn->subfunctions ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
620 for (const auto& str_val_p : subfcns)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
621 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
622 if (str_val_p.second.is_user_function ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
623 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
624 auto *dbg_subfcn = str_val_p.second.user_function_value ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
625
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
626 // Check if lineno is within dbg_subfcn.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
627 // FIXME: we could break when beginning_line() > lineno,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
628 // but that makes the code "fragile"
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
629 // if the order of walking subfcns changes,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
630 // for a minor speed improvement in non-critical code.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
631 if (dbg_subfcn->ending_line () < earliest_end
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
632 && dbg_subfcn->ending_line () >= lineno
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
633 && dbg_subfcn->beginning_line () <= lineno)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
634 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
635 earliest_end = dbg_subfcn->ending_line ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
636 retval = find_fcn_by_line (dbg_subfcn, lineno, &earliest_end);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
637 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
638
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
639 // Find the first fcn starting after lineno.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
640 // This is used if line is not inside any function.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
641 if (dbg_subfcn->beginning_line () >= lineno && ! next_fcn)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
642 next_fcn = dbg_subfcn;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
643 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
644 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
645
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
646 // The breakpoint is either in the subfunction found above,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
647 // or in the main function, which we check now.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
648 if (main_fcn->is_user_function ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
649 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
650 int e = dynamic_cast<octave_user_function *> (main_fcn)->ending_line ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
651 if (e >= lineno && e < earliest_end)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
652 retval = main_fcn;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
653
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
654 if (! retval)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
655 retval = next_fcn;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
656 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
657 else // main_fcn is a script.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
658 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
659 if (! retval)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
660 retval = main_fcn;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
661 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
662
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
663 if (end_line && earliest_end < *end_line)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
664 *end_line = earliest_end;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
665
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
666 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
667 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
668
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
669 // Given file name fname, find the subfunction at line and create
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
670 // a breakpoint there. Put the system into debug_mode.
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
671 int bp_table::add_breakpoint_in_function (const std::string& fname,
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
672 const std::string& class_name,
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
673 int line, const std::string& condition)
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
674 {
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
675 bp_lines line_info;
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
676 line_info.insert (line);
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
677
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
678 bp_lines result
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
679 = add_breakpoints_in_function (fname, class_name, line_info, condition);
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
680
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
681 return result.empty () ? 0 : *(result.begin ());
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
682 }
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
683
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
684 // Given file name fname, find the subfunction at line and create
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
685 // a breakpoint there. Put the system into debug_mode.
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
686 bp_table::bp_lines
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
687 bp_table::add_breakpoints_in_function (const std::string& fname,
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
688 const std::string& class_name,
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
689 const bp_table::bp_lines& lines,
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
690 const std::string& condition)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
691 {
26975
de826e69a5ea make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents: 26954
diff changeset
692 octave_user_code *main_fcn = m_evaluator.get_user_code (fname, class_name);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
693
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
694 if (! main_fcn)
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
695 error ("add_breakpoints_in_function: unable to find function '%s'\n",
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
696 fname.c_str ());
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
697
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
698 condition_valid (condition); // Throw error if condition not valid.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
699
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
700 bp_lines retval;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
701
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
702 for (const auto& lineno : lines)
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
703 {
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
704 octave_user_code *dbg_fcn = find_fcn_by_line (main_fcn, lineno);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
705
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
706 // We've found the right (sub)function. Now insert the breakpoint.
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
707 bp_lines line_info;
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
708 line_info.insert (lineno);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
709
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
710 bp_lines ret_one;
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
711 if (dbg_fcn && add_breakpoint_1 (dbg_fcn, fname, line_info,
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
712 condition, ret_one))
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
713 {
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
714 if (! ret_one.empty ())
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
715 {
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
716 int line = *(ret_one.begin ());
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
717
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
718 if (line)
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
719 retval.insert (line);
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
720 }
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
721 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
722 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
723
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27000
diff changeset
724 m_evaluator.reset_debug_state ();
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
725
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
726 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
727 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
728
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
729 int bp_table::add_breakpoint_in_file (const std::string& file,
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
730 int line,
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
731 const std::string& condition)
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
732 {
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
733 // Duplicates what the GUI was doing previously, but this action
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
734 // should not be specific to the GUI.
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
735
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
736 bp_file_info info (m_evaluator, file);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
737
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
738 if (! info.ok ())
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
739 return 0;
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
740
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
741 return add_breakpoint_in_function (info.fcn (), info.class_name (),
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
742 line, condition);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
743 }
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
744
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
745 bp_table::bp_lines
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
746 bp_table::add_breakpoints_in_file (const std::string& file,
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
747 const bp_lines& lines,
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
748 const std::string& condition)
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
749 {
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
750 // Duplicates what the GUI was doing previously, but this action
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
751 // should not be specific to the GUI.
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
752
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
753 bp_file_info info (m_evaluator, file);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
754
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
755 if (! info.ok ())
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
756 return bp_lines ();
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
757
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
758 return add_breakpoints_in_function (info.fcn (), info.class_name (),
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
759 lines, condition);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
760 }
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
761
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
762 int bp_table::remove_breakpoint_1 (octave_user_code *fcn,
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
763 const std::string& fname,
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
764 const bp_table::bp_lines& lines)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
765 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
766 int retval = 0;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
767
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
768 std::string file = fcn->fcn_file_name ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
769
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
770 tree_statement_list *cmds = fcn->body ();
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
771
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
772 // FIXME: move the operation on cmds to the tree_statement_list class?
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
773
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
774 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
775 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
776 octave_value_list results = cmds->list_breakpoints ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
777
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
778 if (results.length () > 0)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
779 {
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27185
diff changeset
780 interpreter& interp = m_evaluator.get_interpreter ();
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27185
diff changeset
781
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
782 event_manager& evmgr = interp.get_event_manager ();
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27185
diff changeset
783
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
784 for (const auto& lineno : lines)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
785 {
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
786 cmds->delete_breakpoint (lineno);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
787
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
788 if (! file.empty ())
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
789 evmgr.update_breakpoint (false, file, lineno);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
790 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
791
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
792 results = cmds->list_breakpoints ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
793
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25336
diff changeset
794 auto it = m_bp_set.find (fname);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
795 if (results.empty () && it != m_bp_set.end ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
796 m_bp_set.erase (it);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
797 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
798
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
799 retval = results.length ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
800 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
801
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
802 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
803 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
804
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
805 int
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
806 bp_table::remove_breakpoint_from_function (const std::string& fname, int line)
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
807 {
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
808 bp_lines line_info;
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
809 line_info.insert (line);
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
810
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
811 return remove_breakpoints_from_function (fname, line_info);
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
812 }
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
813
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
814 int
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
815 bp_table::remove_breakpoints_from_function (const std::string& fname,
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
816 const bp_table::bp_lines& lines)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
817 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
818 int retval = 0;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
819
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
820 if (lines.empty ())
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
821 {
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
822 bp_lines results = remove_all_breakpoints_from_function (fname);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
823 retval = results.size ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
824 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
825 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
826 {
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25347
diff changeset
827 octave_user_code *dbg_fcn = m_evaluator.get_user_code (fname);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
828
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
829 if (! dbg_fcn)
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
830 error ("remove_breakpoints_from_function: unable to find function %s\n",
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
831 fname.c_str ());
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
832
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
833 retval = remove_breakpoint_1 (dbg_fcn, fname, lines);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
834
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
835 // Search subfunctions in the order they appear in the file.
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
836
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
837 const std::list<std::string> subfcn_names
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
838 = dbg_fcn->subfunction_names ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
839
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
840 std::map<std::string, octave_value> subfcns
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
841 = dbg_fcn->subfunctions ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
842
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
843 for (const auto& subf_nm : subfcn_names)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
844 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
845 const auto q = subfcns.find (subf_nm);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
846
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
847 if (q != subfcns.end ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
848 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
849 octave_user_code *dbg_subfcn = q->second.user_code_value ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
850
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
851 retval += remove_breakpoint_1 (dbg_subfcn, fname, lines);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
852 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
853 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
854 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
855
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27000
diff changeset
856 m_evaluator.reset_debug_state ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
857
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
858 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
859 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
860
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
861 // Remove all breakpoints from a file, including those in subfunctions.
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
862
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
863 bp_table::bp_lines
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
864 bp_table::remove_all_breakpoints_from_function (const std::string& fname,
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
865 bool silent)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
866 {
29457
313b8b897733 revamp handling of breakpoint line positions
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
867 bp_lines retval;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
868
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25347
diff changeset
869 octave_user_code *dbg_fcn = m_evaluator.get_user_code (fname);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
870
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
871 if (dbg_fcn)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
872 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
873 std::string file = dbg_fcn->fcn_file_name ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
874
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
875 tree_statement_list *cmds = dbg_fcn->body ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
876
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
877 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
878 {
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27185
diff changeset
879 interpreter& interp = m_evaluator.get_interpreter ();
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27185
diff changeset
880
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
881 event_manager& evmgr = interp.get_event_manager ();
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27185
diff changeset
882
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
883 retval = cmds->remove_all_breakpoints (evmgr, file);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
884
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25336
diff changeset
885 auto it = m_bp_set.find (fname);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
886 if (it != m_bp_set.end ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
887 m_bp_set.erase (it);
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
888 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
889 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
890 else if (! silent)
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
891 error ("remove_all_breakpoints_from_function: "
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
892 "unable to find function %s\n", fname.c_str ());
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
893
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27000
diff changeset
894 m_evaluator.reset_debug_state ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
895
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
896 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
897 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
898
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
899 int
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
900 bp_table::remove_breakpoint_from_file (const std::string& file, int line)
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
901 {
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
902 // Duplicates what the GUI was doing previously, but this action
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
903 // should not be specific to the GUI.
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
904
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
905 bp_file_info info (m_evaluator, file);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
906
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
907 if (! info.ok ())
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
908 return 0;
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
909
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
910 return remove_breakpoint_from_function (info.fcn (), line);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
911 }
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
912
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
913 int
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
914 bp_table::remove_breakpoints_from_file (const std::string& file,
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
915 const bp_lines& lines)
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
916 {
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
917 // Duplicates what the GUI was doing previously, but this action
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
918 // should not be specific to the GUI.
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
919
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
920 bp_file_info info (m_evaluator, file);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
921
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
922 if (! info.ok ())
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
923 return 0;
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
924
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
925 return remove_breakpoints_from_function (info.fcn (), lines);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
926 }
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
927
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
928 bp_table::bp_lines
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
929 bp_table::remove_all_breakpoints_from_file (const std::string& file,
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
930 bool silent)
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
931 {
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
932 // Duplicates what the GUI was doing previously, but this action
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
933 // should not be specific to the GUI.
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
934
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
935 bp_file_info info (m_evaluator, file);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
936
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
937 if (! info.ok ())
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
938 return bp_lines ();
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
939
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
940 return remove_all_breakpoints_from_function (info.fcn (), silent);
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
941 }
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
942
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
943 void bp_table::remove_all_breakpoints (void)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
944 {
25342
416856765a55 be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
945 // Odd loop structure required because delete will invalidate
416856765a55 be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
946 // m_bp_set iterators.
25343
4d7790d9793f use cbegin, crbegin, cend, and crend and auto decls where possible
John W. Eaton <jwe@octave.org>
parents: 25342
diff changeset
947 for (auto it = m_bp_set.cbegin (), it_next = it;
4d7790d9793f use cbegin, crbegin, cend, and crend and auto decls where possible
John W. Eaton <jwe@octave.org>
parents: 25342
diff changeset
948 it != m_bp_set.cend ();
25342
416856765a55 be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
949 it = it_next)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
950 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
951 ++it_next;
29458
c0f86150aa6c begin allowing breakpoints to be set using file name
John W. Eaton <jwe@octave.org>
parents: 29457
diff changeset
952 remove_all_breakpoints_from_function (*it);
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
953 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
954
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27000
diff changeset
955 m_evaluator.reset_debug_state ();
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
956 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
957
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
958 std::string find_bkpt_list (octave_value_list slist, std::string match)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
959 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
960 std::string retval;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
961
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
962 for (int i = 0; i < slist.length (); i++)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
963 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
964 if (slist(i).string_value () == match)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
965 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
966 retval = slist(i).string_value ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
967 break;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
968 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
969 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
970
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
971 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
972 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
973
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
974 bp_table::fname_bp_map
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
975 bp_table::get_breakpoint_list (const octave_value_list& fname_list)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
976 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
977 fname_bp_map retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
978
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
979 // make copy since changes may invalidate iters of m_bp_set.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
980 std::set<std::string> tmp_bp_set = m_bp_set;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
981
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
982 for (auto& bp_fname : tmp_bp_set)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
983 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
984 if (fname_list.empty ()
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
985 || find_bkpt_list (fname_list, bp_fname) != "")
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
986 {
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25347
diff changeset
987 octave_user_code *dbg_fcn = m_evaluator.get_user_code (bp_fname);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
988
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
989 if (dbg_fcn)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
990 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
991 tree_statement_list *cmds = dbg_fcn->body ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
992
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
993 // FIXME: move the operation on cmds to the
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
994 // tree_statement_list class?
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
995 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
996 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
997 std::list<bp_type> bkpts = cmds->breakpoints_and_conds ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
998
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
999 if (! bkpts.empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1000 retval[bp_fname] = bkpts;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1001 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1002
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1003 // look for breakpoints in subfunctions
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1004 const std::list<std::string> subf_nm
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1005 = dbg_fcn->subfunction_names ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1006
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1007 std::map<std::string, octave_value> subfcns
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1008 = dbg_fcn->subfunctions ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1009
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1010 for (const auto& subfcn_nm : subf_nm)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1011 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1012 const auto q = subfcns.find (subfcn_nm);
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1013
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1014 if (q != subfcns.end ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1015 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1016 octave_user_code *dbg_subfcn
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1017 = q->second.user_code_value ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1018
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1019 cmds = dbg_subfcn->body ();
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1020 if (cmds)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1021 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1022 std::list<bp_type> bkpts
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1023 = cmds->breakpoints_and_conds ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1024
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1025 if (! bkpts.empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1026 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1027 std::string key
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1028 = bp_fname + '>' + dbg_subfcn->name ();
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1029
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1030 retval[key] = bkpts;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1031 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1032 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1033 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1034 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1035 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1036 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1037 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1038
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1039 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1040 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1041
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1042 // Report the status of "dbstop if error ..." and "dbstop if warning ..."
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1043 // If to_screen is true, the output goes to octave_stdout; otherwise it is
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1044 // returned.
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1045 // If dbstop if error is true but no explicit IDs are specified, the return
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1046 // value will have an empty field called "errs". If IDs are specified, the
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1047 // "errs" field will have a row per ID. If dbstop if error is false, there
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1048 // is no "errs" field. The "warn" field is set similarly by dbstop if warning
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1049
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1050 octave_map bp_table::stop_on_err_warn_status (bool to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1051 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1052 octave_map retval;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1053
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
1054 interpreter& interp = m_evaluator.get_interpreter ();
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
1055 error_system& es = interp.get_error_system ();
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
1056
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1057 // print dbstop if error information
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
1058 if (es.debug_on_error ())
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1059 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1060 if (m_errors_that_stop.empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1061 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1062 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1063 octave_stdout << "stop if error\n";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1064 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1065 retval.assign ("errs", octave_value(""));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1066 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1067 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1068 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1069 Cell errs (dim_vector (bp_table::m_errors_that_stop.size (), 1));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1070 int i = 0;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1071
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1072 for (const auto& e : m_errors_that_stop)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1073 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1074 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1075 octave_stdout << "stop if error " << e << "\n";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1076 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1077 errs(i++) = e;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1078 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1079 if (! to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1080 retval.assign ("errs", octave_value (errs));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1081 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1082 }
24286
6bfb96ab73cb * bp-table.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 24279
diff changeset
1083
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1084 // print dbstop if caught error information
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
1085 if (es.debug_on_caught ())
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1086 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1087 if (m_caught_that_stop.empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1088 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1089 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1090 octave_stdout << "stop if caught error\n";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1091 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1092 retval.assign ("caught", octave_value(""));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1093 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1094 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1095 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1096 Cell errs (dim_vector (m_caught_that_stop.size (), 1));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1097 int i = 0;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1098
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1099 for (const auto& e : m_caught_that_stop)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1100 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1101 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1102 octave_stdout << "stop if caught error " << e << "\n";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1103 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1104 errs(i++) = e;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1105 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1106 if (! to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1107 retval.assign ("caught", octave_value (errs));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1108 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1109 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1110
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1111 // print dbstop if warning information
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
1112 if (es.debug_on_warning ())
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1113 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1114 if (m_warnings_that_stop.empty ())
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1115 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1116 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1117 octave_stdout << "stop if warning\n";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1118 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1119 retval.assign ("warn", octave_value(""));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1120 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1121 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1122 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1123 Cell warn (dim_vector (m_warnings_that_stop.size (), 1));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1124 int i = 0;
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1125
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1126 for (const auto& w : m_warnings_that_stop)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1127 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1128 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1129 octave_stdout << "stop if warning " << w << "\n";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1130 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1131 warn(i++) = w;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1132 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1133 if (! to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1134 retval.assign ("warn", octave_value (warn));
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1135 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1136 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1137
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1138 // print dbstop if interrupt information
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
1139 if (Vdebug_on_interrupt)
24738
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1140 {
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1141 if (to_screen)
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1142 octave_stdout << "stop if interrupt\n";
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1143 else
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1144 retval.assign ("intr", octave_value ());
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1145 }
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1146
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1147 return retval;
3695c2cd69b8 don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1148 }
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1149 }