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);