[lttng-dev] What is DEFINE_LTTNG_UST_SIGBUS_STATE for and other beginner questions

Christopher Harvey chris at cwharvey.ca
Wed Oct 4 12:56:31 EDT 2023


Hi all,

I'm just getting started with lttng and have a couple of questions. My target is getting userspace tracepoints to work in a c++ application I control. I don't need kernel or system tracing. The target is running in a docker container I have control over as well. Running with --privileged is possible in my setup. I could run lttng inside the target container, outside on the host, or in another container on the same host. It's all the same to me. I don't know which setup is best, or if it even matters given that I don't need system or kernel traces.

I am using:
lttng-tools-2.13.11/      and       lttng-ust-2.13.6/
with userspace-rcu-0.14.0/

There is a slight version mismatch there, I just downloaded the "-lastest" from the links in the guide.

Here is my tracepoint provider header:
-----
#undef LTTNG_UST_TRACEPOINT_PROVIDER
#define LTTNG_UST_TRACEPOINT_PROVIDER my_provider

#undef LTTNG_UST_TRACEPOINT_INCLUDE
#define LTTNG_UST_TRACEPOINT_INCLUDE "./myLttngUstProvider.hpp"

#if !defined(_TP_H) || defined(LTTNG_UST_TRACEPOINT_HEADER_MULTI_READ)
#define _TP_H

#include "lttng/tracepoint.h"

LTTNG_UST_TRACEPOINT_EVENT(
    /* Tracepoint provider name */
    my_provider,

    /* Tracepoint name */
    test,

    /* Input arguments */
    LTTNG_UST_TP_ARGS(
        int, arg1
    ),

    /* Output event fields */
    LTTNG_UST_TP_FIELDS(
        lttng_ust_field_integer(int, arg1, arg1)
    )
)

#endif /* _TP_H */

#include "lttng/tracepoint-event.h"
--------

and the cpp:
-------
#define LTTNG_UST_TRACEPOINT_CREATE_PROBES
#define LTTNG_UST_TRACEPOINT_DEFINE

#include "myLttngUstProvider.hpp"
#include "lttng/ust-sigbus.h"

DEFINE_LTTNG_UST_SIGBUS_STATE();
----

I'm suspicious of a couple of things in my setup.

First, if I omit the DEFINE_LTTNG_UST_SIGBUS_STATE(); line, my program fails to compile with the following error:
liblttng-ust-ctl.so: undefined reference to `lttng_ust_sigbus_state'

The getting started guide doesn't say anything about needing DEFINE_LTTNG_UST_SIGBUS_STATE so it makes me wonder if I have done something else wrong somewhere else. I ran a find *.so | xargs nm -D | grep lttng_ust_sigbus_state and nothing in lttng-ust provides that symbol, so it looks like the target application has to define it. Is that normal?

If I leave DEFINE_LTTNG_UST_SIGBUS_STATE in then my program compiles. If I run lttng-sessiond in the target container, then run lttng list --userspace I see no tracepoints in the list.

I tried looking at the lttng source code but there is a lot there. I'm looking for some next steps for debugging this setup. What are some things I could check to make sure the lttng daemon is running properly? What is the mechanism for advertising tracepoints to the lttng daemon? Is it possible that docker has somehow interfered with the lttng ipc mechanism? It would be a tiny bit more convenient for me to simply deploy lttng-tools as a separate container, can I consider doing that instead? I'm not running anything as root, just a normal user.

I appreciate any and all guidance. Looking forward to using this neat looking tool.

-Chris


More information about the lttng-dev mailing list