mustang51
mustang51

Reputation: 21

Can I query LTTNG if a given tracepoint with given args is going to be traced, before tracing it?

We need to adapt a huge number of existing traces, printf-like, to LTTNG. One of the issues we are foreseeing is that we will need a catch-all tracepoint with the format of args plus a char* string. We are trying to find a way to avoid having to compose the string before calling the LTTNG tracepoint. Is there any way to know beforehand if the tracepoint "will be traced" before passing it to the LTTNG library? Any method we can call to know if the trace is a match?

Thanks a lot!

P.S. We know that having this kind of tracepoint is a bad practice, but zillions of trace lines are flying above us.

Upvotes: 2

Views: 303

Answers (2)

Rama krishnan
Rama krishnan

Reputation: 11

Use tracepoint_enabled() and do_tracepoint() macros as following, code copied from man page:

if (tracepoint_enabled(ust_tests_hello, tptest)) {
    /* prepare arguments */
    do_tracepoint(ust_tests_hello, tptest, i, netint, values,
        text, strlen(text), dbl, flt);
}

Note: For this to work you need to have atleast LTTng-UST 2.7.0-rc1

Upvotes: 1

alexmonthy
alexmonthy

Reputation: 113

You could technically query the status of the tracing session through liblttng-ctl. However if your goal is to improve performance, I am not sure doing a lookup through this library every time you hit a tracepoint will be more efficient than a string formatting. You would have to benchmark it.

As a side note, if you are moving existing printf() calls to LTTng tracepoints, you may want to look at tracef(), which is basically a single-format-string tracepoint already defined by the tracer. There is also a slightly more advanced tracelog() function which will be introduced in LTTng 2.7.

Upvotes: 0

Related Questions