MATLAB Function Reference Previous page   Next Page
dbstop

Set breakpoints

Graphical Interface

Some of the dbstop functionality can be accessed through the Debug menu or the toolbar buttons of the Editor/Debugger.

Syntax

Description

dbstop in mfile temporarily stops execution of running mfile, at the first executable line, putting MATLAB in debug mode. mfile must be in a directory that is on the search path or in the current directory. If you have graphical debugging enabled, the MATLAB Debugger opens with a breakpoint at the first executable line of mfile. You can then use the debugging utilities, review the workspace, or issue any valid MATLAB function. Use dbcont or dbstep to resume execution of mfile. Use dbquit to exit from debugging mode.

dbstop in mfile at lineno temporarily stops execution of running mfile just prior to execution of the line whose number is lineno, putting MATLAB in debug mode. mfile must be in a directory that is on the search path or in the current directory. If you have graphical debugging enabled, MATLAB opens mfile with a breakpoint at line lineno. If that line is not executable, execution stops and the breakpoint is set at the next executable line following lineno. When execution stops, you can use the debugging utilities, review the workspace, or issue any valid MATLAB function. Use dbcont or dbstep to resume execution of mfile. Use dbquit to exit from debugging mode.

dbstop in mfile at lineno@ stops just after any call to the first anonymous function in the specified line number in mfile.

dbstop in mfile at lineno@n stops just after any call to the nth anonymous function in the specified line number in mfile.

dbstop in mfile at subfun temporarily stops execution of running mfile just prior to execution of the subfunction subfun, putting MATLAB in debug mode. mfile must be in a directory that is on the search path or in the current directory. If you have graphical debugging enabled, MATLAB opens mfile with a breakpoint at the subfunction specified by subfun. You can then use the debugging utilities, review the workspace, or issue any valid MATLAB function. Use dbcont or dbstep to resume execution of mfile. Use dbquit to exit from debugging mode.

dbstop in mfile at lineno if expression temporarily stops execution of running mfile, just prior to execution of the line whose number is lineno, putting MATLAB in debug mode. Execution will stop only if expression evaluates to true. The expression expression is evaluated (as if by eval), in mfile's workspace when the breakpoint is encountered, and must evaluate to a scalar logical value (1 or 0 for true or false). mfile must be in a directory that is on the search path or in the current directory. If you have graphical debugging enabled, MATLAB opens mfile with a breakpoint at line lineno. If that line is not executable, execution stops and the breakpoint is set at the next executable line following lineno. When execution stops, you can use the debugging utilities, review the workspace, or issue any valid MATLAB function. Use dbcont or dbstep to resume execution of mfile. Use dbquit to exit from debugging mode.

dbstop in mfile at lineno@ if expression stops just after any call to the first anonymous function in the specified line number in mfile if expression evaluates to logical 1 (true).

dbstop in mfile at lineno@n if expression stops just after any call to the nth anonymous function in the specified line number in mfile if expression evaluates to logical 1 (true).

dbstop in mfile at subfun if expression temporarily stops execution of running mfile, just prior to execution of the subfunction subfun, putting MATLAB in debug mode. Execution will stop only if expression evaluates to logical 1 (true). The expression expression is evaluated (as if by eval), in mfile's workspace when the breakpoint is encountered, and must evaluate to a scalar logical value (0 or 1 for true or false). mfile must be in a directory that is on the search path or in the current directory. If you have graphical debugging enabled, MATLAB opens mfile with a breakpoint at the subfunction specified by subfun. You can then use the debugging utilities, review the workspace, or issue any valid MATLAB function. Use dbcont or dbstep to resume execution of mfile. Use dbquit to exit from debugging mode.

dbstop in mfile if expression temporarily stops execution of running mfile, at the first executable line, putting MATLAB in debug mode. Execution will stop only if expression evaluates to logical 1 (true). The expression expression is evaluated (as if by eval), in mfile's workspace when the breakpoint is encountered, and must evaluate to a scalar logical value (0 or 1 for true or false). mfile must be in a directory that is on the search path or in the current directory. If you have graphical debugging enabled, MATLAB opens mfile with a breakpoint at the first executable line of mfile. You can then use the debugging utilities, review the workspace, or issue any valid MATLAB function. Use dbcont or dbstep to resume execution of mfile. Use dbquit to exit from debugging mode.

dbstop if error stops execution when any M-file you subsequently run produces a run-time error, putting MATLAB in debug mode, paused at the line that generated the error. The M-file must be in a directory that is on the search path or in the current directory. The errors that stop execution do not include run-time errors that are detected within a try...catch block. You cannot resume execution after an uncaught run-time error. Use dbquit to exit from debugging mode.

dbstop if error identifier stops execution when any M-file you subsequently run produces a run-time error whose message identifier is identifier, putting MATLAB in debug mode, paused at the line that generated the error. The M-file must be in a directory that is on the search path or in the current directory. The errors that stop execution do not include run-time errors that are detected within a try...catch block. You cannot resume execution after an uncaught run-time error. Use dbquit to exit from debugging mode.

dbstop if caught error stops execution when any M-file you subsequently run produces a run-time error, putting MATLAB in debug mode, paused at the line that generated the error. The M-file must be in a directory that is on the search path or in the current directory. The errors that stop execution will only be those that are detected within a try...catch block. You cannot resume execution after an uncaught run-time error. Use dbquit to exit from debugging mode.

dbstop if caught error identifier stops execution when any M-file you subsequently run produces a run-time error whose message identifier is identifier, putting MATLAB in debug mode, paused at the line that generated the error. The M-file must be in a directory that is on the search path or in the current directory. The errors that stop execution will only be those that are detected within a try...catch block. You cannot resume execution after an uncaught run-time error. Use dbquit to exit from debugging mode.

dbstop if warning stops execution when any M-file you subsequently run produces a run-time warning, putting MATLAB in debug mode, paused at the line that generated the warning. The M-file must be in a directory that is on the search path or in the current directory. Use dbcont or dbstep to resume execution.

dbstop if warning identifier stops execution when any M-file you subsequently run produces a run-time warning whose message identifier is identifier, putting MATLAB in debug mode, paused at the line that generated the warning. The M-file must be in a directory that is on the search path or in the current directory. Use dbcont or dbstep to resume execution.

dbstop if naninf or dbstop if infnan stops execution when any M-file you subsequently run encounters an infinite value (Inf) or a value that is not a number (NaN), putting MATLAB in debug mode, paused at the line where Inf or NaN was encountered. For convenience, you can use either naninf or infnan--they perform in exactly the same manner. The M-file must be in a directory that is on the search path or in the current directory. Use dbcont or dbstep to resume execution. Use dbquit to exit from debugging mode.

Remarks

The at and in keywords are optional.

In the syntax, mfile can be an M-file, or the path to a function within a file. For example

stops at the myfun function in the file foo.m.

Examples

The file buggy, used in these examples, consists of three lines.

Stop at First Executable Line

The statements

stop execution at the first executable line in buggy:

The function

advances to the next line, at which point you can examine the value of n.

Stop if Error

Because buggy only works on vectors, it produces an error if the input x is a full matrix. The statements

produce

and put MATLAB in debug mode.

Stop if InfNaN

In buggy, if any of the elements of the input x is zero, a division by zero occurs. The statements

produce

and put MATLAB in debug mode.

See Also

break, dbclear, dbcont, dbdown, dbquit, dbstack, dbstatus, dbstep, dbtype, dbup, keyboard, partialpath, return


Previous page  dbstep dbtype Next page

© 1994-2005 The MathWorks, Inc.