[lttng-dev] LTTng-UST alternative to LD_PRELOAD

Lars lars at grandepotatis.se
Sun Jun 17 11:08:23 EDT 2012


I have recently started to use LTTng-UST and am using LD_PRELOAD
to make it possilbe to execute instrumented code on systems without
LTTng-UST installed.

To define LD_PRELOAD however affects too much. For instance all
forked processes also get the library loaded. This can be fixed by
removing the library from the LD_PRELOAD variable early in the main
function. This looks odd and required some explaining in comments.

Also, in my case, the instrumented program is started with a "wrapper"
program which I can not alter. This wrapper also gets the library

As an alternative to using LD_PRELOAD I would like to use an explicit
function, like;

  int traceload(char const* library_path);

that is called early in main (instead of the LD_PRELOAD environment
manipulation) and loads the library with dlopen if it exists.

I have already tried this (of course) and it almost works already.
The tracepoints becomes visible but I get no trace data written.
So I think a really small modification is needed.

Is anything like this planned?

Or can anybody give me a hint on what is missing?

I checked the mailing list a couple of months back but did not
find anything.

Best Regards,
Lars Ekman

More information about the lttng-dev mailing list