O'Reilly logo

Exploring Expect by Don Libes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining Breakpoints

So far, I have shown how to execute a fixed number of commands or procedure calls with debugger commands such as s and n. In contrast, breakpoints provide a way to stop execution upon a condition. The conditions include:

  • line number and filename matching

  • expression testing

  • command and argument name matching

Now I will demonstrate these conditions and also show how Tcl’s trace facility can be used to cause breakpoints.

Breakpoint By Line Number And Filename

Line numbers and filenames are the most common way to specify a breakpoint.[64]This form is correspondingly the most compact. For example, the following command causes execution to break before executing line 7.

dbg2.26> b 7
0

After creation of a breakpoint, an integer identifying the breakpoint is printed. Later, I will show how this is helpful when you have to keep track of multiple breakpoints.

By default, the line number refers to the file associated with the current scope. A filename may be used to refer to a different file. A colon is used to separate the filename and line number.

dbg2.27> b foo.exp:7
1

Breakpoint By Expression

It is possible to break only when an expression is true. For example, the following command causes execution to break only when foo is greater than 3.

dbg2.28> b if {$foo > 3}
2

Expressions follow the usual Tcl syntax and may be arbitrarily complex.

No breakpointing occurs inside of the evaluation of breakpoint expressions (unless another breakpoint dictates this).

Line numbers and expressions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required