[lttng-dev] Use LTTng in legacy codebase/variable arguments

Sudhagar Chinnaswamy sudhagar at gmail.com
Mon Dec 22 16:46:21 EST 2014


Hi:

I have the same need as discussed in the below mentioned thread. I want to
use LTTng, but most of the cases we need to log different parameters under
the same provider and event.

http://lists.lttng.org/pipermail/lttng-dev/2013-December/022134.html

When I tried a simple program to log the variable arguments under same
provider/event as suggested in the above thread using the macro below, I
found that the function "my_snprintf" is called "twice" when the logging
for the event is enabled for each tracepoint call. It seems inefficient to
call the same function twice. Is there something that could be done to make
it efficient or am I missing something?

— 8< —

#define tracepoint_for_format_string(provider, name, …) \

      do { \

            char msg_buf[MAX_BUFFER_SIZE]; \

            tracepoint(provider, name, my_snprintf(msg_buf,
MAX_BUFFER_SIZE, __VA_ARGS__)); \

      } while (0)

— 8< —

Alternatively, is there any other approach to achieve my requirement: Need
to use same provider & event name to log variable arguments?

For e.g.,
my_tracepoint(hello_world, test, "argc=%d, argv=%p", argc, argv);
my_tracepoint(hello_world, test, "argv[%u] :: %s", x, argv[x]);
my_tracepoint(hello_world, test, "Quitting now!");

Thanks in advance.

Regards,
Sudhagar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20141222/dd66988a/attachment.html>


More information about the lttng-dev mailing list