Skip to content
Namhyung Kim edited this page Sep 29, 2016 · 16 revisions

Overview

uftrace is a tool to trace and analyze execution of a program written in C/C++. It was inspired by Linux kernel's ftrace (especially function graph tracer), and supports userspace programs on Linux. In order to use uftrace, the program should be compiled with -pg or -finstrument-functions option. (On ARM platforms, you may need to add -fno-omit-frame-pointer option also). The example output looks like below:

$ cat hello.c
#include <stdio.h>
int main(void)
{
   return printf("%s world\n", "Hello");
}

$ gcc -pg -o hello hello.c

$ uftrace ./hello
Hello world
# DURATION    TID     FUNCTION
            [ 7516] | main() {
 414.023 us [ 7516] |   printf();
 697.310 us [ 7516] | } /* main */

In the above example, uftrace ran the hello program (it printed "Hello world") and showed the execution replay with duration and tid. As you can see, the uftrace replay output resembles the original source code. In addition, uftrace provides useful commands and features to analyze behavior of your program.

Quick install

The uftrace depends on libelf from elfutils (plus a couple of optional libraries). On debian-based systems, you can install uftrace and the required packages with below command:

$ sudo apt-get install build-essential git libelf-dev
$ git clone https://github.com/namhyung/uftrace.git
$ cd uftrace
$ make
$ sudo make install

For more information, please refer INSTALL.md page.

Tutorials

Man pages

Clone this wiki locally