Getting started with UDB

UDB is Undo’s Time Travel Debugger. It records the execution history of a program, so that the program can be executed forward and backward and its state examined at any time in its history. This makes it possible to diagnose the cause of defects by executing backwards from incorrect results to the code that created the results.

UDB can also load recordings of your software created by LiveRecorder.

Launching a program in UDB

Start udb, naming the program to be debugged on the command line:

$ udb -q examples/hashtable
Reading symbols from examples/hashtable...

Then use the run command in UDB to run the program with command-line arguments:

not running> run 12345
Starting program: examples/hashtable 12345
hashtable: hashtable.c:131: main: Assertion `table_contains(table, element)' failed.

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.

Alternatively, start udb with the --args command-line option to specify the program and its command-line arguments:

$ udb -q --args examples/hashtable 12345
Reading symbols from examples/hashtable...

Then use the run command in UDB to run the program with the arguments already given:

not running> run
Starting program: examples/hashtable 12345
hashtable: hashtable.c:131: main: Assertion `table_contains(table, element)' failed.

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.

See Invoking UDB for more details.

Attaching to an existing process

Attach UDB to a running process using the udb --pid PID command-line option. For example:

$ examples/deadlock & udb -q --pid $!

No more reverse-execution history.
Reading symbols from /lib/x86_64-linux-gnu/libpthread.so.0...
Reading symbols from /usr/lib/debug/.build-id/a0/32da2858a8dc53ef58fc7de01b293bb047201e.debug...
Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...
Reading symbols from /usr/lib/debug/.build-id/5c/c2a90d68d2a039e555d4739eaf5a2395d9e009.debug...
Reading symbols from /lib64/ld-linux-x86-64.so.2...
Reading symbols from /usr/lib/debug/.build-id/a2/2b4ae056ad8cdd0ad900b001533e9a1c8a061a.debug...
Have reached start of recorded history.
0x00007fdfe650f4b6 in __GI___pthread_timedjoin_ex (threadid=140599616608000, thread_return=0x0, abstime=<optimized out>, block=<optimized out>) at pthread_join_common.c:84
84      pthread_join_common.c: No such file or directory.
recording 1> info threads
  Id   Target Id              Frame
* 1    Thread 2100202.2100202 0x00007fdfe650f4b6 in __GI___pthread_timedjoin_ex (threadid=140599616608000, thread_return=0x0, abstime=<optimized out>, block=<optimized out>) at pthread_join_common.c:84
  2    Thread 2100202.2100204 __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:101
  3    Thread 2100202.2100205 __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:101

Forward and reverse execution

To execute the program forward, use the execution commands. For example, the step command executes the program forward to the next source line, and the continue command continues execution of the program until a breakpoint is hit or the program stops on a signal.

To execute the program backward, use the reverse-execution commands. For example, the reverse-step command executes the program backward to the previous source line, and the reverse-continue command executes the program backward until a breakpoint is hit, or the program stops on a signal, or it reaches the start of execution history.

Other methods of navigation

Use the ugo start or ugo end commands to jump to the beginning or end of your program’s execution history.

You can jump to a point in the middle of your program’s execution history by jumping to a bookmark that you’ve previously created (see Bookmarks), or by jumping to a wall-clock time (see Log Jump).