dbstop in file
dbstop in file at location
dbstop in file if expression
dbstop in file at location if expression
dbstop if error
dbstop if caught error
dbstop(b)
| Parameter | Description |
|---|---|
| file | file name where the breakpoint is set, specified as a character vector or string scalar. The file must be accessible on the search path or in the current folder. A filemarker (>) can be used to specify a local function. A filemarker cannot be combined with at location. |
| location | breakpoint location in the file: a line number, or the name of a local function (its first executable line is used). A breakpoint requested on a comment, a blank line or a function declaration moves to the next executable line. The end line of a for or while loop is a breakpoint location of its own: execution pauses there at every iteration. |
| expression | condition evaluated in the workspace of the paused function each time the line is reached. Execution pauses only when the expression is a scalar logical or numeric value that is true. A non-scalar value or an expression that fails raises a warning and pauses execution anyway. A syntax error is rejected when the breakpoint is set. Setting a breakpoint again on the same line replaces its condition. |
| b | structure array previously returned by dbstatus, containing saved breakpoints to restore. The seven fields name, file, line, anonymous, expression, cond and identifier are required; conditions and error breakpoints are restored as well. |
dbstop sets breakpoints in programs for interactive debugging. When execution reaches a breakpoint, execution pauses, the line about to run is displayed and the interpreter enters debug mode (prompt K>>).
dbstop if error pauses execution on the line that raises a run-time error not caught by a try/catch block. The error is reported, the variables of the paused function can be inspected, and dbcont, dbstep or dbquit end the execution.
dbstop if caught error pauses execution on a run-time error raised inside the try part of a try/catch block; dbcont resumes in the catch block. The conditions warning and naninf are not supported.
Breakpoints are kept until dbclear removes them or the session ends. This function can only be called from the command line.
Text editor debugging features integrate with these functions for interactive debugging.
See also the Debugging Workflow for an overview of debugging in Nelson.
function z = buggy(x)
n = length(x);
z = (1:n) / x';
end
dbstop in buggy
buggy(1:5)
dbstop in myfile>myfunc
dbstop in myfile at myfunc
dbstop in buggy at 3 if n > 2
dbstatus
dbstop if error
buggy(1:5)
dbquit
dbclear if error
b = dbstatus();
dbclear all
dbstop(b)
| Version | Description |
|---|---|
| 1.16.0 | initial version |
| 2.0.0 | conditional breakpoints, dbstop if error, dbstop if caught error, local function as location, seven-field dbstatus structure |