[lttng-dev] Writing a babeltrace output plugin

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Tue Apr 17 11:05:58 EDT 2012


* 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: <env. >,
 - Trace Packet Header: <trace.packet.header. >,
 - Stream Packet Context: <stream.packet.context. >,
 - Event Header: <stream.event.header. >,
 - Stream Event Context: <stream.event.context. >,
 - Event Context: <event.context. >,
 - Event Payload: <event.fields. >."

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



More information about the lttng-dev mailing list