[lttng-dev] Writing .tp files for lttng-gen-tp

Boisvert, Sebastien boisvert at anl.gov
Mon Oct 20 16:07:35 EDT 2014


Hi Daniel,

TRACEPOINT_EVENT_CLASS + TRACEPOINT_EVENT_INSTANCE work.

Thanks.

The documentation is in include/lttng/ust-tracepoint-event.h (lttng-ust) and the last change was made
in 2011:

1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  63) /*
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  64)  * TRACEPOINT_EVENT_CLASS declares a class of tracepoints receiving the
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  65)  * same arguments and having the same field layout.
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  66)  *
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  67)  * TRACEPOINT_EVENT_INSTANCE declares an instance of a tracepoint, with
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  68)  * its own provider and name. It refers to a class (template).
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  69)  *
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  70)  * TRACEPOINT_EVENT declared both a class and an instance and does a
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  71)  * direct mapping from the instance to the class.
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  72)  */
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  73) 
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  74) #undef TRACEPOINT_EVENT
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  75) #define TRACEPOINT_EVENT(_provider, _name, _args, _fields)   \
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  76)      TRACEPOINT_EVENT_CLASS(_provider, _name,                \
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  77)                       _TP_PARAMS(_args),                     \
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  78)                       _TP_PARAMS(_fields))                   \
1c324e59 (Mathieu Desnoyers 2011-11-18 12:36:52 -0500  79)      TRACEPOINT_EVENT_INSTANCE(_provider, _name, _name,      \
68755429 (Mathieu Desnoyers 2012-03-01 14:39:02 -0500  80)                       _TP_PARAMS(_args))


Question: why is it required to give the the arguments  to TRACEPOINT_EVENT_INSTANCE since all tracepoints from the same
class use the same arguments and same field layout ?

> ________________________________________
> From: Thibault, Daniel [Daniel.Thibault at drdc-rddc.gc.ca]
> Sent: Monday, October 20, 2014 8:29 AM
> To: lttng-dev at lists.lttng.org
> Cc: Boisvert, Sebastien
> Subject: RE: [lttng-dev] Writing .tp files for lttng-gen-tp
> ----------------------------------------------------------------------
> Date: Fri, 17 Oct 2014 21:39:21 +0000
> From: "Boisvert, Sebastien" <boisvert at anl.gov>
> > I wrote a big .tp file to define numerous tracepoints that only differ in the event name.
> > They all take the same arguments and they all dump the same fields.
> >
> > .tp file: https://github.com/sebhtml/biosal/blob/master/engine/thorium/tracepoints/lttng/message.tp
> >
> > Is there a more compact way of doing that ?
> >
> >               Sébastien
> ----------------------------------------------------------------------
>    In the kernel domain, one can declare a "tracepoint class" with DECLARE_EVENT_CLASS, and then use DEFINE_EVENT to instantiate the abstract event class into individual trace events that share a single signature.  Surely the same can be done in user-space?
>    Looking at /usr/src/lttng-ust/include/lttng/tracepoint.h, we see there are TRACEPOINT_EVENT_CLASS and TRACEPOINT_EVENT_INSTANCE macros right beside TRACEPOINT_EVENT, so I suspect you could replace your message.tp with something like:
> [...]
> TRACEPOINT_EVENT_CLASS(
> thorium_message,
> thorium_event_template,
> TP_ARGS(
> struct thorium_message *, message
> ),
> TP_FIELDS(
> ctf_integer(int, message_number, message->number)
> ctf_integer(int, message_action, message->action)
> ctf_integer(int, message_count, message->count)
> ctf_integer(int, message_source_actor, message->source_actor)
> ctf_integer(int, message_destination_actor, message->destination_actor)
> ctf_integer(int, message_source_node, message->source_node)
> ctf_integer(int, message_destination_node, message->destination_node)
> )
> )
> TRACEPOINT_EVENT_INSTANCE(
> thorium_message,
> thorium_event_template,
> actor_send,
> TP_ARGS(
> struct thorium_message *, message
> )
> )
> TRACEPOINT_EVENT_INSTANCE(
> thorium_message,
> thorium_event_template,
> node_send,
> TP_ARGS(
> struct thorium_message *, message
> )
> )
> [...]
>    Try it and let us know.  This should be added to the lttng-gen-tp man pages if it works.
> Daniel U. Thibault
> Protection des systèmes et contremesures (PSC) | Systems Protection & Countermeasures (SPC)
> Cyber sécurité pour les missions essentielles (CME) | Mission Critical Cyber Security (MCCS)
> RDDC - Centre de recherches de Valcartier | DRDC - Valcartier Research Centre
> 2459 route de la Bravoure
> Québec QC  G3J 1X5
> CANADA
> Vox : (418) 844-4000 x4245
> Fax : (418) 844-4538
> NAC : 918V QSDJ <http://www.travelgis.com/map.asp?addr=918V%20QSDJ>
> Gouvernement du Canada | Government of Canada
> <http://www.valcartier.drdc-rddc.gc.ca/>



More information about the lttng-dev mailing list