Main Content

dbstatus

List all breakpoints

Description

example

dbstatus lists all the breakpoints in effect, including errors, caught errors, warnings, and naninfs. For nonerror breakpoints, MATLAB® displays the line number for which the breakpoint is set. Each line number is a hyperlink that you can click to go directly to that line in the Editor.

example

dbstatus file lists all breakpoints in effect for the specified file.

example

dbstatus -completenames displays, for each breakpoint, the fully qualified name of the function or file containing the breakpoint.

example

dbstatus file -completenames displays, for each breakpoint in the specified file, the fully qualified name for the function or file containing the breakpoint.

example

b = dbstatus(___) returns breakpoint information in an m-by-1 structure. To save the current breakpoints to restore them later using dbstop(b), use this syntax. You also can specify the file name and 'completenames'.

Examples

collapse all

Create a file, myfile.m, that contains these statements.

function n = myfile(x)
n = myfunction(x-1);

function z = myfunction(y)
z = 2/y ;

Set an error breakpoint, and a standard breakpoint at the first line in myfile.

dbstop if error
dbstop in myfile

Run the dbstatus command. MATLAB displays the active breakpoints: the standard breakpoint inmyfile, and the error breakpoint.

dbstatus
Breakpoint for myfile is on line 2.
Stop if error.

List all breakpoints in a specified file, showing complete names.

Create a file, myfile.m, that contains these statements.

function n = myfile(x)
n = myfunction(x-1);

function z = myfunction(y)
z = 2 / y ;

Set an error breakpoint and a standard breakpoint at the first line in myfile.

dbstop if error
dbstop in myfile

Run the dbstatus command, specifying the file myfile and requesting complete names. MATLAB displays the active breakpoints: the standard breakpoint inmyfile, and the error breakpoint.

dbstatus myfile -completenames
Breakpoint for C:\myProject\myfile.m>myfile is on line 2.

Notice that the error breakpoint is not listed. Only breakpoints specific to the specified file are included in the list.

Set, save, clear, and then restore saved breakpoints.

Create a file, buggy.m, which contains these statements.

function z = buggy(x)
n = length(x);
z = (1:n)./x;

Set an error breakpoint and a standard breakpoint at the second line in buggy.

dbstop at 2 in buggy
dbstop if error

Run dbstatus. MATLAB describes the breakpoints you set.

dbstatus
Breakpoint for buggy is on line 2.
Stop if error.

Assign a structure representing the breakpoints to the variable b, and then save b to the MAT-file buggybrkpnts. Use b=dbstatus('-completenames') to save absolute paths and the breakpoint function nesting sequence.

b = dbstatus('-completenames');
save buggybrkpnts b

Clear all breakpoints.

dbclear all

Restore the breakpoints by loading the MAT-file and calling dbstop with the saved structure, b.

load buggybrkpnts
dbstop(b)

Input Arguments

collapse all

File name, specified as a character vector or string scalar. The file name can include a partial path, but must be in a folder on the search path, or in the current folder.

Example: myfile.m

When specifying methods, private functions, or private methods, use the / character.

Example: myclass/myfunction

Example: private/myfunction

Example: myclass/private/myfunction

In addition, file can include a filemarker (>) to specify the path to a particular local function or to a nested function within the file.

Example: myfile>myfunction

Data Types: char | string

Output Arguments

collapse all

List of breakpoints currently in effect, returned as a m-by-1 structure, where m is the number of breakpoints. This table shows the fields in the structure.

name

Function name.

file

Full path for file containing breakpoints.

line

Vector of breakpoint line numbers.

anonymous

Vector of integers representing the anonymous functions in the line numbers represented by the line field. For example, 2 means the second anonymous function in that line. A value of 0 means that the breakpoint is at the start of the line, not in an anonymous function.

expression

Cell vector of character vectors, containing the breakpoint conditional expressions corresponding to line numbers in the line field.

cond

Character vector containing the condition ('error', 'caught error', 'warning', or 'naninf').

identifier

If cond is 'error', 'caught error', or 'warning', a cell vector of character vectors containing MATLAB message identifiers for which the particular cond state is set.

Version History

Introduced before R2006a