Install uftrace on Ubuntu 24.04

Install uftrace on Ubuntu 24.04

The uftrace is a tracing tool for Linux systems, particularly useful for tracing function calls in the applications. It helps developers understand the behavior of their applications by showing when and how functions are called, how long they take to execute, and in what order. This tutorial explains how to install uftrace on Ubuntu 24.04.

Install uftrace

Ensure that the package lists are up-to-date:

sudo apt update

Run the following command to install uftrace:

sudo apt install -y uftrace

To verify installation, check uftrace version:

uftrace --version

Testing uftrace

To use uftrace, simply prefix the command with uftrace to trace its function calls:

uftrace myprog arg1 arg2

Replace myprog arg1 arg2 with the actual command. For example:

uftrace --force echo "Hello world"

This runs the echo command while tracing all user-space function calls it makes. The output shows each function called, the thread ID (TID), and how long each function took to execute. This helps you understand the runtime behavior and performance of a program at the function level. The --force option is required to trace standard binaries that lack embedded debugging information.

Truncated output example:


Hello world
# DURATION     TID     FUNCTION
   1.826 us [  1821] | getenv();
   0.124 us [  1821] | strrchr();
 103.233 us [  1821] | setlocale();
   0.294 us [  1821] | bindtextdomain();
   0.211 us [  1821] | textdomain();
   0.145 us [  1821] | __cxa_atexit();
...
   0.068 us [  1821] | __fpending();
   0.064 us [  1821] | fileno();
   0.054 us [  1821] | __freading();
   0.062 us [  1821] | __freading();
   0.058 us [  1821] | fflush();
   0.348 us [  1821] | fclose();

Uninstall uftrace

To completely uninstall uftrace along with its dependencies, run this command:

sudo apt purge --autoremove -y uftrace

Leave a Comment

Cancel reply

Your email address will not be published.