Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: eeppeliteloop@gmail.com (Philippe Proulx)
Subject: [lttng-dev] sdt.h tracepoints with unicode data and/or structs
Date: Tue, 4 Oct 2016 11:50:06 -0400	[thread overview]
Message-ID: <CAB4xu_1JBA_d3w8ZU3Dbh1wUSCoVK0CnM6n-+9uHg13LZpWh-w@mail.gmail.com> (raw)
In-Reply-To: <1527185266.45326.1475595408856.JavaMail.zimbra@efficios.com>

>> This sounds excellent. Can you tell me how? Could you maybe add an example to
>> lttng-ust. Also note how http://lttng.org/man/3/lttng-ust/v2.7 says:
>>
>>       if (tracepoint_enabled(ust_tests_hello, tptest)) {
>>               /* prepare arguments */
>>               do_tracepoint(ust_tests_hello, tptest, i, netint, values,
>>                       text, strlen(text), dbl, flt);
>>       }
>>
>> If I understood you correctly, then I could do something like
>>
>>       if (tracepoint_enabled(ust_tests_hello, tptest)) {
>>               /* don't prepare arguments */
>>               do_tracepoint(ust_tests_hello, my_complex_data);
>>       }
>>
>> And then have the "prepare" code somewhere in my TRACEPOINT_EVENT?
>>
>
> Yes. Both approaches can be used.
>
> Note that the second approach you refer to is the same as using a
> plain tracepoint() macro and doing the preparation within
> the TRACEPOINT_EVENT() macro.

Here's an example (C++):

    #define _my_enum_evaluation(_enum, _field, _member)                     \
      ctf_enum(my_provider, _enum, int, _field,                             \
               (_member).is_bound() ?                                       \
                 ((SomeApi::_enum::enum_type) (_member) <
SomeApi::_enum::UNKNOWN_VALUE ? \
                   (int) ((SomeApi::_enum::enum_type) (_member)) : INT_MAX  \
                 ) : INT_MAX)

    TRACEPOINT_ENUM(
      my_provider,
      my_enum,
      TP_ENUM_VALUES(
        ctf_enum_value("unknown", 0)
        ctf_enum_value("apple", 1)
        ctf_enum_value("banana", 2)
        ctf_enum_value("orange", 3)
        ctf_enum_value("strawberry", 4)
      )
    )

    TRACEPOINT_EVENT(
      my_provider,
      my_tracepoint,
      TP_ARGS(
        int something,
        const SomeApi::SomeObject&, object
      ),
      TP_FIELDS(
      ctf_integer(int, int_field, something)
        _my_enum_evaluation(my_enum, enum_field, object.someMember())
      )
    )

You can call functions in there, evaluate conditions using the ternary operator,
etc.

Phil

>
> The preparation within TRACEPOINT_EVENT() can currently only be
> done as expression evaluation in the TP_FIELDS. LTTng-modules has
> more flexibility in that respect, but not lttng-ust yet.
>
> A patch contributing such example to lttng-ust would be welcome :)
>
> Thanks,
>
> Mathieu
>
>
>> Thanks
>> --
>> Milian Wolff | milian.wolff at kdab.com | Software Engineer
>> KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
>> Tel: +49-30-521325470
>> KDAB - The Qt Experts
>
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com


  reply	other threads:[~2016-10-04 15:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <133954640.uMaX5Hy6f7@agathebauer>
     [not found] ` <CAB4xu_2r+eNS6s5CWTGoNGPRJwp8H_gr6TDTG+6LJCgvDtO5gg@mail.gmail.com>
     [not found]   ` <1494937800.28038.1474478555753.JavaMail.zimbra@efficios.com>
     [not found]     ` <12621392.supdKG9qFk@milian-kdab2>
2016-10-04 15:36       ` Mathieu Desnoyers
2016-10-04 15:50         ` Philippe Proulx [this message]
2016-10-05  8:05           ` Milian Wolff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAB4xu_1JBA_d3w8ZU3Dbh1wUSCoVK0CnM6n-+9uHg13LZpWh-w@mail.gmail.com \
    --to=eeppeliteloop@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox