GNU Octave Manual Version 3 by John W. Eaton, David Bateman, Søren Hauberg Paperback (6"x9"), 568 pages ISBN 095461206X RRP £24.95 ($39.95) |
13.2 Breakpoints
Breakpoints can be set in any Octave function, using the dbstop
function.
- Loadable Function: rline = dbstop (func, line, ...)
- Set a breakpoint in a function
func
- String representing the function name. When already in debug mode this should be left out and only the line should be given.
line
- Line number you would like the breakpoint to be set on. Multiple lines might be given as separate arguments or as a vector.
The rline returned is the real line that the breakpoint was set at.
See also dbclear, dbstatus, dbnext
Note that breakpoints cannot be set in built-in functions
(e.g. sin
, etc) or dynamically loaded function (i.e. oct-files). To
set a breakpoint immediately on entering a function, the breakpoint
should be set to line 1. The leading comment block will be ignored and
the breakpoint will be set to the first executable statement in the
function. For example
dbstop ("asind", 1) => 27
Note that the return value of 27
means that the breakpoint was
effectively set to line 27. The status of breakpoints in a function can
be queried with the dbstatus
function.
- Loadable Function: lst = dbstatus (func)
- Return a vector containing the lines on which a function has
breakpoints set.
func
- String representing the function name. When already in debug mode this should be left out.
See also dbclear, dbwhere
Taking the above as an example, dbstatus ("asind")
should return
27. The breakpoints can then be cleared with the dbclear
function
- Loadable Function: dbclear (func, line, ...)
- Delete a breakpoint in a function
func
- String representing the function name. When already in debug mode this should be left out and only the line should be given.
line
- Line number where you would like to remove the breakpoint. Multiple lines might be given as separate arguments or as a vector.
No checking is done to make sure that the line you requested is really a breakpoint. If you get the wrong line nothing will happen.
See also dbstop, dbstatus, dbwhere
These functions can be used to clear all the breakpoints in a function. For example,
dbclear ("asind", dbstatus ("asind"));
Another simple way of setting a breakpoint in an Octave script is the
use of the keyboard
function.
- Built-in Function: keyboard (prompt)
- This function is normally used for simple debugging. When the
keyboard
function is executed, Octave prints a prompt and waits for user input. The input strings are then evaluated and the results are printed. This makes it possible to examine the values of variables within a function, and to assign new values to variables. No value is returned from thekeyboard
function, and it continues to prompt for input until the user types ‘quit’, or ‘exit’.If
keyboard
is invoked without any arguments, a default prompt of ‘debug> ’ is used.
The keyboard
function is typically placed in a script at the
point where the user desires that the execution is stopped. It
automatically sets the running script into the debug mode.
ISBN 095461206X | GNU Octave Manual Version 3 | See the print edition |