annotate libinterp/corefcn/debug.cc @ 22196:dd992fd74fce

put parser, lexer, and evaluator in namespace; interpreter now owns evaluator * oct-parse.in.yy, parse.h: Move parser classes to octave namespace. * lex.ll, lex.h: Move lexer classes to octave namespace. * pt-eval.h, pt-eval.cc: Move evaluator class to octave namespace. Don't define global current evaluator pointer here. * debug.cc, error.cc, input.cc, input.h, ls-mat-ascii.cc, pt-jit.cc, sighandlers.cc, utils.cc, variables.cc, ov-usr-fcn.cc, pt-assign.cc, pt-exp.h, pt-id.cc: Update for namespaces. * interpreter.cc, interpreter.h (current_evaluator): New global var. (interpreter::m_evaluator): New data member. (interpreter::~interpreter): Delete evaluator.
author John W. Eaton <jwe@octave.org>
date Tue, 12 Jul 2016 14:28:07 -0400
parents 5d4a286061c8
children bac0d6f07a3e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1 /*
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19597
diff changeset
3 Copyright (C) 2001-2015 Ben Sapp
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11058
diff changeset
4 Copyright (C) 2007-2009 John Swensen
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
5
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
7
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
11 option) any later version.
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
12
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
16 for more details.
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
17
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
20 <http://www.gnu.org/licenses/>.
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
21
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
22 */
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21703
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21259
diff changeset
24 # include "config.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
25 #endif
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
26
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
27 #include <deque>
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
28 #include <fstream>
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
29 #include <iomanip>
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
30 #include <iostream>
21703
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
31 #include <limits>
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
32 #include <set>
3948
126177939aae [project @ 2002-05-23 01:17:29 by jwe]
jwe
parents: 3947
diff changeset
33 #include <string>
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
34
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
35 #include "file-stat.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
36 #include "singleton-cleanup.h"
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
37
22091
0f6fc2ec3b1a move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
38 #include "call-stack.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
39 #include "defun.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
40 #include "error.h"
21258
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
41 #include "file-ops.h"
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
42 #include "help.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
43 #include "input.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
44 #include "pager.h"
16418
e1d92db3a715 use octave-link instead of hooks for breakpoint set/clear functions
John W. Eaton <jwe@octave.org>
parents: 16386
diff changeset
45 #include "octave-link.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20925
diff changeset
46 #include "ovl.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
47 #include "utils.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
48 #include "parse.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
49 #include "symtab.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21094
diff changeset
50 #include "errwarn.h"
20925
667861ffffab Extracted header class octave-preserve-stream-state from utils.{cc/h}.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20918
diff changeset
51 #include "octave-preserve-stream-state.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
52 #include "ov.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
53 #include "ov-usr-fcn.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
54 #include "ov-fcn.h"
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
55 #include "ov-struct.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
56 #include "pt-pr-code.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
57 #include "pt-bp.h"
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
58 #include "pt-eval.h"
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
59 #include "pt-exp.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
60 #include "pt-stmt.h"
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
61 #include "sighandlers.h"
22094
9203833cab7d move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents: 22091
diff changeset
62 #include "interpreter.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
63 #include "unwind-prot.h"
17818
f1b59ef34eda attempt to avoid setting persistent state on i/o streams (bug #40396)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
64 #include "utils.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
65 #include "variables.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
66
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
67 #include "debug.h"
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
68
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
69 // Initialize the singleton object
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
70 bp_table *bp_table::instance = 0;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
71
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
72 std::set<std::string> bp_table::errors_that_stop;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
73 std::set<std::string> bp_table::caught_that_stop;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
74 std::set<std::string> bp_table::warnings_that_stop;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
75
21562
6c2fd62db1f7 maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents: 21547
diff changeset
76 // Read entire file called fname and return the contents as a string
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
77 static std::string
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
78 snarf_file (const std::string& fname)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
79 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
80 std::string retval;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
81
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
82 octave::sys::file_stat fs (fname);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
83
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
84 if (fs)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
85 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
86 size_t sz = fs.size ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
87
21662
5b9868c2e212 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21645
diff changeset
88 std::ifstream file (fname.c_str (), std::ios::in | std::ios::binary);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
89
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
90 if (file)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
91 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
92 std::string buf (sz+1, 0);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
93
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
94 file.read (&buf[0], sz+1);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
95
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
96 if (! file.eof ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
97 error ("error reading file %s", fname.c_str ());
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
98
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
99 // Expected to read the entire file.
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
100 retval = buf;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
101 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
102 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
103
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
104 return retval;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
105 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
106
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
107 static std::deque<size_t>
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
108 get_line_offsets (const std::string& buf)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
109 {
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
110 // FIXME: This could maybe be smarter. Is deque the right thing to use here?
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
111
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
112 std::deque<size_t> offsets;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
113
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
114 offsets.push_back (0);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
115
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
116 size_t len = buf.length ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
117
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
118 for (size_t i = 0; i < len; i++)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
119 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
120 char c = buf[i];
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
121
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
122 if (c == '\r' && ++i < len)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
123 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
124 c = buf[i];
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
125
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
126 if (c == '\n')
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
127 offsets.push_back (i+1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
128 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
129 offsets.push_back (i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
130 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
131 else if (c == '\n')
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
132 offsets.push_back (i+1);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
133 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
134
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
135 offsets.push_back (len);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
136
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
137 return offsets;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
138 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
139
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
140 std::string
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
141 get_file_line (const std::string& fname, size_t line)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
142 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
143 std::string retval;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
144
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
145 static std::string last_fname;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
146
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
147 static std::string buf;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
148
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
149 static std::deque<size_t> offsets;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
150
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
151 if (fname != last_fname)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
152 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
153 buf = snarf_file (fname);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
154
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
155 offsets = get_line_offsets (buf);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
156 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
157
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
158 if (line > 0)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
159 line--;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
160
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
161 if (line < offsets.size () - 1)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
162 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
163 size_t bol = offsets[line];
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
164 size_t eol = offsets[line+1];
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
165
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
166 while (eol > 0 && eol > bol && (buf[eol-1] == '\n' || buf[eol-1] == '\r'))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
167 eol--;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
168
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
169 retval = buf.substr (bol, eol - bol);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
170 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
171
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
172 return retval;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
173 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
174
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5645
diff changeset
175 // Return a pointer to the user-defined function FNAME. If FNAME is
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5645
diff changeset
176 // empty, search backward for the first user-defined function in the
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5645
diff changeset
177 // current call stack.
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
178
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
179 static octave_user_code *
21017
93748bcaec17 maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents: 20980
diff changeset
180 get_user_code (const std::string& fname = "")
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
181 {
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
182 octave_user_code *dbg_fcn = 0;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
183
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
184 if (fname.empty ())
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
185 dbg_fcn = octave_call_stack::debug_user_code ();
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5645
diff changeset
186 else
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
187 {
18236
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
188 std::string name = fname;
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
189
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
190 if (octave::sys::file_ops::dir_sep_char () != '/' && name[0] == '@')
21628
37a44d8af461 Allow dbstop @class/method with forward slash on Windows (bug #47575).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21623
diff changeset
191 {
37a44d8af461 Allow dbstop @class/method with forward slash on Windows (bug #47575).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21623
diff changeset
192 int len = name.length () - 1; // -1: can't have trailing '/'
37a44d8af461 Allow dbstop @class/method with forward slash on Windows (bug #47575).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21623
diff changeset
193 for (int i = 2; i < len; i++) // 2: can't have @/method
37a44d8af461 Allow dbstop @class/method with forward slash on Windows (bug #47575).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21623
diff changeset
194 if (name[i] == '/')
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
195 name[i] = octave::sys::file_ops::dir_sep_char ();
21628
37a44d8af461 Allow dbstop @class/method with forward slash on Windows (bug #47575).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21623
diff changeset
196 }
37a44d8af461 Allow dbstop @class/method with forward slash on Windows (bug #47575).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21623
diff changeset
197
18236
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
198 size_t name_len = name.length ();
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
199
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
200 if (! name.empty () && name_len > 2 && name.substr (name_len-2) == ".m")
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
201 name = name.substr (0, name_len-2);
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
202
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
203 octave_value fcn = symbol_table::find_function (name);
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
204
8123
eb2beef9a9ff clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents: 8114
diff changeset
205 if (fcn.is_defined () && fcn.is_user_code ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
206 dbg_fcn = fcn.user_code_value ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
207 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
208
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
209 return dbg_fcn;
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
210 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
211
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21703
diff changeset
212 #if defined (DBSTOP_NANINF)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21157
diff changeset
213 # include "sigfpe.cc"
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
214 #endif
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
215
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
216 enum
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
217 dbstop_args {dbstop_in, dbstop_at, dbstop_if, dbstop_none};
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
218
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
219 // Parse parameters (args) of dbstop and dbclear commands.
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
220 // For dbstop, who=="dbstop"; for dbclear, who=="dbclear".
21562
6c2fd62db1f7 maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents: 21547
diff changeset
221 // The syntax is: dbstop [[in] symbol] [[at] line [line [...]]] [if condition]
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
222 // where the form of condition depends on whether or not a file or line has
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
223 // been seen.
21562
6c2fd62db1f7 maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents: 21547
diff changeset
224 // Also execute "if [error|warning|interrupt|naninf]" clauses.
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
225 void
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
226 parse_dbfunction_params (const char *who, const octave_value_list& args,
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
227 std::string& symbol_name, bp_table::intmap& lines,
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
228 std::string& cond)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
229 {
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
230 int nargin = args.length ();
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
231 int list_idx = 0;
21017
93748bcaec17 maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents: 20980
diff changeset
232 symbol_name = "";
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
233 lines = bp_table::intmap ();
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
234
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
235 if (nargin == 0 || ! args(0).is_string ())
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
236 print_usage (who);
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
237
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
238 // elements already processed
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
239 bool seen_in = false, seen_at = false, seen_if = false;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
240 int pos = 0;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
241 dbstop_args token = dbstop_none;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
242 while (pos < nargin)
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
243 {
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
244 // allow "in" and "at" to be implicit
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
245 if (args(pos).is_string ())
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
246 {
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
247 std::string arg = args(pos).string_value ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
248 if (arg == "in")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
249 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
250 token = dbstop_in;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
251 pos++;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
252 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
253 else if (arg == "at")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
254 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
255 token = dbstop_at;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
256 pos++;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
257 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
258 else if (arg == "if")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
259 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
260 token = dbstop_if;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
261 pos++;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
262 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
263 else if (atoi (args(pos).string_value ().c_str ()) > 0)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
264 token = dbstop_at;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
265 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
266 token = dbstop_in;
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
267 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
268 else
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
269 token = dbstop_at;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
270
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
271 if (pos >= nargin)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
272 error ("%s: '%s' missing argument", who,
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
273 ( token == dbstop_in ? "in" :
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
274 (token == dbstop_at ? "at" : "if")));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
275
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
276 // process the actual arguments
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
277 switch (token)
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
278 {
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
279 case dbstop_in:
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
280 symbol_name = args(pos).string_value ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
281 if (seen_in)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
282 error ("%s: Too many function names specified -- %s",
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
283 who, symbol_name.c_str ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
284 else if (seen_at || seen_if)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
285 error ("%s: function name must come before line number and 'if'",
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
286 who);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
287 seen_in = true;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
288 pos++;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
289 break;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
290
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
291 case dbstop_at:
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
292 if (seen_at)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
293 error ("%s: Only one 'at' clause is allowed -- %s",
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
294 who, args(pos).string_value ().c_str ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
295 else if (seen_if)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
296 error ("%s: line number must come before 'if' clause\n");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
297 seen_at = true;
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
298
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
299 if (! seen_in)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
300 {
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21743
diff changeset
301 // It was a line number. Get function name from debugger.
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
302 if (Vdebugging)
21623
555b6c78d677 Fix regression preventing "dbstop <line>" in debug mode (bug #47621)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21580
diff changeset
303 symbol_name = get_user_code ()->profiler_name ();
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
304 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
305 error ("%s: function name must come before line number "
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
306 "and 'if'", who);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
307 seen_in = true;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
308 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
309 else if (seen_if)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
310 error ("%s: line number must come before 'if' clause\n");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
311
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
312 // Read a list of line numbers (or arrays thereof)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
313 for ( ; pos < nargin; pos++)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
314 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
315 if (args(pos).is_string ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
316 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
317 int line = atoi (args(pos).string_value ().c_str ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
318
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
319 if (line > 0)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
320 lines[list_idx++] = line;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
321 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
322 break; // may be "if"
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
323 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
324 else if (args(pos).is_numeric_type ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
325 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
326 const NDArray arg = args(pos).array_value ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
327
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
328 for (octave_idx_type j = 0; j < arg.numel (); j++)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
329 lines[list_idx++] = static_cast<int> (arg.elem (j));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
330 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
331 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
332 error ("%s: Invalid argument type %s",
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
333 args(pos).type_name ().c_str ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
334 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
335 break;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
336
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
337 case dbstop_if:
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
338 if (seen_in) // conditional breakpoint
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
339 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
340 cond = ""; // remaining arguments form condition
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
341 for (; pos < nargin; pos++)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
342 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
343 if (args(pos).is_string ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
344 cond = cond + " " + args(pos).string_value ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
345 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
346 error ("%s: arguments to 'if' must all be strings", who);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
347 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
348
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
349 cond = cond.substr (1); // omit initial space
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
350 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
351 else // stop on event (error, warning, interrupt, NaN/inf)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
352 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
353 std::string condition = args(pos).string_value ();
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
354 int on_off = ! strcmp(who, "dbstop");
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
355
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
356 // list of error/warning IDs to update
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
357 std::set<std::string> *id_list = NULL;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
358 bool *stop_flag = NULL; // Vdebug_on_... flag
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
359
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
360 if (condition == "error")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
361 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
362 id_list = &bp_table::errors_that_stop;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
363 stop_flag = &Vdebug_on_error;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
364 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
365 else if (condition == "warning")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
366 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
367 id_list = &bp_table::warnings_that_stop;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
368 stop_flag = &Vdebug_on_warning;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
369 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
370 else if (condition == "caught" && nargin > pos+1
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
371 && args(pos+1).string_value () == "error")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
372 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
373 id_list = &bp_table::caught_that_stop;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
374 stop_flag = &Vdebug_on_caught;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
375 pos++;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
376 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
377 else if (condition == "interrupt")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
378 {
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
379 octave::Vdebug_on_interrupt = on_off;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
380 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
381 else if (condition == "naninf")
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21703
diff changeset
382 #if defined (DBSTOP_NANINF)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
383 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
384 Vdebug_on_naninf = on_off;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
385 enable_fpe (on_off);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
386 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
387 #else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
388 warning ("%s: condition '%s' not yet supported",
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
389 who, condition.c_str ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
390 #endif
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
391 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
392 error ("%s: invalid condition %s",
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
393 who, condition.c_str ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
394
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
395 // process ID list for "dbstop if error <error_ID>" etc
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
396 if (id_list != NULL)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
397 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
398 pos++;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
399 if (pos < nargin) // only affect a single error ID
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
400 {
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
401 if (! args(pos).is_string () || nargin > pos+1)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
402 error ("%s: ID must be a single string", who);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
403 else if (on_off == 1)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
404 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
405 id_list->insert (args(pos).string_value ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
406 *stop_flag = 1;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
407 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
408 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
409 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
410 id_list->erase (args(pos).string_value ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
411 if (id_list->empty ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
412 *stop_flag = 0;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
413 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
414 }
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
415 else // unqualified. Turn all on or off
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
416 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
417 id_list->clear ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
418 *stop_flag = on_off;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
419 if (stop_flag == &Vdebug_on_error)
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
420 {
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
421 // Matlab stops on both.
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
422 octave::Vdebug_on_interrupt = on_off;
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
423 }
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
424 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
425 }
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
426
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
427 pos = nargin;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
428 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
429 break;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
430
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
431 default: // dbstop_none should never occur
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
432 break;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
433 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
434 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
435 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
436
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
437 /*
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
438 %!test
21645
9810e483b42f Fix dbstop BIST tests on Windows platforms.
Rik <rik@octave.org>
parents: 21628
diff changeset
439 %! dbclear all; # Clear out breakpoints before test
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
440 %! dbstop help;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
441 %! dbstop in ls;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
442 %! dbstop help at 100;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
443 %! dbstop in ls 100;
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21754
diff changeset
444 %! dbstop help 201 if a==5;
21703
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
445 %! dbstop if error Octave:undefined-function;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
446 %! s = dbstatus;
21703
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
447 %! dbclear all;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
448 %! assert ({s.bkpt(:).name}, {"help", "help", "help>do_contents", "ls", "ls"});
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21754
diff changeset
449 %! assert ([s.bkpt(:).line], [48, 100, 201, 58, 100]);
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
450 %! assert (s.errs, {"Octave:undefined-function"});
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
451 */
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
452
21562
6c2fd62db1f7 maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents: 21547
diff changeset
453 // Return true if there is a valid breakpoint table, false otherwise.
6c2fd62db1f7 maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents: 21547
diff changeset
454 // If no table exists, one is created; false is only returned if this fails.
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
455 bool
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
456 bp_table::instance_ok (void)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
457 {
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
458 if (! instance)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
459 {
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
460 instance = new bp_table ();
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
461
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
462 if (instance)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
463 singleton_cleanup_list::add (cleanup_instance);
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
464 }
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
465
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
466 if (! instance)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20819
diff changeset
467 error ("unable to create breakpoint table!");
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
468
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
469 return true;
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
470 }
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
471
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
472 // Clear all reasons to stop, other than breakpoints
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
473 void
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
474 bp_table::dbclear_all_signals (void)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
475 {
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
476 Vdebug_on_error = false;
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
477 bp_table::errors_that_stop.clear ();
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
478
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
479 Vdebug_on_caught = false;
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
480 bp_table::caught_that_stop.clear ();
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
481
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
482 Vdebug_on_warning = false;
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
483 bp_table::warnings_that_stop.clear ();
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
484
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
485 octave::Vdebug_on_interrupt = false;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
486 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
487
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
488 // Process the "warn", "errs", "caught" and "intr" fields for a call of
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
489 // "dbstop (p)".
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
490 void
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
491 bp_table::dbstop_process_map_args (const octave_map& mv)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
492 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
493 // process errs
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
494 // why so many levels of indirection needed?
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
495 bool fail = false;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
496 Cell U = mv.contents ("errs");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
497 if (U.numel () != 1)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
498 fail = (U.numel () > 1);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
499 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
500 {
21358
f2ae78f5827f Resolve compile time issues, when octave_idx_type is long.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21329
diff changeset
501 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0));
21877
dc0347131364 maint: More code cleanup for debug.cc and C++11.
Rik <rik@octave.org>
parents: 21875
diff changeset
502 if (W.is_empty () || W(0).is_empty () == 0)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
503 Vdebug_on_error = 1; // like "dbstop if error" with no identifier
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
504 else if (! W(0).is_cell ())
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
505 fail = true;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
506 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
507 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
508 Cell V = W(0).cell_value ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
509 for (int i = 0; i < V.numel (); i++)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
510 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
511 errors_that_stop.insert (V(i).string_value ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
512 Vdebug_on_error = 1;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
513 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
514 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
515 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
516 if (fail)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
517 error ("dbstop: invalid 'errs' field");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
518
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
519 // process caught
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
520 // why so many levels of indirection needed?
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
521 fail = false;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
522 U = mv.contents ("caught");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
523 if (U.numel () != 1)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
524 fail = (U.numel () > 1);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
525 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
526 {
21358
f2ae78f5827f Resolve compile time issues, when octave_idx_type is long.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21329
diff changeset
527 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0));
21877
dc0347131364 maint: More code cleanup for debug.cc and C++11.
Rik <rik@octave.org>
parents: 21875
diff changeset
528 if (W.is_empty () || W(0).is_empty ())
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
529 Vdebug_on_caught = 1; // like "dbstop if caught error" with no ID
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
530 else if (! W(0).is_cell ())
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
531 fail = true;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
532 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
533 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
534 Cell V = W(0).cell_value ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
535 for (int i = 0; i < V.numel (); i++)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
536 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
537 caught_that_stop.insert (V(i).string_value ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
538 Vdebug_on_caught = 1;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
539 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
540 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
541 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
542 if (fail)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
543 error ("dbstop: invalid 'caught' field");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
544
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
545 // process warn
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
546 // why so many levels of indirection needed?
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
547 fail = false;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
548 U = mv.contents ("warn");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
549 if (U.numel () != 1)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
550 fail = (U.numel () > 1);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
551 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
552 {
21358
f2ae78f5827f Resolve compile time issues, when octave_idx_type is long.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 21329
diff changeset
553 Array<octave_value> W = U.index (static_cast<octave_idx_type> (0));
21877
dc0347131364 maint: More code cleanup for debug.cc and C++11.
Rik <rik@octave.org>
parents: 21875
diff changeset
554 if (W.is_empty () || W(0).is_empty ())
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
555 Vdebug_on_warning = 1; // like "dbstop if warning" with no identifier
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
556 else if (! W(0).is_cell ())
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
557 fail = true;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
558 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
559 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
560 Cell V = W(0).cell_value ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
561 for (int i = 0; i < V.numel (); i++)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
562 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
563 warnings_that_stop.insert (V(i).string_value ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
564 Vdebug_on_warning = 1;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
565 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
566 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
567 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
568 if (fail)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
569 error ("dbstop: invalid 'warn' field");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
570
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
571 // process interrupt
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
572 if (mv.isfield ("intr"))
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
573 octave::Vdebug_on_interrupt = 1;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
574 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
575
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
576 // Insert a breakpoint in function fcn at line within file fname,
21562
6c2fd62db1f7 maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents: 21547
diff changeset
577 // to stop only when condition is true.
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
578 // Record in bp_set that fname contains a breakpoint.
16596
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
579 bool
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
580 bp_table::do_add_breakpoint_1 (octave_user_code *fcn,
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
581 const std::string& fname,
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
582 const bp_table::intmap& line,
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
583 const std::string& condition,
16596
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
584 bp_table::intmap& retval)
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
585 {
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
586 bool found = false;
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
587
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
588 tree_statement_list *cmds = fcn->body ();
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
589
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
590 std::string file = fcn->fcn_file_name ();
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
591
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
592 if (cmds)
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
593 {
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
594 retval = cmds->add_breakpoint (file, line, condition);
16596
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
595
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
596 for (auto& idx_line_p : retval)
16596
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
597 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
598 if (idx_line_p.second != 0)
16596
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
599 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
600 // Normalize to store only the file name.
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
601 // Otherwise, there can be an entry for both file>subfunction and
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
602 // file, which causes a crash on dbclear all
21258
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
603 const char *s = strchr (fname.c_str (), Vfilemarker);
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
604 if (s)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
605 bp_set.insert (fname.substr (0, s - fname.c_str ()));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
606 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
607 bp_set.insert (fname);
16596
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
608 found = true;
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
609 break;
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
610 }
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
611 }
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
612 }
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
613
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
614 return found;
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
615 }
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
616
21562
6c2fd62db1f7 maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents: 21547
diff changeset
617 // Cursory check that cond is a valid condition to use for a breakpoint.
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
618 // Currently allows conditions with side-effects, like 'y+=10' and 'y++';
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
619 // it is odd that the former is not flagged by "is_assignment_expression".
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
620 // Throws an exception if not valid.
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21301
diff changeset
621 bool
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21301
diff changeset
622 bp_table::condition_valid (const std::string& cond)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
623 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
624 if (cond.length () > 0)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
625 {
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
626 octave::parser parser (cond + " ;"); // ; to reject partial expr like "y=="
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
627 parser.reset ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
628 int parse_status = parser.run ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
629 if (parse_status)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
630 error ("dbstop: Cannot parse condition '%s'", cond.c_str ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
631 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
632 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
633 tree_statement *stmt = 0;
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
634 if (! parser.stmt_list)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
635 error ("dbstop: "
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
636 "condition is not empty, but has nothing to evaluate");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
637 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
638 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
639 if (parser.stmt_list->length () == 1
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
640 && (stmt = parser.stmt_list->front ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
641 && stmt->is_expression ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
642 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
643 tree_expression *expr = stmt->expression ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
644 if (expr->is_assignment_expression ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
645 error ("dbstop: condition cannot be an assignment. "
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
646 "Did you mean '=='?");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
647 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
648 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
649 error ("dbstop: condition must be an expression");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
650 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
651 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
652 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
653 return true;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
654 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
655
21754
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
656 // Return the sub/nested/main function of MAIN_FCN that contains
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
657 // line number LINENO of the source file.
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
658 // If END_LINE != 0, *END_LINE is set to last line of the returned function.
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
659 static octave_user_code*
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
660 find_fcn_by_line (octave_user_code *main_fcn, int lineno, int *end_line = 0)
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
661 {
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
662 octave_user_code *retval = 0;
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
663 octave_user_code *next_fcn = 0; // 1st function starting after lineno
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
664
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
665 // Find innermost nested (or parent) function containing lineno.
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
666 int earliest_end = std::numeric_limits<int>::max ();
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
667
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
668 std::map<std::string, octave_value> subfcns = main_fcn->subfunctions ();
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
669 for (const auto& str_val_p : subfcns)
21754
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
670 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
671 if (str_val_p.second.is_user_function ())
21754
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
672 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
673 auto *dbg_subfcn = str_val_p.second.user_function_value ();
21754
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
674
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
675 // Check if lineno is within dbg_subfcn.
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
676 // FIXME: we could break when beginning_line() > lineno,
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
677 // but that makes the code "fragile"
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
678 // if the order of walking subfcns changes,
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
679 // for a minor speed improvement in non-critical code.
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
680 if (dbg_subfcn->ending_line () < earliest_end
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
681 && dbg_subfcn->ending_line () >= lineno
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
682 && dbg_subfcn->beginning_line () <= lineno)
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
683 {
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
684 earliest_end = dbg_subfcn->ending_line ();
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
685 retval = find_fcn_by_line (dbg_subfcn, lineno, &earliest_end);
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
686 }
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
687
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
688 // Find the first fcn starting after lineno.
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
689 // This is used if line is not inside any function.
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
690 if (dbg_subfcn->beginning_line () >= lineno && ! next_fcn)
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
691 next_fcn = dbg_subfcn;
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
692 }
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
693 }
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
694
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
695 // The breakpoint is either in the subfunction found above,
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
696 // or in the main function, which we check now.
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
697 if (main_fcn->is_user_function ())
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
698 {
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
699 int e = dynamic_cast<octave_user_function*> (main_fcn)->ending_line ();
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
700 if (e >= lineno && e < earliest_end)
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
701 retval = main_fcn;
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
702
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
703 if (! retval)
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
704 retval = next_fcn;
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
705 }
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
706 else // main_fcn is a script.
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
707 {
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
708 if (! retval)
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
709 retval = main_fcn;
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
710 }
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
711
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
712 if (end_line != 0 && earliest_end < *end_line)
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
713 *end_line = earliest_end;
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
714
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
715 return retval;
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
716 }
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
717
21562
6c2fd62db1f7 maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents: 21547
diff changeset
718 // Given file name fname, find the subfunction at line and create
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
719 // a breakpoint there. Put the system into debug_mode.
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
720 bp_table::intmap
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
721 bp_table::do_add_breakpoint (const std::string& fname,
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
722 const bp_table::intmap& line,
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
723 const std::string& condition)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
724 {
21703
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
725 octave_user_code *main_fcn = get_user_code (fname);
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
726
21703
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
727 if (! main_fcn)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
728 error ("add_breakpoint: unable to find function '%s'\n", fname.c_str ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
729
21703
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
730 condition_valid (condition); // Throw error if condition not valid.
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
731
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
732 intmap retval;
16627
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
733
21703
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
734 octave_idx_type len = line.size ();
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
735
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
736 for (int i = 0; i < len; i++)
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
737 {
21703
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
738 const_intmap_iterator m = line.find (i);
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
739
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
740 if (m != line.end ())
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
741 {
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
742 int lineno = m->second;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
743
21754
34a582f2edd7 Allow dbstop in functions nested in subfunctions (bug #47918).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21753
diff changeset
744 octave_user_code *dbg_fcn = find_fcn_by_line (main_fcn, lineno);
21703
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
745
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
746 // We've found the right (sub)function. Now insert the breakpoint.
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
747 // We insert all breakpoints.
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
748 // If multiple are in the same function, we insert multiple times.
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
749 intmap ret_one;
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
750 if (dbg_fcn
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
751 && do_add_breakpoint_1 (dbg_fcn, fname, line, condition, ret_one))
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
752 retval.insert (std::pair<int,int> (i, ret_one.find (i)->second));
16531
f3a63fdbd725 finish botched changeset 7ca7e7d5eb91
John W. Eaton <jwe@octave.org>
parents: 16530
diff changeset
753 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
754 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
755
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
756 octave::tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
757
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
758 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
759 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
760
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
761 int
16627
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
762 bp_table::do_remove_breakpoint_1 (octave_user_code *fcn,
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
763 const std::string& fname,
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
764 const bp_table::intmap& line)
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
765 {
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
766 int retval = 0;
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
767
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
768 std::string file = fcn->fcn_file_name ();
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
769
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
770 tree_statement_list *cmds = fcn->body ();
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
771
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
772 // FIXME: move the operation on cmds to the tree_statement_list class?
16627
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
773
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
774 if (cmds)
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
775 {
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
776 octave_value_list results = cmds->list_breakpoints ();
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
777
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
778 if (results.length () > 0)
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
779 {
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
780 octave_idx_type len = line.size ();
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
781
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
782 for (int i = 0; i < len; i++)
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
783 {
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
784 const_intmap_iterator p = line.find (i);
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
785
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
786 if (p != line.end ())
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
787 {
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
788 int lineno = p->second;
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
789
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
790 cmds->delete_breakpoint (lineno);
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
791
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
792 if (! file.empty ())
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
793 octave_link::update_breakpoint (false, file, lineno);
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
794 }
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
795 }
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
796
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
797 results = cmds->list_breakpoints ();
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
798
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
799 bp_set_iterator it = bp_set.find (fname);
21877
dc0347131364 maint: More code cleanup for debug.cc and C++11.
Rik <rik@octave.org>
parents: 21875
diff changeset
800 if (results.empty () && it != bp_set.end ())
16627
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
801 bp_set.erase (it);
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
802 }
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
803
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
804 retval = results.length ();
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
805 }
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
806
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
807 return retval;
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
808 }
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
809
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
810 int
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
811 bp_table::do_remove_breakpoint (const std::string& fname,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
812 const bp_table::intmap& line)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
813 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
814 int retval = 0;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
815
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
816 octave_idx_type len = line.size ();
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
817
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
818 if (len == 0)
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
819 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
820 intmap results = remove_all_breakpoints_in_file (fname);
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
821 retval = results.size ();
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
822 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
823 else
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
824 {
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
825 octave_user_code *dbg_fcn = get_user_code (fname);
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
826
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
827 if (! dbg_fcn)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
828 error ("remove_breakpoint: unable to find function %s\n",
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
829 fname.c_str ());
16386
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16342
diff changeset
830
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
831 retval = do_remove_breakpoint_1 (dbg_fcn, fname, line);
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
832
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
833 // Search subfunctions in the order they appear in the file.
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
834
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
835 const std::list<std::string> subfcn_names
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
836 = dbg_fcn->subfunction_names ();
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
837
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
838 std::map<std::string, octave_value> subfcns
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
839 = dbg_fcn->subfunctions ();
16386
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16342
diff changeset
840
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
841 for (const auto& subf_nm : subfcn_names)
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
842 {
21877
dc0347131364 maint: More code cleanup for debug.cc and C++11.
Rik <rik@octave.org>
parents: 21875
diff changeset
843 const auto q = subfcns.find (subf_nm);
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
844
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
845 if (q != subfcns.end ())
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
846 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
847 octave_user_code *dbg_subfcn = q->second.user_code_value ();
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
848
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
849 retval += do_remove_breakpoint_1 (dbg_subfcn, fname, line);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
850 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
851 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
852 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
853
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
854 octave::tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
855
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
856 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
857 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
858
20674
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
859 // Remove all breakpoints from a file, including those in subfunctions
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
860 bp_table::intmap
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
861 bp_table::do_remove_all_breakpoints_in_file (const std::string& fname,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
862 bool silent)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
863 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
864 intmap retval;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
865
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
866 octave_user_code *dbg_fcn = get_user_code (fname);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
867
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
868 if (dbg_fcn)
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
869 {
20674
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
870 std::string file = dbg_fcn->fcn_file_name ();
16386
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16342
diff changeset
871
20674
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
872 tree_statement_list *cmds = dbg_fcn->body ();
16627
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
873
20674
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
874 if (cmds)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
875 {
20674
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
876 retval = cmds->remove_all_breakpoints (file);
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
877
20674
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
878 bp_set_iterator it = bp_set.find (fname);
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
879 if (it != bp_set.end ())
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
880 bp_set.erase (it);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
881 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
882 }
8123
eb2beef9a9ff clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents: 8114
diff changeset
883 else if (! silent)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
884 error ("remove_all_breakpoint_in_file: "
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
885 "unable to find function %s\n", fname.c_str ());
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
886
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
887 octave::tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
888
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
889 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
890 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
891
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
892 void
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
893 bp_table::do_remove_all_breakpoints (void)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
894 {
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
895 // Odd loop structure required because delete will invalidate bp_set iterators
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
896 for (const_bp_set_iterator it=bp_set.begin (), it_next=it;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
897 it != bp_set.end ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
898 it=it_next)
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
899 {
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
900 ++it_next;
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
901 remove_all_breakpoints_in_file (*it);
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
902 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
903
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
904 octave::tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
905 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
906
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
907 std::string
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
908 do_find_bkpt_list (octave_value_list slist, std::string match)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
909 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
910 std::string retval;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
911
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
912 for (int i = 0; i < slist.length (); i++)
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
913 {
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
914 if (slist(i).string_value () == match)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
915 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
916 retval = slist(i).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
917 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
918 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
919 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
920
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
921 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
922 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
923
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
924 bp_table::fname_bp_map
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
925 bp_table::do_get_breakpoint_list (const octave_value_list& fname_list)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
926 {
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
927 fname_bp_map retval;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
928
21094
622e34f6ede3 Fix segfault with dbstatus (bug #44195)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21077
diff changeset
929 // make copy since changes may invalidate iters of bp_set.
622e34f6ede3 Fix segfault with dbstatus (bug #44195)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21077
diff changeset
930 std::set<std::string> tmp_bp_set = bp_set;
622e34f6ede3 Fix segfault with dbstatus (bug #44195)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21077
diff changeset
931
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
932 for (auto& bp_fname : tmp_bp_set)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
933 {
21877
dc0347131364 maint: More code cleanup for debug.cc and C++11.
Rik <rik@octave.org>
parents: 21875
diff changeset
934 if (fname_list.empty ()
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
935 || do_find_bkpt_list (fname_list, bp_fname) != "")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
936 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
937 octave_user_code *f = get_user_code (bp_fname);
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
938
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
939 if (f)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
940 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
941 tree_statement_list *cmds = f->body ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
942
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
943 // FIXME: move the operation on cmds to the
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
944 // tree_statement_list class?
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
945 if (cmds)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
946 {
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
947 std::list<bp_type> bkpts = cmds->breakpoints_and_conds ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
948
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
949 if (! bkpts.empty ())
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
950 retval[bp_fname] = bkpts;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
951 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
952
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
953 // look for breakpoints in subfunctions
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
954 const std::list<std::string> subf_nm = f->subfunction_names ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
955
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
956 std::map<std::string, octave_value> subf = f->subfunctions ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
957
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
958 for (const auto& subfcn_nm : subf_nm)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
959 {
21877
dc0347131364 maint: More code cleanup for debug.cc and C++11.
Rik <rik@octave.org>
parents: 21875
diff changeset
960 const auto q = subf.find (subfcn_nm);
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
961
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
962 if (q != subf.end ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
963 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
964 octave_user_code *ff = q->second.user_code_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
965
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
966 cmds = ff->body ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
967 if (cmds)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
968 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
969 std::list<bp_type> bkpts
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
970 = cmds->breakpoints_and_conds ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
971
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
972 if (! bkpts.empty ())
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
973 retval[bp_fname + Vfilemarker + ff->name ()] = bkpts;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
974 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
975 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
976 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
977 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
978 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
979 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
980
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
981 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
982 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
983
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
984 static octave_value
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
985 intmap_to_ov (const bp_table::intmap& line)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
986 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
987 int idx = 0;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
988
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
989 NDArray retval (dim_vector (1, line.size ()));
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
990
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
991 for (size_t i = 0; i < line.size (); i++)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
992 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
993 bp_table::const_intmap_iterator p = line.find (i);
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
994
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
995 if (p != line.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
996 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
997 int lineno = p->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
998 retval(idx++) = lineno;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
999 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
1000 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1001
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
1002 retval.resize (dim_vector (1, idx));
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1003
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
1004 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
1005 }
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1006
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1007 DEFUN (dbstop, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1008 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1009 @deftypefn {} {} dbstop @var{func}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1010 @deftypefnx {} {} dbstop @var{func} @var{line}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1011 @deftypefnx {} {} dbstop @var{func} @var{line1} @var{line2} @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1012 @deftypefnx {} {} dbstop @var{line1} @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1013 @deftypefnx {} {} dbstop in @var{func}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1014 @deftypefnx {} {} dbstop in @var{func} at @var{line}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1015 @deftypefnx {} {} dbstop in @var{func} at @var{line} if "@var{condition}"
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1016 @deftypefnx {} {} dbstop if @var{event}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1017 @deftypefnx {} {} dbstop if @var{event} @var{ID}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1018 @deftypefnx {} {} dbstop (@var{bp_struct})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1019 @deftypefnx {} {@var{rline} =} dbstop @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1020
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1021 Set breakpoints for the built-in debugger.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1022
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1023 @var{func} is the name of a function on the current @code{path}. When
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1024 already in debug mode the @var{func} argument can be omitted and the current
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1025 function will be used. Breakpoints at subfunctions are set with the scope
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1026 operator @samp{>}. For example, If @file{file.m} has a subfunction
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1027 @code{func2}, then a breakpoint in @code{func2} can be specified by
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1028 @code{file>func2}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1029
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1030 @var{line} is the line number at which to break. If @var{line} is not
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1031 specified, it defaults to the first executable line in the file
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1032 @file{func.m}. Multiple lines can be specified in a single command; when
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1033 function syntax is used, the lines may also be passed as a single vector
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1034 argument (@code{[@var{line1}, @var{line2}, @dots{}]}).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1035
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1036 @var{condition} is any Octave expression that can be evaluated in the code
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1037 context that exists at the breakpoint. When the breakpoint is encountered,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1038 @var{condition} will be evaluated, and execution will stop if
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1039 @var{condition} is true. If @var{condition} cannot be evaluated, for
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1040 example because it refers to an undefined variable, an error will be thrown.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1041 Expressions with side effects (such as @code{y++ > 1}) will alter
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1042 variables, and should generally be avoided. Conditions containing quotes
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1043 (@samp{"}, @samp{'}) or comment characters (@samp{#}, @samp{%}) must be
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1044 enclosed in quotes. (This does not apply to conditions entered from the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1045 editor's context menu.) For example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1046
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1047 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1048 dbstop in strread at 209 if 'any (format == "%f")'
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1049 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1050
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1051 The form specifying @var{event} does not cause a specific breakpoint at a
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1052 given function and line number. Instead it causes debug mode to be entered
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1053 when certain unexpected events are encountered. Possible values are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1054
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1055 @table @code
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1056 @item error
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1057 Stop when an error is reported. This is equivalent to specifying
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1058 both @code{debug_on_error (true)} and @code{debug_on_interrupt (true)}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1059
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1060 @item caught error
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1061 Stop when an error is caught by a try-catch block (not yet implemented).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1062
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1063 @item interrupt
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1064 Stop when an interrupt (@kbd{Ctrl-C}) occurs.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1065
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1066 @item naninf
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1067 Stop when code returns a non-finite value (not yet implemented).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1068
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1069 @item warning
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1070 Stop when a warning is reported. This is equivalent to specifying
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1071 @code{debug_on_warning (true)}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1072 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1073
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1074 The events @code{error}, @code{caught error}, and @code{warning} can all be
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1075 followed by a string specifying an error ID or warning ID@. If that is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1076 done, only errors with the specified ID will cause execution to stop. To
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1077 stop on one of a set of IDs, multiple @code{dbstop} commands must be
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1078 issued.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1079
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1080 Breakpoints and events can be removed using the @code{dbclear} command with
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1081 the same syntax.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1082
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1083 It is possible to save all breakpoints and restore them at once by issuing
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1084 the commands @code{bp_state = dbstatus; @dots{}; dbstop (bp_state)}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1085
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1086 The optional output @var{rline} is the real line number where the breakpoint
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1087 was set. This can differ from the specified line if the line is not
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1088 executable. For example, if a breakpoint attempted on a blank line then
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1089 Octave will set the real breakpoint at the next executable line.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1090
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1091 When a file is re-parsed, such as when it is modified outside the GUI,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1092 all breakpoints within the file are cleared.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1093
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1094 @seealso{dbclear, dbstatus, dbstep, debug_on_error, debug_on_warning, debug_on_interrupt}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1095 @end deftypefn */)
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1096 {
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1097 bp_table::intmap retmap;
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1098 std::string symbol_name = ""; // stays empty for "dbstop if error" etc
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1099 bp_table::intmap lines;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1100 std::string condition = "";
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1101 octave_value retval;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1102
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1103 if (args.length() >= 1 && ! args(0).is_map ())
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1104 {
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1105 // explicit function / line / condition
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1106 parse_dbfunction_params ("dbstop", args, symbol_name, lines, condition);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1107
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1108 if (lines.size () == 0)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1109 lines[0] = 1;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1110
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1111 if (symbol_name != "")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1112 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1113 retmap = bp_table::add_breakpoint (symbol_name, lines, condition);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1114 retval = intmap_to_ov (retmap);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1115 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1116 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1117 else if (args.length () != 1)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1118 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1119 print_usage ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1120 }
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1121 else // structure of the form output by dbstatus
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1122 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1123 octave_map mv = args(0).map_value ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1124 if (mv.isfield ("bkpt") || mv.isfield ("errs") || mv.isfield ("warn")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1125 || mv.isfield ("intr"))
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1126 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1127 bp_table::dbstop_process_map_args (mv);
6646
bd0a70c3f2db [project @ 2007-05-22 02:27:43 by jwe]
jwe
parents: 6317
diff changeset
1128
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1129 // Replace mv by "bkpt", to use the processing below.
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1130 octave_value bkpt = mv.getfield ("bkpt");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1131 if (bkpt.is_empty ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1132 mv = octave_map ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1133 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1134 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1135 if (bkpt.is_cell () && bkpt.cell_value ().numel () > 0
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1136 && bkpt.cell_value () (0).is_map ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1137 mv = bkpt.cell_value () (0).map_value ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1138 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1139 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1140 error ("dbstop: invalid 'bkpt' field");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1141 mv = octave_map ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1142 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1143 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1144 }
21885
0806871e3e1e maint: Prefer is_empty() rather than "length () == 0".
Rik <rik@octave.org>
parents: 21877
diff changeset
1145 if (mv.is_empty ())
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1146 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1147 // no changes requested. Occurs if "errs" non-empty but "bkpt" empty
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1148 }
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1149 else if (! mv.isfield ("name") || ! mv.isfield ("line"))
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1150 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1151 error ("dbstop: Cell array must contain fields 'name' and 'line'");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1152 retval = octave_value (0);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1153 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1154 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1155 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1156 bool use_cond = mv.isfield ("cond");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1157 Cell name = mv.getfield ("name");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1158 Cell line = mv.getfield ("line");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1159 Cell cond = (use_cond ? mv.getfield ("cond") : Cell ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1160 std::string unconditional = "";
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1161 for (octave_idx_type i = 0; i < line.numel (); i++)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1162 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1163 lines [0] = line(i).double_value ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1164 bp_table::add_breakpoint (name(i).string_value (), lines,
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1165 use_cond ? cond(i).string_value ()
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1166 : unconditional );
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1167 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1168 retval = octave_value (line.numel ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1169 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1170 }
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1171
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1172 return retval;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1173 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1174
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1175 DEFUN (dbclear, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1176 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1177 @deftypefn {} {} dbclear @var{func}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1178 @deftypefnx {} {} dbclear @var{func} @var{line}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1179 @deftypefnx {} {} dbclear @var{func} @var{line1} @var{line2} @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1180 @deftypefnx {} {} dbclear @var{line} @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1181 @deftypefnx {} {} dbclear all
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1182 @deftypefnx {} {} dbclear in @var{func}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1183 @deftypefnx {} {} dbclear in @var{func} at @var{line}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1184 @deftypefnx {} {} dbclear if @var{event}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1185 @deftypefnx {} {} dbclear ("@var{func}")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1186 @deftypefnx {} {} dbclear ("@var{func}", @var{line})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1187 @deftypefnx {} {} dbclear ("@var{func}", @var{line1}, @var{line2}, @dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1188 @deftypefnx {} {} dbclear ("@var{func}", @var{line1}, @dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1189 @deftypefnx {} {} dbclear (@var{line}, @dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1190 @deftypefnx {} {} dbclear ("all")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1191 Delete a breakpoint at line number @var{line} in the function @var{func}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1192
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1193 Arguments are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1194
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1195 @table @var
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1196 @item func
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1197 Function name as a string variable. When already in debug mode this
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1198 argument can be omitted and the current function will be used.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1199
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1200 @item line
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1201 Line number from which to remove a breakpoint. Multiple lines may be given
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1202 as separate arguments or as a vector.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1203
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1204 @item event
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1205 An event such as @code{error}, @code{interrupt}, or @code{warning}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1206 (@pxref{XREFdbstop,,dbstop} for details).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1207 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1208
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1209 When called without a line number specification all breakpoints in the named
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1210 function are cleared.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1211
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1212 If the requested line is not a breakpoint no action is performed.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1213
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1214 The special keyword @qcode{"all"} will clear all breakpoints from all
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1215 files.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1216 @seealso{dbstop, dbstatus, dbwhere}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1217 @end deftypefn */)
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1218 {
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1219 std::string symbol_name = ""; // stays empty for "dbclear if error" etc
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1220 bp_table::intmap lines;
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1221 std::string dummy; // "if" condition -- only used for dbstop
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1222
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1223 int nargin = args.length ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1224
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1225 parse_dbfunction_params ("dbclear", args, symbol_name, lines, dummy);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1226
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1227 if (nargin == 1 && symbol_name == "all")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1228 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1229 bp_table::remove_all_breakpoints ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1230 bp_table::dbclear_all_signals ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1231 }
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
1232 else
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1233 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1234 if (symbol_name != "")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1235 bp_table::remove_breakpoint (symbol_name, lines);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1236 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1237
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1238 return ovl ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1239 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1240
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1241 // Report the status of "dbstop if error ..." and "dbstop if warning ..."
21562
6c2fd62db1f7 maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents: 21547
diff changeset
1242 // If to_screen is true, the output goes to octave_stdout; otherwise it is
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1243 // returned.
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1244 // If dbstop if error is true but no explicit IDs are specified, the return
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1245 // value will have an empty field called "errs". If IDs are specified, the
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1246 // "errs" field will have a row per ID. If dbstop if error is false, there
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1247 // is no "errs" field. The "warn" field is set similarly by dbstop if warning
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1248 octave_map
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1249 bp_table::stop_on_err_warn_status (bool to_screen)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1250 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1251 octave_map retval;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1252
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1253 // print dbstop if error information
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1254 if (Vdebug_on_error)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1255 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1256 if (errors_that_stop.empty ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1257 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1258 if (to_screen)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1259 octave_stdout << "stop if error\n";
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1260 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1261 retval.assign ("errs", octave_value(""));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1262 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1263 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1264 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1265 Cell errs (dim_vector (bp_table::errors_that_stop.size (), 1));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1266 int i = 0;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1267
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1268 for (const auto& e : errors_that_stop)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1269 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1270 if (to_screen)
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1271 octave_stdout << "stop if error " << e << "\n";
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1272 else
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1273 errs(i++) = e;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1274 }
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1275 if (! to_screen)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1276 retval.assign ("errs", octave_value (errs));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1277 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1278 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1279
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1280 // print dbstop if caught error information
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1281 if (Vdebug_on_caught)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1282 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1283 if (caught_that_stop.empty ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1284 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1285 if (to_screen)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1286 octave_stdout << "stop if caught error\n";
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1287 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1288 retval.assign ("caught", octave_value(""));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1289 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1290 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1291 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1292 Cell errs (dim_vector (caught_that_stop.size (), 1));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1293 int i = 0;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1294
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1295 for (const auto& e : caught_that_stop)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1296 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1297 if (to_screen)
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1298 octave_stdout << "stop if caught error " << e << "\n";
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1299 else
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1300 errs(i++) = e;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1301 }
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1302 if (! to_screen)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1303 retval.assign ("caught", octave_value (errs));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1304 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1305 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1306
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1307 // print dbstop if warning information
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1308 if (Vdebug_on_warning)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1309 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1310 if (warnings_that_stop.empty ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1311 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1312 if (to_screen)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1313 octave_stdout << "stop if warning\n";
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1314 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1315 retval.assign ("warn", octave_value(""));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1316 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1317 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1318 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1319 Cell warn (dim_vector (warnings_that_stop.size (), 1));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1320 int i = 0;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1321
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1322 for (const auto& w : warnings_that_stop)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1323 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1324 if (to_screen)
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1325 octave_stdout << "stop if warning " << w << "\n";
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1326 else
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1327 warn(i++) = w;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1328 }
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1329 if (! to_screen)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1330 retval.assign ("warn", octave_value (warn));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1331 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1332 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1333
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1334 // print dbstop if interrupt information
22051
6db928d06b07 move signal functions into octave namespace
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
1335 if (octave::Vdebug_on_interrupt)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1336 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1337 if (to_screen)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1338 octave_stdout << "stop if interrupt\n";
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1339 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1340 retval.assign ("intr", octave_value ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1341 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1342
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1343 return retval;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1344 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1345
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1346 DEFUN (dbstatus, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1347 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1348 @deftypefn {} {} dbstatus
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1349 @deftypefnx {} {} dbstatus @var{func}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1350 @deftypefnx {} {@var{bp_list} =} dbstatus @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1351 Report the location of active breakpoints.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1352
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1353 When called with no input or output arguments, print the list of all
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1354 functions with breakpoints and the line numbers where those breakpoints are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1355 set.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1356
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1357 If a function name @var{func} is specified then only report breakpoints
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1358 for the named function and its subfunctions.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1359
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1360 The optional return argument @var{bp_list} is a struct array with the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1361 following fields.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1362
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1363 @table @asis
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1364 @item name
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1365 The name of the function with a breakpoint. A subfunction, say @code{func2}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1366 within an m-file, say @file{file.m}, is specified as @code{file>func2}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1367
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1368 @item file
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1369 The name of the m-file where the function code is located.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1370
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1371 @item line
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1372 The line number with the breakpoint.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1373
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1374 @item cond
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1375 The condition that must be satisfied for the breakpoint to be active, or
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1376 the empty string for unconditional breakpoints.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1377 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1378
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1379 @c Note: When @code{dbstatus} is called from the debug prompt within a function,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1380 @c the list of breakpoints is automatically trimmed to the breakpoints in the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1381 @c current function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1382 If @code{dbstop if error} is true but no explicit IDs are specified, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1383 return value will have an empty field called @qcode{"errs"}. If IDs are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1384 specified, the @code{errs} field will have one row per ID@. If
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1385 @code{dbstop if error} is false, there is no @qcode{"errs"} field.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1386 The @qcode{"warn"} field is set similarly by @code{dbstop if warning}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1387
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1388 @seealso{dbstop, dbclear, dbwhere, dblist, dbstack}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1389 @end deftypefn */)
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1390 {
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1391 int nargin = args.length ();
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1392
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1393 if (nargin != 0 && nargin != 1)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1394 error ("dbstatus: only zero or one arguments accepted\n");
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1395
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
1396 octave_value_list fcn_list;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1397 bp_table::fname_bp_map bp_list;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1398 std::string symbol_name;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1399
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1400 if (nargin == 1)
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1401 {
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
1402 if (! args(0).is_string ())
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21094
diff changeset
1403 err_wrong_type_arg ("dbstatus", args(0));
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
1404
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
1405 symbol_name = args(0).string_value ();
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
1406 fcn_list(0) = symbol_name;
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
1407 bp_list = bp_table::get_breakpoint_list (fcn_list);
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
1408 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
1409 else
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
1410 {
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1411 /*
18376
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
1412 if (Vdebugging)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
1413 {
18376
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
1414 octave_user_code *dbg_fcn = get_user_code ();
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
1415 if (dbg_fcn)
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
1416 {
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
1417 symbol_name = dbg_fcn->name ();
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
1418 fcn_list(0) = symbol_name;
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
1419 }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
1420 }
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1421 */
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1422
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
1423 bp_list = bp_table::get_breakpoint_list (fcn_list);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1424 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1425
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1426 if (nargout == 0)
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1427 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1428 // Print out the breakpoint information.
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1429
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1430 for (auto& fnm_bp_p: bp_list)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1431 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1432 std::list<bp_type> m = fnm_bp_p.second;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1433
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1434 // print unconditional breakpoints, if any, on a single line
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1435
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1436 // first, check to see if there are any
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1437 int have_unconditional = 0;
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1438 for (const auto& bp : m)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1439 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1440 if (bp.cond == "")
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1441 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1442 if (have_unconditional++)
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1443 break; // stop once we know its plural
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1444 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1445 }
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1446 // If we actually have some, print line numbers only
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1447 if (have_unconditional)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1448 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1449 const char *_s_ = (have_unconditional > 1) ? "s" : "";
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1450 octave_stdout << "breakpoint" << _s_ <<" in " << fnm_bp_p.first
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1451 << " at line" << _s_ << " ";
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1452
21877
dc0347131364 maint: More code cleanup for debug.cc and C++11.
Rik <rik@octave.org>
parents: 21875
diff changeset
1453 for (const auto& bp : m)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1454 {
21877
dc0347131364 maint: More code cleanup for debug.cc and C++11.
Rik <rik@octave.org>
parents: 21875
diff changeset
1455 if (bp.cond == "")
dc0347131364 maint: More code cleanup for debug.cc and C++11.
Rik <rik@octave.org>
parents: 21875
diff changeset
1456 octave_stdout << bp.line << " ";
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1457 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1458 octave_stdout << std::endl;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1459 }
14228
0beb62668d69 Use correct plural for dbstatus if there is more than 1 breakpoint set in file.
Rik <octave@nomad.inbox5.com>
parents: 14227
diff changeset
1460
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1461 // print conditional breakpoints, one per line, with conditions
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1462 for (const auto& bp : m)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1463 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1464 if (bp.cond != "")
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1465 octave_stdout << "breakpoint in " << fnm_bp_p.first
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1466 << " at line " << bp.line
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1467 << " if " << bp.cond << "\n";
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1468 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1469 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1470
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1471 bp_table::stop_on_err_warn_status (true);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1472
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1473 return ovl ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1474 }
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1475 else
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1476 {
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1477 // Fill in an array for return.
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1478 int i = 0;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1479 octave_map retmap;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1480 octave_value retval;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1481
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1482 // count the number of breakpoints in all files
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1483 int count = 0;
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1484 for (const auto& fnm_bp_p : bp_list)
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1485 count += fnm_bp_p.second.size ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1486
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1487 Cell names (dim_vector (count, 1));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1488 Cell file (dim_vector (count, 1));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1489 Cell line (dim_vector (count, 1));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1490 Cell cond (dim_vector (count, 1));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1491
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1492 for (const auto& fnm_bp_p : bp_list)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1493 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1494 std::string filename = fnm_bp_p.first;
21258
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
1495 const char *sub_fun = strchr (filename.c_str (), Vfilemarker);
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1496 if (sub_fun)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1497 filename = filename.substr(0, sub_fun - filename.c_str ());
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1498 octave_value path_name;
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1499 path_name = octave::sys::canonicalize_file_name (do_which (filename));
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1500
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1501 for (const auto& bp : fnm_bp_p.second)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1502 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1503 names(i) = fnm_bp_p.first;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1504 file(i) = path_name;
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1505 line(i) = octave_value (bp.line);
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1506 cond(i) = octave_value (bp.cond);
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1507 i++;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1508 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1509 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1510
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1511 retmap.assign ("name", names);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1512 retmap.assign ("file", file);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1513 retmap.assign ("line", line);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1514 retmap.assign ("cond", cond);
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
1515
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1516 octave_map ew = bp_table::stop_on_err_warn_status (false);
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
1517 if (ew.is_empty ())
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1518 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1519 retval = octave_value (retmap);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1520 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1521 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1522 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1523 octave_map outer (dim_vector (3,1));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1524 outer.assign ("bkpt", Cell (retmap));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1525 for (octave_map::const_iterator f = ew.begin (); f != ew.end (); f++)
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1526 outer.setfield (f->first, ew.contents (f));
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1527
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1528 retval = octave_value (outer);
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1529 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1530
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
1531 return retval;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1532 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1533 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1534
21258
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
1535 /*
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
1536 %!test
21645
9810e483b42f Fix dbstop BIST tests on Windows platforms.
Rik <rik@octave.org>
parents: 21628
diff changeset
1537 %! dbclear all; # Clear out breakpoints before test
21258
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
1538 %! dbstop @ftp/dir;
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
1539 %! dbstop @audioplayer/set 70;
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
1540 %! dbstop quantile>__quantile__;
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
1541 %! dbstop ls;
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1542 %! s = dbstatus;
21703
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
1543 %! dbclear all;
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
1544 %! assert (s(1).name, "@audioplayer/set>setproperty");
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
1545 %! assert (s(2).name, "@ftp/dir");
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
1546 %! assert (s(3).name, "ls");
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
1547 %! assert (s(4).name, "quantile>__quantile__");
21645
9810e483b42f Fix dbstop BIST tests on Windows platforms.
Rik <rik@octave.org>
parents: 21628
diff changeset
1548 %! assert (s(2).file(end-10:end), [filesep "@ftp" filesep "dir.m"]);
21258
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
1549 */
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
1550
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1551 DEFUN (dbwhere, , ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1552 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1553 @deftypefn {} {} dbwhere
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1554 In debugging mode, report the current file and line number where execution
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1555 is stopped.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1556 @seealso{dbstack, dblist, dbstatus, dbcont, dbstep, dbup, dbdown}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1557 @end deftypefn */)
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1558 {
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
1559 octave_user_code *dbg_fcn = get_user_code ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1560
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1561 if (! dbg_fcn)
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1562 {
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1563 octave_stdout << "stopped at top level" << std::endl;
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1564 return ovl ();
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1565 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1566
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1567 octave_stdout << "stopped in " << dbg_fcn->name () << " at ";
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1568
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1569 int l = octave_call_stack::debug_user_code_line ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1570
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1571 if (l > 0)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1572 {
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1573 octave_stdout << "line " << l;
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1574
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1575 std::string file_name = dbg_fcn->fcn_file_name ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1576
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1577 if (! file_name.empty ())
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1578 {
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1579 octave_stdout << " [" << file_name << "]" << std::endl;
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1580
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1581 std::string line = get_file_line (file_name, l);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1582
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1583 if (! line.empty ())
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1584 octave_stdout << l << ": " << line << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1585 }
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1586 else
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1587 octave_stdout << std::endl;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1588 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1589 else
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1590 octave_stdout << "<unknown line>" << std::endl;
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1591
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1592 return ovl ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1593 }
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1594
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
1595 void
3949
294f13627ee8 [project @ 2002-05-23 01:22:11 by jwe]
jwe
parents: 3948
diff changeset
1596 do_dbtype (std::ostream& os, const std::string& name, int start, int end)
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1597 {
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1598 std::string ff = fcn_file_in_path (name);
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1599
21077
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1600 if (ff.empty ())
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1601 os << "dbtype: unknown function " << name << "\n";
21077
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1602 else
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1603 {
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1604 std::ifstream fs (ff.c_str (), std::ios::in);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1605
21077
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1606 if (! fs)
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1607 os << "dbtype: unable to open '" << ff << "' for reading!\n";
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1608 else
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1609 {
21077
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1610 int line = 1;
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1611 std::string text;
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1612
21077
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1613 while (std::getline (fs, text) && line <= end)
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1614 {
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1615 if (line >= start)
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1616 os << line << "\t" << text << "\n";
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1617
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1618 line++;
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1619 }
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1620 }
21077
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
1621 }
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1622
6646
bd0a70c3f2db [project @ 2007-05-22 02:27:43 by jwe]
jwe
parents: 6317
diff changeset
1623 os.flush ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1624 }
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1625
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1626 DEFUN (dbtype, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1627 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1628 @deftypefn {} {} dbtype
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1629 @deftypefnx {} {} dbtype @var{lineno}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1630 @deftypefnx {} {} dbtype @var{startl:endl}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1631 @deftypefnx {} {} dbtype @var{startl:end}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1632 @deftypefnx {} {} dbtype @var{func}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1633 @deftypefnx {} {} dbtype @var{func} @var{lineno}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1634 @deftypefnx {} {} dbtype @var{func} @var{startl:endl}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1635 @deftypefnx {} {} dbtype @var{func} @var{startl:end}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1636 Display a script file with line numbers.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1637
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1638 When called with no arguments in debugging mode, display the script file
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1639 currently being debugged.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1640
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1641 An optional range specification can be used to list only a portion of the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1642 file. The special keyword @qcode{"end"} is a valid line number
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1643 specification for the last line of the file.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1644
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1645 When called with the name of a function, list that script file with line
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1646 numbers.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1647 @seealso{dblist, dbwhere, dbstatus, dbstop}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1648 @end deftypefn */)
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1649 {
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
1650 octave_user_code *dbg_fcn;
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
1651
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1652 string_vector argv = args.make_argv ("dbtype");
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
1653
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
1654 switch (args.length ())
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1655 {
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1656 case 0: // dbtype
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1657 dbg_fcn = get_user_code ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1658
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1659 if (! dbg_fcn)
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1660 error ("dbtype: must be inside a user function to give no arguments to dbtype\n");
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1661
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1662 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1663 0, std::numeric_limits<int>::max ());
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1664
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1665 break;
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1666
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1667 case 1: // (dbtype start:end) || (dbtype func) || (dbtype lineno)
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1668 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1669 std::string arg = argv[1];
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1670
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1671 size_t ind = arg.find (':');
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1672
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1673 if (ind != std::string::npos) // (dbtype start:end)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1674 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1675 dbg_fcn = get_user_code ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1676
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1677 if (dbg_fcn)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1678 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1679 std::string start_str = arg.substr (0, ind);
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1680 std::string end_str = arg.substr (ind + 1);
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1681
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1682 int start, end;
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1683 start = atoi (start_str.c_str ());
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1684 if (end_str == "end")
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1685 end = std::numeric_limits<int>::max ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1686 else
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1687 end = atoi (end_str.c_str ());
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1688
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1689 if (std::min (start, end) <= 0)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20819
diff changeset
1690 error ("dbtype: start and end lines must be >= 1\n");
18393
6a2cc29f55fc Correctly handle 'dbtype lineno' case.
Rik <rik@octave.org>
parents: 18392
diff changeset
1691
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1692 if (start > end)
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1693 error ("dbtype: start line must be less than end line\n");
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1694
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1695 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1696 start, end);
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1697 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1698 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1699 else // (dbtype func) || (dbtype lineno)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1700 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1701 int line = atoi (arg.c_str ());
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1702
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1703 if (line == 0) // (dbtype func)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1704 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1705 dbg_fcn = get_user_code (arg);
14227
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1706
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1707 if (! dbg_fcn)
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1708 error ("dbtype: function <%s> not found\n", arg.c_str ());
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1709
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1710 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1711 0, std::numeric_limits<int>::max ());
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1712 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1713 else // (dbtype lineno)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1714 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1715 if (line <= 0)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20819
diff changeset
1716 error ("dbtype: start and end lines must be >= 1\n");
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1717
14227
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1718 dbg_fcn = get_user_code ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1719
14227
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1720 if (dbg_fcn)
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1721 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1722 line, line);
14227
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1723 }
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1724 }
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1725 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1726 break;
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1727
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
1728 case 2: // (dbtype func start:end) || (dbtype func start)
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1729 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1730 dbg_fcn = get_user_code (argv[1]);
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1731
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1732 if (! dbg_fcn)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1733 error ("dbtype: function <%s> not found\n", argv[1].c_str ());
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1734
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1735 std::string arg = argv[2];
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1736 int start, end;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1737 size_t ind = arg.find (':');
6317
8c67f8be341d [project @ 2007-02-16 08:10:53 by jwe]
jwe
parents: 5744
diff changeset
1738
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1739 if (ind != std::string::npos)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1740 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1741 std::string start_str = arg.substr (0, ind);
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1742 std::string end_str = arg.substr (ind + 1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1743
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1744 start = atoi (start_str.c_str ());
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1745 if (end_str == "end")
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1746 end = std::numeric_limits<int>::max ();
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1747 else
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1748 end = atoi (end_str.c_str ());
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1749 }
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1750 else
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1751 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1752 start = atoi (arg.c_str ());
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1753 end = start;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1754 }
14227
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1755
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1756 if (std::min (start, end) <= 0)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1757 error ("dbtype: start and end lines must be >= 1\n");
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1758
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1759 if (start > end)
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1760 error ("dbtype: start line must be less than end line\n");
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1761
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1762 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), start, end);
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1763 }
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1764 break;
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1765
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1766 default:
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1767 error ("dbtype: expecting zero, one, or two arguments\n");
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1768 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1769
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1770 return ovl ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1771 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1772
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1773 DEFUN (dblist, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1774 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1775 @deftypefn {} {} dblist
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1776 @deftypefnx {} {} dblist @var{n}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1777 In debugging mode, list @var{n} lines of the function being debugged
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1778 centered around the current line to be executed.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1779
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1780 If unspecified @var{n} defaults to 10 (+/- 5 lines)
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1781 @seealso{dbwhere, dbtype, dbstack}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1782 @end deftypefn */)
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1783 {
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1784 int n = 10;
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1785
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1786 if (args.length () == 1)
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1787 {
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1788 octave_value arg = args(0);
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1789
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1790 if (arg.is_string ())
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1791 {
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1792 std::string s_arg = arg.string_value ();
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1793
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1794 n = atoi (s_arg.c_str ());
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1795 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1796 else
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1797 n = args(0).int_value ();
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1798
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1799 if (n < 0)
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1800 error ("dblist: N must be a non-negative integer");
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1801 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1802
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1803 octave_user_code *dbg_fcn = get_user_code ();
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1804
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1805 if (! dbg_fcn)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1806 error ("dblist: must be inside a user function to use dblist\n");
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1807
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1808 bool have_file = true;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1809
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1810 std::string name = dbg_fcn->fcn_file_name ();
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1811
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1812 if (name.empty ())
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1813 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1814 have_file = false;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1815 name = dbg_fcn->name ();
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1816 }
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1817
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
1818 int l = octave_call_stack::debug_user_code_line ();
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1819
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1820 if (l > 0)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1821 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1822 if (have_file)
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1823 {
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1824 int l_min = std::max (l - n/2, 0);
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1825 int l_max = l + n/2;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1826 do_dbtype (octave_stdout, name, l_min, l-1);
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1827
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1828 std::string line = get_file_line (name, l);
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1829 if (! line.empty ())
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1830 octave_stdout << l << "-->\t" << line << std::endl;
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1831
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1832 do_dbtype (octave_stdout, name, l+1, l_max);
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1833 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1834 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1835 else
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1836 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1837 octave_stdout << "dblist: unable to determine source code line"
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1838 << std::endl;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1839 }
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1840
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1841 return ovl ();
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1842 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1843
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1844 static octave_value_list
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1845 do_dbstack (const octave_value_list& args, int nargout, std::ostream& os)
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1846 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1847 int nargin = args.length ();
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1848
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1849 if (nargin > 2)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1850 print_usage ();
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1851
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1852 octave_value_list retval;
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1853
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
1854 octave::unwind_protect frame;
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1855
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7897
diff changeset
1856 octave_idx_type curr_frame = -1;
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1857
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7897
diff changeset
1858 size_t nskip = 0;
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1859
20817
3d551b2ae928 Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents: 20804
diff changeset
1860 if (nargin == 1 || nargin == 2)
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1861 {
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1862 int n = 0;
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1863
20817
3d551b2ae928 Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents: 20804
diff changeset
1864 for (octave_idx_type i = 0; i < nargin; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1865 {
17649
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1866 octave_value arg = args(i);
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1867
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1868 if (arg.is_string ())
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1869 {
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1870 std::string s_arg = arg.string_value ();
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1871
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1872 // Skip "-completenames", octave returns full names anyway.
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1873 if (s_arg == "-completenames")
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1874 continue;
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1875
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1876 n = atoi (s_arg.c_str ());
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1877 }
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1878 else
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1879 n = arg.int_value ();
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1880
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1881 if (n <= 0)
17649
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1882 error ("dbstack: N must be a non-negative integer");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1883 }
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1884
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1885 if (n > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1886 nskip = n;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1887 }
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1888
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1889 if (nargout == 0)
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1890 {
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1891 octave_map stk = octave_call_stack::backtrace (nskip, curr_frame);
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1892 octave_idx_type nframes_to_display = stk.numel ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1893
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1894 if (nframes_to_display > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1895 {
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1896 octave_preserve_stream_state stream_state (os);
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1897
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1898 os << "stopped in:\n\n";
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1899
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1900 Cell names = stk.contents ("name");
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1901 Cell files = stk.contents ("file");
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1902 Cell lines = stk.contents ("line");
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1903
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1904 bool show_top_level = true;
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1905
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1906 size_t max_name_len = 0;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1907
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1908 for (octave_idx_type i = 0; i < nframes_to_display; i++)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1909 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1910 std::string name = names(i).string_value ();
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1911
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1912 max_name_len = std::max (name.length (), max_name_len);
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1913 }
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1914
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1915 for (octave_idx_type i = 0; i < nframes_to_display; i++)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1916 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1917 std::string name = names(i).string_value ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1918 std::string file = files(i).string_value ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1919 int line = lines(i).int_value ();
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1920
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1921 if (show_top_level && i == curr_frame)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1922 show_top_level = false;
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1923
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1924 os << (i == curr_frame ? " --> " : " ")
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1925 << std::setw (max_name_len) << name
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1926 << " at line " << line
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1927 << " [" << file << "]"
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1928 << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1929 }
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1930
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1931 if (show_top_level)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1932 os << " --> top level" << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1933 }
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1934 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1935 else
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1936 {
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1937 octave_map stk = octave_call_stack::backtrace (nskip, curr_frame, false);
18440
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18398
diff changeset
1938
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1939 retval = ovl (stk, curr_frame < 0 ? 1 : curr_frame + 1);
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1940 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1941
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1942 return retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1943 }
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1944
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1945 // A function that can be easily called from a debugger print the Octave stack.
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1946 // This can be useful for finding what line of code the interpreter is
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1947 // currently executing when the debugger is stopped in some C++ function,
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1948 // for example.
13326
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
1949
13784
0bbe319bf26b octave_class::size: return matrix with correct dimensions
John W. Eaton <jwe@octave.org>
parents: 13689
diff changeset
1950 void
13326
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
1951 show_octave_dbstack (void)
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
1952 {
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1953 do_dbstack (octave_value_list (), 0, std::cerr);
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1954 }
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1955
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1956 DEFUN (dbstack, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1957 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1958 @deftypefn {} {} dbstack
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1959 @deftypefnx {} {} dbstack @var{n}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1960 @deftypefnx {} {} dbstack @var{-completenames}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1961 @deftypefnx {} {[@var{stack}, @var{idx}] =} dbstack (@dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1962 Display or return current debugging function stack information.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1963
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1964 With optional argument @var{n}, omit the @var{n} innermost stack frames.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1965
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1966 Although accepted, the argument @var{-completenames} is silently ignored.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1967 Octave always returns absolute filenames.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1968
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1969 The arguments @var{n} and @var{-completenames} can be both specified in any
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1970 order.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1971
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1972 The optional return argument @var{stack} is a struct array with the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1973 following fields:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1974
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1975 @table @asis
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1976 @item file
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1977 The name of the m-file where the function code is located.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1978
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1979 @item name
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1980 The name of the function with a breakpoint.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1981
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1982 @item line
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1983 The line number of an active breakpoint.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1984
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1985 @item column
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1986 The column number of the line where the breakpoint begins.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1987
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1988 @item scope
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1989 Undocumented.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1990
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1991 @item context
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1992 Undocumented.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1993 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1994
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1995 The return argument @var{idx} specifies which element of the @var{stack}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1996 struct array is currently active.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1997 @seealso{dbup, dbdown, dbwhere, dblist, dbstatus}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1998 @end deftypefn */)
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1999 {
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
2000 return do_dbstack (args, nargout, octave_stdout);
13326
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
2001 }
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
2002
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2003 static void
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2004 do_dbupdown (const octave_value_list& args, const std::string& who)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2005 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2006 int n = 1;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2007
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2008 if (args.length () == 1)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2009 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2010 octave_value arg = args(0);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2011
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2012 if (arg.is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2013 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2014 std::string s_arg = arg.string_value ();
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2015
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2016 n = atoi (s_arg.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2017 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2018 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2019 n = args(0).int_value ();
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2020 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2021
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
2022 if (who == "dbup")
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
2023 n = -n;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2024
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
2025 if (! octave_call_stack::goto_frame_relative (n, true))
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
2026 error ("%s: invalid stack frame", who.c_str ());
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2027 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2028
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
2029 DEFUN (dbup, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2030 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2031 @deftypefn {} {} dbup
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2032 @deftypefnx {} {} dbup @var{n}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2033 In debugging mode, move up the execution stack @var{n} frames.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2034
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2035 If @var{n} is omitted, move up one frame.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2036 @seealso{dbstack, dbdown}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2037 @end deftypefn */)
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2038 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2039 do_dbupdown (args, "dbup");
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2040
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
2041 return ovl ();
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2042 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2043
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
2044 DEFUN (dbdown, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2045 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2046 @deftypefn {} {} dbdown
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2047 @deftypefnx {} {} dbdown @var{n}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2048 In debugging mode, move down the execution stack @var{n} frames.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2049
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2050 If @var{n} is omitted, move down one frame.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2051 @seealso{dbstack, dbup}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2052 @end deftypefn */)
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2053 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
2054 do_dbupdown (args, "dbdown");
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
2055
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
2056 return ovl ();
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
2057 }
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
2058
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
2059 DEFUN (dbstep, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2060 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2061 @deftypefn {} {} dbstep
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2062 @deftypefnx {} {} dbstep @var{n}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2063 @deftypefnx {} {} dbstep in
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2064 @deftypefnx {} {} dbstep out
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2065 @deftypefnx {} {} dbnext @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2066 In debugging mode, execute the next @var{n} lines of code.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2067
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2068 If @var{n} is omitted, execute the next single line of code. If the next
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2069 line of code is itself defined in terms of an m-file remain in the existing
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2070 function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2071
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2072 Using @code{dbstep in} will cause execution of the next line to step into
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2073 any m-files defined on the next line.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2074
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2075 Using @code{dbstep out} will cause execution to continue until the current
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2076 function returns.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2077
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2078 @code{dbnext} is an alias for @code{dbstep}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2079 @seealso{dbcont, dbquit}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2080 @end deftypefn */)
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2081 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2082 if (! Vdebugging)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2083 error ("dbstep: can only be called in debug mode");
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2084
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2085 int nargin = args.length ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2086
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2087 if (nargin > 1)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2088 print_usage ();
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
2089
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2090 if (nargin == 1)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2091 {
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2092 std::string arg = args(0).xstring_value ("dbstep: input argument must be a string");
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2093
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2094 if (arg == "in")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2095 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2096 Vdebugging = false;
22164
5d4a286061c8 Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22094
diff changeset
2097 Vtrack_line_num = true;
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2098
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2099 octave::tree_evaluator::dbstep_flag = -1;
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2100 }
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2101 else if (arg == "out")
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2102 {
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2103 Vdebugging = false;
22164
5d4a286061c8 Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22094
diff changeset
2104 Vtrack_line_num = true;
20582
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20557
diff changeset
2105
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2106 octave::tree_evaluator::dbstep_flag = -2;
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2107 }
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2108 else
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2109 {
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2110 int n = atoi (arg.c_str ());
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2111
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
2112 if (n < 1)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
2113 error ("dbstep: invalid argument");
19743
67f2c76f9f4d Remove unnecessary checking of error_state after is_string validation.
Rik <rik@octave.org>
parents: 19697
diff changeset
2114
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
2115 Vdebugging = false;
22164
5d4a286061c8 Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22094
diff changeset
2116 Vtrack_line_num = true;
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
2117
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2118 octave::tree_evaluator::dbstep_flag = n;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
2119 }
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2120 }
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2121 else
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2122 {
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2123 Vdebugging = false;
22164
5d4a286061c8 Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22094
diff changeset
2124 Vtrack_line_num = true;
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2125
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2126 octave::tree_evaluator::dbstep_flag = 1;
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2127 }
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2128
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
2129 return ovl ();
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2130 }
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2131
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
2132 DEFALIAS (dbnext, dbstep);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
2133
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
2134 DEFUN (dbcont, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2135 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2136 @deftypefn {} {} dbcont
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2137 Leave command-line debugging mode and continue code execution normally.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2138 @seealso{dbstep, dbquit}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2139 @end deftypefn */)
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2140 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2141 if (! Vdebugging)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2142 error ("dbcont: can only be called in debug mode");
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
2143
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2144 if (args.length () != 0)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2145 print_usage ();
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
2146
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2147 Vdebugging = false;
22164
5d4a286061c8 Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22094
diff changeset
2148 Vtrack_line_num = true;
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2149
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2150 octave::tree_evaluator::reset_debug_state ();
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2151
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
2152 return ovl ();
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2153 }
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2154
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
2155 DEFUN (dbquit, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2156 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2157 @deftypefn {} {} dbquit
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2158 Quit debugging mode immediately without further code execution and return to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2159 the Octave prompt.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2160 @seealso{dbcont, dbstep}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2161 @end deftypefn */)
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2162 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2163 if (! Vdebugging)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2164 error ("dbquit: can only be called in debug mode");
10186
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
2165
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2166 if (args.length () != 0)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2167 print_usage ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
2168
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2169 Vdebugging = false;
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
2170
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2171 octave::tree_evaluator::reset_debug_state ();
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2172
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2173 octave_throw_interrupt_exception ();
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2174
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
2175 return ovl ();
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2176 }
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
2177
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
2178 DEFUN (isdebugmode, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2179 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2180 @deftypefn {} {} isdebugmode ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2181 Return true if in debugging mode, otherwise false.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2182 @seealso{dbwhere, dbstack, dbstatus}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2183 @end deftypefn */)
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
2184 {
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
2185 if (args.length () != 0)
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
2186 print_usage ();
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
2187
21127
df7891224709 maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents: 21118
diff changeset
2188 return ovl (Vdebugging);
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
2189 }
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
2190
19855
a59c5a16c9ab Rename db_next_breakpoint_quiet to internal function.
Rik <rik@octave.org>
parents: 19743
diff changeset
2191 DEFUN (__db_next_breakpoint_quiet__, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2192 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2193 @deftypefn {} {} __db_next_breakpoint_quiet__ ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2194 @deftypefnx {} {} __db_next_breakpoint_quiet__ (@var{flag})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2195 Disable line info printing at the next breakpoint.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2196
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2197 With a logical argument @var{flag}, set the state on or off.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
2198 @end deftypefn */)
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
2199 {
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
2200 int nargin = args.length ();
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
2201
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
2202 if (nargin > 1)
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
2203 print_usage ();
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
2204
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
2205 bool state = true;
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
2206
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
2207 if (nargin == 1)
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
2208 state = args(0).bool_value ();
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
2209
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2210 octave::tree_evaluator::quiet_breakpoint_flag = state;
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
2211
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
2212 return ovl ();
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
2213 }
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
2214