# Breakpoints¶

Breakpoints can be used to request that UndoDB pauses the execution of the debuggee process when it reaches a particular position in the program. They are supported for both forwards and reverse execution.

## Setting and hitting a breakpoint¶

The break <location> command can be used to ask UndoDB to stop at the given location. A location can be one of:

• A function (e.g. break your_function_name)
• A file and line number (e.g. break your_file.c:12)
• A line number in the current source file (e.g. break 12)
• A program counter value (e.g. break *0x422fd0)
• The next instruction - No argument requried for this case (i.e. break).

Note

See the GDB documentation for a full list of valid location values.

Once a breakpoint has been set, UndoDB will pause the debuggee whenever it reaches the location specified by the breakpoint. Here’s an example:

(udb) break main
Breakpoint 1 at 0x422fd0
(udb) run
Starting program: your-program

Breakpoint 1, 0x0000000000422fd0 in main ()
(udb)


In this case the run command has been used to start the debuggee, which will run until it has reached the main function. At this point we can execute commands to analyse the state. For example:

(udb) backtrace
#0  0x0000000000422fd0 in main ()
(udb)


We can also use continue and reverse-continue to move between the breakpoint and other points in the execution of program. For example:

(udb) continue
Continuing.

Program received signal SIGSTOP, Stopped (signal).
udb: The program has exited, but is still being debugged.
udb: (You may use undodb commands to go backwards.)
(udb) reverse-continue
Continuing.

Breakpoint 1, 0x0000000000422fd0 in main ()
(udb)


In this case we’ve used continue to unpause the debuggee and run it until it terminated. We’ve then used reverse-continue to play the debuggee backwards until it hits the breakpoint again.

## Managing breakpoints¶

Breakpoints can be viewed using the info breakpoints command. For example:

(udb) info breakpoints
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000000000422fd0 <main>
(udb)


You can delete a chosen breakpoint using delete. For example:

(udb) delete 1
(udb) continue
Continuing.

Program received signal SIGSTOP, Stopped (signal).
udb: The program has exited, but is still being debugged.
udb: (You may use undodb commands to go backwards.)
(udb) reverse-continue
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
udb: Have reached start of recorded history.
(udb)


Since we deleted the breakpoint on main, the reverse-continue command moves us to the beginning of recorded history. You can delete all breakpoints by specifying delete without any arguments:

(udb) delete
Delete all breakpoints? (y or n) y
(udb)


## Conditional breakpoints¶

By default UndoDB accelerates conditional breakpoints using it’s intrumentation engine. In practical terms, this means that conditional breakpoints in UndoDB are at least several hundred times faster than GDB’s default conditional breakpoints.

There is no special configuration or syntax required to take advantage of this feature. Simply set conditional breakpoints in the same manner as one would in GDB.

In addition to accelerating conditional breakpoints UndoDB will accelerate dynamic printf calls. As with conditinal breakpoints, no special syntax is required to take advantage of this feature and a significant performance boost should be apparent.