[lttng-dev] how do I print a value from an array of structs in a userspace tracepoint?

Jérémie Galarneau jeremie.galarneau at efficios.com
Tue Aug 18 13:01:23 EDT 2015

On Tue, Aug 18, 2015 at 8:00 AM, Jeff Layton <jlayton at poochiereds.net>

> I'd like to add a tracepoint to my code that can walk a
> dynamically-sized array of structs and print one of the fields from
> each struct. For instance, suppose I have an array of structs that
> looks like this:
> struct foo
> {
>         int bar;
>         int baz;
>         ...
> }
> At the time of the tracepoint, I know the number of elements in the
> array and can pass that in. Is there any way to have lttng walk the
> array of structs and print out only the "bar" field from each?
> I've tried using ctf_sequence, but it doesn't seem to do the right
> thing. You can't tell it that you want to print out an "int" while
> walking an array of differently-sized objects.
Indeed, sequences assume elements are of the same type/size. That would,
presumably, be possible using variants, but they remain unsupported by the
current tracer implementations.

For now, you could serialize your fields to a dynamically-sized array and
extract this array using a ctf_sequence.


Any help is appreciated!
> --
> Jeff Layton <jlayton at poochiereds.net>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Jérémie Galarneau
EfficiOS Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20150818/11e553f0/attachment.html>

More information about the lttng-dev mailing list