There are three additional support functions that allow the user to find out where in the execution of a script Octave entered the debug mode, and to print the code in the script surrounding the point where Octave entered debug mode.
In debugging mode, report the current file and line number where execution is stopped.
See also: dbstack, dblist, dbstatus, dbcont, dbstep, dbup, dbdown.
lineno
¶startl:endl
¶startl:end
¶fcn
¶fcn lineno
¶fcn startl:endl
¶fcn startl:end
¶Display a script file with line numbers.
When called with no arguments in debugging mode, display the script file currently being debugged.
An optional range specification can be used to list only a portion of the
file. The special keyword "end"
is a valid line number specification
for the last line of the file.
When called with the name of a function, list that script file with line numbers.
n
¶In debugging mode, list n lines of the function being debugged centered around the current line to be executed.
If unspecified n defaults to 10 (+/- 5 lines)
You may also use isdebugmode
to determine whether the debugger is
currently active.
tf =
isdebugmode ()
¶Return true if in debugging mode, otherwise false.
Debug mode also allows single line stepping through a function using
the command dbstep
.
n
¶in
¶out
¶…
¶In debugging mode, execute the next n lines of code.
If n is omitted, execute the next single line of code. If the next line of code is itself defined in terms of an m-file remain in the existing function.
Using dbstep in
will cause execution of the next line to step into
any m-files defined on the next line.
Using dbstep out
will cause execution to continue until the current
function returns.
Programming Note: dbnext
is an alias for dbstep
and can be used
interchangeably.
When in debug mode the RETURN key will execute the last entered command.
This is useful, for example, after hitting a breakpoint and entering
dbstep
once. After that, one can advance line by line through the code
with only a single key stroke. This feature may be disabled using the
auto_repeat_debug_command
function.
val =
auto_repeat_debug_command ()
¶old_val =
auto_repeat_debug_command (new_val)
¶old_val =
auto_repeat_debug_command (new_val, "local")
¶Query or set the internal variable that controls whether debugging commands are automatically repeated when the input line is empty (typing just RET).
When called from inside a function with the "local"
option, the
variable is changed locally for the function and any subroutines it calls.
The original variable value is restored when exiting the function.