Mercurial > hg > octave-lyh
annotate doc/interpreter/debug.txi @ 11523:fd0a3ac60b0e
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 14 Jan 2011 05:47:45 -0500 |
parents | 322f43e0e170 |
children | 2dbac27e0e40 |
rev | line source |
---|---|
11523 | 1 @c Copyright (C) 1996-2011 John W. Eaton |
7018 | 2 @c |
3 @c This file is part of Octave. | |
4 @c | |
5 @c Octave is free software; you can redistribute it and/or modify it | |
6 @c under the terms of the GNU General Public License as published by the | |
7 @c Free Software Foundation; either version 3 of the License, or (at | |
8 @c your option) any later version. | |
9 @c | |
10 @c Octave is distributed in the hope that it will be useful, but WITHOUT | |
11 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
13 @c for more details. | |
14 @c | |
15 @c You should have received a copy of the GNU General Public License | |
16 @c along with Octave; see the file COPYING. If not, see | |
17 @c <http://www.gnu.org/licenses/>. | |
4175 | 18 |
19 @node Debugging | |
20 @chapter Debugging | |
21 | |
6646 | 22 Octave includes a built-in debugger to aid in the development of |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
23 scripts. This can be used to interrupt the execution of an Octave script |
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
24 at a certain point, or when certain conditions are met. Once execution |
6646 | 25 has stopped, and debug mode is entered, the symbol table at the point |
26 where execution has stopped can be examined and modified to check for | |
27 errors. | |
4175 | 28 |
8485
2beb59bf773a
[docs] commandline => command-line
Brian Gough <bjg@gnu.org>
parents:
8347
diff
changeset
|
29 The normal command-line editing and history functions are available in |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
30 debug mode. |
6646 | 31 |
32 @menu | |
33 * Entering Debug Mode:: | |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
34 * Leaving Debug Mode:: |
6646 | 35 * Breakpoints:: |
36 * Debug Mode:: | |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
37 * Call Stack:: |
6646 | 38 @end menu |
4175 | 39 |
6646 | 40 @node Entering Debug Mode |
41 @section Entering Debug Mode | |
4175 | 42 |
6646 | 43 There are two basic means of interrupting the execution of an Octave |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
44 script. These are breakpoints @pxref{Breakpoints}, discussed in the next |
6646 | 45 section and interruption based on some condition. |
46 | |
47 Octave supports three means to stop execution based on the values set in | |
48 the functions @code{debug_on_interrupt}, @code{debug_on_warning} and | |
49 @code{debug_on_error}. | |
4175 | 50 |
4185 | 51 @DOCSTRING(debug_on_interrupt) |
4175 | 52 |
53 @DOCSTRING(debug_on_warning) | |
4185 | 54 |
55 @DOCSTRING(debug_on_error) | |
6646 | 56 |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
57 @node Leaving Debug Mode |
10791
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
9209
diff
changeset
|
58 @section Leaving Debug Mode |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
59 |
8828 | 60 To leave the debug mode, use either @code{dbcont} |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
61 or @code{return}. |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
62 |
8275 | 63 @DOCSTRING(dbcont) |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
64 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
65 To quit debug mode and return directly to the prompt @code{dbquit} |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
66 should be used instead |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
67 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
68 @DOCSTRING(dbquit) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
69 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
70 Finally, typing @code{exit} or @code{quit} at the debug prompt will |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
71 result in Octave terminating normally. |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
72 |
6646 | 73 @node Breakpoints |
74 @section Breakpoints | |
75 | |
76 Breakpoints can be set in any Octave function, using the @code{dbstop} | |
77 function. | |
78 | |
79 @DOCSTRING(dbstop) | |
80 | |
81 @noindent | |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
8286
diff
changeset
|
82 Note that breakpoints cannot be set in built-in functions |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9039
diff
changeset
|
83 (e.g., @code{sin}, etc.) or dynamically loaded function (i.e., oct-files). To |
6646 | 84 set a breakpoint immediately on entering a function, the breakpoint |
85 should be set to line 1. The leading comment block will be ignored and | |
86 the breakpoint will be set to the first executable statement in the | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
87 function. For example: |
6646 | 88 |
89 @example | |
90 @group | |
91 dbstop ("asind", 1) | |
92 @result{} 27 | |
93 @end group | |
94 @end example | |
95 | |
96 @noindent | |
97 Note that the return value of @code{27} means that the breakpoint was | |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9039
diff
changeset
|
98 effectively set to line 27. The status of breakpoints in a function can |
6646 | 99 be queried with the @code{dbstatus} function. |
100 | |
101 @DOCSTRING(dbstatus) | |
102 | |
103 @noindent | |
104 Taking the above as an example, @code{dbstatus ("asind")} should return | |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9039
diff
changeset
|
105 27. The breakpoints can then be cleared with the @code{dbclear} function |
6646 | 106 |
107 @DOCSTRING(dbclear) | |
108 | |
109 @noindent | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
110 These functions can be used to clear all the breakpoints in a function. For |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
111 example: |
6646 | 112 |
113 @example | |
114 dbclear ("asind", dbstatus ("asind")); | |
115 @end example | |
116 | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
117 A breakpoint can be set in a subfunction. For example if a file contains |
7984
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
118 the functions |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
119 |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
120 @example |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9039
diff
changeset
|
121 @group |
7984
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
122 function y = func1 (x) |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
123 y = func2 (x); |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
124 endfunction |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
125 function y = func2 (x) |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
126 y = x + 1; |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
127 endfunction |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9039
diff
changeset
|
128 @end group |
7984
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
129 @end example |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
130 |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
131 @noindent |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
132 then a breakpoint can be set at the start of the subfunction directly |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
133 with |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
134 |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
135 @example |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
136 @group |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
137 dbstop (["func1", filemarker(), "func2"]) |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
138 @result{} 5 |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
139 @end group |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
140 @end example |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
141 |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
142 Note that @code{filemarker} returns a character that marks the |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
143 subfunctions from the file containing them. |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
144 |
8828 | 145 Another simple way of setting a breakpoint in an Octave script is the |
6646 | 146 use of the @code{keyboard} function. |
147 | |
148 @DOCSTRING(keyboard) | |
149 | |
150 @noindent | |
151 The @code{keyboard} function is typically placed in a script at the | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
152 point where the user desires that the execution is stopped. It |
6646 | 153 automatically sets the running script into the debug mode. |
154 | |
155 @node Debug Mode | |
156 @section Debug Mode | |
157 | |
158 There are two additional support functions that allow the user to | |
159 interrogate where in the execution of a script Octave entered the debug | |
160 mode and to print the code in the script surrounding the point where | |
161 Octave entered debug mode. | |
162 | |
163 @DOCSTRING(dbwhere) | |
164 | |
165 @DOCSTRING(dbtype) | |
6647 | 166 |
8817
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8485
diff
changeset
|
167 You may also use @code{isdebugmode} to determine whether the debugger is |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8485
diff
changeset
|
168 currently active. |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8485
diff
changeset
|
169 |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8485
diff
changeset
|
170 @DOCSTRING(isdebugmode) |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8485
diff
changeset
|
171 |
8828 | 172 Debug mode also allows single line stepping through a function using |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
173 the commands @code{dbstep}. |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
174 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
175 @DOCSTRING(dbstep) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
176 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
177 @node Call Stack |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
178 @section Call Stack |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
179 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
180 @DOCSTRING(dbstack) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
181 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
182 @DOCSTRING(dbup) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
183 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
184 @DOCSTRING(dbdown) |