1

I have to migrate some code to LTTng. We were using syslog-like tool and using printf-like format...

I have found several log lines printing pointers with %p but I do not know how to "translate" those lines into LTTng.

Any help will be really appreciated.

thamurath
  • 765
  • 8
  • 24

1 Answers1

1

If you're using LTTng 2.7+, your best bet is using tracelog(), a special API that was designed to ease the migration from logging to tracing.

You should be able to use %p with tracelog() since it uses the vsprintf() family of functions to format the recorded message.

If you already tread on the path to defining static tracepoints, I suggest using a CTF integer backed by a uintptr_t if your compiler supports C99, otherwise unsigned long long or perhaps size_t (which should be able to hold an address most of the time, although it's not guaranteed):

#include <stdint.h>

TRACEPOINT_EVENT(
    my_provider,
    my_memory_address,

    /* arguments (input) */
    TP_ARGS(
        const void *, address
    ),

    /* event fields (output)  */
    TP_FIELDS(
        ctf_integer_hex(uintptr_t, address, address)
    )
)

Then you can use it like this:

tracepoint(my_provider, my_memory_address, my_pointer);
eepp
  • 7,255
  • 1
  • 38
  • 56
  • Hi, sorry to add comment here, I just ask a question would you please check it: http://stackoverflow.com/questions/40698938/segmentation-fault-in-read-lttng-events-with-python – Saeid Nov 19 '16 at 23:26