lttng

Events not traced with Dynamic loading


I'm using the sample C application supplied in the docs of lttng with identical files.

http://lttng.org/docs/#doc-tracing-your-own-user-application

i create my shared library as stated in the docs.

gcc -shared -W1,--no-as-needed -o hello-tp.so -llttng-ust hello-tp.o 

gcc -o hello hello.c hello-tp.o -ldl

hello-tp.so is created in the same folder as the application hello. So I run

LD_PRELOAD=./hello-tp.so ./hello and beyond

I check that the event is available

PID: 13120 - Name: ./hello
  ust_baddr_statedump:soinfo (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint)

and as expected it was loaded correctly.

I enable all events to be traced. I run my application and start tracing. I then stop and use 'lttng view' to see the trace.

But my trace file is empty.

Is there a reason that none of the events are being traced even though I have enabled it?

Thanks for any help.


Solution

  • I had to move #define TRACEPOINT_DEFINE #define TRACEPOINT_PROBE_DYNAMIC_LINKAGE #include "hello-tp.h" //the header file containing the event

    into my hello.c

    But didn't know i had to keep #define TRACEPOINT_CREATE_PROBES inside my hello-tp.c so when i linked against hello-tp.o it registered the event but never traced anything. And so the hello-tp.so wouldn't have worked. This resource helped me a bunch. https://github.com/giraldeau/lttng-ust/tree/master/doc/examples/demo