[lttng-dev] Iterate events in one packet

Yao Qi yao at codesourcery.com
Wed Feb 27 02:19:53 EST 2013


Hi,
When I generate CTF, I logically group events and put them into one 
packet.  When reading the CTF data (w/ libbabeltrace), can I iterate 
over events in one packet (and stop when iterator goes to the next packet)?

For example,

stream {
         packet.context := struct {
                 uint32_t content_size;
                 uint32_t packet_size;
         };
         event.header := struct {
                 uint32_t id;
         };
};

event {
         name = "tsv";
         id = 1;
         fields := struct {
                 uint64_t val;
                 uint32_t num;
         };
};

event {
         name = "register";
         id = 0;
         fields := struct {
                 uint8_t contents[440];
         };
};

we have multiple events and put them into different packets according to 
my logic,

packet 1: tsv1, register1,
packet 2: tsv2, tsv3, register2

from iterator's point of view, packet boundary is invisible and iterator 
will go through them like "tsv1, register1, tsv2, tsv3, register2".  In 
order to identify the boundary of packet in the iterator, I have to 
create a event "marker" and put it at the first event of one packet.

event {
         name = "marker";
         id = 2;
         fields := struct {
         };
};

packet 1: marker1, tsv1, register1,
packet 2: marker2, tsv2, tsv3, register2

We'll stop the iteration once we see "marker" event.  It works for me, 
but I am wondering we can solve this problem in a better way?

-- 
Yao (齐尧)



More information about the lttng-dev mailing list