lttng-dev.lists.lttng.org archive mirror
 help / color / mirror / Atom feed
From: Norbert Lange via lttng-dev <lttng-dev@lists.lttng.org>
To: lttng-dev <lttng-dev@lists.lttng.org>
Subject: [lttng-dev] tracelog / tracef feature
Date: Wed, 19 May 2021 13:19:27 +0200	[thread overview]
Message-ID: <CADYdroO2NR71YoQ=-PSwa-Ej2LsvfqGNWMDiytPG7ADsUuuw7A@mail.gmail.com> (raw)

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
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

                 reply	other threads:[~2021-05-19 11:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADYdroO2NR71YoQ=-PSwa-Ej2LsvfqGNWMDiytPG7ADsUuuw7A@mail.gmail.com' \
    --to=lttng-dev@lists.lttng.org \
    --cc=nolange79@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).