Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: Kienan Stewart via lttng-dev <lttng-dev@lists.lttng.org>
To: lttng-dev@lists.lttng.org, chris@cwharvey.ca
Subject: Re: [lttng-dev] What is DEFINE_LTTNG_UST_SIGBUS_STATE for and other beginner questions
Date: Wed, 4 Oct 2023 15:04:36 -0400	[thread overview]
Message-ID: <2795ad9b-acbd-460a-bfcb-61f0101180d4@efficios.com> (raw)
In-Reply-To: <0c1fcf2c-c061-4074-a20e-44b870fbeef5@app.fastmail.com>

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:
> -----
> #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'
> 

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.
https://github.com/lttng/lttng-ust/blob/master/include/lttng/ust-sigbus.h#L39

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

> 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

thanks,
kienan

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

  reply	other threads:[~2023-10-04 19:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04 16:56 Christopher Harvey via lttng-dev
2023-10-04 19:04 ` Kienan Stewart via lttng-dev [this message]
2023-10-04 23:12   ` Christopher Harvey via lttng-dev
2023-10-05 19:40     ` Christopher Harvey via lttng-dev
2023-10-05 19:59       ` Kienan Stewart via lttng-dev

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=2795ad9b-acbd-460a-bfcb-61f0101180d4@efficios.com \
    --to=lttng-dev@lists.lttng.org \
    --cc=chris@cwharvey.ca \
    --cc=kstewart@efficios.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