☮️uftrace

Linux debug utility

Get utility

Ubuntu X86_64
sudo apt install uftrace
ARM64 in Yocto
IMAGE_INSTALL_append = " uftrace"
app.c
#include<stdio.h>

int main(void) {
        printf("This is app\n");
        sample_lib();
        return 0;
}
sample lib.c
#include <stdio.h>
#include <time.h>

void sample_lib(void) {
        sleep(10);
        printf("Inside Library\n");
}
// Compiling library dynamically
gcc -fpic -shared -pg sample.c -o libsample.so

// compile app
gcc -pg app.c libsample.so -o app

"-pg" option should be used for compiling app/libraries

export LD_LIBRARY_PATH=<path to so>
# execute app using uftrace
uftrace record ./app
uftrace replay
# DURATION     TID     FUNCTION
            [645920] | main() {
  19.924 us [645920] |   puts();
            [645920] |   sample_lib() {
  10.000  s [645920] |     sample_lib();
  10.000  s [645920] |   } /* sample_lib */
  10.000  s [645920] | } /* main */
 uftrace graph
# Function Call Graph for 'a.out' (session: e29b6ce8fa6d7e63)
========== FUNCTION CALL GRAPH ==========
# TOTAL TIME   FUNCTION
   10.000  s : (1) a.out
   10.000  s : (1) main
   19.924 us :  +-(1) puts
             :  |
   10.000  s :  +-(1) sample_lib
   10.000  s :    (1) sample_lib

TBD

  • Live C programming

  • Display each line while executing ( similar to -x in bash )

Last updated