[lttng-dev] sdt.h tracepoints with unicode data and/or structs

Milian Wolff milian.wolff at kdab.com
Wed Oct 5 08:05:40 UTC 2016


On Tuesday, October 4, 2016 11:50:06 AM CEST Philippe Proulx wrote:
> >> 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.

Thank you, that is exactly the example that I was looking for.

Cheers

-- 
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5903 bytes
Desc: not available
URL: <https://lists.lttng.org/pipermail/lttng-dev/attachments/20161005/f838498a/attachment-0001.bin>


More information about the lttng-dev mailing list