[lttng-dev] Sequence of strings

Philippe Proulx eeppeliteloop at gmail.com
Mon Jan 19 19:16:03 EST 2015


On Mon, Jan 19, 2015 at 5:50 PM, Francis Giraldeau
<francis.giraldeau at gmail.com> wrote:
>
> Hi,
>
> I would like to record a sequence of strings. Here is an example:
>
> struct foo {
>   string _my_string;
> };
>
> event {
>   ...
>   fields := struct {
>     uint8_t _num;
>     struct foo _items[_num];
>   };
> };
>
> The program barectf does not allow it, and I wanted to know whether it's an implementation limitation or if CTF supports it at all.

Hi Francis,

CTF and Babeltrace certainly allow this.

It's a current barectf limitation: inner structures, as well as array/sequence
elements must have a fixed size. This is because they are currently copied
to the packet buffer as is using memcpy() with this precomputed fixed size.

Your best approach today is to precompute the total length of all the
concatenated strings (including terminating null characters) in your application
code, and use a sequence of bytes instead, also keeping the original number
of strings:

    event {
      ...
      fields := struct {
        uint32_t _len; /* length of all strings */
        uint8_t _num; /* number of concatenated strings */
        uint8_t _strings[_len];
      };
    };

Then, after running barectf, change this for:

    event {
      ...
      fields := struct {
        uint32_t _len;
        uint8_t _num;
        string _strings[_num];
      };
    };

and you should be able to see a sequence of strings in Babeltrace once
your streams are produced by barectf C code.

Ugly, but should work!

Supporting variable-length inner structures and array/sequence elements
is definitely on the TODO list for a future barectf release.

Thanks for the input,
Phil

>
> Thanks,
>
> Francis
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>



More information about the lttng-dev mailing list