From mboxrd@z Thu Jan 1 00:00:00 1970 From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers) Date: Tue, 17 Apr 2012 11:05:58 -0400 Subject: [lttng-dev] Writing a babeltrace output plugin In-Reply-To: <524C960C5DFC794E82BE548D825F05CF29F0FE@EU-MBX-04.mgc.mentorg.com> References: <524C960C5DFC794E82BE548D825F05CF29D8A8@EU-MBX-04.mgc.mentorg.com> <524C960C5DFC794E82BE548D825F05CF29D8C6@EU-MBX-04.mgc.mentorg.com> <20120403125754.GC14534@Krystal> <524C960C5DFC794E82BE548D825F05CF29F0FE@EU-MBX-04.mgc.mentorg.com> Message-ID: <20120417150558.GA31475@Krystal> * Oestman, Fredrik (Fredrik_Oestman at mentor.com) wrote: > Mathieu Desnoyers wrote: > > The second solution is to look at include/babeltrace/ctf-ir/metadata.h > > in-tree, and include/babeltrace/types.h (also in-tree). Those files > > contain almost all the metadata of the CTF trace read, so you should be > > able to extract your own metadata from those. > > Is there a special reason that the field names in the metadata are > prefixed with an underscore? Yes, prefixing the field names is an oddness caused by the need to not have ambiguity between field names declared within the local scope and root scope names (event, stream, env, trace). Lets assume we have a field called "stream" within an event (I am not saying this should be done, I'm just saying this kind of thing happens to be done automatically by the tracer, depending on the instrumentation sources): uint32_t stream; Followed by a sequence that refers to it: uint8_t myfield2[stream]; It is ambiguous whether "stream" should refer to the "stream" in the local scope, or the toplevel "stream" dynamic scope as in: (7.3.2 Static and Dynamic Scopes from CTF spec) "The dynamic scope prefixes are thus: - Trace Environment: , - Trace Packet Header: , - Stream Packet Context: , - Event Header: , - Stream Event Context: , - Event Context: , - Event Payload: ." This applies to both sequence and variant types, which both need to refer to another field. The sequence for the length, the variant for the "choice" selection (an enumeration). The ideas I pondered were either to change the grammar late in the game and prefix a dot (".") before any toplevel dynamic scope, or make the LTTng tracer preprend an underscore before each event field, which gets removed by the trace analyzer. I'm not particularly proud of this hack though. Comments are welcome. Thanks, Mathieu -- Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com