[lttng-dev] Read CTF events

Salman Rafiq salman.rafiq at esk.fraunhofer.de
Thu Feb 23 12:43:55 EST 2012


Dear Mathieu,



I am trying to read the events generated by LTTng kernel tracer in my Application. I can successfully read the event name and timestamp with the help of babeltrace API/library. But the problem comes with reading remaining fields.

e.g. my metadata file generated via LTTng kernel trace has:



event {

        name = sched_switch;

        id = 0;

        stream_id = 0;

        fields := struct {

                integer { size = 8; align = 8; signed = 1; encoding = UTF8; base = 10; } _prev_comm[16];

                integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _prev_tid;

                integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _prev_prio;

                integer { size = 64; align = 8; signed = 1; encoding = none; base = 10; } _prev_state;

                integer { size = 8; align = 8; signed = 1; encoding = UTF8; base = 10; } _next_comm[16];

                integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _next_tid;

                integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _next_prio;

        };

};



I wanted to read event fields like _prev_command and _next_command. The pseudocode of my application is:



1)    Create context

2)    Add trace to context with given context, input_path and defaults (NULL) for packet seek, mmap_stream_list, and FILE*

3)    Allocate a CTF trace collection iterator using context above and NULL (default for begin_pos and end_pos)

4)    Using iterator read event in bt_ctf_event struct , until iterator move to next event in trace collection

5)    Read event name and timestamp



But I could not figure out the way to read event fields in general, since with different types of events they will change. Kindly suggest me which files to look into? Or suggest some way through which I can achieve this.



I shall be really thankful to you.



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



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20120223/91862af5/attachment.html>


More information about the lttng-dev mailing list