Navigation

Operators and Keywords

Function List:

C++ API

: dbstop func
: dbstop func line
: dbstop func line1 line2
: dbstop line1
: dbstop in func
: dbstop in func at line
: dbstop in func at line if "condition"
: dbstop if event
: dbstop if event ID
: dbstop (bp_struct)
: rline = dbstop

Set breakpoints for the built-in debugger.

func is the name of a function on the current path. When already in debug mode the func argument can be omitted and the current function will be used. Breakpoints at subfunctions are set with the scope operator ‘>’. For example, If file.m has a subfunction func2, then a breakpoint in func2 can be specified by file>func2.

line is the line number at which to break. If line is not specified, it defaults to the first executable line in the file func.m. Multiple lines can be specified in a single command; when function syntax is used, the lines may also be passed as a single vector argument ([line1, line2, …]).

condition is any Octave expression that can be evaluated in the code context that exists at the breakpoint. When the breakpoint is encountered, condition will be evaluated, and execution will stop if condition is true. If condition cannot be evaluated, for example because it refers to an undefined variable, an error will be thrown. Expressions with side effects (such as y++ > 1) will alter variables, and should generally be avoided. Conditions containing quotes (‘"’, ‘'’) or comment characters (‘#’, ‘%’) must be enclosed in quotes. (This does not apply to conditions entered from the editor’s context menu.) For example:

dbstop in strread at 209 if 'any (format == "%f")'

The form specifying event does not cause a specific breakpoint at a given function and line number. Instead it causes debug mode to be entered when certain unexpected events are encountered. Possible values are

error

Stop when an error is reported. This is equivalent to specifying both debug_on_error (true) and debug_on_interrupt (true).

caught error

Stop when an error is caught by a try-catch block (not yet implemented).

interrupt

Stop when an interrupt (Ctrl-C) occurs.

naninf

Stop when code returns a non-finite value (not yet implemented).

warning

Stop when a warning is reported. This is equivalent to specifying debug_on_warning (true).

The events error, caught error, and warning can all be followed by a string specifying an error ID or warning ID. If that is done, only errors with the specified ID will cause execution to stop. To stop on one of a set of IDs, multiple dbstop commands must be issued.

Breakpoints and events can be removed using the dbclear command with the same syntax.

It is possible to save all breakpoints and restore them at once by issuing the commands bp_state = dbstatus; …; dbstop (bp_state).

The optional output rline is the real line number where the breakpoint was set. This can differ from the specified line if the line is not executable. For example, if a breakpoint attempted on a blank line then Octave will set the real breakpoint at the next executable line.

When a file is re-parsed, such as when it is modified outside the GUI, all breakpoints within the file are cleared.

See also: dbclear, dbstatus, dbstep, debug_on_error, debug_on_warning, debug_on_interrupt.

Package: octave