Bug #1213
closedCannot print trace under chroot
0%
Description
I want to use lttng under chroot, here is what I did:
- The root directory of chroot is / var / chroot.
- Install userspace-rcu-0.10.1-1.el7.x86_64.rpm, lttng-ust-2.10.3-1.el7.x86_64.rpm, lttng-tools-2.10.4-1.el7.x86_64.rpm And babeltrace-1.5.5-1.el7.x86_64.rpm to / var / chroot.
- Copy the corresponding dependent libraries to / var / chroot.
- mount --bind / dev / shm / var / chroot / dev / shm
This is fine at first, and can print the trace, but it won't work later, I don't know the reason. Here are the commands I executed under chroot:
lttng-sessiond --no-kernel --daemonize
lttng create
lttng enable-event -u sal _ *, sql *
lttng add-context --type = vpid --type = pthread_id -u
lttng start
lttng stop
lttng view
And I found that if lttng add-context --type = vpid --type = pthread_id -u is not executed, the trace can be printed.
I read the source code of lttng-ust, and printed some logs, and found that the problem was in the frontend_api.h: lib_ring_buffer_reserve function:
static inline
int lib_ring_buffer_reserve (const struct lttng_ust_lib_ring_buffer_config * config,
struct lttng_ust_lib_ring_buffer_ctx * ctx)
{
struct channel * chan = ctx-> chan;
struct lttng_ust_shm_handle * handle = ctx-> handle;
struct lttng_ust_lib_ring_buffer * buf;
unsigned long o_begin, o_end, o_old;
size_t before_hdr_pad = 0;
if (caa_unlikely (uatomic_read (& chan-> record_disabled)))
return -EAGAIN;
if (config-> alloc == RING_BUFFER_ALLOC_PER_CPU)
buf = shmp (handle, chan-> backend.buf [ctx-> cpu] .shmp);
else
buf = shmp (handle, chan-> backend.buf [0] .shmp);
if (caa_unlikely (! buf))
return -EIO;
if (caa_unlikely (uatomic_read (& buf-> record_disabled)))
return -EAGAIN;
ctx-> buf = buf;
...
I found that the function would return in if (caa_unlikely (! Buf)) and if (caa_unlikely (uatomic_read (& buf-> record_disabled))), resulting in the code that generates the trace cannot be reached, so the trace cannot be printed.
I researched for a while, but I couldn't find the reason, so I came here for help.
Files