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

Kienan Stewart kstewart at efficios.com
Wed Oct 4 15:04:36 EDT 2023

Hi Chris,

On 2023-10-04 12:56, Christopher Harvey via lttng-dev wrote:
> 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:
> -----
> #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"
>      /* Tracepoint provider name */
>      my_provider,
>      /* Tracepoint name */
>      test,
>      /* Input arguments */
>          int, arg1
>      ),
>      /* Output event fields */
>          lttng_ust_field_integer(int, arg1, arg1)
>      )
> )
> #endif /* _TP_H */
> #include "lttng/tracepoint-event.h"
> --------
> and the cpp:
> -------
> #include "myLttngUstProvider.hpp"
> #include "lttng/ust-sigbus.h"
> ----
> 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'

I wasn't able to reproduce the compilation error you are seeing. Could 
you describe in more detail how you are compiling and linking your 
tracepoint provider and application?

> 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 the application is actually using liblttng-ust-ctl, then it would be 
normal to do the define. The header file explains that this is done to 
avoid unnecessarily pre-allocating space in the thread-local storage.

Traced applications typically don't link against liblttng-ust-ctl.

> 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.

Is your application actively running while you run `lttng list --userspace`?

`lttng list --userspace` will only list the userspace tracepoints of 
applications which are currently registered to the running session 
daemon. If an application disconnects, the tracepoints it registered are 

> 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


> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

More information about the lttng-dev mailing list