[lttng-dev] WG: Reading CTF trace using Babeltrace API

Jérémie Galarneau jeremie.galarneau at efficios.com
Mon May 6 16:17:09 EDT 2013


On Thu, May 2, 2013 at 4:43 PM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> Jérémie, can you have a look at these questions ?
>
> Thanks,
>
> Mathieu
>
> * Salman Rafiq (salman.rafiq at esk.fraunhofer.de) wrote:
>> Hello All,
>>
>> In continuation to my previous questions related to reading CTF traces from particular timestamp, I can now further summarize few problems/questions I have:
>>
>>
>> 1.       Is it possible to seek CTF file_stream using 'begin' and 'end' iterator position i.e. BT_SEEK_TIME?
>>

I'm not sure I understand your question. The iterator API provides a
seeking mechanism that accepts time-based positions expressed in
nanoseconds (with bt_iter_pos.type == BT_SEEK_TIME) and
BT_SEEK_BEGIN/BT_SEEK_LAST.

See bt_iter_set_pos(struct bt_iter *iter, const struct bt_iter_pos
*iter_pos) (include/babeltrace/iterator.h:114)

>>
>>
>> a.       We cannot use babel trace API for CTF iterator creation using defined start and end position based on time. Seems this is in progress?

It is supported via the position parameters of bt_ctf_iter_create
(include/babeltrace/ctf/iterator.h:62). Are you getting an error?

>>
>> b.      The other possible solution I am using, is to create the iterator using defaults, and then later use API to 'create iterator time position based on Raw Timestamp (only takes raw time)' and then 'set iterator position to that timed position'.
>>

This should work too.

>>
>>
>> 2.       But, since the area of interest for me was only the time when user application which I am tracing using Lttng-kernel tracer, started recording events (application use external trace recording format).
>>
>> User application contains a definition file which tells me the epoch time (us resolution) when it started and stopped tracing. I wanted to use this information to set iterator positions.
>>
>>
>>
>> a.       Question is Can I convert this time to raw time which babeltrace API takes as an argument?
>>
>> b.      Or Is there any way to read Clock struct from CTF metadata file (is there any scope defined for this), so that I can extract offset variable value to convert epoch time from other trace to raw time?
>>

Yes. I suggest you have a look at what the ctf-text plugin does in
ctf_text_write_event[1] and perhaps ctf_get_real_timestamp[2] to
understand these time conversions.

Regards,
Jérémie

[1] formats/ctf-text/ctf-text.c:272
[2] formats/ctf/events-private.h:38

>>
>> It will be really great if I can get few suggestions/help related to these issues.
>> Thanking in anticipation!
>>
>>
>> Best Regards,
>>
>> Salman Rafiq
>> Research Engineer
>> Industrial Communication
>> Fraunhofer-Einrichtung für Systeme der Kommunikationstechnik ESK
>>
>> Hansastraße 32 | 80686 München
>> Telefon, Fax:  +49 89 547088-356 | +49 89 547088-66-356
>> E-Mail:   salman.rafiq at esk.fraunhofer.de<http://www.esk.fraunhofer.de/>
>>
>> Internet:
>> http://www.esk.fraunhofer.de<http://www.esk.fraunhofer.de/>
>> http://www.facebook.com/FraunhoferESK
>> http://www.twitter.com/FraunhoferESK
>>
>> Von: Salman Rafiq [mailto:salman.rafiq at esk.fraunhofer.de]
>> Gesendet: Mittwoch, 18. Juli 2012 15:28
>> An: lttng-dev at lists.lttng.org
>> Betreff: [lttng-dev] Reading CTF trace from time T
>>
>> Hello All,
>>
>> I am tracing a user application using lttng kernel tracer, i.e.,
>>
>> Start lttng kernel trace
>> ./application
>> Stop lttng kernel trace
>>
>> Before I was reading kernel CTF trace using babeltrace API's from beginning of trace, e.g.,
>> struct  bt_iter_pos  begin_pos
>> struct bt_ctf_iter *iterator
>>
>> begin_pos.type = BT_SEEK_BEGIN
>> iterator = create_iterator(context,  &begin_pos, NULL)
>> .. and then read events start from that iterator postion.
>>
>> Recently, I have been trying to seek trace using timestamp from when the application started to application end.
>> I would like to know if I am doing it right. Would the method below enough to achieve this? Or I am missing something here :-S
>>
>> begin_pos.type = BT_SEEK_TIME
>> end_pos.type = BT_SEEK_TIME
>>
>> begin_pos.u.seek_time = timestamp1 (for now manually taken from CTF kernel trace when application started)
>> end_pos.u.seek_time = timestamp2 (for now manually taken from CTF kernel trace when application ended)
>>
>> iterator = create_iterator(context,  &begin_pos, &end_pos);
>> and then with reading events at iterator position until end_pos.
>>
>>
>> I am using babeltrace package version "1.0.0-pre4".
>> Any help related to achieving this functionality will be highly appreciated.
>>
>> Best Regards,
>> Salman
>>
>>
>> --
>> Salman Rafiq
>> Industrial Communication
>> Fraunhofer-Einrichtung für Systeme der Kommunikationstechnik ESK
>>
>> Hansastraße 32 | 80686 München
>> Telefon, Fax:  +49 89 547088-356 | +49 89 547088-66-356
>> E-Mail:   salman.rafiq at esk.fraunhofer.de<http://www.esk.fraunhofer.de/>
>>
>> Internet:
>> http://www.esk.fraunhofer.de<http://www.esk.fraunhofer.de/>
>> http://www.facebook.com/FraunhoferESK
>> http://www.twitter.com/FraunhoferESK
>>
>
> Content-Description: ATT00001.txt
>> _______________________________________________
>> lttng-dev mailing list
>> lttng-dev at lists.lttng.org
>> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>
>
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list