[lttng-dev] Access specific fields from metadata file

Philippe Proulx eeppeliteloop at gmail.com
Wed Dec 13 15:42:11 EST 2023


Replying to an email from Volodymyr Fialko which was mistakenly erased.

> Hello all,
>
> I'm trying to parse metadata file only, to get information about all
> possible trace points. I'm using "Inspect event classes" example:
> https://babeltrace.org/docs/v2.0/python/bt2/examples.html#inspect-event-classes
> It mainly does all what I need, but there still some fields, that I
> could not figure out how to access:
>
> 1. How to access event.header struct from stream?
>        stream definition:
>        stream {
>            packet.context := struct {
>                uint8_t core_id;
>            };
>             event.header := struct {
>                uint8_t id;
>            };
>        };
>
>    It's possible to access packet.context via
>    stream_class.packet_context_field_class, but I dot not see similar
>    property for event.header. (event_common_context_field_class -
>    returns None)

You can't: headers, and some fields of the packet context, are specific
to CTF itself, therefore a `src.ctf.*` component uses them, but they
don't reach the downstream components. The libbabeltrace2 API itself
doesn't offer packet and event header access.

Why do you need them?

> 2. How to obtain string length?

>    Event definition:
>    typealias integer {size = 8; base = x;}:= uint8_t;
>    typealias integer {size = 8; signed = false; encoding = ASCII; } := string_bounded_t;
>        event {
>            id = 0x00;
>            name = "trace_point_1";
>            fields := struct {
>                uint8_t arr[32];
>                string_bounded_t str[32];
>            };
>        };
>    Fields are parsed into following Classes:
>        arr: `bt2._StaticArrayFieldClassConst`: has length property
>        str: `bt2._StringFieldClassConst`:      no length property
>    Is there some other way to get str length?

There's no way currently. A `src.ctf.*` component recognizes an array of
integer fields having an encoding as a string, and translates this to a
libbabeltrace2 string field (that's what the intention is after all).

Again, what would be the use case here?

Please note that the upcoming major revision of CTF, CTF 2, features a
JSON metadata stream, meaning you'll be able to get that information
much more easily than with the metadata DSL (TSDL) of CTF 1.8.

The latest specification RC is available here:
<https://diamon.org/ctf/files/>.

Babeltrace 2.1 and LTTng 2.15 will support CTF 2.

BR,

Philippe Proulx


More information about the lttng-dev mailing list