[lttng-dev] Writing from a trace to a new one with Babeltrace 2.0.0-pre1 C API

Marie Martin marie.martin at polymtl.ca
Thu Jun 29 17:37:59 UTC 2017


Hi everyone!

I'm trying to use Babeltrace 2.0.0-pre1 C API to copy some events of  
an existing CTF trace (generated with LTTng) into a new one. So I was  
wondering how I should open the existing trace and iterate over its  
events, as there is no method bt_ctf_iter_create,  
bt_ctf_iter_read_event and such, anymore.

Before, with the 1.5 API, I was reading the trace like this :
     struct bt_context *ctx = bt_context_create();
     int trace_id = bt_context_add_trace(ctx, read_trace_path, "ctf",  
NULL, NULL, NULL);
     struct bt_ctf_iter *iter = bt_ctf_iter_create(ctx, NULL, NULL);
     while ((ctf_event = bt_ctf_iter_read_event(iter))) { ... }

I'm not sure about the proper way to do it now. I tried to replicate  
some of the code from babeltrace.c (especially the cmd_run function)  
and I'm able to print metadata from the trace (using  
bt_component_class_query(src_component_class, "metadata-info", params)  
after gettting the ctf plugin and the source component). Can I use  
queries in a similar way to access trace events data ?

I also tried to instantiate a new graph, add the ctf plugin components  
to the graph and run it, but I don't know how to collect events.

Also, should I define my own custom plugin for that purpose ?

Thanks,

Marie Martin




More information about the lttng-dev mailing list