annotate libinterp/corefcn/debug.cc @ 20980:81c2b14c209f

maint: invert if/else/error instances. * Cell.cc, __ilu__.cc, bitfcns.cc, cellfun.cc data.cc, debug.cc, error.cc: Invert if/else/error instances.
author John W. Eaton <jwe@octave.org>
date Thu, 24 Dec 2015 13:55:51 -0500
parents 3aa293be0e8d
children 93748bcaec17
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1 /*
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19597
diff changeset
3 Copyright (C) 2001-2015 Ben Sapp
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11058
diff changeset
4 Copyright (C) 2007-2009 John Swensen
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
5
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
7
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
11 option) any later version.
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
12
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
16 for more details.
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
17
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
20 <http://www.gnu.org/licenses/>.
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
21
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
22 */
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
25 #endif
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
26
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
27 #include <deque>
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
28 #include <fstream>
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
29 #include <iomanip>
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
30 #include <iostream>
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
31 #include <set>
3948
126177939aae [project @ 2002-05-23 01:17:29 by jwe]
jwe
parents: 3947
diff changeset
32 #include <string>
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
33
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
34 #include "file-stat.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
35 #include "singleton-cleanup.h"
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
36
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
37 #include "defun.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
38 #include "error.h"
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
39 #include "help.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
40 #include "input.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
41 #include "pager.h"
16418
e1d92db3a715 use octave-link instead of hooks for breakpoint set/clear functions
John W. Eaton <jwe@octave.org>
parents: 16386
diff changeset
42 #include "octave-link.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20925
diff changeset
43 #include "ovl.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
44 #include "utils.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
45 #include "parse.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
46 #include "symtab.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
47 #include "gripes.h"
20925
667861ffffab Extracted header class octave-preserve-stream-state from utils.{cc/h}.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20918
diff changeset
48 #include "octave-preserve-stream-state.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
49 #include "ov.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
50 #include "ov-usr-fcn.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
51 #include "ov-fcn.h"
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
52 #include "ov-struct.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
53 #include "pt-pr-code.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
54 #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
55 #include "pt-eval.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
56 #include "pt-stmt.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
57 #include "toplev.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
58 #include "unwind-prot.h"
17818
f1b59ef34eda attempt to avoid setting persistent state on i/o streams (bug #40396)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
59 #include "utils.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
60 #include "variables.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
61
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
62 #include "debug.h"
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
63
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
64 // Initialize the singleton object
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
65 bp_table *bp_table::instance = 0;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
66
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
67 static std::string
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
68 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
69 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
70 std::string retval;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
71
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
72 file_stat fs (fname);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
73
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
74 if (fs)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
75 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
76 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
77
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
78 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
79
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
80 if (file)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
81 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
82 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
83
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
84 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
85
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
86 if (! file.eof ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
87 error ("error reading file %s", fname.c_str ());
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
88
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
89 // Expected to read the entire file.
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
90 retval = buf;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
91 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
92 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
93
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
94 return retval;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
95 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
96
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
97 static std::deque<size_t>
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
98 get_line_offsets (const std::string& buf)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
99 {
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
100 // This could maybe be smarter. Is deque the right thing to use here?
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
101
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
102 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
103
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
104 offsets.push_back (0);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
105
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
106 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
107
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
108 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
109 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
110 char c = buf[i];
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
111
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
112 if (c == '\r' && ++i < len)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
113 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
114 c = buf[i];
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
115
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
116 if (c == '\n')
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
117 offsets.push_back (i+1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
118 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
119 offsets.push_back (i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
120 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
121 else if (c == '\n')
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
122 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
123 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
124
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
125 offsets.push_back (len);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
126
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
127 return offsets;
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
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
130 std::string
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
131 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
132 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
133 std::string retval;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
134
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
135 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
136
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
137 static std::string buf;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
138
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
139 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
140
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
141 if (fname != last_fname)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
142 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
143 buf = snarf_file (fname);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
144
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
145 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
146 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
147
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
148 if (line > 0)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
149 line--;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
150
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
151 if (line < offsets.size () - 1)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
152 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
153 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
154 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
155
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
156 while (eol > 0 && eol > bol && (buf[eol-1] == '\n' || buf[eol-1] == '\r'))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
157 eol--;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
158
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
159 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
160 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
161
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
162 return retval;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
163 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
164
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5645
diff changeset
165 // 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
166 // 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
167 // current call stack.
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
168
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
169 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
170 get_user_code (const std::string& fname = std::string ())
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
171 {
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
172 octave_user_code *dbg_fcn = 0;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
173
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
174 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
175 dbg_fcn = octave_call_stack::caller_user_code ();
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5645
diff changeset
176 else
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
177 {
18236
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
178 std::string name = fname;
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
179
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
180 size_t name_len = name.length ();
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
181
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
182 if (! name.empty () && name_len > 2 && name.substr (name_len-2) == ".m")
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
183 name = name.substr (0, name_len-2);
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
184
0806c9e75e08 strip .m when setting or clearing breakpoints (bug #41126)
John W. Eaton <jwe@octave.org>
parents: 17818
diff changeset
185 octave_value fcn = symbol_table::find_function (name);
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
186
8123
eb2beef9a9ff clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents: 8114
diff changeset
187 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
188 dbg_fcn = fcn.user_code_value ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
189 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
190
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
191 return dbg_fcn;
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
192 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
193
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
194 static void
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
195 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
196 std::string& symbol_name, bp_table::intmap& lines)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
197 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
198 int idx = 0;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
199 int list_idx = 0;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
200 symbol_name = std::string ();
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
201 lines = bp_table::intmap ();
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
202
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
203 if (args.length () == 0)
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
204 return;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
205
18377
7cb745caaab5 Allow dbstop to set breakpoints outside of the function currently being debugged.
Rik <rik@octave.org>
parents: 18376
diff changeset
206 if (args(0).is_string ())
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
207 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
208 // string could be function name or line number
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
209 int isint = atoi (args(0).string_value ().c_str ());
18377
7cb745caaab5 Allow dbstop to set breakpoints outside of the function currently being debugged.
Rik <rik@octave.org>
parents: 18376
diff changeset
210
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
211 if (isint == 0)
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
212 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
213 // It was a function name
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
214 symbol_name = args(0).string_value ();
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
215
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
216 idx = 1;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
217 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
218 else
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
219 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
220 // It was a line number. Need to get function name from debugger.
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
221 if (! Vdebugging)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20819
diff changeset
222 error ("%s: no function specified", who);
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
223
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
224 symbol_name = get_user_code ()->name ();
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
225 idx = 0;
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
226 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
227 }
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
228 else if (args(0).is_map ())
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
229 {
18377
7cb745caaab5 Allow dbstop to set breakpoints outside of the function currently being debugged.
Rik <rik@octave.org>
parents: 18376
diff changeset
230 // This is a problem because parse_dbfunction_params()
7cb745caaab5 Allow dbstop to set breakpoints outside of the function currently being debugged.
Rik <rik@octave.org>
parents: 18376
diff changeset
231 // can only pass out a single function.
7cb745caaab5 Allow dbstop to set breakpoints outside of the function currently being debugged.
Rik <rik@octave.org>
parents: 18376
diff changeset
232 error ("%s: struct input not implemented", who);
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
233 }
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
234 else
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
235 error ("%s: invalid parameter specified", who);
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
236
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
237 for (int i = idx; i < args.length (); i++)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
238 {
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
239 if (args(i).is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
240 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14228
diff changeset
241 int line = atoi (args(i).string_value ().c_str ());
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
242
10315
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 }
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
245 else if (args(i).is_map ())
18377
7cb745caaab5 Allow dbstop to set breakpoints outside of the function currently being debugged.
Rik <rik@octave.org>
parents: 18376
diff changeset
246 octave_stdout << who << ": skipping struct input" << std::endl;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
247 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
248 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
249 const NDArray arg = args(i).array_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
250
20228
00cf2847355d Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20172
diff changeset
251 for (octave_idx_type j = 0; j < arg.numel (); j++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
252 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
253 int line = static_cast<int> (arg.elem (j));
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
254
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
255 lines[list_idx++] = line;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
256 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
257 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
258 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
259 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
260
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
261 bool
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
262 bp_table::instance_ok (void)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
263 {
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
264 if (! instance)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
265 {
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
266 instance = new bp_table ();
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
267
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
268 if (instance)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
269 singleton_cleanup_list::add (cleanup_instance);
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
270 }
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
271
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
272 if (! instance)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20819
diff changeset
273 error ("unable to create breakpoint table!");
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
274
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
275 return true;
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
276 }
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13784
diff changeset
277
16596
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
278 bool
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
279 bp_table::do_add_breakpoint_1 (octave_user_code *fcn,
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
280 const std::string& fname,
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
281 const bp_table::intmap& line,
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
282 bp_table::intmap& retval)
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
283 {
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
284 bool found = false;
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
285
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
286 tree_statement_list *cmds = fcn->body ();
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
287
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
288 std::string file = fcn->fcn_file_name ();
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
289
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
290 if (cmds)
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
291 {
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
292 retval = cmds->add_breakpoint (file, line);
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
293
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
294 for (intmap_iterator p = retval.begin (); p != retval.end (); p++)
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
295 {
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
296 if (p->second != 0)
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
297 {
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
298 bp_set.insert (fname);
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
299 found = true;
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
300 break;
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
301 }
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
302 }
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
303 }
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
304
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
305 return found;
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
306 }
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
307
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
308 bp_table::intmap
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
309 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
310 const bp_table::intmap& line)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
311 {
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
312 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
313
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
314 if (! dbg_fcn)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
315 error ("add_breakpoint: unable to find the requested function\n");
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
316
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
317 intmap retval;
16627
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
318
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
319 if (! do_add_breakpoint_1 (dbg_fcn, fname, line, retval))
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
320 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
321 // Search subfunctions in the order they appear in the file.
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
322
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
323 const std::list<std::string> subfcn_names
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
324 = dbg_fcn->subfunction_names ();
16531
f3a63fdbd725 finish botched changeset 7ca7e7d5eb91
John W. Eaton <jwe@octave.org>
parents: 16530
diff changeset
325
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
326 std::map<std::string, octave_value> subfcns
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
327 = dbg_fcn->subfunctions ();
16596
645672f1c873 handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents: 16531
diff changeset
328
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
329 for (std::list<std::string>::const_iterator p = subfcn_names.begin ();
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
330 p != subfcn_names.end (); p++)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
331 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
332 std::map<std::string, octave_value>::const_iterator
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
333 q = subfcns.find (*p);
16627
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
334
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
335 if (q != subfcns.end ())
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
336 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
337 octave_user_code *dbg_subfcn = q->second.user_code_value ();
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
338
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
339 if (do_add_breakpoint_1 (dbg_subfcn, fname, line, retval))
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
340 break;
16531
f3a63fdbd725 finish botched changeset 7ca7e7d5eb91
John W. Eaton <jwe@octave.org>
parents: 16530
diff changeset
341 }
f3a63fdbd725 finish botched changeset 7ca7e7d5eb91
John W. Eaton <jwe@octave.org>
parents: 16530
diff changeset
342 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
343 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
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
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
350 int
16627
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
351 bp_table::do_remove_breakpoint_1 (octave_user_code *fcn,
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
352 const std::string& fname,
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
353 const bp_table::intmap& line)
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
354 {
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
355 int retval = 0;
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
356
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
357 std::string file = fcn->fcn_file_name ();
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
358
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
359 tree_statement_list *cmds = fcn->body ();
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
360
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
361 // FIXME: move the operation on cmds to the tree_statement_list class?
16627
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
362
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
363 if (cmds)
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
364 {
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
365 octave_value_list results = cmds->list_breakpoints ();
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
366
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
367 if (results.length () > 0)
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
368 {
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
369 octave_idx_type len = line.size ();
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
370
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
371 for (int i = 0; i < len; i++)
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
372 {
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
373 const_intmap_iterator p = line.find (i);
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
374
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
375 if (p != line.end ())
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
376 {
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
377 int lineno = p->second;
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
378
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
379 cmds->delete_breakpoint (lineno);
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
380
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
381 if (! file.empty ())
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
382 octave_link::update_breakpoint (false, file, lineno);
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
383 }
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
384 }
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
385
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
386 results = cmds->list_breakpoints ();
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
387
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
388 bp_set_iterator it = bp_set.find (fname);
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
389 if (results.length () == 0 && it != bp_set.end ())
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
390 bp_set.erase (it);
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
391 }
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
392
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
393 retval = results.length ();
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
394 }
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
395
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
396 return retval;
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
397 }
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
398
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
399 int
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
400 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
401 const bp_table::intmap& line)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
402 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
403 int retval = 0;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
404
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
405 octave_idx_type len = line.size ();
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 (len == 0)
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
408 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
409 intmap results = remove_all_breakpoints_in_file (fname);
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
410 retval = results.size ();
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
411 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
412 else
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
413 {
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
414 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
415
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
416 if (! dbg_fcn)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
417 error ("remove_breakpoint: unable to find the requested function\n");
16386
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16342
diff changeset
418
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
419 retval = do_remove_breakpoint_1 (dbg_fcn, fname, line);
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
420
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
421 // Search subfunctions in the order they appear in the file.
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
422
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
423 const std::list<std::string> subfcn_names
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
424 = dbg_fcn->subfunction_names ();
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
425
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
426 std::map<std::string, octave_value> subfcns
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
427 = dbg_fcn->subfunctions ();
16386
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16342
diff changeset
428
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
429 for (std::list<std::string>::const_iterator p = subfcn_names.begin ();
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
430 p != subfcn_names.end (); p++)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
431 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
432 std::map<std::string, octave_value>::const_iterator
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
433 q = subfcns.find (*p);
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
434
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
435 if (q != subfcns.end ())
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
436 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
437 octave_user_code *dbg_subfcn = q->second.user_code_value ();
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
438
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
439 retval += do_remove_breakpoint_1 (dbg_subfcn, fname, line);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
440 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
441 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
442 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
443
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
444 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
445
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
446 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
447 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
448
20674
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
449 // Remove all breakpoints from a file, including those in subfunctions
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
450 bp_table::intmap
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
451 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
452 bool silent)
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 intmap retval;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
455
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
456 octave_user_code *dbg_fcn = get_user_code (fname);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
457
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
458 if (dbg_fcn)
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
459 {
20674
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
460 std::string file = dbg_fcn->fcn_file_name ();
16386
4902484f9181 callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents: 16342
diff changeset
461
20674
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
462 tree_statement_list *cmds = dbg_fcn->body ();
16627
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
463
20674
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
464 if (cmds)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
465 {
20674
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
466 retval = cmds->remove_all_breakpoints (file);
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
467
20674
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
468 bp_set_iterator it = bp_set.find (fname);
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
469 if (it != bp_set.end ())
78b3e9868b67 Fix segfault with 'dbclear all' (bug #41843).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20172
diff changeset
470 bp_set.erase (it);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
471 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
472 }
8123
eb2beef9a9ff clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents: 8114
diff changeset
473 else if (! silent)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
474 error ("remove_all_breakpoint_in_file: "
14049
b5a8e245b4eb Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents: 14035
diff changeset
475 "unable to find the requested function\n");
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
476
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
477 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
478
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
479 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
480 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
481
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
482 void
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
483 bp_table::do_remove_all_breakpoints (void)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
484 {
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
485 // Odd loop structure required because delete will invalidate bp_set iterators
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
486 for (const_bp_set_iterator it=bp_set.begin (), it_next=it;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
487 it != bp_set.end ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
488 it=it_next)
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
489 {
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
490 ++it_next;
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
491 remove_all_breakpoints_in_file (*it);
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
492 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
493
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
494 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
495 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
496
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
497 std::string
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
498 do_find_bkpt_list (octave_value_list slist, std::string match)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
499 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
500 std::string retval;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
501
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
502 for (int i = 0; i < slist.length (); i++)
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
503 {
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
504 if (slist(i).string_value () == match)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
505 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
506 retval = slist(i).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
507 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
508 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
509 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
510
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
511 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
512 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
513
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
514 bp_table::fname_line_map
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
515 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
516 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
517 fname_line_map retval;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
518
9183
94ae487acd1b use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents: 9039
diff changeset
519 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
520 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
521 if (fname_list.length () == 0
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
522 || do_find_bkpt_list (fname_list, *it) != "")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
523 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
524 octave_user_code *f = get_user_code (*it);
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
525
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
526 if (f)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
527 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
528 tree_statement_list *cmds = f->body ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
529
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
530 // FIXME: move the operation on cmds to the
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
531 // tree_statement_list class?
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
532 if (cmds)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
533 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
534 octave_value_list bkpts = cmds->list_breakpoints ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
535 octave_idx_type len = bkpts.length ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
536
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
537 if (len > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
538 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
539 bp_table::intmap bkpts_vec;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
540
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
541 for (int i = 0; i < len; i++)
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
542 bkpts_vec[i] = bkpts(i).double_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
543
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
544 std::string symbol_name = f->name ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
545
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
546 retval[symbol_name] = bkpts_vec;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
547 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
548 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
549 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
550 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
551 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
552
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
553 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
554 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
555
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
556 static octave_value
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
557 intmap_to_ov (const bp_table::intmap& line)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
558 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
559 int idx = 0;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
560
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
561 NDArray retval (dim_vector (1, line.size ()));
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
562
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
563 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
564 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
565 bp_table::const_intmap_iterator p = line.find (i);
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
566
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
567 if (p != line.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
568 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
569 int lineno = p->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
570 retval(idx++) = lineno;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
571 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
572 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
573
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
574 retval.resize (dim_vector (1, idx));
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
575
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
576 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
577 }
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
578
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
579 DEFUN (dbstop, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
580 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
581 @deftypefn {} {} dbstop @var{func}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
582 @deftypefnx {} {} dbstop @var{func} @var{line}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
583 @deftypefnx {} {} dbstop @var{func} @var{line1} @var{line2} @dots{}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
584 @deftypefnx {} {} dbstop @var{line} @dots{}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
585 @deftypefnx {} {@var{rline} =} dbstop (\"@var{func}\")\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
586 @deftypefnx {} {@var{rline} =} dbstop (\"@var{func}\", @var{line})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
587 @deftypefnx {} {@var{rline} =} dbstop (\"@var{func}\", @var{line1}, @var{line2}, @dots{})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
588 @deftypefnx {} {} dbstop (\"@var{func}\", [@var{line1}, @dots{}])\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
589 @deftypefnx {} {} dbstop (@var{line}, @dots{})\n\
18380
b48391da83fc doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents: 18379
diff changeset
590 Set a breakpoint at line number @var{line} in function @var{func}.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
591 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
592 Arguments are\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
593 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
594 @table @var\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
595 @item func\n\
18380
b48391da83fc doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents: 18379
diff changeset
596 Function name as a string variable. When already in debug mode this argument\n\
b48391da83fc doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents: 18379
diff changeset
597 can be omitted and the current function will be used.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10839
diff changeset
598 \n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
599 @item line\n\
18380
b48391da83fc doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents: 18379
diff changeset
600 Line number where the breakpoint should be set. Multiple lines may be given\n\
b48391da83fc doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents: 18379
diff changeset
601 as separate arguments or as a vector.\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
602 @end table\n\
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
603 \n\
18380
b48391da83fc doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents: 18379
diff changeset
604 When called with a single argument @var{func}, the breakpoint is set at the\n\
b48391da83fc doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents: 18379
diff changeset
605 first executable line in the named function.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
606 \n\
18380
b48391da83fc doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents: 18379
diff changeset
607 The optional output @var{rline} is the real line number where the breakpoint\n\
b48391da83fc doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents: 18379
diff changeset
608 was set. This can differ from the specified line if the line is not\n\
b48391da83fc doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents: 18379
diff changeset
609 executable. For example, if a breakpoint attempted on a blank line then\n\
b48391da83fc doc: Improve docstrings for dbstop, dbup, dbdown.
Rik <rik@octave.org>
parents: 18379
diff changeset
610 Octave will set the real breakpoint at the next executable line.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
611 @seealso{dbclear, dbstatus, dbstep, debug_on_error, debug_on_warning, debug_on_interrupt}\n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
612 @end deftypefn")
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
613 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
614 bp_table::intmap retval;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
615 std::string symbol_name;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
616 bp_table::intmap lines;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
617
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
618 parse_dbfunction_params ("dbstop", args, symbol_name, lines);
6646
bd0a70c3f2db [project @ 2007-05-22 02:27:43 by jwe]
jwe
parents: 6317
diff changeset
619
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
620 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
621 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
622
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
623 retval = bp_table::add_breakpoint (symbol_name, lines);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
624
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
625 return intmap_to_ov (retval);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
626 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
627
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
628 DEFUN (dbclear, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
629 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
630 @deftypefn {} {} dbclear @var{func}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
631 @deftypefnx {} {} dbclear @var{func} @var{line}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
632 @deftypefnx {} {} dbclear @var{func} @var{line1} @var{line2} @dots{}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
633 @deftypefnx {} {} dbclear @var{line} @dots{}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
634 @deftypefnx {} {} dbclear all\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
635 @deftypefnx {} {} dbclear (\"@var{func}\")\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
636 @deftypefnx {} {} dbclear (\"@var{func}\", @var{line})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
637 @deftypefnx {} {} dbclear (\"@var{func}\", @var{line1}, @var{line2}, @dots{})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
638 @deftypefnx {} {} dbclear (\"@var{func}\", [@var{line1}, @dots{}])\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
639 @deftypefnx {} {} dbclear (@var{line}, @dots{})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
640 @deftypefnx {} {} dbclear (\"all\")\n\
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
641 Delete a breakpoint at line number @var{line} in the function @var{func}.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
642 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
643 Arguments are\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
644 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
645 @table @var\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
646 @item func\n\
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
647 Function name as a string variable. When already in debug mode this argument\n\
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
648 can be omitted and the current function will be used.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10839
diff changeset
649 \n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
650 @item line\n\
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
651 Line number from which to remove a breakpoint. Multiple lines may be given\n\
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
652 as separate arguments or as a vector.\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
653 @end table\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
654 \n\
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
655 When called without a line number specification all breakpoints in the named\n\
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
656 function are cleared.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
657 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
658 If the requested line is not a breakpoint no action is performed.\n\
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
659 \n\
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
660 The special keyword @qcode{\"all\"} will clear all breakpoints from all\n\
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
661 files.\n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
662 @seealso{dbstop, dbstatus, dbwhere}\n\
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
663 @end deftypefn")
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
664 {
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
665 std::string symbol_name = "";
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
666 bp_table::intmap lines;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
667
7348
d1a97ad87264 [project @ 2008-01-04 21:49:15 by jwe]
jwe
parents: 7336
diff changeset
668 parse_dbfunction_params ("dbclear", args, symbol_name, lines);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
669
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
670 if (args.length () == 1 && symbol_name == "all")
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
671 bp_table::remove_all_breakpoints ();
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
672 else
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
673 bp_table::remove_breakpoint (symbol_name, lines);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
674
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
675 return ovl ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
676 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
677
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
678 DEFUN (dbstatus, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
679 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
680 @deftypefn {} {} dbstatus ()\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
681 @deftypefnx {} {@var{brk_list} =} dbstatus ()\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
682 @deftypefnx {} {@var{brk_list} =} dbstatus (\"@var{func}\")\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
683 Report the location of active breakpoints.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
684 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
685 When called with no input or output arguments, print the list of all\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
686 functions with breakpoints and the line numbers where those breakpoints are\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
687 set.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
688 \n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
689 If a function name @var{func} is specified then only report breakpoints\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
690 for the named function.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
691 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
692 The optional return argument @var{brk_list} is a struct array with the\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
693 following fields.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
694 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
695 @table @asis\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
696 @item name\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
697 The name of the function with a breakpoint.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
698 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
699 @item file\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
700 The name of the m-file where the function code is located.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
701 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
702 @item line\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
703 A line number, or vector of line numbers, with a breakpoint.\n\
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
704 @end table\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
705 \n\
18377
7cb745caaab5 Allow dbstop to set breakpoints outside of the function currently being debugged.
Rik <rik@octave.org>
parents: 18376
diff changeset
706 Note: When @code{dbstatus} is called from the debug prompt within a function,\n\
7cb745caaab5 Allow dbstop to set breakpoints outside of the function currently being debugged.
Rik <rik@octave.org>
parents: 18376
diff changeset
707 the list of breakpoints is automatically trimmed to the breakpoints in the\n\
7cb745caaab5 Allow dbstop to set breakpoints outside of the function currently being debugged.
Rik <rik@octave.org>
parents: 18376
diff changeset
708 current function.\n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
709 @seealso{dbclear, dbwhere}\n\
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
710 @end deftypefn")
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
711 {
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
712 int nargin = args.length ();
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
713
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
714 if (nargin != 0 && nargin != 1)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
715 error ("dbstatus: only zero or one arguments accepted\n");
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
716
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
717 octave_value_list fcn_list;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
718 bp_table::fname_line_map bp_list;
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
719 std::string symbol_name;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
720
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
721 if (nargin == 1)
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
722 {
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
723 if (args(0).is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
724 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
725 symbol_name = args(0).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
726 fcn_list(0) = symbol_name;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
727 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
728 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
729 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
730 gripe_wrong_type_arg ("dbstatus", args(0));
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
731 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
732 else
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
733 {
18376
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
734 if (Vdebugging)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
735 {
18376
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
736 octave_user_code *dbg_fcn = get_user_code ();
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
737 if (dbg_fcn)
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
738 {
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
739 symbol_name = dbg_fcn->name ();
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
740 fcn_list(0) = symbol_name;
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
741 }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
742 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
743
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
744 bp_list = bp_table::get_breakpoint_list (fcn_list);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
745 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
746
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
747 if (nargout == 0)
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
748 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
749 // Print out the breakpoint information.
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
750
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
751 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
752 it != bp_list.end (); it++)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
753 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
754 bp_table::intmap m = it->second;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
755
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
756 size_t nel = m.size ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
757
14228
0beb62668d69 Use correct plural for dbstatus if there is more than 1 breakpoint set in file.
Rik <octave@nomad.inbox5.com>
parents: 14227
diff changeset
758 octave_stdout << "breakpoint in " << it->first;
0beb62668d69 Use correct plural for dbstatus if there is more than 1 breakpoint set in file.
Rik <octave@nomad.inbox5.com>
parents: 14227
diff changeset
759 if (nel > 1)
0beb62668d69 Use correct plural for dbstatus if there is more than 1 breakpoint set in file.
Rik <octave@nomad.inbox5.com>
parents: 14227
diff changeset
760 octave_stdout << " at lines ";
0beb62668d69 Use correct plural for dbstatus if there is more than 1 breakpoint set in file.
Rik <octave@nomad.inbox5.com>
parents: 14227
diff changeset
761 else
0beb62668d69 Use correct plural for dbstatus if there is more than 1 breakpoint set in file.
Rik <octave@nomad.inbox5.com>
parents: 14227
diff changeset
762 octave_stdout << " at line ";
0beb62668d69 Use correct plural for dbstatus if there is more than 1 breakpoint set in file.
Rik <octave@nomad.inbox5.com>
parents: 14227
diff changeset
763
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
764 for (size_t j = 0; j < nel; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
765 octave_stdout << m[j] << ((j < nel - 1) ? ", " : ".");
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
766
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
767 if (nel > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
768 octave_stdout << std::endl;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
769 }
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
770 return ovl ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
771 }
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
772 else
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
773 {
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
774 // Fill in an array for return.
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
775
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
776 int i = 0;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
777 Cell names (dim_vector (bp_list.size (), 1));
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
778 Cell file (dim_vector (bp_list.size (), 1));
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
779 Cell line (dim_vector (bp_list.size (), 1));
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
780
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
781 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
782 it != bp_list.end (); it++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
783 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
784 names(i) = it->first;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
785 line(i) = intmap_to_ov (it->second);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
786 file(i) = do_which (it->first);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
787 i++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
788 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
789
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
790 octave_map retval;
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
791 retval.assign ("name", names);
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
792 retval.assign ("file", file);
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
793 retval.assign ("line", line);
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
794
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
795 return ovl (retval);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
796 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
797 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
798
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
799 DEFUN (dbwhere, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
800 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
801 @deftypefn {} {} dbwhere\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
802 In debugging mode, report the current file and line number where execution\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
803 is stopped.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
804 @seealso{dbstatus, dbcont, dbstep, dbup}\n\
5645
9c9bd01099ce [project @ 2006-03-06 22:33:54 by jwe]
jwe
parents: 5642
diff changeset
805 @end deftypefn")
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
806 {
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7539
diff changeset
807 octave_user_code *dbg_fcn = get_user_code ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
808
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
809 if (! dbg_fcn)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
810 error ("dbwhere: must be inside a user function to use dbwhere\n");
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
811
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
812 bool have_file = true;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
813
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
814 std::string name = dbg_fcn->fcn_file_name ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
815
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
816 if (name.empty ())
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
817 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
818 have_file = false;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
819
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
820 name = dbg_fcn->name ();
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
821 }
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9377
diff changeset
822
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
823 octave_stdout << "stopped in " << name << " at ";
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
824
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
825 int l = octave_call_stack::caller_user_code_line ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
826
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
827 if (l > 0)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
828 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
829 octave_stdout << "line " << l << std::endl;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
830
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
831 if (have_file)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
832 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
833 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
834
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
835 if (! line.empty ())
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
836 octave_stdout << l << ": " << line << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
837 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
838 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
839 else
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
840 octave_stdout << "<unknown line>" << std::endl;
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
841
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
842 return ovl ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
843 }
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
844
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
845 void
3949
294f13627ee8 [project @ 2002-05-23 01:22:11 by jwe]
jwe
parents: 3948
diff changeset
846 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
847 {
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
848 std::string ff = fcn_file_in_path (name);
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
849
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
850 if (! ff.empty ())
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
851 os << "dbtype: unknown function " << name << "\n";
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
852
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
853 std::ifstream fs (ff.c_str (), std::ios::in);
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
854
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
855 if (! fs)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
856 os << "dbtype: unable to open '" << ff << "' for reading!\n";
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
857
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
858 int line = 1;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
859 std::string text;
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19405
diff changeset
860
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
861 while (std::getline (fs, text) && line <= end)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
862 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
863 if (line >= start)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
864 os << line << "\t" << text << "\n";
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
865
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
866 line++;
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
867 }
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
868
6646
bd0a70c3f2db [project @ 2007-05-22 02:27:43 by jwe]
jwe
parents: 6317
diff changeset
869 os.flush ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
870 }
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
871
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
872 DEFUN (dbtype, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
873 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
874 @deftypefn {} {} dbtype\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
875 @deftypefnx {} {} dbtype @var{lineno}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
876 @deftypefnx {} {} dbtype @var{startl:endl}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
877 @deftypefnx {} {} dbtype @var{startl:end}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
878 @deftypefnx {} {} dbtype @var{func}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
879 @deftypefnx {} {} dbtype @var{func} @var{lineno}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
880 @deftypefnx {} {} dbtype @var{func} @var{startl:endl}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
881 @deftypefnx {} {} dbtype @var{func} @var{startl:end}\n\
15577
cef958fbae2d doc: Update docstring for dbtype().
Rik <rik@octave.org>
parents: 15467
diff changeset
882 Display a script file with line numbers.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
883 \n\
15577
cef958fbae2d doc: Update docstring for dbtype().
Rik <rik@octave.org>
parents: 15467
diff changeset
884 When called with no arguments in debugging mode, display the script file\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
885 currently being debugged.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
886 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
887 An optional range specification can be used to list only a portion of the\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
888 file. The special keyword @qcode{\"end\"} is a valid line number\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
889 specification for the last line of the file.\n\
15577
cef958fbae2d doc: Update docstring for dbtype().
Rik <rik@octave.org>
parents: 15467
diff changeset
890 \n\
cef958fbae2d doc: Update docstring for dbtype().
Rik <rik@octave.org>
parents: 15467
diff changeset
891 When called with the name of a function, list that script file with line\n\
cef958fbae2d doc: Update docstring for dbtype().
Rik <rik@octave.org>
parents: 15467
diff changeset
892 numbers.\n\
cef958fbae2d doc: Update docstring for dbtype().
Rik <rik@octave.org>
parents: 15467
diff changeset
893 @seealso{dbwhere, dbstatus, dbstop}\n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
894 @end deftypefn")
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
895 {
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
896 octave_user_code *dbg_fcn;
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
897
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
898 string_vector argv = args.make_argv ("dbtype");
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
899
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
900 switch (args.length ())
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
901 {
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
902 case 0: // dbtype
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
903 dbg_fcn = get_user_code ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
904
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
905 if (! dbg_fcn)
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
906 error ("dbtype: must be inside a user function to give no arguments to dbtype\n");
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
907
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
908 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
909 0, std::numeric_limits<int>::max ());
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
910
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
911 break;
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
912
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
913 case 1: // (dbtype start:end) || (dbtype func) || (dbtype lineno)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
914 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
915 std::string arg = argv[1];
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
916
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
917 size_t ind = arg.find (':');
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
918
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
919 if (ind != std::string::npos) // (dbtype start:end)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
920 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
921 dbg_fcn = get_user_code ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
922
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
923 if (dbg_fcn)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
924 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
925 std::string start_str = arg.substr (0, ind);
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
926 std::string end_str = arg.substr (ind + 1);
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
927
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
928 int start, end;
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
929 start = atoi (start_str.c_str ());
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
930 if (end_str == "end")
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
931 end = std::numeric_limits<int>::max ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
932 else
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
933 end = atoi (end_str.c_str ());
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
934
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
935 if (std::min (start, end) <= 0)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20819
diff changeset
936 error ("dbtype: start and end lines must be >= 1\n");
18393
6a2cc29f55fc Correctly handle 'dbtype lineno' case.
Rik <rik@octave.org>
parents: 18392
diff changeset
937
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
938 if (start > end)
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
939 error ("dbtype: start line must be less than end line\n");
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
940
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
941 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
942 start, end);
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
943 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
944 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
945 else // (dbtype func) || (dbtype lineno)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
946 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
947 int line = atoi (arg.c_str ());
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
948
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
949 if (line == 0) // (dbtype func)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
950 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
951 dbg_fcn = get_user_code (arg);
14227
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
952
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
953 if (! dbg_fcn)
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
954 error ("dbtype: function <%s> not found\n", arg.c_str ());
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
955
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
956 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
957 0, std::numeric_limits<int>::max ());
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
958 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
959 else // (dbtype lineno)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
960 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
961 if (line <= 0)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20819
diff changeset
962 error ("dbtype: start and end lines must be >= 1\n");
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
963
14227
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
964 dbg_fcn = get_user_code ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
965
14227
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
966 if (dbg_fcn)
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
967 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
968 line, line);
14227
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
969 }
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
970 }
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
971 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
972 break;
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
973
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
974 case 2: // (dbtype func start:end) || (dbtype func start)
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
975 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
976 dbg_fcn = get_user_code (argv[1]);
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
977
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
978 if (! dbg_fcn)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
979 error ("dbtype: function <%s> not found\n", argv[1].c_str ());
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
980
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
981 std::string arg = argv[2];
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
982 int start, end;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
983 size_t ind = arg.find (':');
6317
8c67f8be341d [project @ 2007-02-16 08:10:53 by jwe]
jwe
parents: 5744
diff changeset
984
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
985 if (ind != std::string::npos)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
986 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
987 std::string start_str = arg.substr (0, ind);
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
988 std::string end_str = arg.substr (ind + 1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
989
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
990 start = atoi (start_str.c_str ());
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
991 if (end_str == "end")
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
992 end = std::numeric_limits<int>::max ();
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
993 else
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
994 end = atoi (end_str.c_str ());
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
995 }
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
996 else
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
997 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
998 start = atoi (arg.c_str ());
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
999 end = start;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1000 }
14227
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1001
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1002 if (std::min (start, end) <= 0)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1003 error ("dbtype: start and end lines must be >= 1\n");
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1004
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
1005 if (start > end)
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1006 error ("dbtype: start line must be less than end line\n");
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1007
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1008 do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (), start, end);
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1009 }
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1010 break;
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1011
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1012 default:
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1013 error ("dbtype: expecting zero, one, or two arguments\n");
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
1014 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1015
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1016 return ovl ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1017 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
1018
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1019 DEFUN (dblist, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
1020 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1021 @deftypefn {} {} dblist\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1022 @deftypefnx {} {} dblist @var{n}\n\
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1023 In debugging mode, list @var{n} lines of the function being debugged\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1024 centered around the current line to be executed.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1025 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1026 If unspecified @var{n} defaults to 10 (+/- 5 lines)\n\
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1027 @seealso{dbwhere, dbtype}\n\
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1028 @end deftypefn")
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1029 {
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1030 int n = 10;
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1031
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1032 if (args.length () == 1)
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1033 {
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1034 octave_value arg = args(0);
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1035
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1036 if (arg.is_string ())
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1037 {
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1038 std::string s_arg = arg.string_value ();
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1039
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1040 n = atoi (s_arg.c_str ());
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1041 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1042 else
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1043 n = args(0).int_value ();
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1044
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1045 if (n < 0)
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1046 error ("dblist: N must be a non-negative integer");
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1047 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1048
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1049 octave_user_code *dbg_fcn = get_user_code ();
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1050
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1051 if (! dbg_fcn)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1052 error ("dblist: must be inside a user function to use dblist\n");
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1053
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1054 bool have_file = true;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1055
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1056 std::string name = dbg_fcn->fcn_file_name ();
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1057
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1058 if (name.empty ())
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1059 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1060 have_file = false;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1061 name = dbg_fcn->name ();
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1062 }
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1063
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1064 int l = octave_call_stack::caller_user_code_line ();
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1065
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1066 if (l > 0)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1067 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1068 if (have_file)
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1069 {
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1070 int l_min = std::max (l - n/2, 0);
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1071 int l_max = l + n/2;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1072 do_dbtype (octave_stdout, name, l_min, l-1);
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1073
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1074 std::string line = get_file_line (name, l);
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1075 if (! line.empty ())
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1076 octave_stdout << l << "-->\t" << line << std::endl;
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1077
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1078 do_dbtype (octave_stdout, name, l+1, l_max);
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1079 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1080 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1081 else
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1082 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1083 octave_stdout << "dblist: unable to determine source code line"
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1084 << std::endl;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1085 }
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1086
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1087 return ovl ();
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1088 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
1089
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1090 static octave_value_list
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1091 do_dbstack (const octave_value_list& args, int nargout, std::ostream& os)
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1092 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1093 int nargin = args.length ();
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1094
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1095 if (nargin > 2)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1096 print_usage ();
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1097
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1098 octave_value_list retval;
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1099
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9724
diff changeset
1100 unwind_protect frame;
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1101
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7897
diff changeset
1102 octave_idx_type curr_frame = -1;
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1103
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7897
diff changeset
1104 size_t nskip = 0;
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1105
20817
3d551b2ae928 Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents: 20804
diff changeset
1106 if (nargin == 1 || nargin == 2)
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1107 {
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1108 int n = 0;
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1109
20817
3d551b2ae928 Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents: 20804
diff changeset
1110 for (octave_idx_type i = 0; i < nargin; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1111 {
17649
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1112 octave_value arg = args(i);
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1113
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1114 if (arg.is_string ())
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1115 {
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1116 std::string s_arg = arg.string_value ();
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1117
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1118 // Skip "-completenames", octave returns full names anyway.
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1119
17649
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1120 if (s_arg == "-completenames")
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1121 continue;
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1122
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1123 n = atoi (s_arg.c_str ());
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1124 }
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1125 else
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1126 n = arg.int_value ();
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1127
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1128 if (n <= 0)
17649
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1129 error ("dbstack: N must be a non-negative integer");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1130 }
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1131
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1132 if (n > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1133 nskip = n;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1134 }
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1135
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1136 if (nargout == 0)
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1137 {
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1138 octave_map stk = octave_call_stack::backtrace (nskip, curr_frame);
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1139 octave_idx_type nframes_to_display = stk.numel ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1140
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1141 if (nframes_to_display > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1142 {
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1143 octave_preserve_stream_state stream_state (os);
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1144
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1145 os << "stopped in:\n\n";
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1146
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1147 Cell names = stk.contents ("name");
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1148 Cell files = stk.contents ("file");
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1149 Cell lines = stk.contents ("line");
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1150
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1151 bool show_top_level = true;
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1152
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1153 size_t max_name_len = 0;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1154
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1155 for (octave_idx_type i = 0; i < nframes_to_display; i++)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1156 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1157 std::string name = names(i).string_value ();
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1158
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1159 max_name_len = std::max (name.length (), max_name_len);
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1160 }
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
1161
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1162 for (octave_idx_type i = 0; i < nframes_to_display; i++)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1163 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1164 std::string name = names(i).string_value ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1165 std::string file = files(i).string_value ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1166 int line = lines(i).int_value ();
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1167
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1168 if (show_top_level && i == curr_frame)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1169 show_top_level = false;
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1170
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1171 os << (i == curr_frame ? " --> " : " ")
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1172 << std::setw (max_name_len) << name
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1173 << " at line " << line
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1174 << " [" << file << "]"
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1175 << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1176 }
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1177
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1178 if (show_top_level)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1179 os << " --> top level" << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1180 }
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1181 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1182 else
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1183 {
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1184 octave_map stk = octave_call_stack::backtrace (nskip, curr_frame, false);
18440
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18398
diff changeset
1185
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1186 retval = ovl (stk, curr_frame < 0 ? 1 : curr_frame + 1);
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1187 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1188
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1189 return retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1190 }
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1191
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1192 // A function that can be easily called from a debugger print the Octave stack.
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1193 // This can be useful for finding what line of code the interpreter is
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1194 // currently executing when the debugger is stopped in some C++ function,
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1195 // for example.
13326
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
1196
13784
0bbe319bf26b octave_class::size: return matrix with correct dimensions
John W. Eaton <jwe@octave.org>
parents: 13689
diff changeset
1197 void
13326
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
1198 show_octave_dbstack (void)
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
1199 {
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1200 do_dbstack (octave_value_list (), 0, std::cerr);
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1201 }
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1202
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1203 DEFUN (dbstack, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
1204 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1205 @deftypefn {} {} dbstack\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1206 @deftypefnx {} {} dbstack @var{n}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1207 @deftypefnx {} {} dbstack @var{-completenames}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1208 @deftypefnx {} {[@var{stack}, @var{idx}] =} dbstack (@dots{})\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1209 Display or return current debugging function stack information.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1210 \n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1211 With optional argument @var{n}, omit the @var{n} innermost stack frames.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1212 \n\
17649
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1213 Although accepted, the argument @var{-completenames} is silently ignored.\n\
20713
2469d78a1d8b Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents: 20700
diff changeset
1214 Octave always returns absolute filenames.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1215 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1216 The arguments @var{n} and @var{-completenames} can be both specified in any\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1217 order.\n\
17649
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
1218 \n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1219 The optional return argument @var{stack} is a struct array with the\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1220 following fields:\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1221 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1222 @table @asis\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1223 @item file\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1224 The name of the m-file where the function code is located.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1225 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1226 @item name\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1227 The name of the function with a breakpoint.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1228 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1229 @item line\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1230 The line number of an active breakpoint.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1231 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1232 @item column\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1233 The column number of the line where the breakpoint begins.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1234 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1235 @item scope\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1236 Undocumented.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1237 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1238 @item context\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1239 Undocumented.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1240 @end table\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1241 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1242 The return argument @var{idx} specifies which element of the @var{stack}\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1243 struct array is currently active.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1244 @seealso{dbup, dbdown, dbwhere, dbstatus}\n\
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1245 @end deftypefn")
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1246 {
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
1247 return do_dbstack (args, nargout, octave_stdout);
13326
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
1248 }
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
1249
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1250 static void
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1251 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
1252 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1253 int n = 1;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1254
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1255 if (args.length () == 1)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1256 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1257 octave_value arg = args(0);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1258
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1259 if (arg.is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1260 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1261 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
1262
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1263 n = atoi (s_arg.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1264 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1265 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1266 n = args(0).int_value ();
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1267 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1268
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1269 if (who == "dbup")
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1270 n = -n;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1271
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1272 if (! octave_call_stack::goto_frame_relative (n, true))
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
1273 error ("%s: invalid stack frame", who.c_str ());
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1274 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1275
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1276 DEFUN (dbup, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
1277 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1278 @deftypefn {} {} dbup\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1279 @deftypefnx {} {} dbup @var{n}\n\
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1280 In debugging mode, move up the execution stack @var{n} frames.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1281 \n\
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1282 If @var{n} is omitted, move up one frame.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1283 @seealso{dbstack, dbdown}\n\
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1284 @end deftypefn")
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1285 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1286 do_dbupdown (args, "dbup");
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1287
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1288 return ovl ();
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1289 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1290
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1291 DEFUN (dbdown, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
1292 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1293 @deftypefn {} {} dbdown\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1294 @deftypefnx {} {} dbdown @var{n}\n\
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1295 In debugging mode, move down the execution stack @var{n} frames.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1296 \n\
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1297 If @var{n} is omitted, move down one frame.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1298 @seealso{dbstack, dbup}\n\
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1299 @end deftypefn")
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1300 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1301 do_dbupdown (args, "dbdown");
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1302
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1303 return ovl ();
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1304 }
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1305
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1306 DEFUN (dbstep, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
1307 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1308 @deftypefn {} {} dbstep\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1309 @deftypefnx {} {} dbstep @var{n}\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1310 @deftypefnx {} {} dbstep in\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1311 @deftypefnx {} {} dbstep out\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1312 @deftypefnx {} {} dbnext @dots{}\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1313 In debugging mode, execute the next @var{n} lines of code.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1314 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1315 If @var{n} is omitted, execute the next single line of code. If the next\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1316 line of code is itself defined in terms of an m-file remain in the existing\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1317 function.\n\
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1318 \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
1319 Using @code{dbstep in} will cause execution of the next line to step into\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1320 any m-files defined on the next line.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1321 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1322 Using @code{dbstep out} will cause execution to continue until the current\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1323 function returns.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1324 \n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1325 @code{dbnext} is an alias for @code{dbstep}.\n\
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1326 @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
1327 @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
1328 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1329 if (! Vdebugging)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1330 error ("dbstep: can only be called in debug mode");
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1331
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1332 int nargin = args.length ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1333
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1334 if (nargin > 1)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1335 print_usage ();
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1336
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1337 if (nargin == 1)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1338 {
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1339 std::string arg = args(0).xstring_value ("dbstep: input argument must be a string");
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1340
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1341 if (arg == "in")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1342 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1343 Vdebugging = false;
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1344
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1345 tree_evaluator::dbstep_flag = -1;
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1346 }
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1347 else if (arg == "out")
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1348 {
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1349 Vdebugging = false;
20582
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20557
diff changeset
1350
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1351 tree_evaluator::dbstep_flag = -2;
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1352 }
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1353 else
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1354 {
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1355 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
1356
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1357 if (n < 1)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1358 error ("dbstep: invalid argument");
19743
67f2c76f9f4d Remove unnecessary checking of error_state after is_string validation.
Rik <rik@octave.org>
parents: 19697
diff changeset
1359
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1360 Vdebugging = false;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1361
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1362 tree_evaluator::dbstep_flag = n;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1363 }
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
1364 }
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
1365 else
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1366 {
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1367 Vdebugging = false;
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1368
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1369 tree_evaluator::dbstep_flag = 1;
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1370 }
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
1371
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
1372 return ovl ();
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1373 }
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
1374
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1375 DEFALIAS (dbnext, dbstep);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1376
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1377 DEFUN (dbcont, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
1378 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1379 @deftypefn {} {} dbcont\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1380 Leave command-line debugging mode and continue code execution normally.\n\
9724
f22bbc5d56e9 Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents: 9484
diff changeset
1381 @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
1382 @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
1383 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1384 if (! Vdebugging)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1385 error ("dbcont: can only be called in debug mode");
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1386
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1387 if (args.length () != 0)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1388 print_usage ();
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1389
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1390 Vdebugging = false;
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1391
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1392 tree_evaluator::reset_debug_state ();
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1393
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
1394 return ovl ();
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1395 }
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
1396
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1397 DEFUN (dbquit, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
1398 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1399 @deftypefn {} {} dbquit\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1400 Quit debugging mode immediately without further code execution and return to\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19861
diff changeset
1401 the Octave prompt.\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1402 @seealso{dbcont, dbstep}\n\
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1403 @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
1404 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1405 if (! Vdebugging)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1406 error ("dbquit: can only be called in debug mode");
10186
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1407
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1408 if (args.length () != 0)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1409 print_usage ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1410
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1411 Vdebugging = false;
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1412
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1413 tree_evaluator::reset_debug_state ();
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1414
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1415 octave_throw_interrupt_exception ();
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1416
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
1417 return ovl ();
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1418 }
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
1419
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1420 DEFUN (isdebugmode, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
1421 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1422 @deftypefn {} {} isdebugmode ()\n\
14035
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1423 Return true if in debugging mode, otherwise false.\n\
3889c3eecaf0 doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents: 13983
diff changeset
1424 @seealso{dbwhere, dbstack, dbstatus}\n\
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1425 @end deftypefn")
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1426 {
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1427 if (args.length () != 0)
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1428 print_usage ();
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1429
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1430 return octave_value (Vdebugging);
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1431 }
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
1432
19855
a59c5a16c9ab Rename db_next_breakpoint_quiet to internal function.
Rik <rik@octave.org>
parents: 19743
diff changeset
1433 DEFUN (__db_next_breakpoint_quiet__, args, ,
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
1434 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1435 @deftypefn {} {} __db_next_breakpoint_quiet__ ()\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20831
diff changeset
1436 @deftypefnx {} {} __db_next_breakpoint_quiet__ (@var{flag})\n\
19855
a59c5a16c9ab Rename db_next_breakpoint_quiet to internal function.
Rik <rik@octave.org>
parents: 19743
diff changeset
1437 Disable line info printing at the next breakpoint.\n\
a59c5a16c9ab Rename db_next_breakpoint_quiet to internal function.
Rik <rik@octave.org>
parents: 19743
diff changeset
1438 \n\
a59c5a16c9ab Rename db_next_breakpoint_quiet to internal function.
Rik <rik@octave.org>
parents: 19743
diff changeset
1439 With a logical argument @var{flag}, set the state on or off.\n\
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
1440 @end deftypefn")
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
1441 {
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
1442 int nargin = args.length ();
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
1443
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1444 if (nargin > 1)
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1445 print_usage ();
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1446
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1447 bool state = true;
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
1448
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1449 if (nargin == 1)
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1450 state = args(0).bool_value ();
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
1451
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1452 tree_evaluator::quiet_breakpoint_flag = state;
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
1453
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
1454 return ovl ();
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
1455 }
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1456