0

I' using lttng to trace the execution of a program and compute the average exectuion time of some functions. As there are millions of traces generated, Python bindings for babeltrace result to be really slow analysing them.

I was wondering if it is possible to read the traces using the libbabeltrace library on a C program for a faster analysis, since I wasn't able to find much documentation regarding the API and its usage. I'd be interested on extracting the timestamp and two fields of each event. I use Babeltrace 2.0.0-pre4.

Furthermore, what I did found about libbabeltrace is http://mcs.une.edu.au/doc/libbabeltrace/API.txt.

Considering this, I wrote a simple program to start with and create a context of the trace:

#include <stdio.h>
#include <babeltrace/context.h>

 int main(void){

     struct bt_context *ctx = bt_context_create();

     int a = bt_context_add_trace(ctx, "./CTF/TRACE/PATH", "ctf", NULL, NULL, NULL);

     return a;
 }

However, I get the following error:

[error] [Context] Format "ctf" unknown.

Can someone help me with this?

Thanks in advance

JMC
  • 1
  • 1
  • 1
    Some nitpicking: There is no language called "C/C++". There is either only C, or there is only C++. Those two are *very* different languages. So even if a library can be used by both languages, only pick the language you're primarily targeting or working in. – Some programmer dude Jan 31 '19 at 09:43
  • Thanks, I fixed it – JMC Jan 31 '19 at 09:56
  • I suggest that you use Babeltrace 1.5 rather the 2.0-pre4 version. The 2.0 version is it's undergoing major changes and most probably have bugs. You better stick with 1.5 for now: https://github.com/efficios/babeltrace/tree/stable-1.5 – fdeslaur Jan 31 '19 at 17:08
  • Thank you for the advise, it runs smoothly now – JMC Feb 07 '19 at 13:24
  • @JMC "Pure" Python is slow for data analysis in general. Consider using babeltrace to parse the trace data and put it into a pandas DataFrame. That will get you near-C speed without any of the C headaches. – BrianTheLion Mar 03 '19 at 23:38

0 Answers0