annotate libinterp/corefcn/debug.cc @ 23137:334119c390b3

move bp_table class to separate file * libinterp/parse-tree/bp-table.h: Rename from libinterp/corefcn/debug.h. Change all uses. * libinterp/parse-tree/bp-table.cc: New file, extracted from debug.h. * bp-table.h, bp-table.cc (bp_table::parse_dbfunction_params): Now static member function instead of friend of bp_table class. Change all uses. * libinterp/corefcn/module.mk, libinterp/parse-tree/module.mk: Update.
author John W. Eaton <jwe@octave.org>
date Thu, 02 Feb 2017 16:16:26 -0500
parents 5a91168a30be
children 898c33f4b9c0
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
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22196
diff changeset
3 Copyright (C) 2001-2016 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
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
9 under the terms of the GNU General Public License as published by
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
10 the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
11 (at your option) any later version.
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
12
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
13 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
14 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
16 GNU General Public License for more details.
3805
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 */
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
23
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21703
diff changeset
24 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21259
diff changeset
25 # include "config.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
26 #endif
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
27
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
28 #include <deque>
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
29 #include <fstream>
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
30 #include <iomanip>
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
31 #include <iostream>
21703
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
32 #include <limits>
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
33 #include <set>
3948
126177939aae [project @ 2002-05-23 01:17:29 by jwe]
jwe
parents: 3947
diff changeset
34 #include <string>
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
35
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
36 #include "dNDArray.h"
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
37
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
38 #include "bp-table.h"
22091
0f6fc2ec3b1a move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
39 #include "call-stack.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
40 #include "defun.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
41 #include "error.h"
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
42 #include "errwarn.h"
21258
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
43 #include "file-ops.h"
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
44 #include "help.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
45 #include "input.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
46 #include "octave-preserve-stream-state.h"
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
47 #include "ov-usr-fcn.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
48 #include "ov.h"
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
49 #include "ovl.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
50 #include "pager.h"
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
51 #include "parse.h"
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
52 #include "pt-eval.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
53 #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
54 #include "utils.h"
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
55 #include "utils.h"
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
56 #include "variables.h"
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
57
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
58 static octave_value
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
59 intmap_to_ov (const bp_table::intmap& line)
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
60 {
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
61 int idx = 0;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
62
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
63 NDArray retval (dim_vector (1, line.size ()));
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
64
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
65 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
66 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
67 bp_table::const_intmap_iterator p = line.find (i);
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
68
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
69 if (p != line.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
70 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
71 int lineno = p->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
72 retval(idx++) = lineno;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
73 }
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
74 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
75
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
76 retval.resize (dim_vector (1, idx));
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
77
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
78 return retval;
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
79 }
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
80
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
81 DEFUN (dbstop, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
82 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
83 @deftypefn {} {} dbstop @var{func}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
84 @deftypefnx {} {} dbstop @var{func} @var{line}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
85 @deftypefnx {} {} dbstop @var{func} @var{line1} @var{line2} @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
86 @deftypefnx {} {} dbstop @var{line1} @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
87 @deftypefnx {} {} dbstop in @var{func}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
88 @deftypefnx {} {} dbstop in @var{func} at @var{line}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
89 @deftypefnx {} {} dbstop in @var{func} at @var{line} if "@var{condition}"
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
90 @deftypefnx {} {} dbstop if @var{event}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
91 @deftypefnx {} {} dbstop if @var{event} @var{ID}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
92 @deftypefnx {} {} dbstop (@var{bp_struct})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
93 @deftypefnx {} {@var{rline} =} dbstop @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
94
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
95 Set breakpoints for the built-in debugger.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
96
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
97 @var{func} is the name of a function on the current @code{path}. When
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
98 already in debug mode the @var{func} argument can be omitted and the current
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
99 function will be used. Breakpoints at subfunctions are set with the scope
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
100 operator @samp{>}. For example, If @file{file.m} has a subfunction
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
101 @code{func2}, then a breakpoint in @code{func2} can be specified by
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
102 @code{file>func2}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
103
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
104 @var{line} is the line number at which to break. If @var{line} is not
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
105 specified, it defaults to the first executable line in the file
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
106 @file{func.m}. Multiple lines can be specified in a single command; when
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
107 function syntax is used, the lines may also be passed as a single vector
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
108 argument (@code{[@var{line1}, @var{line2}, @dots{}]}).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
109
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
110 @var{condition} is any Octave expression that can be evaluated in the code
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
111 context that exists at the breakpoint. When the breakpoint is encountered,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
112 @var{condition} will be evaluated, and execution will stop if
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
113 @var{condition} is true. If @var{condition} cannot be evaluated, for
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
114 example because it refers to an undefined variable, an error will be thrown.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
115 Expressions with side effects (such as @code{y++ > 1}) will alter
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
116 variables, and should generally be avoided. Conditions containing quotes
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
117 (@samp{"}, @samp{'}) or comment characters (@samp{#}, @samp{%}) must be
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
118 enclosed in quotes. (This does not apply to conditions entered from the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
119 editor's context menu.) For example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
120
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
121 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
122 dbstop in strread at 209 if 'any (format == "%f")'
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
123 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
124
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
125 The form specifying @var{event} does not cause a specific breakpoint at a
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
126 given function and line number. Instead it causes debug mode to be entered
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
127 when certain unexpected events are encountered. Possible values are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
128
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
129 @table @code
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
130 @item error
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
131 Stop when an error is reported. This is equivalent to specifying
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
132 both @code{debug_on_error (true)} and @code{debug_on_interrupt (true)}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
133
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
134 @item caught error
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
135 Stop when an error is caught by a try-catch block (not yet implemented).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
136
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
137 @item interrupt
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
138 Stop when an interrupt (@kbd{Ctrl-C}) occurs.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
139
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
140 @item naninf
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
141 Stop when code returns a non-finite value (not yet implemented).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
142
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
143 @item warning
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
144 Stop when a warning is reported. This is equivalent to specifying
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
145 @code{debug_on_warning (true)}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
146 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
147
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
148 The events @code{error}, @code{caught error}, and @code{warning} can all be
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
149 followed by a string specifying an error ID or warning ID@. If that is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
150 done, only errors with the specified ID will cause execution to stop. To
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
151 stop on one of a set of IDs, multiple @code{dbstop} commands must be
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
152 issued.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
153
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
154 Breakpoints and events can be removed using the @code{dbclear} command with
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
155 the same syntax.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
156
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
157 It is possible to save all breakpoints and restore them at once by issuing
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
158 the commands @code{bp_state = dbstatus; @dots{}; dbstop (bp_state)}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
159
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
160 The optional output @var{rline} is the real line number where the breakpoint
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
161 was set. This can differ from the specified line if the line is not
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
162 executable. For example, if a breakpoint attempted on a blank line then
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
163 Octave will set the real breakpoint at the next executable line.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
164
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
165 When a file is re-parsed, such as when it is modified outside the GUI,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
166 all breakpoints within the file are cleared.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
167
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
168 @seealso{dbclear, dbstatus, dbstep, debug_on_error, debug_on_warning, debug_on_interrupt}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
169 @end deftypefn */)
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
170 {
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
171 bp_table::intmap retmap;
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
172 std::string symbol_name = ""; // stays empty for "dbstop if error" etc
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
173 bp_table::intmap lines;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
174 std::string condition = "";
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
175 octave_value retval;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
176
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
177 if (args.length() >= 1 && ! args(0).is_map ())
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
178 {
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
179 // explicit function / line / condition
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
180 bp_table::parse_dbfunction_params ("dbstop", args, symbol_name,
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
181 lines, condition);
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
182
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
183 if (lines.size () == 0)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
184 lines[0] = 1;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
185
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
186 if (symbol_name != "")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
187 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
188 retmap = bp_table::add_breakpoint (symbol_name, lines, condition);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
189 retval = intmap_to_ov (retmap);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
190 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
191 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
192 else if (args.length () != 1)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
193 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
194 print_usage ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
195 }
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
196 else // structure of the form output by dbstatus
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
197 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
198 octave_map mv = args(0).map_value ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
199 if (mv.isfield ("bkpt") || mv.isfield ("errs") || mv.isfield ("warn")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
200 || mv.isfield ("intr"))
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
201 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
202 bp_table::dbstop_process_map_args (mv);
6646
bd0a70c3f2db [project @ 2007-05-22 02:27:43 by jwe]
jwe
parents: 6317
diff changeset
203
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
204 // Replace mv by "bkpt", to use the processing below.
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
205 octave_value bkpt = mv.getfield ("bkpt");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
206 if (bkpt.is_empty ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
207 mv = octave_map ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
208 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
209 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
210 if (bkpt.is_cell () && bkpt.cell_value ().numel () > 0
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
211 && bkpt.cell_value () (0).is_map ())
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
212 mv = bkpt.cell_value () (0).map_value ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
213 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
214 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
215 error ("dbstop: invalid 'bkpt' field");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
216 mv = octave_map ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
217 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
218 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
219 }
21885
0806871e3e1e maint: Prefer is_empty() rather than "length () == 0".
Rik <rik@octave.org>
parents: 21877
diff changeset
220 if (mv.is_empty ())
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
221 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
222 // no changes requested. Occurs if "errs" non-empty but "bkpt" empty
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
223 }
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
224 else if (! mv.isfield ("name") || ! mv.isfield ("line"))
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
225 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
226 error ("dbstop: Cell array must contain fields 'name' and 'line'");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
227 retval = octave_value (0);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
228 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
229 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
230 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
231 bool use_cond = mv.isfield ("cond");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
232 Cell name = mv.getfield ("name");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
233 Cell line = mv.getfield ("line");
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
234 Cell cond = (use_cond ? mv.getfield ("cond") : Cell ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
235 std::string unconditional = "";
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
236 for (octave_idx_type i = 0; i < line.numel (); i++)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
237 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
238 lines [0] = line(i).double_value ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
239 bp_table::add_breakpoint (name(i).string_value (), lines,
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
240 use_cond ? cond(i).string_value ()
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
241 : unconditional );
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
242 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
243 retval = octave_value (line.numel ());
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
244 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
245 }
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
246
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
247 return retval;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
248 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
249
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
250 DEFUN (dbclear, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
251 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
252 @deftypefn {} {} dbclear @var{func}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
253 @deftypefnx {} {} dbclear @var{func} @var{line}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
254 @deftypefnx {} {} dbclear @var{func} @var{line1} @var{line2} @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
255 @deftypefnx {} {} dbclear @var{line} @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
256 @deftypefnx {} {} dbclear all
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
257 @deftypefnx {} {} dbclear in @var{func}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
258 @deftypefnx {} {} dbclear in @var{func} at @var{line}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
259 @deftypefnx {} {} dbclear if @var{event}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
260 @deftypefnx {} {} dbclear ("@var{func}")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
261 @deftypefnx {} {} dbclear ("@var{func}", @var{line})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
262 @deftypefnx {} {} dbclear ("@var{func}", @var{line1}, @var{line2}, @dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
263 @deftypefnx {} {} dbclear ("@var{func}", @var{line1}, @dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
264 @deftypefnx {} {} dbclear (@var{line}, @dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
265 @deftypefnx {} {} dbclear ("all")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
266 Delete a breakpoint at line number @var{line} in the function @var{func}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
267
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
268 Arguments are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
269
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
270 @table @var
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
271 @item func
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
272 Function name as a string variable. When already in debug mode this
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
273 argument can be omitted and the current function will be used.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
274
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
275 @item line
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
276 Line number from which to remove a breakpoint. Multiple lines may be given
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
277 as separate arguments or as a vector.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
278
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
279 @item event
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
280 An event such as @code{error}, @code{interrupt}, or @code{warning}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
281 (@pxref{XREFdbstop,,dbstop} for details).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
282 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
283
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
284 When called without a line number specification all breakpoints in the named
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
285 function are cleared.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
286
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
287 If the requested line is not a breakpoint no action is performed.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
288
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
289 The special keyword @qcode{"all"} will clear all breakpoints from all
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
290 files.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
291 @seealso{dbstop, dbstatus, dbwhere}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
292 @end deftypefn */)
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
293 {
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
294 std::string symbol_name = ""; // stays empty for "dbclear if error" etc
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
295 bp_table::intmap lines;
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
296 std::string dummy; // "if" condition -- only used for dbstop
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
297
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
298 int nargin = args.length ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
299
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
300 bp_table::parse_dbfunction_params ("dbclear", args, symbol_name,
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
301 lines, dummy);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
302
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
303 if (nargin == 1 && symbol_name == "all")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
304 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
305 bp_table::remove_all_breakpoints ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
306 bp_table::dbclear_all_signals ();
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
307 }
18379
80d39575fd44 Add new input keyword "all" for dbclear to remove all breakpoints.
Rik <rik@octave.org>
parents: 18377
diff changeset
308 else
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
309 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
310 if (symbol_name != "")
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
311 bp_table::remove_breakpoint (symbol_name, lines);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
312 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
313
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
314 return ovl ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
315 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
316
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
317 DEFUN (dbstatus, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
318 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
319 @deftypefn {} {} dbstatus
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
320 @deftypefnx {} {} dbstatus @var{func}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
321 @deftypefnx {} {@var{bp_list} =} dbstatus @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
322 Report the location of active breakpoints.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
323
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
324 When called with no input or output arguments, print the list of all
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
325 functions with breakpoints and the line numbers where those breakpoints are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
326 set.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
327
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
328 If a function name @var{func} is specified then only report breakpoints
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
329 for the named function and its subfunctions.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
330
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
331 The optional return argument @var{bp_list} is a struct array with the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
332 following fields.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
333
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
334 @table @asis
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
335 @item name
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
336 The name of the function with a breakpoint. A subfunction, say @code{func2}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
337 within an m-file, say @file{file.m}, is specified as @code{file>func2}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
338
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
339 @item file
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
340 The name of the m-file where the function code is located.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
341
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
342 @item line
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
343 The line number with the breakpoint.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
344
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
345 @item cond
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
346 The condition that must be satisfied for the breakpoint to be active, or
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
347 the empty string for unconditional breakpoints.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
348 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
349
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
350 @c Note: When @code{dbstatus} is called from the debug prompt within a function,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
351 @c the list of breakpoints is automatically trimmed to the breakpoints in the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
352 @c current function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
353 If @code{dbstop if error} is true but no explicit IDs are specified, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
354 return value will have an empty field called @qcode{"errs"}. If IDs are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
355 specified, the @code{errs} field will have one row per ID@. If
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
356 @code{dbstop if error} is false, there is no @qcode{"errs"} field.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
357 The @qcode{"warn"} field is set similarly by @code{dbstop if warning}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
358
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
359 @seealso{dbstop, dbclear, dbwhere, dblist, dbstack}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
360 @end deftypefn */)
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
361 {
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
362 int nargin = args.length ();
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
363
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
364 if (nargin != 0 && nargin != 1)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
365 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
366
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
367 octave_value_list fcn_list;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
368 bp_table::fname_bp_map bp_list;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
369 std::string symbol_name;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
370
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
371 if (nargin == 1)
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
372 {
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
373 if (! args(0).is_string ())
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21094
diff changeset
374 err_wrong_type_arg ("dbstatus", args(0));
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
375
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
376 symbol_name = args(0).string_value ();
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
377 fcn_list(0) = symbol_name;
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
378 bp_list = bp_table::get_breakpoint_list (fcn_list);
7082
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
379 }
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
380 else
ac7179f00422 [project @ 2007-10-31 01:24:12 by jwe]
jwe
parents: 7017
diff changeset
381 {
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
382 /*
18376
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
383 if (Vdebugging)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
384 {
18376
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
385 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
386 if (dbg_fcn)
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
387 {
bb162f81881d Correctly return all breakpoints when called with no arguments (bug #41338).
Rik <rik@octave.org>
parents: 18375
diff changeset
388 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
389 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
390 }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
391 }
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
392 */
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
393
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17753
diff changeset
394 bp_list = bp_table::get_breakpoint_list (fcn_list);
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
395 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
396
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
397 if (nargout == 0)
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
398 {
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
399 // Print out the breakpoint information.
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
400
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
401 for (auto& fnm_bp_p: bp_list)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
402 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
403 std::list<bp_type> m = fnm_bp_p.second;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
404
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
405 // print unconditional breakpoints, if any, on a single line
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
406
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
407 // first, check to see if there are any
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
408 int have_unconditional = 0;
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
409 for (const auto& bp : m)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
410 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
411 if (bp.cond == "")
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
412 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
413 if (have_unconditional++)
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
414 break; // stop once we know its plural
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
415 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
416 }
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
417 // If we actually have some, print line numbers only
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
418 if (have_unconditional)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
419 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
420 const char *_s_ = (have_unconditional > 1) ? "s" : "";
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
421 octave_stdout << "breakpoint" << _s_ <<" in " << fnm_bp_p.first
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
422 << " at line" << _s_ << " ";
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
423
21877
dc0347131364 maint: More code cleanup for debug.cc and C++11.
Rik <rik@octave.org>
parents: 21875
diff changeset
424 for (const auto& bp : m)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
425 {
21877
dc0347131364 maint: More code cleanup for debug.cc and C++11.
Rik <rik@octave.org>
parents: 21875
diff changeset
426 if (bp.cond == "")
dc0347131364 maint: More code cleanup for debug.cc and C++11.
Rik <rik@octave.org>
parents: 21875
diff changeset
427 octave_stdout << bp.line << " ";
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
428 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
429 octave_stdout << std::endl;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
430 }
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
431
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
432 // print conditional breakpoints, one per line, with conditions
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
433 for (const auto& bp : m)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
434 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
435 if (bp.cond != "")
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
436 octave_stdout << "breakpoint in " << fnm_bp_p.first
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
437 << " at line " << bp.line
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
438 << " if " << bp.cond << "\n";
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
439 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
440 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
441
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
442 bp_table::stop_on_err_warn_status (true);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
443
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
444 return ovl ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
445 }
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
446 else
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
447 {
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
448 // Fill in an array for return.
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
449 int i = 0;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
450 octave_map retmap;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
451 octave_value retval;
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
452
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
453 // count the number of breakpoints in all files
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
454 int count = 0;
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
455 for (const auto& fnm_bp_p : bp_list)
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
456 count += fnm_bp_p.second.size ();
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
457
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
458 Cell names (dim_vector (count, 1));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
459 Cell file (dim_vector (count, 1));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
460 Cell line (dim_vector (count, 1));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
461 Cell cond (dim_vector (count, 1));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
462
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
463 for (const auto& fnm_bp_p : bp_list)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
464 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
465 std::string filename = fnm_bp_p.first;
21258
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
466 const char *sub_fun = strchr (filename.c_str (), Vfilemarker);
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
467 if (sub_fun)
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
468 filename = filename.substr(0, sub_fun - filename.c_str ());
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
469 octave_value path_name;
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
470 path_name = octave::sys::canonicalize_file_name (do_which (filename));
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
471
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
472 for (const auto& bp : fnm_bp_p.second)
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
473 {
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
474 names(i) = fnm_bp_p.first;
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
475 file(i) = path_name;
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
476 line(i) = octave_value (bp.line);
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
477 cond(i) = octave_value (bp.cond);
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
478 i++;
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
479 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
480 }
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
481
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
482 retmap.assign ("name", names);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
483 retmap.assign ("file", file);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
484 retmap.assign ("line", line);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
485 retmap.assign ("cond", cond);
7083
24fde8abfb90 [project @ 2007-10-31 02:12:16 by jwe]
jwe
parents: 7082
diff changeset
486
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
487 octave_map ew = bp_table::stop_on_err_warn_status (false);
21875
6c09e42b7ac4 debug.[cc|h]: Use C++ for-range syntax.
Rik <rik@octave.org>
parents: 21758
diff changeset
488 if (ew.is_empty ())
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
489 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
490 retval = octave_value (retmap);
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
491 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
492 else
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
493 {
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
494 octave_map outer (dim_vector (3,1));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
495 outer.assign ("bkpt", Cell (retmap));
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
496 for (octave_map::const_iterator f = ew.begin (); f != ew.end (); f++)
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
497 outer.setfield (f->first, ew.contents (f));
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
498
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
499 retval = octave_value (outer);
21157
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
500 }
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
501
94fc5f13d51b dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21127
diff changeset
502 return retval;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
503 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
504 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
505
21258
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
506 /*
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
507 %!test
21645
9810e483b42f Fix dbstop BIST tests on Windows platforms.
Rik <rik@octave.org>
parents: 21628
diff changeset
508 %! dbclear all; # Clear out breakpoints before test
21258
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
509 %! dbstop @ftp/dir;
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
510 %! dbstop @audioplayer/set 70;
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
511 %! dbstop quantile>__quantile__;
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
512 %! dbstop ls;
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
513 %! s = dbstatus;
21703
4bf980861fd6 Allow breakpoints in nested functions, and in mixed subfunctions (bug #47917).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21662
diff changeset
514 %! dbclear all;
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
515 %! assert (s(1).name, "@audioplayer/set>setproperty");
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
516 %! assert (s(2).name, "@ftp/dir");
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
517 %! assert (s(3).name, "ls");
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21568
diff changeset
518 %! assert (s(4).name, "quantile>__quantile__");
21645
9810e483b42f Fix dbstop BIST tests on Windows platforms.
Rik <rik@octave.org>
parents: 21628
diff changeset
519 %! assert (s(2).file(end-10:end), [filesep "@ftp" filesep "dir.m"]);
21258
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
520 */
b248c28d9a7b Make dbstatus return correct filename and function name (bug #41540).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21200
diff changeset
521
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
522 DEFUN (dbwhere, , ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
523 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
524 @deftypefn {} {} dbwhere
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
525 In debugging mode, report the current file and line number where execution
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
526 is stopped.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
527 @seealso{dbstack, dblist, dbstatus, dbcont, dbstep, dbup, dbdown}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
528 @end deftypefn */)
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
529 {
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
530 octave_user_code *dbg_fcn = get_user_code ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
531
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
532 if (! dbg_fcn)
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
533 {
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
534 octave_stdout << "stopped at top level" << std::endl;
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
535 return ovl ();
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
536 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
537
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
538 octave_stdout << "stopped in " << dbg_fcn->name () << " at ";
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
539
23052
f97e22a9012a move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
540 int l = octave::call_stack::debug_user_code_line ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
541
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
542 if (l > 0)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
543 {
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
544 octave_stdout << "line " << l;
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
545
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
546 std::string file_name = dbg_fcn->fcn_file_name ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
547
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
548 if (! file_name.empty ())
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
549 {
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
550 octave_stdout << " [" << file_name << "]" << std::endl;
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
551
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
552 std::string line = get_file_line (file_name, l);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
553
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
554 if (! line.empty ())
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
555 octave_stdout << l << ": " << line << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
556 }
21322
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
557 else
909129eb77c5 use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents: 21318
diff changeset
558 octave_stdout << std::endl;
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
559 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
560 else
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
561 octave_stdout << "<unknown line>" << std::endl;
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
562
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
563 return ovl ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
564 }
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
565
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
566 void
3949
294f13627ee8 [project @ 2002-05-23 01:22:11 by jwe]
jwe
parents: 3948
diff changeset
567 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
568 {
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
569 std::string ff = fcn_file_in_path (name);
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
570
21077
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
571 if (ff.empty ())
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
572 os << "dbtype: unknown function " << name << "\n";
21077
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
573 else
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
574 {
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
575 std::ifstream fs (ff.c_str (), std::ios::in);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
576
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
577 if (! fs)
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
578 os << "dbtype: unable to open '" << ff << "' for reading!\n";
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
579 else
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
580 {
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
581 int line = 1;
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
582 std::string text;
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
583
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
584 while (std::getline (fs, text) && line <= end)
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
585 {
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
586 if (line >= start)
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
587 os << line << "\t" << text << "\n";
21077
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
588
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
589 line++;
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
590 }
21077
40f931a63a91 Undo incorrect if/else inversion in cset 3aa293be0e8d.
Rik <rik@octave.org>
parents: 21017
diff changeset
591 }
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
592 }
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
593
6646
bd0a70c3f2db [project @ 2007-05-22 02:27:43 by jwe]
jwe
parents: 6317
diff changeset
594 os.flush ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
595 }
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
596
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
597 DEFUN (dbtype, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
598 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
599 @deftypefn {} {} dbtype
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
600 @deftypefnx {} {} dbtype @var{lineno}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
601 @deftypefnx {} {} dbtype @var{startl:endl}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
602 @deftypefnx {} {} dbtype @var{startl:end}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
603 @deftypefnx {} {} dbtype @var{func}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
604 @deftypefnx {} {} dbtype @var{func} @var{lineno}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
605 @deftypefnx {} {} dbtype @var{func} @var{startl:endl}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
606 @deftypefnx {} {} dbtype @var{func} @var{startl:end}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
607 Display a script file with line numbers.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
608
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
609 When called with no arguments in debugging mode, display the script file
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
610 currently being debugged.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
611
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
612 An optional range specification can be used to list only a portion of the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
613 file. The special keyword @qcode{"end"} is a valid line number
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
614 specification for the last line of the file.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
615
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
616 When called with the name of a function, list that script file with line
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
617 numbers.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
618 @seealso{dblist, dbwhere, dbstatus, dbstop}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
619 @end deftypefn */)
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
620 {
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
621 octave_user_code *dbg_fcn;
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
622
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
623 string_vector argv = args.make_argv ("dbtype");
3946
eab957395758 [project @ 2002-05-23 00:42:15 by jwe]
jwe
parents: 3895
diff changeset
624
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20817
diff changeset
625 switch (args.length ())
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
626 {
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
627 case 0: // dbtype
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
628 dbg_fcn = get_user_code ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
629
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
630 if (! dbg_fcn)
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
631 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
632
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
633 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
634 0, std::numeric_limits<int>::max ());
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
635
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
636 break;
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
637
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
638 case 1: // (dbtype start:end) || (dbtype func) || (dbtype lineno)
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
639 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
640 std::string arg = argv[1];
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
641
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
642 size_t ind = arg.find (':');
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
643
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
644 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
645 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
646 dbg_fcn = get_user_code ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
647
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
648 if (dbg_fcn)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
649 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
650 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
651 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
652
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
653 int start, end;
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
654 start = atoi (start_str.c_str ());
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
655 if (end_str == "end")
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
656 end = std::numeric_limits<int>::max ();
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
657 else
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
658 end = atoi (end_str.c_str ());
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
659
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
660 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
661 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
662
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
663 if (start > end)
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
664 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
665
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
666 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
667 start, end);
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
668 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
669 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
670 else // (dbtype func) || (dbtype lineno)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
671 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
672 int line = atoi (arg.c_str ());
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
673
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
674 if (line == 0) // (dbtype func)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
675 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
676 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
677
20980
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
678 if (! dbg_fcn)
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
679 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
680
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
681 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
682 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
683 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
684 else // (dbtype lineno)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
685 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
686 if (line <= 0)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20819
diff changeset
687 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
688
14227
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
689 dbg_fcn = get_user_code ();
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
690
14227
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
691 if (dbg_fcn)
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
692 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
693 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
694 }
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
695 }
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
696 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
697 break;
3895
d38c7538b954 [project @ 2002-04-10 19:18:39 by jwe]
jwe
parents: 3805
diff changeset
698
21259
4ee768b71a0e maint: Clean up debug.cc file.
Rik <rik@octave.org>
parents: 21258
diff changeset
699 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
700 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
701 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
702
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
703 if (! dbg_fcn)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
704 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
705
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
706 std::string arg = argv[2];
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
707 int start, end;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
708 size_t ind = arg.find (':');
6317
8c67f8be341d [project @ 2007-02-16 08:10:53 by jwe]
jwe
parents: 5744
diff changeset
709
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
710 if (ind != std::string::npos)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
711 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
712 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
713 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
714
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
715 start = atoi (start_str.c_str ());
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
716 if (end_str == "end")
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
717 end = std::numeric_limits<int>::max ();
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
718 else
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
719 end = atoi (end_str.c_str ());
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
720 }
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
721 else
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
722 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
723 start = atoi (arg.c_str ());
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
724 end = start;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
725 }
14227
c24833c6ebc2 Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
726
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
727 if (std::min (start, end) <= 0)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
728 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
729
81c2b14c209f maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
730 if (start > end)
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
731 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
732
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
733 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
734 }
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
735 break;
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
736
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
737 default:
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
738 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
739 }
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
740
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
741 return ovl ();
3805
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
742 }
44386b0e53da [project @ 2001-03-01 16:54:31 by jwe]
jwe
parents:
diff changeset
743
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
744 DEFUN (dblist, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
745 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
746 @deftypefn {} {} dblist
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
747 @deftypefnx {} {} dblist @var{n}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
748 In debugging mode, list @var{n} lines of the function being debugged
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
749 centered around the current line to be executed.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
750
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
751 If unspecified @var{n} defaults to 10 (+/- 5 lines)
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
752 @seealso{dbwhere, dbtype, dbstack}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
753 @end deftypefn */)
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
754 {
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
755 int n = 10;
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
756
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
757 if (args.length () == 1)
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
758 {
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
759 octave_value arg = args(0);
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
760
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
761 if (arg.is_string ())
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
762 {
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
763 std::string s_arg = arg.string_value ();
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
764
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
765 n = atoi (s_arg.c_str ());
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
766 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
767 else
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
768 n = args(0).int_value ();
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
769
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
770 if (n < 0)
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
771 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
772 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
773
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
774 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
775
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
776 if (! dbg_fcn)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
777 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
778
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
779 bool have_file = true;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
780
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
781 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
782
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
783 if (name.empty ())
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
784 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
785 have_file = false;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
786 name = dbg_fcn->name ();
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
787 }
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
788
23052
f97e22a9012a move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
789 int l = octave::call_stack::debug_user_code_line ();
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
790
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
791 if (l > 0)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
792 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
793 if (have_file)
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
794 {
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
795 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
796 int l_max = l + n/2;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
797 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
798
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
799 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
800 if (! line.empty ())
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
801 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
802
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
803 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
804 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
805 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
806 else
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
807 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
808 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
809 << std::endl;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
810 }
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
811
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
812 return ovl ();
16842
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
813 }
035b5fe157ad Add new dblist command to debugger (bug #38953)
Rik <rik@octave.org>
parents: 16771
diff changeset
814
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
815 static octave_value_list
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
816 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
817 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
818 int nargin = args.length ();
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
819
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
820 if (nargin > 2)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
821 print_usage ();
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
822
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
823 octave_value_list retval;
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
824
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
825 octave::unwind_protect frame;
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
826
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7897
diff changeset
827 octave_idx_type curr_frame = -1;
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
828
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7897
diff changeset
829 size_t nskip = 0;
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
830
20817
3d551b2ae928 Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents: 20804
diff changeset
831 if (nargin == 1 || nargin == 2)
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
832 {
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
833 int n = 0;
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
834
20817
3d551b2ae928 Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents: 20804
diff changeset
835 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
836 {
17649
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
837 octave_value arg = args(i);
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
838
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
839 if (arg.is_string ())
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
840 {
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
841 std::string s_arg = arg.string_value ();
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
842
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
843 // Skip "-completenames", octave returns full names anyway.
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
844 if (s_arg == "-completenames")
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
845 continue;
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
846
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
847 n = atoi (s_arg.c_str ());
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
848 }
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
849 else
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
850 n = arg.int_value ();
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
851
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
852 if (n <= 0)
17649
a09511ebf7ef Make dbstack to accept -completenames.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17281
diff changeset
853 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
854 }
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
855
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
856 if (n > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
857 nskip = n;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
858 }
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
859
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
860 if (nargout == 0)
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
861 {
23052
f97e22a9012a move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
862 octave_map stk = octave::call_stack::backtrace (nskip, curr_frame);
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
863 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
864
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
865 if (nframes_to_display > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
866 {
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
867 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
868
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
869 os << "stopped in:\n\n";
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
870
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
871 Cell names = stk.contents ("name");
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
872 Cell files = stk.contents ("file");
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
873 Cell lines = stk.contents ("line");
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
874
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
875 bool show_top_level = true;
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
876
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
877 size_t max_name_len = 0;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
878
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
879 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
880 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
881 std::string name = names(i).string_value ();
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
882
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
883 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
884 }
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7818
diff changeset
885
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
886 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
887 {
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
888 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
889 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
890 int line = lines(i).int_value ();
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
891
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
892 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
893 show_top_level = false;
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
894
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
895 os << (i == curr_frame ? " --> " : " ")
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
896 << std::setw (max_name_len) << name
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
897 << " at line " << line
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
898 << " [" << file << "]"
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
899 << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
900 }
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
901
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
902 if (show_top_level)
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
903 os << " --> top level" << std::endl;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
904 }
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
905 }
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
906 else
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
907 {
23052
f97e22a9012a move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
908 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
909
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
910 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
911 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
912
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
913 return retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
914 }
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
915
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
916 // 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
917 // 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
918 // 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
919 // for example.
13326
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
920
13784
0bbe319bf26b octave_class::size: return matrix with correct dimensions
John W. Eaton <jwe@octave.org>
parents: 13689
diff changeset
921 void
13326
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
922 show_octave_dbstack (void)
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
923 {
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
924 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
925 }
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
926
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
927 DEFUN (dbstack, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
928 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
929 @deftypefn {} {} dbstack
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
930 @deftypefnx {} {} dbstack @var{n}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
931 @deftypefnx {} {} dbstack @var{-completenames}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
932 @deftypefnx {} {[@var{stack}, @var{idx}] =} dbstack (@dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
933 Display or return current debugging function stack information.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
934
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
935 With optional argument @var{n}, omit the @var{n} innermost stack frames.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
936
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
937 Although accepted, the argument @var{-completenames} is silently ignored.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
938 Octave always returns absolute filenames.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
939
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
940 The arguments @var{n} and @var{-completenames} can be both specified in any
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
941 order.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
942
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
943 The optional return argument @var{stack} is a struct array with the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
944 following fields:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
945
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
946 @table @asis
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
947 @item file
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
948 The name of the m-file where the function code is located.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
949
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
950 @item name
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
951 The name of the function with a breakpoint.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
952
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
953 @item line
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
954 The line number of an active breakpoint.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
955
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
956 @item column
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
957 The column number of the line where the breakpoint begins.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
958
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
959 @item scope
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
960 Undocumented.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
961
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
962 @item context
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
963 Undocumented.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
964 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
965
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
966 The return argument @var{idx} specifies which element of the @var{stack}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
967 struct array is currently active.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
968 @seealso{dbup, dbdown, dbwhere, dblist, dbstatus}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
969 @end deftypefn */)
13689
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
970 {
b68d95054947 print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents: 13326
diff changeset
971 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
972 }
23cc9c13b622 show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
973
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
974 static void
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
975 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
976 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
977 int n = 1;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
978
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
979 if (args.length () == 1)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
980 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
981 octave_value arg = args(0);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
982
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
983 if (arg.is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
984 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
985 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
986
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
987 n = atoi (s_arg.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
988 }
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
989 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
990 n = args(0).int_value ();
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
991 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
992
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
993 if (who == "dbup")
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
994 n = -n;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
995
23052
f97e22a9012a move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
996 if (! octave::call_stack::goto_frame_relative (n, true))
20557
b10432a40432 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
997 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
998 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
999
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1000 DEFUN (dbup, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1001 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1002 @deftypefn {} {} dbup
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1003 @deftypefnx {} {} dbup @var{n}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1004 In debugging mode, move up the execution stack @var{n} frames.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1005
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1006 If @var{n} is omitted, move up one frame.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1007 @seealso{dbstack, dbdown}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1008 @end deftypefn */)
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1009 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1010 do_dbupdown (args, "dbup");
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1011
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1012 return ovl ();
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1013 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1014
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1015 DEFUN (dbdown, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1016 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1017 @deftypefn {} {} dbdown
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1018 @deftypefnx {} {} dbdown @var{n}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1019 In debugging mode, move down the execution stack @var{n} frames.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1020
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1021 If @var{n} is omitted, move down one frame.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1022 @seealso{dbstack, dbup}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1023 @end deftypefn */)
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1024 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
1025 do_dbupdown (args, "dbdown");
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1026
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1027 return ovl ();
7736
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1028 }
a059b5679fbb implement dbstack
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
1029
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1030 DEFUN (dbstep, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1031 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1032 @deftypefn {} {} dbstep
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1033 @deftypefnx {} {} dbstep @var{n}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1034 @deftypefnx {} {} dbstep in
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1035 @deftypefnx {} {} dbstep out
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1036 @deftypefnx {} {} dbnext @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1037 In debugging mode, execute the next @var{n} lines of code.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1038
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1039 If @var{n} is omitted, execute the next single line of code. If the next
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1040 line of code is itself defined in terms of an m-file remain in the existing
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1041 function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1042
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1043 Using @code{dbstep in} will cause execution of the next line to step into
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1044 any m-files defined on the next line.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1045
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1046 Using @code{dbstep out} will cause execution to continue until the current
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1047 function returns.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1048
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1049 @code{dbnext} is an alias for @code{dbstep}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1050 @seealso{dbcont, dbquit}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1051 @end deftypefn */)
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1052 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1053 if (! Vdebugging)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1054 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
1055
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1056 int nargin = args.length ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1057
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1058 if (nargin > 1)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1059 print_usage ();
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1060
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1061 if (nargin == 1)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1062 {
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1063 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
1064
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1065 if (arg == "in")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1066 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1067 Vdebugging = false;
22164
5d4a286061c8 Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22094
diff changeset
1068 Vtrack_line_num = true;
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1069
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
1070 octave::tree_evaluator::dbstep_flag = -1;
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1071 }
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1072 else if (arg == "out")
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1073 {
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1074 Vdebugging = false;
22164
5d4a286061c8 Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22094
diff changeset
1075 Vtrack_line_num = true;
20582
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20557
diff changeset
1076
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
1077 octave::tree_evaluator::dbstep_flag = -2;
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1078 }
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1079 else
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1080 {
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1081 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
1082
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1083 if (n < 1)
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1084 error ("dbstep: invalid argument");
19743
67f2c76f9f4d Remove unnecessary checking of error_state after is_string validation.
Rik <rik@octave.org>
parents: 19697
diff changeset
1085
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1086 Vdebugging = false;
22164
5d4a286061c8 Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22094
diff changeset
1087 Vtrack_line_num = true;
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20941
diff changeset
1088
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
1089 octave::tree_evaluator::dbstep_flag = n;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10232
diff changeset
1090 }
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1091 }
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1092 else
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1093 {
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1094 Vdebugging = false;
22164
5d4a286061c8 Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22094
diff changeset
1095 Vtrack_line_num = true;
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1096
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
1097 octave::tree_evaluator::dbstep_flag = 1;
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1098 }
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
1099
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
1100 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
1101 }
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
1102
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1103 DEFALIAS (dbnext, dbstep);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1104
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1105 DEFUN (dbcont, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1106 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1107 @deftypefn {} {} dbcont
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1108 Leave command-line debugging mode and continue code execution normally.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1109 @seealso{dbstep, dbquit}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1110 @end deftypefn */)
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1111 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1112 if (! Vdebugging)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1113 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
1114
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1115 if (args.length () != 0)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1116 print_usage ();
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1117
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1118 Vdebugging = false;
22164
5d4a286061c8 Track line numbers when in debug mode (bug #45764)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 22094
diff changeset
1119 Vtrack_line_num = true;
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1120
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
1121 octave::tree_evaluator::reset_debug_state ();
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1122
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
1123 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
1124 }
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1125
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1126 DEFUN (dbquit, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1127 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1128 @deftypefn {} {} dbquit
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1129 Quit debugging mode immediately without further code execution and return to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1130 the Octave prompt.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1131 @seealso{dbcont, dbstep}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1132 @end deftypefn */)
7787
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1133 {
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1134 if (! Vdebugging)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1135 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
1136
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1137 if (args.length () != 0)
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1138 print_usage ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8365
diff changeset
1139
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1140 Vdebugging = false;
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1141
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
1142 octave::tree_evaluator::reset_debug_state ();
20918
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1143
6f0bd96f93c0 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20884
diff changeset
1144 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
1145
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
1146 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
1147 }
6b521b1e3631 Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents: 7752
diff changeset
1148
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8677
diff changeset
1149 DEFUN (isdebugmode, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1150 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1151 @deftypefn {} {} isdebugmode ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1152 Return true if in debugging mode, otherwise false.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1153 @seealso{dbwhere, dbstack, dbstatus}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1154 @end deftypefn */)
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1155 {
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1156 if (args.length () != 0)
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1157 print_usage ();
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1158
21127
df7891224709 maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents: 21118
diff changeset
1159 return ovl (Vdebugging);
8114
cbbea37b95e8 debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents: 8021
diff changeset
1160 }
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
1161
19855
a59c5a16c9ab Rename db_next_breakpoint_quiet to internal function.
Rik <rik@octave.org>
parents: 19743
diff changeset
1162 DEFUN (__db_next_breakpoint_quiet__, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1163 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1164 @deftypefn {} {} __db_next_breakpoint_quiet__ ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1165 @deftypefnx {} {} __db_next_breakpoint_quiet__ (@var{flag})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1166 Disable line info printing at the next breakpoint.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1167
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1168 With a logical argument @var{flag}, set the state on or off.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21885
diff changeset
1169 @end deftypefn */)
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
1170 {
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
1171 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
1172
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1173 if (nargin > 1)
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1174 print_usage ();
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1175
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1176 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
1177
20804
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1178 if (nargin == 1)
a6eaedd8bd75 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20713
diff changeset
1179 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
1180
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
1181 octave::tree_evaluator::quiet_breakpoint_flag = state;
19379
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 18236
diff changeset
1182
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
1183 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
1184 }