annotate src/debug.cc @ 14164:a737b3fb9c4d stable ss-3-5-92

snapshot 3.5.92 * configure.ac (AC_INIT): Version is now 3.5.92. (OCTAVE_RELEASE_DATE): Now 2012-01-06.
author John W. Eaton <jwe@octave.org>
date Fri, 06 Jan 2012 14:34:06 -0500
parents 72c96de7a403
children c24833c6ebc2 d174210ce1ec
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
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 14049
diff changeset
3 Copyright (C) 2001-2012 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 */
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
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>
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
31 #include <set>
3948
126177939aae [project @ 2002-05-23 01:17:29 by jwe]
jwe
parents: 3947
diff changeset
32 #include <string>
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
33
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
34 #include "file-stat.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
35 #include "singleton-cleanup.h"
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
36
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
37 #include "defun.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
38 #include "error.h"
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
39 #include "help.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
40 #include "input.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
41 #include "pager.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
42 #include "oct-obj.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
43 #include "utils.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
44 #include "parse.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
45 #include "symtab.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
46 #include "gripes.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
47 #include "ov.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
48 #include "ov-usr-fcn.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
49 #include "ov-fcn.h"
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
50 #include "ov-struct.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
51 #include "pt-pr-code.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
52 #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
53 #include "pt-eval.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
54 #include "pt-stmt.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
55 #include "toplev.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
56 #include "unwind-prot.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
57 #include "variables.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
58
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
59 #include "debug.h"
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
60
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
61 // Initialize the singleton object
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
62 bp_table *bp_table::instance = 0;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
63
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
64 static std::string
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
65 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
66 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
67 std::string retval;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
68
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
69 file_stat fs (fname);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
70
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
71 if (fs)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
72 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
73 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
74
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
75 std::ifstream file (fname.c_str (), std::ios::in|std::ios::binary);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
76
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
77 if (file)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
78 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
79 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
80
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
81 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
82
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
83 if (file.eof ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
84 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
85 // Expected to read the entire file.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
86
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
87 retval = buf;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
88 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
89 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
90 error ("error reading file %s", fname.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
91 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
92 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
93
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
94 return retval;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
95 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
96
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
97 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
98 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
99 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
100 // This could maybe be smarter. Is deque the right thing to use
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
101 // here?
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 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
104
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
105 offsets.push_back (0);
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 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
108
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
109 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
110 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
111 char c = buf[i];
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
112
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
113 if (c == '\r' && ++i < len)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
114 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
115 c = buf[i];
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
116
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
117 if (c == '\n')
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
118 offsets.push_back (i+1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
119 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
120 offsets.push_back (i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
121 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
122 else if (c == '\n')
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
123 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
124 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
125
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
126 offsets.push_back (len);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
127
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
128 return offsets;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
129 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
130
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
131 std::string
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
132 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
133 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
134 std::string retval;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
135
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
136 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
137
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
138 static std::string buf;
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 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
141
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
142 if (fname != last_fname)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
143 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
144 buf = snarf_file (fname);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
145
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
146 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
147 }
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 if (line > 0)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
150 line--;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
151
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
152 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
153 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
154 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
155 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
156
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
157 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
158 eol--;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
159
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
160 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
161 }
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 return retval;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
164 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
165
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5645
diff changeset
166 // 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
167 // 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
168 // current call stack.
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
169
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
170 static octave_user_code *
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
171 get_user_code (const std::string& fname = std::string ())
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
172 {
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
173 octave_user_code *dbg_fcn = 0;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
174
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
175 if (fname.empty ())
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7901
diff changeset
176 dbg_fcn = octave_call_stack::caller_user_code ();
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5645
diff changeset
177 else
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
178 {
7539
3e107d73aeb4 debug.cc: use find_function instead of find_user_function
John Swensen
parents: 7348
diff changeset
179 octave_value fcn = symbol_table::find_function (fname);
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
180
8123
eb2beef9a9ff clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents: 8114
diff changeset
181 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
182 dbg_fcn = fcn.user_code_value ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
183 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
184
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
185 return dbg_fcn;
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
186 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
187
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
188 static void
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
189 parse_dbfunction_params (const char *who, const octave_value_list& args,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
190 std::string& symbol_name, bp_table::intmap& lines)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
191 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
192 int nargin = args.length ();
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
193 int idx = 0;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
194 int list_idx = 0;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
195 symbol_name = std::string ();
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
196 lines = bp_table::intmap ();
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
197
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
198 if (args.length () == 0)
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
199 return;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
200
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
201 // If we are already in a debugging function.
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
202 if (octave_call_stack::caller_user_code ())
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
203 {
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
204 idx = 0;
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
205 symbol_name = get_user_code ()->name ();
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
206 }
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
207 else if (args(0).is_map ())
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
208 {
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
209 // Problem because parse_dbfunction_params() can only pass out a
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
210 // single function
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
211 }
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
212 else if (args(0).is_string())
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
213 {
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
214 symbol_name = args(0).string_value ();
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
215 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
216 return;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
217 idx = 1;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
218 }
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
219 else
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
220 error ("%s: invalid parameter specified", who);
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
221
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
222 for (int i = idx; i < nargin; i++ )
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
223 {
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
224 if (args(i).is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
225 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
226 int line = atoi (args(i).string_value().c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
227 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
228 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
229 lines[list_idx++] = line;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
230 }
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
231 else if (args(i).is_map ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
232 octave_stdout << who << ": accepting a struct" << std::endl;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
233 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
234 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
235 const NDArray arg = args(i).array_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
236
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
237 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
238 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
239
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
240 for (octave_idx_type j = 0; j < arg.nelem (); j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
241 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
242 int line = static_cast<int> (arg.elem (j));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
243 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
244 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
245 lines[list_idx++] = line;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
246 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
247
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
248 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
249 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
250 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
251 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
252 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
253
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
254 bool
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
255 bp_table::instance_ok (void)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
256 {
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
257 bool retval = true;
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
258
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
259 if (! instance)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
260 {
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
261 instance = new bp_table ();
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
262
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
263 if (instance)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
264 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
265 }
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
266
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
267 if (! instance)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
268 {
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
269 ::error ("unable to create breakpoint table!");
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
270 retval = false;
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
271 }
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
272
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
273 return retval;
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
274 }
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
275
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
276 bp_table::intmap
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
277 bp_table::do_add_breakpoint (const std::string& fname,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
278 const bp_table::intmap& line)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
279 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
280 intmap retval;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
281
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
282 octave_idx_type len = line.size ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
283
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
284 octave_user_code *dbg_fcn = get_user_code (fname);
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
285
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
286 if (dbg_fcn)
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
287 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
288 tree_statement_list *cmds = dbg_fcn->body ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
289
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
290 if (cmds)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
291 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
292 for (int i = 0; i < len; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
293 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
294 const_intmap_iterator p = line.find (i);
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
295
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
296 if (p != line.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
297 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
298 int lineno = p->second;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
299
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
300 retval[i] = cmds->set_breakpoint (lineno);
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
301
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
302 if (retval[i] != 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
303 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
304 bp_set.insert (fname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
305 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
306 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
307 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
308 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
309 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
310 else
14049
b5a8e245b4eb Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents: 14035
diff changeset
311 error ("add_breakpoint: unable to find the requested function\n");
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
312
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
313 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
314
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
315 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
316 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
317
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
318
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
319 int
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
320 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
321 const bp_table::intmap& line)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
322 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
323 int retval = 0;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
324
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
325 octave_idx_type len = line.size ();
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
326
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
327 if (len == 0)
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
328 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
329 intmap results = remove_all_breakpoints_in_file (fname);
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
330 retval = results.size ();
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
331 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
332 else
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
333 {
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
334 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
335
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
336 if (dbg_fcn)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
337 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
338 tree_statement_list *cmds = dbg_fcn->body ();
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
339
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
340 if (cmds)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
341 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
342 octave_value_list results = cmds->list_breakpoints ();
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
343
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
344 if (results.length () > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
345 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
346 for (int i = 0; i < len; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
347 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
348 const_intmap_iterator p = line.find (i);
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
349
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
350 if (p != line.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
351 cmds->delete_breakpoint (p->second);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
352 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
353
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
354 results = cmds->list_breakpoints ();
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
355
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
356 bp_set_iterator it = bp_set.find (fname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
357 if (results.length () == 0 && it != bp_set.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
358 bp_set.erase (it);
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
359
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
360 }
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
361
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
362 retval = results.length ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
363 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
364 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
365 else
14049
b5a8e245b4eb Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents: 14035
diff changeset
366 error ("remove_breakpoint: unable to find the requested function\n");
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
367 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
368
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
369 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
370
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
371 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
372 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
373
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
374
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
375 bp_table::intmap
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
376 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
377 bool silent)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
378 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
379 intmap retval;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
380
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
381 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
382
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
383 if (dbg_fcn)
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
384 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
385 tree_statement_list *cmds = dbg_fcn->body ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
386
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
387 if (cmds)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
388 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
389 octave_value_list bkpts = cmds->list_breakpoints ();
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
390
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
391 for (int i = 0; i < bkpts.length (); i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
392 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
393 int lineno = static_cast<int> (bkpts(i).int_value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
394 cmds->delete_breakpoint (lineno);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
395 retval[i] = lineno;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
396 }
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
397
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
398 bp_set_iterator it = bp_set.find (fname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
399 if (it != bp_set.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
400 bp_set.erase (it);
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
401
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
402 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
403 }
8123
eb2beef9a9ff clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents: 8114
diff changeset
404 else if (! silent)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
405 error ("remove_all_breakpoint_in_file: "
14049
b5a8e245b4eb Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents: 14035
diff changeset
406 "unable to find the requested function\n");
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
407
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
408 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
409
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
410 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
411 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
412
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
413 void
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
414 bp_table::do_remove_all_breakpoints (void)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
415 {
9183
94ae487acd1b use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents: 9039
diff changeset
416 for (const_bp_set_iterator it = bp_set.begin (); it != bp_set.end (); it++)
94ae487acd1b use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents: 9039
diff changeset
417 remove_all_breakpoints_in_file (*it);
94ae487acd1b use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents: 9039
diff changeset
418
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
419
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
420 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
421 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
422
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
423 std::string
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
424 do_find_bkpt_list (octave_value_list slist,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
425 std::string match)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
426 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
427 std::string retval;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
428
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
429 for (int i = 0; i < slist.length (); i++)
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
430 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
431 if (slist (i).string_value () == match)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
432 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
433 retval = slist(i).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
434 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
435 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
436 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
437
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
438 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
439 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
440
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
441
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
442 bp_table::fname_line_map
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
443 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
444 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
445 fname_line_map retval;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
446
9183
94ae487acd1b use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents: 9039
diff changeset
447 for (bp_set_iterator it = bp_set.begin (); it != bp_set.end (); it++)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
448 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
449 if (fname_list.length () == 0
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
450 || do_find_bkpt_list (fname_list, *it) != "")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
451 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
452 octave_user_code *f = get_user_code (*it);
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
453
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
454 if (f)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
455 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
456 tree_statement_list *cmds = f->body ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
457
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
458 if (cmds)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
459 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
460 octave_value_list bkpts = cmds->list_breakpoints ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
461 octave_idx_type len = bkpts.length ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
462
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
463 if (len > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
464 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
465 bp_table::intmap bkpts_vec;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
466
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
467 for (int i = 0; i < len; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
468 bkpts_vec[i] = bkpts (i).double_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
469
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
470 std::string symbol_name = f->name ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
471
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
472 retval[symbol_name] = bkpts_vec;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
473 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
474 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
475 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
476 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
477 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
478
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
479 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
480 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
481
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
482 static octave_value
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
483 intmap_to_ov (const bp_table::intmap& line)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
484 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
485 int idx = 0;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
486
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
487 NDArray retval (dim_vector (1, line.size ()));
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
488
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
489 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
490 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
491 bp_table::const_intmap_iterator p = line.find (i);
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
492
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
493 if (p != line.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
494 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
495 int lineno = p->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
496 retval(idx++) = lineno;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
497 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
498 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
499
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
500 retval.resize (dim_vector (1, idx));
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
501
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
502 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
503 }
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
504
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
505 DEFUN (dbstop, args, ,
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
506 "-*- texinfo -*-\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
507 @deftypefn {Loadable Function} {@var{rline} =} dbstop (\"@var{func}\")\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
508 @deftypefnx {Loadable Function} {@var{rline} =} dbstop (\"@var{func}\", @var{line}, @dots{})\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
509 Set a breakpoint in function @var{func}.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
510 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
511 Arguments are\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
512 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
513 @table @var\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
514 @item func\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
515 Function name as a string variable. When already in debug\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
516 mode this should be left out and only the line should be given.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10839
diff changeset
517 \n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
518 @item line\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
519 Line number where the breakpoint should be set. Multiple\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
520 lines may be given as separate arguments or as a vector.\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
521 @end table\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
522 \n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
523 When called with a single argument @var{func}, the breakpoint\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
524 is set at the first executable line in the named function.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
525 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
526 The optional output @var{rline} is the real line number where the\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
527 breakpoint was set. This can differ from specified line if\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
528 the line is not executable. For example, if a breakpoint attempted on a\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
529 blank line then Octave will set the real breakpoint at the\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
530 next executable line.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
531 @seealso{dbclear, dbstatus, dbstep, debug_on_error, debug_on_warning, debug_on_interrupt}\n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
532 @end deftypefn")
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
533 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
534 bp_table::intmap retval;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
535 std::string symbol_name;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
536 bp_table::intmap lines;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
537
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
538 parse_dbfunction_params ("dbstop", args, symbol_name, lines);
6646
bd0a70c3f2db [project @ 2007-05-22 02:27:43 by jwe]
jwe
parents: 6317
diff changeset
539
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
540 if (lines.size () == 0)
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
541 lines[0] = 1;
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
542
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
543 if (! error_state)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
544 retval = bp_table::add_breakpoint (symbol_name, lines);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
545
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
546 return intmap_to_ov (retval);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
547 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
548
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
549 DEFUN (dbclear, args, ,
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
550 "-*- texinfo -*-\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
551 @deftypefn {Loadable Function} {} dbclear (\"@var{func}\")\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
552 @deftypefnx {Loadable Function} {} dbclear (\"@var{func}\", @var{line}, @dots{})\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
553 Delete a breakpoint in the function @var{func}.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
554 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
555 Arguments are\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
556 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
557 @table @var\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
558 @item func\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
559 Function name as a string variable. When already in debug\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
560 mode this should be left out and only the line should be given.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10839
diff changeset
561 \n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
562 @item line\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
563 Line number from which to remove a breakpoint. Multiple\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
564 lines may be given as separate arguments or as a vector.\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
565 @end table\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
566 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
567 When called without a line number specification all breakpoints\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
568 in the named function are cleared.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
569 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
570 If the requested line is not a breakpoint no action is performed.\n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
571 @seealso{dbstop, dbstatus, dbwhere}\n\
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
572 @end deftypefn")
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
573 {
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
574 octave_value retval;
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
575 std::string symbol_name = "";
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
576 bp_table::intmap lines;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
577
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
578 parse_dbfunction_params ("dbclear", args, symbol_name, lines);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
579
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
580 if (! error_state)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
581 bp_table::remove_breakpoint (symbol_name, lines);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
582
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
583 return retval;
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
584 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
585
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
586 DEFUN (dbstatus, args, nargout,
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
587 "-*- texinfo -*-\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
588 @deftypefn {Loadable Function} {} dbstatus ()\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
589 @deftypefnx {Loadable Function} {@var{brk_list} =} dbstatus ()\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
590 @deftypefnx {Loadable Function} {@var{brk_list} =} dbstatus (\"@var{func}\")\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
591 Report the location of active breakpoints.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
592 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
593 When called with no input or output arguments, print the list of\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
594 all functions with breakpoints and the line numbers where those\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
595 breakpoints are set.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
596 If a function name @var{func} is specified then only report breakpoints\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
597 for the named function.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
598 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
599 The optional return argument @var{brk_list} is a struct array with the\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
600 following fields.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
601 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
602 @table @asis\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
603 @item name\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
604 The name of the function with a breakpoint.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
605 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
606 @item file\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
607 The name of the m-file where the function code is located.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
608 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
609 @item line\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
610 A line number, or vector of line numbers, with a breakpoint.\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
611 @end table\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
612 \n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
613 @seealso{dbclear, dbwhere}\n\
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
614 @end deftypefn")
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
615 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
616 octave_map retval;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
617 int nargin = args.length ();
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
618 octave_value_list fcn_list;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
619 bp_table::fname_line_map bp_list;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
620 std::string symbol_name;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
621
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
622 if (nargin != 0 && nargin != 1)
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
623 {
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
624 error ("dbstatus: only zero or one arguments accepted\n");
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
625 return octave_value ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
626 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
627
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
628 if (nargin == 1)
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
629 {
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
630 if (args(0).is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
631 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
632 symbol_name = args(0).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
633 fcn_list(0) = symbol_name;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
634 bp_list = bp_table::get_breakpoint_list (fcn_list);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
635 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
636 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
637 gripe_wrong_type_arg ("dbstatus", args(0));
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
638 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
639 else
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
640 {
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
641 octave_user_code *dbg_fcn = get_user_code ();
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
642 if (dbg_fcn)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
643 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
644 symbol_name = dbg_fcn->name ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
645 fcn_list(0) = symbol_name;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
646 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
647
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
648 bp_list = bp_table::get_breakpoint_list (fcn_list);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
649 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
650
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
651 if (nargout == 0)
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
652 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
653 // Print out the breakpoint information.
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
654
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
655 for (bp_table::fname_line_map_iterator it = bp_list.begin ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
656 it != bp_list.end (); it++)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
657 {
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
658 octave_stdout << "breakpoint in " << it->first << " at line(s) ";
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
659
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
660 bp_table::intmap m = it->second;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
661
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
662 size_t nel = m.size ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
663
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
664 for (size_t j = 0; j < nel; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
665 octave_stdout << m[j] << ((j < nel - 1) ? ", " : ".");
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
666
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
667 if (nel > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
668 octave_stdout << std::endl;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
669 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
670 return octave_value ();
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
671 }
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
672 else
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
673 {
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
674 // Fill in an array for return.
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
675
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
676 int i = 0;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
677 Cell names (dim_vector (bp_list.size (), 1));
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
678 Cell file (dim_vector (bp_list.size (), 1));
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
679 Cell line (dim_vector (bp_list.size (), 1));
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
680
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
681 for (bp_table::const_fname_line_map_iterator it = bp_list.begin ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
682 it != bp_list.end (); it++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
683 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
684 names(i) = it->first;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
685 line(i) = intmap_to_ov (it->second);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
686 file(i) = do_which (it->first);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
687 i++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
688 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
689
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
690 retval.assign ("name", names);
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
691 retval.assign ("file", file);
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
692 retval.assign ("line", line);
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
693
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
694 return octave_value (retval);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
695 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
696 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
697
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
698 DEFUN (dbwhere, , ,
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
699 "-*- texinfo -*-\n\
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
700 @deftypefn {Loadable Function} {} dbwhere ()\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
701 In debugging mode, report the current file and line number where\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
702 execution is stopped.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
703 @seealso{dbstatus, dbcont, dbstep, dbup}\n\
5645
9c9bd01099ce [project @ 2006-03-06 22:33:54 by jwe]
jwe
parents: 5642
diff changeset
704 @end deftypefn")
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
705 {
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
706 octave_value retval;
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
707
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
708 octave_user_code *dbg_fcn = get_user_code ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
709
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
710 if (dbg_fcn)
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
711 {
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
712 bool have_file = true;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
713
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
714 std::string name = dbg_fcn->fcn_file_name ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
715
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
716 if (name.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
717 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
718 have_file = false;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
719
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
720 name = dbg_fcn->name ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
721 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
722
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
723 octave_stdout << "stopped in " << name << " at ";
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9377
diff changeset
724
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
725 int l = octave_call_stack::caller_user_code_line ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
726
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
727 if (l > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
728 {
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
729 octave_stdout << " line " << l << std::endl;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
730
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
731 if (have_file)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
732 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
733 std::string line = get_file_line (name, l);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
734
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
735 if (! line.empty ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
736 octave_stdout << l << ": " << line << std::endl;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
737 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
738 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
739 else
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
740 octave_stdout << " <unknown line>" << std::endl;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
741 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
742 else
14049
b5a8e245b4eb Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents: 14035
diff changeset
743 error ("dbwhere: must be inside a user function to use dbwhere\n");
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
744
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
745 return retval;
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
746 }
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
747
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
748 // Copied and modified from the do_type command in help.cc
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
749 // Maybe we could share some code?
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
750 void
3949
294f13627ee8 [project @ 2002-05-23 01:22:11 by jwe]
jwe
parents: 3948
diff changeset
751 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
752 {
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
753 std::string ff = fcn_file_in_path (name);
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
754
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
755 if (! ff.empty ())
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
756 {
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
757 std::ifstream fs (ff.c_str (), std::ios::in);
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
758
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
759 if (fs)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
760 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
761 char ch;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
762 int line = 1;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
763
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
764 if (line >= start && line <= end)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
765 os << line << "\t";
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
766
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
767 while (fs.get (ch))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
768 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
769 if (line >= start && line <= end)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
770 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
771 os << ch;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
772 }
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
773
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
774 if (ch == '\n')
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
775 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
776 line++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
777 if (line >= start && line <= end)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
778 os << line << "\t";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
779 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
780 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
781 }
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
782 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
783 os << "dbtype: unable to open `" << ff << "' for reading!\n";
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
784 }
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
785 else
6317
8c67f8be341d [project @ 2007-02-16 08:10:53 by jwe]
jwe
parents: 5744
diff changeset
786 os << "dbtype: unknown function " << name << "\n";
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
787
6646
bd0a70c3f2db [project @ 2007-05-22 02:27:43 by jwe]
jwe
parents: 6317
diff changeset
788 os.flush ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
789 }
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
790
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
791 DEFUN (dbtype, args, ,
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
792 "-*- texinfo -*-\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
793 @deftypefn {Loadable Function} {} dbtype ()\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
794 @deftypefnx {Loadable Function} {} dbtype (\"startl:endl\")\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
795 @deftypefnx {Loadable Function} {} dbtype (\"@var{func}\")\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
796 @deftypefnx {Loadable Function} {} dbtype (\"@var{func}\", \"startl:endl\")\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
797 When in debugging mode and called with no arguments, list the script file\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
798 being debugged with line numbers. An optional range specification,\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
799 specified as a string, can be used to list only a portion of the file.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
800 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
801 When called with the name of a function, list that script file\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
802 with line numbers.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
803 @seealso{dbstatus, dbstop}\n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
804 @end deftypefn")
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
805 {
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
806 octave_value retval;
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
807 octave_user_code *dbg_fcn;
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
808
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
809 int nargin = args.length ();
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
810 string_vector argv = args.make_argv ("dbtype");
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
811
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
812 if (! error_state)
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
813 {
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
814 switch (nargin)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
815 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
816 case 0: // dbtype
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
817 dbg_fcn = get_user_code ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
818
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
819 if (dbg_fcn)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
820 do_dbtype (octave_stdout, dbg_fcn->name (), 0, INT_MAX);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
821 else
14049
b5a8e245b4eb Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents: 14035
diff changeset
822 error ("dbtype: must be inside a user function to give no arguments to dbtype\n");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
823 break;
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
824
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
825 case 1: // (dbtype func) || (dbtype start:end)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
826 dbg_fcn = get_user_code (argv[1]);
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
827
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
828 if (dbg_fcn)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
829 do_dbtype (octave_stdout, dbg_fcn->name (), 0, INT_MAX);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
830 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
831 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
832 dbg_fcn = get_user_code ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
833
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
834 if (dbg_fcn)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
835 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
836 std::string arg = argv[1];
3948
126177939aae [project @ 2002-05-23 01:17:29 by jwe]
jwe
parents: 3947
diff changeset
837
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
838 size_t ind = arg.find (':');
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
839
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
840 if (ind != std::string::npos)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
841 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
842 std::string start_str = arg.substr (0, ind);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
843 std::string end_str = arg.substr (ind + 1);
3948
126177939aae [project @ 2002-05-23 01:17:29 by jwe]
jwe
parents: 3947
diff changeset
844
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
845 int start = atoi (start_str.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
846 int end = atoi (end_str.c_str ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
847
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
848 if (std::min (start, end) <= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
849 error ("dbtype: start and end lines must be >= 1\n");
6317
8c67f8be341d [project @ 2007-02-16 08:10:53 by jwe]
jwe
parents: 5744
diff changeset
850
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
851 if (start <= end)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
852 do_dbtype (octave_stdout, dbg_fcn->name (), start, end);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
853 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
854 error ("dbtype: start line must be less than end line\n");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
855 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
856 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
857 error ("dbtype: line specification must be `start:end'");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
858 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
859 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
860 break;
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
861
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
862 case 2: // (dbtype func start:end) , (dbtype func start)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
863 dbg_fcn = get_user_code (argv[1]);
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
864
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
865 if (dbg_fcn)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
866 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
867 std::string arg = argv[2];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
868 int start = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
869 int end = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
870 size_t ind = arg.find (':');
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
871
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
872 if (ind != std::string::npos)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
873 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
874 std::string start_str = arg.substr (0, ind);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
875 std::string end_str = arg.substr (ind + 1);
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
876
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
877 start = atoi (start_str.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
878 end = atoi (end_str.c_str ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
879
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
880 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
881 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
882 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
883 start = atoi (arg.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
884 end = start;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
885 }
6317
8c67f8be341d [project @ 2007-02-16 08:10:53 by jwe]
jwe
parents: 5744
diff changeset
886
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
887 if (std::min (start, end) <= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
888 error ("dbtype: start and end lines must be >= 1\n");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
889
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
890 if (start <= end)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
891 do_dbtype (octave_stdout, dbg_fcn->name (), start, end);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
892 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
893 error ("dbtype: start line must be less than end line\n");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
894 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
895 break;
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
896
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
897 default:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
898 error ("dbtype: expecting zero, one, or two arguments\n");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
899 }
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
900 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
901
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
902 return retval;
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
903 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
904
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
905 static octave_value_list
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
906 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
907 {
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
908 octave_value_list retval;
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
909
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9724
diff changeset
910 unwind_protect frame;
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
911
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7897
diff changeset
912 octave_idx_type curr_frame = -1;
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
913
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7897
diff changeset
914 size_t nskip = 0;
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
915
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
916 if (args.length () == 1)
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
917 {
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
918 int n = 0;
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
919
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
920 octave_value arg = args(0);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
921
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
922 if (arg.is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
923 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
924 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
925
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
926 n = atoi (s_arg.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
927 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
928 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
929 n = args(0).int_value ();
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
930
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
931 if (n > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
932 nskip = n;
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
933 else
14049
b5a8e245b4eb Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents: 14035
diff changeset
934 error ("dbstack: N must be a non-negative integer");
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
935 }
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
936
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
937 if (! error_state)
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
938 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
939 octave_map stk = octave_call_stack::backtrace (nskip, curr_frame);
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
940
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
941 if (nargout == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
942 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
943 octave_idx_type nframes_to_display = stk.numel ();
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
944
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
945 if (nframes_to_display > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
946 {
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
947 os << "stopped in:\n\n";
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
948
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
949 Cell names = stk.contents ("name");
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
950 Cell files = stk.contents ("file");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
951 Cell lines = stk.contents ("line");
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
952
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
953 bool show_top_level = true;
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
954
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
955 size_t max_name_len = 0;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
956
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
957 for (octave_idx_type i = 0; i < nframes_to_display; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
958 {
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
959 std::string name = names(i).string_value ();
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
960
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
961 max_name_len = std::max (name.length (), max_name_len);
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
962 }
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
963
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
964 for (octave_idx_type i = 0; i < nframes_to_display; i++)
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
965 {
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
966 std::string name = names(i).string_value ();
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
967 std::string file = files(i).string_value ();
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
968 int line = lines(i).int_value ();
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
969
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
970 if (show_top_level && i == curr_frame)
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
971 show_top_level = false;
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
972
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
973 os << (i == curr_frame ? " --> " : " ")
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
974 << std::setw (max_name_len) << name
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
975 << " at line " << line
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
976 << " [" << file << "]"
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
977 << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
978 }
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
979
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
980 if (show_top_level)
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
981 os << " --> top level" << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
982 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
983 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
984 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
985 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
986 retval(1) = curr_frame < 0 ? 1 : curr_frame + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
987 retval(0) = stk;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
988 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
989 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
990
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
991 return retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
992 }
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
993
13326
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
994 // A function that can be easily called from a debugger print the Octave
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
995 // stack. This can be useful for finding what line of code the
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
996 // interpreter is currently executing when the debugger is stopped in
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
997 // some C++ function, for example.
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
998
13784
0bbe319bf26b octave_class::size: return matrix with correct dimensions
John W. Eaton <jwe@octave.org>
parents: 13689
diff changeset
999 void
13326
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
1000 show_octave_dbstack (void)
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
1001 {
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1002 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
1003 }
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1004
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1005 DEFUN (dbstack, args, nargout,
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1006 "-*- texinfo -*-\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1007 @deftypefn {Loadable Function} {} dbstack ()\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1008 @deftypefnx {Loadable Function} {} dbstack (@var{n})\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1009 @deftypefnx {Loadable Function} {[@var{stack}, @var{idx}] =} dbstack (@dots{})\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1010 Display or return current debugging function stack information.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1011 With optional argument @var{n}, omit the @var{n} innermost stack frames.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1012 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1013 The optional return argument @var{stack} is a struct array with the\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1014 following fields:\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1015 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1016 @table @asis\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1017 @item file\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1018 The name of the m-file where the function code is located.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1019 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1020 @item name\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1021 The name of the function with a breakpoint.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1022 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1023 @item line\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1024 The line number of an active breakpoint.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1025 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1026 @item column\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1027 The column number of the line where the breakpoint begins.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1028 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1029 @item scope\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1030 Undocumented.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1031 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1032 @item context\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1033 Undocumented.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1034 @end table\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1035 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1036 The return argument @var{idx} specifies which element of the @var{stack}\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1037 struct array is currently active.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1038 @seealso{dbup, dbdown, dbwhere, dbstatus}\n\
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1039 @end deftypefn")
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1040 {
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1041 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
1042 }
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
1043
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1044 static void
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1045 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
1046 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1047 int n = 1;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1048
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1049 if (args.length () == 1)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1050 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1051 octave_value arg = args(0);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1052
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1053 if (arg.is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1054 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1055 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
1056
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1057 n = atoi (s_arg.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1058 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1059 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1060 n = args(0).int_value ();
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1061 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1062
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1063 if (! error_state)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1064 {
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1065 if (who == "dbup")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1066 n = -n;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1067
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1068 if (! octave_call_stack::goto_frame_relative (n, true))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1069 error ("%s: invalid stack frame", who.c_str ());
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1070 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1071 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1072
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1073 DEFUN (dbup, args, ,
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1074 "-*- texinfo -*-\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1075 @deftypefn {Loadable Function} {} dbup\n\
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1076 @deftypefnx {Loadable Function} {} dbup (@var{n})\n\
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1077 In debugging mode, move up the execution stack @var{n} frames.\n\
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1078 If @var{n} is omitted, move up one frame.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1079 @seealso{dbstack, dbdown}\n\
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1080 @end deftypefn")
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1081 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1082 octave_value retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1083
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1084 do_dbupdown (args, "dbup");
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1085
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1086 return retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1087 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1088
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1089 DEFUN (dbdown, args, ,
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1090 "-*- texinfo -*-\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1091 @deftypefn {Loadable Function} {} dbdown\n\
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1092 @deftypefnx {Loadable Function} {} dbdown (@var{n})\n\
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1093 In debugging mode, move down the execution stack @var{n} frames.\n\
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1094 If @var{n} is omitted, move down one frame.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1095 @seealso{dbstack, dbup}\n\
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1096 @end deftypefn")
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1097 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1098 octave_value retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1099
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1100 do_dbupdown (args, "dbdown");
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1101
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1102 return retval;
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1103 }
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1104
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1105 DEFUN (dbstep, args, ,
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
1106 "-*- texinfo -*-\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1107 @deftypefn {Command} {} dbstep\n\
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1108 @deftypefnx {Command} {} dbstep @var{n}\n\
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
1109 @deftypefnx {Command} {} dbstep in\n\
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
1110 @deftypefnx {Command} {} dbstep out\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1111 @deftypefnx {Command} {} dbnext @dots{}\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1112 In debugging mode, execute the next @var{n} lines of code.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1113 If @var{n} is omitted, execute the next single line of code.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1114 If the next line of code is itself defined in terms of an m-file remain in\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1115 the existing function.\n\
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
1116 \n\
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
1117 Using @code{dbstep in} will cause execution of the next line to step into\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1118 any m-files defined on the next line. Using @code{dbstep out} will cause\n\
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
1119 execution to continue until the current function returns.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1120 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1121 @code{dbnext} is an alias for @code{dbstep}.\n\
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
1122 @seealso{dbcont, dbquit}\n\
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
1123 @end deftypefn")
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
1124 {
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
1125 if (Vdebugging)
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
1126 {
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
1127 int nargin = args.length ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1128
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
1129 if (nargin > 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1130 print_usage ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1131 else if (nargin == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1132 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1133 if (args(0).is_string ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1134 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1135 std::string arg = args(0).string_value ();
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
1136
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1137 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1138 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1139 if (arg == "in")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1140 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1141 Vdebugging = false;
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
1142
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1143 tree_evaluator::dbstep_flag = -1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1144 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1145 else if (arg == "out")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1146 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1147 Vdebugging = false;
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
1148
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1149 tree_evaluator::dbstep_flag = -2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1150 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1151 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1152 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1153 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
1154
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1155 if (n > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1156 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1157 Vdebugging = false;
7818
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1158
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1159 tree_evaluator::dbstep_flag = n;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1160 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1161 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1162 error ("dbstep: invalid argument");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1163 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1164 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1165 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1166 else
14049
b5a8e245b4eb Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents: 14035
diff changeset
1167 error ("dbstep: input argument must be a character string");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1168 }
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
1169 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1170 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1171 Vdebugging = false;
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
1172
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1173 tree_evaluator::dbstep_flag = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1174 }
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
1175 }
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
1176 else
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
1177 error ("dbstep: can only be called in debug mode");
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
1178
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
1179 return octave_value_list ();
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
1180 }
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
1181
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1182 DEFALIAS (dbnext, dbstep);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1183
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1184 DEFUN (dbcont, args, ,
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
1185 "-*- texinfo -*-\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1186 @deftypefn {Command} {} dbcont\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1187 Leave command-line debugging mode and continue code execution normally.\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1188 @seealso{dbstep, dbquit}\n\
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
1189 @end deftypefn")
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
1190 {
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
1191 if (Vdebugging)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1192 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1193 if (args.length () == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1194 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1195 Vdebugging = false;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1196
10186
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1197 tree_evaluator::reset_debug_state ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1198 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1199 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1200 print_usage ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1201 }
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
1202 else
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
1203 error ("dbcont: can only be called in debug mode");
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
1204
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
1205 return octave_value_list ();
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
1206 }
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
1207
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1208 DEFUN (dbquit, args, ,
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
1209 "-*- texinfo -*-\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1210 @deftypefn {Command} {} dbquit\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1211 Quit debugging mode immediately without further code execution and\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1212 return to the Octave prompt.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1213 @seealso{dbcont, dbstep}\n\
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
1214 @end deftypefn")
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
1215 {
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
1216 if (Vdebugging)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1217 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1218 if (args.length () == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1219 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1220 Vdebugging = false;
10186
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1221
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1222 tree_evaluator::reset_debug_state ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1223
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1224 octave_throw_interrupt_exception ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1225 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1226 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1227 print_usage ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1228 }
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
1229 else
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
1230 error ("dbquit: can only be called in debug mode");
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
1231
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
1232 return octave_value_list ();
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
1233 }
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
1234
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1235 DEFUN (isdebugmode, args, ,
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1236 "-*- texinfo -*-\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1237 @deftypefn {Loadable Function} {} isdebugmode ()\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1238 Return true if in debugging mode, otherwise false.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1239 @seealso{dbwhere, dbstack, dbstatus}\n\
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1240 @end deftypefn")
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1241 {
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1242 octave_value retval;
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1243
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1244 if (args.length () == 0)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1245 retval = Vdebugging;
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1246 else
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1247 print_usage ();
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1248
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1249 return retval;
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1250 }