annotate src/debug.cc @ 10785:c2041adcf234

remove unnecessary sparse indexing overloads
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 13 Jul 2010 12:08:08 +0200
parents 57a59eae83cc
children 65bc065bec95
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
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8746
diff changeset
3 Copyright (C) 2007, 2008, 2009 John Swensen
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
4 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Ben Sapp
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>
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
29 #include <iostream>
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
30 #include <set>
3948
126177939aae [project @ 2002-05-23 01:17:29 by jwe]
jwe
parents: 3947
diff changeset
31 #include <string>
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
32
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
33 #include "file-stat.h"
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
34
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
35 #include "defun.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
36 #include "error.h"
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
37 #include "help.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
38 #include "input.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
39 #include "pager.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
40 #include "oct-obj.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
41 #include "utils.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
42 #include "parse.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
43 #include "symtab.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
44 #include "gripes.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
45 #include "ov.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
46 #include "ov-usr-fcn.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
47 #include "ov-fcn.h"
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
48 #include "ov-struct.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
49 #include "pt-pr-code.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
50 #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
51 #include "pt-eval.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
52 #include "pt-stmt.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
53 #include "toplev.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
54 #include "unwind-prot.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
55 #include "variables.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
56
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
57 #include "debug.h"
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
58
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
59 // Initialize the singleton object
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
60 bp_table *bp_table::instance = 0;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
61
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
62 static std::string
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
63 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
64 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
65 std::string retval;
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 file_stat fs (fname);
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 if (fs)
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 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
72
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
73 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
74
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
75 if (file)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
76 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
77 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
78
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
79 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
80
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
81 if (file.eof ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
82 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
83 // 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
84
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
85 retval = buf;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
86 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
87 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
88 error ("error reading file %s", fname.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
89 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
90 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
91
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
92 return retval;
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
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
95 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
96 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
97 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
98 // 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
99 // here?
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
100
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
101 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
102
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
103 offsets.push_back (0);
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 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
106
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
107 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
108 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
109 char c = buf[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 if (c == '\r' && ++i < len)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
112 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
113 c = buf[i];
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
114
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
115 if (c == '\n')
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
116 offsets.push_back (i+1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
117 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
118 offsets.push_back (i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
119 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
120 else if (c == '\n')
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
121 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
122 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
123
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
124 offsets.push_back (len);
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 return offsets;
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
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
129 std::string
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
130 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
131 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
132 std::string retval;
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 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
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 buf;
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::deque<size_t> offsets;
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 if (fname != last_fname)
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 buf = snarf_file (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 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
145 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
146
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
147 if (line > 0)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
148 line--;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
149
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
150 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
151 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
152 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
153 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
154
8677
095ae5e0a831 eliminte some compiler warnings
John W. Eaton <jwe@octave.org>
parents: 8658
diff changeset
155 while (eol > 0 && (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
156 eol--;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
157
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
158 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
159 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
160
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
161 return retval;
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
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5645
diff changeset
164 // 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
165 // 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
166 // current call stack.
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
167
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
168 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
169 get_user_code (const std::string& fname = std::string ())
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
170 {
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
171 octave_user_code *dbg_fcn = 0;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
172
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
173 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
174 dbg_fcn = octave_call_stack::caller_user_code ();
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5645
diff changeset
175 else
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
176 {
7539
3e107d73aeb4 debug.cc: use find_function instead of find_user_function
John Swensen
parents: 7348
diff changeset
177 octave_value fcn = symbol_table::find_function (fname);
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
178
8123
eb2beef9a9ff clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents: 8114
diff changeset
179 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
180 dbg_fcn = fcn.user_code_value ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
181 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
182
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
183 return dbg_fcn;
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
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
186 static void
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
187 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
188 std::string& symbol_name, bp_table::intmap& lines)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
189 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
190 int nargin = args.length ();
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
191 int idx = 0;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
192 int list_idx = 0;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
193 symbol_name = std::string ();
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
194 lines = bp_table::intmap ();
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
195
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
196 if (args.length () == 0)
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
197 return;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
198
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
199 // 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
200 if (octave_call_stack::caller_user_code ())
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
201 {
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
202 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
203 symbol_name = get_user_code ()->name ();
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
204 }
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
205 else if (args(0).is_map ())
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
206 {
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
207 // 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
208 // single function
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
209 }
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
210 else if (args(0).is_string())
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 symbol_name = args(0).string_value ();
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
213 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
214 return;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
215 idx = 1;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
216 }
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
217 else
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
218 error ("%s: invalid parameter specified", who);
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
219
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
220 for (int i = idx; i < nargin; i++ )
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
221 {
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
222 if (args(i).is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
223 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
224 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
225 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
226 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
227 lines[list_idx++] = line;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
228 }
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
229 else if (args(i).is_map ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
230 octave_stdout << who << ": accepting a struct" << std::endl;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
231 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
232 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
233 const NDArray arg = args(i).array_value ();
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 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
236 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
237
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
238 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
239 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
240 int line = static_cast<int> (arg.elem (j));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
241 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
242 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
243 lines[list_idx++] = line;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
244 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
245
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
246 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
247 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
248 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
249 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
250 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
251
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
252 bp_table::intmap
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
253 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
254 const bp_table::intmap& line)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
255 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
256 intmap retval;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
257
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
258 octave_idx_type len = line.size ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
259
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
260 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
261
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
262 if (dbg_fcn)
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
263 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
264 tree_statement_list *cmds = dbg_fcn->body ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
265
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
266 if (cmds)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
267 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
268 for (int i = 0; i < len; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
269 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
270 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
271
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
272 if (p != line.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
273 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
274 int lineno = p->second;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
275
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
276 retval[i] = cmds->set_breakpoint (lineno);
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
277
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
278 if (retval[i] != 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
279 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
280 bp_set.insert (fname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
281 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
282 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
283 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
284 }
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 else
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
287 error ("add_breakpoint: unable to find the function requested\n");
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
288
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
289 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
290
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
291 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
292 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
293
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
294
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
295 int
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
296 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
297 const bp_table::intmap& line)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
298 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
299 int retval = 0;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
300
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
301 octave_idx_type len = line.size ();
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
302
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
303 if (len == 0)
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
304 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
305 intmap results = remove_all_breakpoints_in_file (fname);
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
306 retval = results.size ();
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
307 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
308 else
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
309 {
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
310 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
311
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
312 if (dbg_fcn)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
313 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
314 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
315
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
316 if (cmds)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
317 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
318 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
319
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
320 if (results.length () > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
321 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
322 for (int i = 0; i < len; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
323 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
324 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
325
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
326 if (p != line.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
327 cmds->delete_breakpoint (p->second);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
328 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
329
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
330 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
331
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
332 bp_set_iterator it = bp_set.find (fname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
333 if (results.length () == 0 && it != bp_set.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
334 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
335
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
336 }
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
337
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
338 retval = results.length ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
339 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
340 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
341 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
342 error ("remove_breakpoint: unable to find the function requested\n");
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
343 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
344
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
345 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
346
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
347 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
348 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
349
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
350
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
351 bp_table::intmap
8123
eb2beef9a9ff clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents: 8114
diff changeset
352 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
353 bool silent)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
354 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
355 intmap retval;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
356
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
357 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
358
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
359 if (dbg_fcn)
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
360 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
361 tree_statement_list *cmds = dbg_fcn->body ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
362
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
363 if (cmds)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
364 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
365 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
366
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
367 for (int i = 0; i < bkpts.length (); i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
368 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
369 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
370 cmds->delete_breakpoint (lineno);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
371 retval[i] = lineno;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
372 }
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
373
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
374 bp_set_iterator it = bp_set.find (fname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
375 if (it != bp_set.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
376 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
377
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
378 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
379 }
8123
eb2beef9a9ff clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents: 8114
diff changeset
380 else if (! silent)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
381 error ("remove_all_breakpoint_in_file: "
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
382 "unable to find the function requested\n");
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
383
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
384 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
385
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
386 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
387 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
388
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
389 void
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
390 bp_table::do_remove_all_breakpoints (void)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
391 {
9183
94ae487acd1b use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents: 9039
diff changeset
392 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
393 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
394
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
395
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
396 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
397 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
398
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
399 std::string
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
400 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
401 std::string match)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
402 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
403 std::string retval;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
404
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
405 for (int i = 0; i < slist.length (); i++)
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
406 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
407 if (slist (i).string_value () == match)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
408 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
409 retval = slist(i).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
410 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
411 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
412 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
413
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
414 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
415 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
416
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
417
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
418 bp_table::fname_line_map
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
419 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
420 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
421 fname_line_map retval;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
422
9183
94ae487acd1b use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents: 9039
diff changeset
423 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
424 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
425 if (fname_list.length () == 0
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
426 || do_find_bkpt_list (fname_list, *it) != "")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
427 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
428 octave_user_code *f = get_user_code (*it);
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
429
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
430 if (f)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
431 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
432 tree_statement_list *cmds = f->body ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
433
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
434 if (cmds)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
435 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
436 octave_value_list bkpts = cmds->list_breakpoints ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
437 octave_idx_type len = bkpts.length ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
438
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
439 if (len > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
440 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
441 bp_table::intmap bkpts_vec;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
442
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
443 for (int i = 0; i < len; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
444 bkpts_vec[i] = bkpts (i).double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
445
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
446 std::string symbol_name = f->name ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
447
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
448 retval[symbol_name] = bkpts_vec;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
449 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
450 }
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 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
453 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
454
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
455 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
456 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
457
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
458 static octave_value
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
459 intmap_to_ov (const bp_table::intmap& line)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
460 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
461 int idx = 0;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
462
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
463 NDArray retval (dim_vector (1, line.size ()));
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
464
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
465 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
466 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
467 bp_table::const_intmap_iterator p = line.find (i);
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
468
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
469 if (p != line.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
470 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
471 int lineno = p->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
472 retval(idx++) = lineno;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
473 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
474 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
475
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
476 retval.resize (dim_vector (1, idx));
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
477
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
478 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
479 }
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
480
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
481 DEFUN (dbstop, args, ,
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
482 "-*- texinfo -*-\n\
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
483 @deftypefn {Loadable Function} {@var{rline} =} dbstop (@var{func}, @var{line}, @dots{})\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
484 Set a breakpoint in a function\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
485 @table @code\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
486 @item func\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
487 String representing the function name. When already in debug\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
488 mode this should be left out and only the line should be given.\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
489 @item line\n\
9039
51dc9691f23f Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
490 Line number you would like the breakpoint to be set on. Multiple\n\
7001
8b0cfeb06365 [project @ 2007-10-10 18:02:59 by jwe]
jwe
parents: 6653
diff changeset
491 lines might 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
492 @end table\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
493 \n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
494 The rline returned is the real line that the breakpoint was set at.\n\
8286
6f2d95255911 fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8123
diff changeset
495 @seealso{dbclear, dbstatus, dbstep}\n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
496 @end deftypefn")
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
497 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
498 bp_table::intmap retval;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
499 std::string symbol_name;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
500 bp_table::intmap lines;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
501
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
502 parse_dbfunction_params ("dbstop", args, symbol_name, lines);
6646
bd0a70c3f2db [project @ 2007-05-22 02:27:43 by jwe]
jwe
parents: 6317
diff changeset
503
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
504 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
505 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
506
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
507 if (! error_state)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
508 retval = bp_table::add_breakpoint (symbol_name, lines);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
509
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
510 return intmap_to_ov (retval);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
511 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
512
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
513 DEFUN (dbclear, args, ,
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
514 "-*- texinfo -*-\n\
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
515 @deftypefn {Loadable Function} {} dbclear (@var{func}, @var{line}, @dots{})\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
516 Delete a breakpoint in a function\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
517 @table @code\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
518 @item func\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
519 String representing the function name. When already in debug\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
520 mode this should be left out and only the line should be given.\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
521 @item line\n\
9039
51dc9691f23f Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
522 Line number where you would like to remove the breakpoint. Multiple\n\
7001
8b0cfeb06365 [project @ 2007-10-10 18:02:59 by jwe]
jwe
parents: 6653
diff changeset
523 lines might 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
524 @end table\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
525 No checking is done to make sure that the line you requested is really\n\
9039
51dc9691f23f Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
526 a breakpoint. If you get the wrong line nothing will happen.\n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
527 @seealso{dbstop, dbstatus, dbwhere}\n\
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
528 @end deftypefn")
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
529 {
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
530 octave_value retval;
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
531 std::string symbol_name = "";
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
532 bp_table::intmap lines;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
533
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
534 parse_dbfunction_params ("dbclear", args, symbol_name, lines);
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
535
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
536 if (! error_state)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
537 bp_table::remove_breakpoint (symbol_name, lines);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
538
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
539 return retval;
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
540 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
541
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
542 DEFUN (dbstatus, args, nargout,
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
543 "-*- texinfo -*-\n\
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
544 @deftypefn {Loadable Function} {lst =} dbstatus (@var{func})\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
545 Return a vector containing the lines on which a function has \n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
546 breakpoints set.\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
547 @table @code\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
548 @item func\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
549 String representing the function name. When already in debug\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
550 mode this should be left out.\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
551 @end table\n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
552 @seealso{dbclear, dbwhere}\n\
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
553 @end deftypefn")
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
554 {
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
555 Octave_map retval;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
556 int nargin = args.length ();
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
557 octave_value_list fcn_list;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
558 bp_table::fname_line_map bp_list;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
559 std::string symbol_name;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
560
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
561 if (nargin != 0 && nargin != 1)
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
562 {
3948
126177939aae [project @ 2002-05-23 01:17:29 by jwe]
jwe
parents: 3947
diff changeset
563 error ("dbstatus: only zero or one arguements accepted\n");
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
564 return octave_value ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
565 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
566
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
567 if (nargin == 1)
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
568 {
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
569 if (args(0).is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
570 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
571 symbol_name = args(0).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
572 fcn_list(0) = symbol_name;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
573 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
574 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
575 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
576 gripe_wrong_type_arg ("dbstatus", args(0));
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
577 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
578 else
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
579 {
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
580 octave_user_code *dbg_fcn = get_user_code ();
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
581 if (dbg_fcn)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
582 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
583 symbol_name = dbg_fcn->name ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
584 fcn_list(0) = symbol_name;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
585 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
586
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
587 bp_list = bp_table::get_breakpoint_list (fcn_list);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
588 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
589
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
590 if (nargout == 0)
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
591 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
592 // Print out the breakpoint information.
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
593
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
594 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
595 it != bp_list.end (); it++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
596 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
597 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
598
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
599 bp_table::intmap m = it->second;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
600
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
601 size_t nel = m.size ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
602
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
603 for (size_t j = 0; j < nel; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
604 octave_stdout << m[j] << ((j < nel - 1) ? ", " : ".");
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
605
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
606 if (nel > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
607 octave_stdout << std::endl;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
608 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
609 return octave_value ();
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
610 }
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
611 else
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
612 {
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
613 // Fill in an array for return.
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
614
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
615 int i = 0;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
616 Cell names (dim_vector (bp_list.size (), 1));
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
617 Cell file (dim_vector (bp_list.size (), 1));
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
618 Cell line (dim_vector (bp_list.size (), 1));
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
619
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
620 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
621 it != bp_list.end (); it++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
622 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
623 names(i) = it->first;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
624 line(i) = intmap_to_ov (it->second);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
625 file(i) = do_which (it->first);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
626 i++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
627 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
628
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
629 retval.assign ("name", names);
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
630 retval.assign ("file", file);
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
631 retval.assign ("line", line);
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
632
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
633 return octave_value (retval);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
634 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
635 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
636
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
637 DEFUN (dbwhere, , ,
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
638 "-*- texinfo -*-\n\
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
639 @deftypefn {Loadable Function} {} dbwhere ()\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
640 Show where we are in the code\n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
641 @seealso{dbclear, dbstatus, dbstop}\n\
5645
9c9bd01099ce [project @ 2006-03-06 22:33:54 by jwe]
jwe
parents: 5642
diff changeset
642 @end deftypefn")
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
643 {
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
644 octave_value retval;
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
645
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
646 octave_user_code *dbg_fcn = get_user_code ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
647
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
648 if (dbg_fcn)
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
649 {
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
650 bool have_file = true;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
651
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
652 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
653
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
654 if (name.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
655 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
656 have_file = false;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
657
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
658 name = dbg_fcn->name ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
659 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
660
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
661 octave_stdout << name << ":";
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
662
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9724
diff changeset
663 unwind_protect frame;
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9377
diff changeset
664
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9724
diff changeset
665 frame.add_fcn (octave_call_stack::restore_frame,
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9724
diff changeset
666 octave_call_stack::current_frame ());
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9377
diff changeset
667
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9377
diff changeset
668 // Skip the frame assigned to the dbwhere function.
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9377
diff changeset
669 octave_call_stack::goto_frame_relative (0);
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9377
diff changeset
670
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9377
diff changeset
671 int l = octave_call_stack::current_line ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
672
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
673 if (l > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
674 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
675 octave_stdout << " line " << l;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
676
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
677 int c = octave_call_stack::current_column ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
678
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
679 if (c > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
680 octave_stdout << ", column " << c;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
681
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
682 octave_stdout << std::endl;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
683
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
684 if (have_file)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
685 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
686 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
687
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
688 if (! line.empty ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
689 octave_stdout << l << ": " << line << std::endl;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
690 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
691 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
692 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
693 octave_stdout << " (unknown line)\n";
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
694 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
695 else
3948
126177939aae [project @ 2002-05-23 01:17:29 by jwe]
jwe
parents: 3947
diff changeset
696 error ("dbwhere: must be inside of a user function to use dbwhere\n");
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
697
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
698 return retval;
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
699 }
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
700
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
701 // 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
702 // Maybe we could share some code?
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
703 void
3949
294f13627ee8 [project @ 2002-05-23 01:22:11 by jwe]
jwe
parents: 3948
diff changeset
704 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
705 {
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
706 std::string ff = fcn_file_in_path (name);
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
707
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
708 if (! ff.empty ())
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
709 {
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
710 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
711
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
712 if (fs)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
713 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
714 char ch;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
715 int line = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
716
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
717 if (line >= start && line <= end)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
718 os << line << "\t";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
719
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
720 while (fs.get (ch))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
721 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
722 if (line >= start && line <= end)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
723 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
724 os << ch;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
725 }
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
726
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
727 if (ch == '\n')
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
728 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
729 line++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
730 if (line >= start && line <= end)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
731 os << line << "\t";
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 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
734 }
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
735 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
736 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
737 }
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
738 else
6317
8c67f8be341d [project @ 2007-02-16 08:10:53 by jwe]
jwe
parents: 5744
diff changeset
739 os << "dbtype: unknown function " << name << "\n";
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
740
6646
bd0a70c3f2db [project @ 2007-05-22 02:27:43 by jwe]
jwe
parents: 6317
diff changeset
741 os.flush ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
742 }
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
743
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
744 DEFUN (dbtype, args, ,
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
745 "-*- texinfo -*-\n\
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
746 @deftypefn {Loadable Function} {} dbtype ()\n\
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
747 List script file with line numbers.\n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
748 @seealso{dbclear, dbstatus, dbstop}\n\
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
749 @end deftypefn")
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
750 {
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
751 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
752 octave_user_code *dbg_fcn;
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
753
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
754 int nargin = args.length ();
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
755 string_vector argv = args.make_argv ("dbtype");
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
756
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
757 if (! error_state)
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
758 {
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
759 switch (nargin)
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 case 0: // dbtype
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
762 dbg_fcn = get_user_code ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
763
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
764 if (dbg_fcn)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
765 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
766 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
767 error ("dbtype: must be in a user function to give no arguments to dbtype\n");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
768 break;
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
769
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
770 case 1: // (dbtype func) || (dbtype start:end)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
771 dbg_fcn = get_user_code (argv[1]);
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
772
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
773 if (dbg_fcn)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
774 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
775 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
776 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
777 dbg_fcn = get_user_code ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
778
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
779 if (dbg_fcn)
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 std::string arg = argv[1];
3948
126177939aae [project @ 2002-05-23 01:17:29 by jwe]
jwe
parents: 3947
diff changeset
782
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
783 size_t ind = arg.find (':');
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
784
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
785 if (ind != std::string::npos)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
786 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
787 std::string start_str = arg.substr (0, ind);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
788 std::string end_str = arg.substr (ind + 1);
3948
126177939aae [project @ 2002-05-23 01:17:29 by jwe]
jwe
parents: 3947
diff changeset
789
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
790 int start = atoi (start_str.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
791 int end = atoi (end_str.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
792
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
793 if (std::min (start, end) <= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
794 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
795
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
796 if (start <= end)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
797 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
798 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
799 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
800 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
801 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
802 error ("dbtype: line specification must be `start:end'");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
803 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
804 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
805 break;
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
806
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
807 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
808 dbg_fcn = get_user_code (argv[1]);
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
809
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
810 if (dbg_fcn)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
811 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
812 std::string arg = argv[2];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
813 int start = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
814 int end = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
815 size_t ind = arg.find (':');
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
816
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
817 if (ind != std::string::npos)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
818 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
819 std::string start_str = arg.substr (0, ind);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
820 std::string end_str = arg.substr (ind + 1);
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
821
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
822 start = atoi (start_str.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
823 end = atoi (end_str.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
824
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
825 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
826 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
827 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
828 start = atoi (arg.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
829 end = start;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
830 }
6317
8c67f8be341d [project @ 2007-02-16 08:10:53 by jwe]
jwe
parents: 5744
diff changeset
831
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
832 if (std::min (start, end) <= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
833 error ("dbtype: start and end lines must be >= 1\n");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
834
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
835 if (start <= end)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
836 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
837 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
838 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
839 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
840 break;
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
841
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
842 default:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
843 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
844 }
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
845 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
846
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
847 return retval;
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
848 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
849
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
850 DEFUN (dbstack, args, nargout,
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
851 "-*- texinfo -*-\n\
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
852 @deftypefn {Loadable Function} {[@var{stack}, @var{idx}]} dbstack (@var{n})\n\
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
853 Print or return current stack information. With optional argument\n\
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
854 @var{n}, omit the @var{n} innermost stack frames.\n\
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
855 @seealso{dbclear, dbstatus, dbstop}\n\
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
856 @end deftypefn")
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
857 {
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
858 octave_value_list retval;
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
859
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9724
diff changeset
860 unwind_protect frame;
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
861
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7897
diff changeset
862 octave_idx_type curr_frame = -1;
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
863
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7897
diff changeset
864 size_t nskip = 0;
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
865
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
866 if (args.length () == 1)
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
867 {
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
868 int n = 0;
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
869
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
870 octave_value arg = args(0);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
871
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
872 if (arg.is_string ())
10315
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 s_arg = arg.string_value ();
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
875
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
876 n = atoi (s_arg.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
877 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
878 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
879 n = args(0).int_value ();
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
880
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
881 if (n > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
882 nskip = n;
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
883 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
884 error ("dbstack: expecting N to be a nonnegative integer");
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
885 }
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
886
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
887 if (! error_state)
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
888 {
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7897
diff changeset
889 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
890
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
891 if (nargout == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
892 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
893 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
894
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
895 if (nframes_to_display > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
896 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
897 octave_stdout << "Stopped in:\n\n";
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
898
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
899 Cell names = stk.contents ("name");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
900 Cell lines = stk.contents ("line");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
901 Cell columns = stk.contents ("column");
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
902
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
903 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
904 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
905 octave_value name = names(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
906 octave_value line = lines(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
907 octave_value column = columns(i);
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
908
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
909 octave_stdout << (i == curr_frame ? "--> " : " ")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
910 << name.string_value ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
911 << " at line " << line.int_value ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
912 << " column " << column.int_value ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
913 << std::endl;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
914 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
915 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
916 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
917 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
918 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
919 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
920 retval(0) = stk;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
921 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
922 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
923
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
924 return retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
925 }
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
926
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
927 static void
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
928 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
929 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
930 int n = 1;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
931
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
932 if (args.length () == 1)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
933 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
934 octave_value arg = args(0);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
935
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
936 if (arg.is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
937 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
938 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
939
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
940 n = atoi (s_arg.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
941 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
942 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
943 n = args(0).int_value ();
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
944 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
945
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
946 if (! error_state)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
947 {
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
948 if (who == "dbup")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
949 n = -n;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
950
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
951 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
952 error ("%s: invalid stack frame", who.c_str ());
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
953 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
954 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
955
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
956 DEFUN (dbup, args, ,
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
957 "-*- texinfo -*-\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
958 @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
959 @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
960 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
961 If @var{n} is omitted, move up one frame.\n\
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
962 @seealso{dbstack}\n\
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
963 @end deftypefn")
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
964 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
965 octave_value retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
966
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
967 do_dbupdown (args, "dbup");
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
968
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
969 return retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
970 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
971
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
972 DEFUN (dbdown, args, ,
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
973 "-*- texinfo -*-\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
974 @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
975 @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
976 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
977 If @var{n} is omitted, move down one frame.\n\
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
978 @seealso{dbstack}\n\
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
979 @end deftypefn")
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
980 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
981 octave_value retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
982
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
983 do_dbupdown (args, "dbdown");
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
984
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
985 return retval;
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
986 }
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
987
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
988 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
989 "-*- texinfo -*-\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
990 @deftypefn {Command} {} dbstep\n\
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
991 @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
992 @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
993 @deftypefnx {Command} {} dbstep out\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
994 In debugging mode, execute the next @var{n} lines of code.\n\
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
995 If @var{n} is omitted , execute the next single line of code.\n\
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
996 If the next line of code is itself\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
997 defined in terms of an m-file remain in the existing function.\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
998 \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
999 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
1000 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
1001 execution to continue until the current function returns.\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
1002 @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
1003 @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
1004 {
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
1005 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
1006 {
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
1007 int nargin = args.length ();
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
1008
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
1009 if (nargin > 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1010 print_usage ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1011 else if (nargin == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1012 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1013 if (args(0).is_string ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1014 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1015 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
1016
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1017 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1018 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1019 if (arg == "in")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1020 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1021 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
1022
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1023 tree_evaluator::dbstep_flag = -1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1024 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1025 else if (arg == "out")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1026 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1027 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
1028
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1029 tree_evaluator::dbstep_flag = -2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1030 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1031 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1032 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1033 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
1034
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1035 if (n > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1036 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1037 Vdebugging = false;
7818
5640a70cbab1 Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents: 7787
diff changeset
1038
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1039 tree_evaluator::dbstep_flag = n;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1040 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1041 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1042 error ("dbstep: invalid argument");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1043 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1044 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1045 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1046 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1047 error ("dbstep: expecting character string as argument");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1048 }
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
1049 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1050 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1051 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
1052
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1053 tree_evaluator::dbstep_flag = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1054 }
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
1055 }
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
1056 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
1057 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
1058
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
1059 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
1060 }
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
1061
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1062 DEFALIAS (dbnext, dbstep);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1063
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1064 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
1065 "-*- texinfo -*-\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1066 @deftypefn {Command} {} dbcont\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
1067 In debugging mode, quit debugging mode and continue execution.\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1068 @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
1069 @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
1070 {
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
1071 if (Vdebugging)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1072 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1073 if (args.length () == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1074 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1075 Vdebugging = false;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1076
10186
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1077 tree_evaluator::reset_debug_state ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1078 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1079 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1080 print_usage ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1081 }
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
1082 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
1083 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
1084
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
1085 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
1086 }
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
1087
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1088 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
1089 "-*- texinfo -*-\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1090 @deftypefn {Command} {} 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
1091 In debugging mode, quit debugging mode and return to the top level.\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
1092 @seealso{dbstep, dbcont}\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
1093 @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
1094 {
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
1095 if (Vdebugging)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1096 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1097 if (args.length () == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1098 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1099 Vdebugging = false;
10186
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1100
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1101 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
1102
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1103 octave_throw_interrupt_exception ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1104 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1105 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1106 print_usage ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1107 }
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
1108 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
1109 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
1110
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
1111 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
1112 }
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
1113
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1114 DEFUN (isdebugmode, args, ,
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1115 "-*- texinfo -*-\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1116 @deftypefn {Loadable Function} {} isdebugmode ()\n\
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1117 Return true if debug mode is on, otherwise false.\n\
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1118 @seealso{dbstack, dbclear, dbstop, dbstatus}\n\
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1119 @end deftypefn")
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1120 {
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1121 octave_value retval;
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1122
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1123 if (args.length () == 0)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1124 retval = Vdebugging;
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1125 else
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1126 print_usage ();
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1127
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1128 return retval;
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1129 }