Skip to Content
Exploring Expect
book

Exploring Expect

by Don Libes
December 1994
Intermediate to advanced
606 pages
16h 7m
English
O'Reilly Media, Inc.
Content preview from Exploring Expect

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

AI Agents in Action

AI Agents in Action

Micheal Lanham
Learning Go

Learning Go

Jon Bodner

Publisher Resources

ISBN: 9781565920903Supplemental ContentErrata Page