[lttng-dev] How to check is tracepoint is currently enabled (UST)

Dmitri Shubin sbn at tbricks.com
Sat Jun 28 05:15:07 EDT 2014


Hi Simon,

Thank you for reply!

On Wed, Jun 25, 2014 at 7:36 PM, Simon Marchi <simon.marchi at polymtl.ca>
wrote:

> I am pretty sure that Dmitri is talking about a check that you can use
> in your application, to see if a specific tracepoint is enabled. If
> some data that you pass to the tracepoint is expensive to compute, yo
> might want to avoid computing it when tracing is disabled.
>

Yes, exactly.
Here is nice explanation from dtrace author --
http://dtrace.org/blogs/ahl/2006/05/08/user-land-tracing-gets-better-and-better/
(see Is-Enabled probes)



> > #define tracepoint_enabled(provider, name)
> caa_unlikely(__tracepoint_##provider##___##name.state)
>
> Dmitri, that macro that you posted, does it work for you?
>

Yes, looks working AFAIKT.
I.e. if (tracepoint_enabled()) { printf(); } gives correct enabled/disabled
state.


Otherwise, you can simply embed the code in the call to tracepoint:
>

Thanks for suggestions!
Moving argument evaluation to function is a bit tedious.
Statement expressions looks nicer, but their portability is questionable
(although clang that we use seems to support them).

So from my point of view having tracepoint_enabled() macro is the best
possible solution.

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20140628/78ce578e/attachment.html>


More information about the lttng-dev mailing list