Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

dbstatus

List all breakpoints

Syntax

Description

example

dbstatus lists all the breakpoints in effect including errors, caught errors, warnings, and naninfs. For non-error breakpoints, MATLAB® displays the line number for which the breakpoint is set. Each line number is a hyperlink 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 for 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 breakpoint status and restore it later using dbstop(b), use this syntax. You also can specify the file name and 'completenames'.

Examples

collapse all

List All Breakpoints

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 breakpoint at the first line in myfile.

dbstop if error
dbstop in myfile

Run the dbstatus command. MATLAB displays the active breakpoints, including the breakpoint in the file, and the error breakpoint.

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

List All Breakpoints in File

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 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, including the breakpoint in the file, 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.

Restore Saved Breakpoints

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 breakpoints from the Command Window.

dbstop at 2 in buggy
dbstop if error

Run dbstatus.

dbstatus

MATLAB describes the breakpoints you set.

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

Save the breakpoints to the structure, 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.

load buggybrkpnts
dbstop(b)

Input Arguments

collapse all

file — File namestring

File name, specified as a string. 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

Output Arguments

collapse all

b — List of breakpointsstructure array

List of breakpoints in effect, returned as a m-by-1 structure, where m is the number of breakpoints currently in effect. 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 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 breakpoint conditional expression strings corresponding to lines in the line field.

cond

Condition string ('error', 'caught error', 'warning', or 'naninf').

identifier

When cond is 'error', 'caught error', or 'warning', a cell vector of MATLAB message identifier strings for which the particular cond state is set.

See Also

| | | | |

Introduced before R2006a

Was this topic helpful?