[lttng-dev] tracelog / tracef feature

Norbert Lange nolange79 at gmail.com
Wed May 19 07:19:27 EDT 2021


Hello,

I finally got some time digging into Lttng (using it on Xenomai, see
[1] for historic reference).

Since we have a hard realtime system, I chosen to use dynamic probes.
That means only
liblttng-ust-tracepoint.so wil get pulled into the process (it its
available), no threads are spawned, etc.
This is to minimize potential issues, without dealing with compiletime
selection/macros.

(Pre-)loading the tracepoint library will then pull in
liblttng-ust.so. So far so good,
but I found out that tracepoint/tracef are unusable currently.

First you need to link with liblttng-ust.so, then you have vasprintf
doing memory allocations.
I did a custom solution with dynamic loading.

# Outlined custom solution

The own binary gets a sourcefile similar to

```c
#define TRACEPOINT_DEFINE
#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
#include <lttng/lttng-ust-tracelog.h>
```

There is no need to add the definition to the own tracepoint library,
the binaries tracepoint library will depend on `liblttng-ust.so` and
the definitions
are pulled in if the tracepoint library is loaded.

There are a own namespaces variant of macros and wrapper functions

## Issues

Thats a short recap, easier to quote and address whether some upstream
solution is possible

### Use tracelog / tracef with dynamic probes

is there an easy solution for doing this?
is the solution of creating the stubs yourself valid?

### Allocations in the tracelog / tracef functions

Would you accept a change, where first some buffer on the stack and
vsnprintf is used,
only in case the buffer is to small a dynamic one will be allocated?

### No Include guards in lttng/lttng-ust-tracelog.h and lttng/lttng-ust-tracef.h

Some other issue is that `<lttng/lttng-ust-tracelog.h>` does not have
include guards
and including both the custom implementation and `<lttng/tracelog.h>` will
lead to duplicate definitions and compile errors.

Regards, Norbert

[1] - https://lists.lttng.org/pipermail/lttng-dev/2019-November/029410.html


More information about the lttng-dev mailing list