lttng-tools.git
4 years agoTests: fd-tracker: fix: leak of test paths
Jérémie Galarneau [Fri, 31 Jan 2020 22:38:23 +0000 (17:38 -0500)] 
Tests: fd-tracker: fix: leak of test paths

Leak of memory or pointers to system resources (CWE-404)

Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id57254c990ee43dc6901c7778655830e0564e975

4 years agosession-descriptor: fix comment typos in session-descriptor.h
Simon Marchi [Fri, 31 Jan 2020 19:22:24 +0000 (14:22 -0500)] 
session-descriptor: fix comment typos in session-descriptor.h

Change-Id: Idafd16fd2851798a47bd95a7887f5bf9ba7828d0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: directory-handle: typo in equals method breaks compat build
Jérémie Galarneau [Fri, 31 Jan 2020 21:48:20 +0000 (16:48 -0500)] 
Fix: directory-handle: typo in equals method breaks compat build

The 'path' member does not exist in a directory handle; 'base_path'
should be used instead. This breaks the build on platforms that
lack dirfd support (e.g. Solaris 10).

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1cedf36520960c575b470d4306755dfeb9417cb4

4 years agoFix: potential use of uninitialized return value
Jérémie Galarneau [Fri, 31 Jan 2020 21:33:26 +0000 (16:33 -0500)] 
Fix: potential use of uninitialized return value

lttng_tracker_ids_serialize() can return an uninitialized value
when 0 ids are being tracked by a tracker. This is not currently
reachable, but generates a warning on some compilers.

'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia54f5276d6a89d39badfc6c718ad0032edb98ec8

4 years agoClean-up: remove instances of loop initial declarations
Jérémie Galarneau [Fri, 31 Jan 2020 21:25:14 +0000 (16:25 -0500)] 
Clean-up: remove instances of loop initial declarations

Loop initial declarations are not permitted by the project's
coding standard and cause the build to fail on Solaris platforms.

tracker.c: In function 'lttng_tracker_ids_serialize':
tracker.c:314:2: error: 'for' loop initial declarations are only allowed in C99 mode
  for (unsigned int i = 0; i < count; i++) {
  ^
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I627974ef82ca26586c96d354f217f9943db9d67c

4 years agoFix: relayd: register listener threads as rcu readers
Jérémie Galarneau [Fri, 31 Jan 2020 21:12:24 +0000 (16:12 -0500)] 
Fix: relayd: register listener threads as rcu readers

Both live and consumer listener threads are now RCU readers as
they use the fd_tracker which makes use of RCU.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8aab8615b8db1f1fea48deb1ae03ad5beeaa6f32

4 years agorelayd: track directory handles through the fd-tracker
Jérémie Galarneau [Thu, 30 Jan 2020 16:45:07 +0000 (11:45 -0500)] 
relayd: track directory handles through the fd-tracker

Track directory handles through the fd-tracker as unsuspendable
file descriptors. New fd-tracker utils are introduced to wrap
the creation and registration of the file descriptors to the
fd-tracker.

Note that file descriptors only need to be tracked when the
dirfd-backed implementation of the directory handles is used.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I754af1943f5d6f02a6219d48c8fc4b8106de1c13

4 years agotests: Move to kernel style SPDX license identifiers
Michael Jeanson [Thu, 7 Mar 2019 19:54:57 +0000 (14:54 -0500)] 
tests: Move to kernel style SPDX license identifiers

The SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

See https://spdx.org/ids-how for details.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I89cd4b4b7440f71f52426a5508252932bb46e796
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: include stdlib.h in compat/string.h
Simon Marchi [Wed, 15 Jan 2020 20:42:31 +0000 (15:42 -0500)] 
Fix: include stdlib.h in compat/string.h

Fixes:

  CC       uuid.lo
In file included from /home/smarchi/src/lttng-tools/src/common/uuid.c:19:0:
/home/smarchi/src/lttng-tools/src/common/compat/string.h: In function ‘lttng_strndup’:
/home/smarchi/src/lttng-tools/src/common/compat/string.h:78:8: error: implicit declaration of function ‘malloc’ [-Werror=implicit-function-declaration]
  ret = malloc(navail);
        ^~~~~~
/home/smarchi/src/lttng-tools/src/common/compat/string.h:78:8: error: incompatible implicit declaration of built-in function ‘malloc’ [-Werror]
/home/smarchi/src/lttng-tools/src/common/compat/string.h:78:8: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’

Note that this is in fallback code when the system doesn't provide
strndup (or, in my case, the system provides it but configure failed to
find it).

Change-Id: I5817b0b2436573b7d8fecb2956577a7b183d6296
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoCleanup: remove superfluous tests.txt
Michael Jeanson [Thu, 30 Jan 2020 21:12:35 +0000 (16:12 -0500)] 
Cleanup: remove superfluous tests.txt

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I0f9a505c5e9c22fbcebe534b9750d25645813174
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agofix: add include guards to compat/path.h
Michael Jeanson [Thu, 30 Jan 2020 23:33:57 +0000 (18:33 -0500)] 
fix: add include guards to compat/path.h

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: Ifb0672dcaf9b98715742546d71e54c5f4cd8dff6
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoMove to kernel style SPDX license identifiers
Michael Jeanson [Thu, 7 Mar 2019 19:53:45 +0000 (14:53 -0500)] 
Move to kernel style SPDX license identifiers

The SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

See https://spdx.org/ids-how for details.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I62e7038e191a061286abcef5550b58f5ee67149d
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoSync ax_have_epoll.m4 with autoconf-archive
Simon Marchi [Sun, 26 Jan 2020 22:21:33 +0000 (17:21 -0500)] 
Sync ax_have_epoll.m4 with autoconf-archive

This updates gets rid of an unused variable warning at configure time,
so removes one hurdle to configure with CFLAGS="-Werror".

Change-Id: I7adfed3f821409d7ea36c79e19e96b1977e32804
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years ago.gitignore: ignore gen-kernel-test-events
Jérémie Galarneau [Tue, 21 Jan 2020 23:27:53 +0000 (18:27 -0500)] 
.gitignore: ignore gen-kernel-test-events

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I668b8f9ed7066a1e10ec542773b7ab346d9c8710
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: lttng: sanity check of `--probe` description
Francis Deslauriers [Fri, 17 Jan 2020 20:09:21 +0000 (15:09 -0500)] 
Fix: lttng: sanity check of `--probe` description

Issue
=====
Run the following command:
  lttng enable-event -k --probe "\do_fork" my_do_fork_event
currently fails and that is expected.

But it does not fail for the right reason. In the `parse_probe_opts()`
function, during the last step of parsing the probe description we assume
it's a raw address and pass the string directly to the `strtoul()`
function. So if the probe description is not an address at all (e.g.
"\do_fork"), the `strtoul()` call will return 0 in the `addr` field of
the probe struct. This is then passed to the kernel tracer that asks the
kernel to instrument that address with a kprobe. This fails because 0x0
is not an address that can be instrumented.

Solution
========
Check that the first character of the tentative address is a digit
before trying to convert the string to an integer. This is not perfect
but at least it prevents some errors.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I444f0e7694098b1cdb56ecbf5d92be8974e406dc
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agolttng-view: make babeltrace2 the default viewer
Jérémie Galarneau [Thu, 30 Jan 2020 17:40:08 +0000 (12:40 -0500)] 
lttng-view: make babeltrace2 the default viewer

Use the `babeltrace2` binary to view traces by default rather than
the legacy `babeltrace`. As the install base of Babeltrace 2.x is
rather small at this point, silently fallback to Babeltrace 1.x
when it is not found on the system.

The man page is updated to reflect this change in behaviour.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie7cd7424f8af1e25238fcc4bb1aa3ee8226da023

4 years agolttng-view: clean-up: remove unneeded empty line
Jérémie Galarneau [Thu, 30 Jan 2020 17:12:45 +0000 (12:12 -0500)] 
lttng-view: clean-up: remove unneeded empty line

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I358abf4e41ac248a4c422772ebdfc4ffdc7fe196

4 years agolttng-view: clean-up: static struct viewers array should be const
Jérémie Galarneau [Thu, 30 Jan 2020 17:10:18 +0000 (12:10 -0500)] 
lttng-view: clean-up: static struct viewers array should be const

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I538bebf471eb15202908c27ab108e27f7f990103

4 years agolttng-view: clean-up: remove commented and unused references to lttv
Jérémie Galarneau [Thu, 30 Jan 2020 17:01:57 +0000 (12:01 -0500)] 
lttng-view: clean-up: remove commented and unused references to lttv

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I207c1a00c37b61bd7bd76a265e17e1e4bdf53d93

4 years agorelayd: register fd tracker instance to all created trace chunks
Jérémie Galarneau [Thu, 30 Jan 2020 06:51:10 +0000 (01:51 -0500)] 
relayd: register fd tracker instance to all created trace chunks

Provide a reference to 'the_fd_tracker' to trace chunks during their
creation. This causes file descriptors created through the relay
daemon's trace chunks to be tracked by the daemon's fd tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9c96851ef06bb7f0be0c7f3e8b7f01638f13fbda

4 years agorelayd: track relayd control connection sockets
Jérémie Galarneau [Thu, 28 Jun 2018 05:16:56 +0000 (01:16 -0400)] 
relayd: track relayd control connection sockets

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If5b0f85aac48bb04a08c95b76398b8f1b2ad98d8

4 years agorelayd: track relayd data connection sockets
Jérémie Galarneau [Thu, 28 Jun 2018 05:16:43 +0000 (01:16 -0400)] 
relayd: track relayd data connection sockets

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I510f2ca49995e56735408d14562cf1d45fef842e

4 years agorelayd: replace uses of block FDs by the fs_handle interface
Jérémie Galarneau [Thu, 30 Jan 2020 06:27:16 +0000 (01:27 -0500)] 
relayd: replace uses of block FDs by the fs_handle interface

Replace all usage of "raw" block-device file descriptors for
relay_streams, viewer_streams, and index files by the fs_handle.

Wrappers are introduced for read, write, seek and truncate operations
in order to reduce code duplication as all uses of fs_handles implies
getting an fd, using it, and putting it back. Those operations allow
the fd-tracker to suspend and restore fs_handles as needed.

The stream_fd util is eliminated as it is completely replaced by
the fs_handle interface.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iedff88d27aeba3891d4e8818b9e08e4b16a927cc

4 years agofd-tracker: restore suspended handles from their inode's path
Jérémie Galarneau [Wed, 29 Jan 2020 04:53:49 +0000 (23:53 -0500)] 
fd-tracker: restore suspended handles from their inode's path

In order to support session rotations and, to a lesser degree, the
"clear" command, the fd-tracker internals (lttng_inode and fs_handle)
need to recover from files being renamed while the handle to it is
suspended.

This refactor introduces a "location" to the lttng_inode which is
updated anytime an unlink or rename is performed on an fs_handle.
Keep in mind that multiple independent fs_handles can refer to the
same lttng_inode (a unique tuple of device id and inode number).

This location is used to restore the fs_handle whenever it is needed.

Moreover, since the session rotation/clear operations sometimes rely
on directories having been emptied after rename/unlink, the current
scheme of renaming unlinked files to the form
"filename-deleted-suffix" no longer works.

The renaming scheme is replaced by a new "unlinked file pool", which
is an hidden directory at the base of the output directory which
contains the files which were unlinked to which
references (fs_handles) are still being held. The API of the
fd-tracker itself had to be changed slightly and the tests are adapted
as a consequence. New tests targeting this new behaviour are also
added.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9b1344da1966c85bdd6b51838507d3208e1d9a42

4 years agodirectory-handle: query if instance is backed by a file descriptor
Jérémie Galarneau [Wed, 29 Jan 2020 04:39:01 +0000 (23:39 -0500)] 
directory-handle: query if instance is backed by a file descriptor

Allow a user of a directory handle to know if a given instance is
backed by a file descriptor. This is needed to ensure the fd-tracker
can accurately track the number of file descriptors in use at a given
moment.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I64aeeae2623a35ed07964432bb18b16aeeeb89ec

4 years agodirectory-handle: make lttng_directory_handle_stat public
Jérémie Galarneau [Wed, 29 Jan 2020 04:37:49 +0000 (23:37 -0500)] 
directory-handle: make lttng_directory_handle_stat public

Allow users of the directory handle API to perform stat() calls
relative to a directory handle (through statat() or stat(), depending
on the implementation).

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4415da6d719999ad051678d0defd9e3edf93c19a

4 years agofd-tracker: replace custom optional implementation by LTTNG_OPTIONAL
Jérémie Galarneau [Thu, 23 Jan 2020 22:10:32 +0000 (17:10 -0500)] 
fd-tracker: replace custom optional implementation by LTTNG_OPTIONAL

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id38724f701ee8aca8f0fecf231d8d4027f0bd885

4 years agodirectory-handle: add an equals method
Jérémie Galarneau [Thu, 23 Jan 2020 22:09:13 +0000 (17:09 -0500)] 
directory-handle: add an equals method

Add an "equals" method to both implementations of directory-handle.
The "directory fd" implementation uses the underlying inode of
the directory to perform comparisons.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9c97f75ea6a79168d772268fca490aee7c333ae2

4 years agotrace chunk: allow associating an fd_tracker to a trace chunk
Jérémie Galarneau [Fri, 20 Dec 2019 04:49:28 +0000 (23:49 -0500)] 
trace chunk: allow associating an fd_tracker to a trace chunk

Introduce lttng_trace_chunk_set_fd_tracker() which may be used
to associate an fd-tracker to a trace chunk instance. An fd-tracker
must be set before any directory handle or files are created
through the trace chunk.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5b3302e26ace2babadba286ca8bd4a016014bdd8

4 years agofd-tracker: refactor: extract fs_handle interface from fd_tracker
Jérémie Galarneau [Tue, 21 Jan 2020 00:44:07 +0000 (19:44 -0500)] 
fd-tracker: refactor: extract fs_handle interface from fd_tracker

Make the fs_handle interface a proper abstract interface containing
overridable callbacks. The objective of this refactor is to make it
possible for lttng_trace_chunk to return fs_handles which are tracked
by an fd_tracker (or not) depending on the execution context (which
daemon).

In effect, the relay daemon will provide a trace chunk with an
fd_tracker to use and then rely on the fs_handle interface to track
the use of file descriptors.

The other daemons using the lttng_trace_chunk interface will use a
dummy implementation of fs_handle which basically directly returns the
underlying file descriptor and performs the unlink/close operations
directly.

This makes is possible to share code interacting with files between
the various daemons without carrying a plethora of optional parameters
in every util.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iaafa0f4442442bdfdaf220ce33a966978877df23

4 years agofd-tracker: remove use of VLA for unsuspendable_fd APIs
Jérémie Galarneau [Wed, 15 Jan 2020 23:41:34 +0000 (18:41 -0500)] 
fd-tracker: remove use of VLA for unsuspendable_fd APIs

fd_tracker_open_unsuspendable_fd() and
fd_tracker_close_unsuspendable_fd() make use of variable-length arrays
to track unsuspendable entries to open/close. These uses of VLA can
easily be replaced by using dynamic allocations. This is not expected
to cause any performance problem as it is used in slow paths.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4d4e95e23eb6df9a66663ecabad40162c321525b

4 years agorelayd: share the same output directory handle accross sessions
Jérémie Galarneau [Fri, 20 Dec 2019 06:41:37 +0000 (01:41 -0500)] 
relayd: share the same output directory handle accross sessions

Now that lttng_directory_handles are reference counted, they can be
shared by multiple sessions and trace chunks.  These modifications
cause sessions that share a trace chunk to share their session output
directory handle.

Moreover, the session output directory handle is now created on
session creation. Hence, a directory handle (fd) is not created
everytime a trace chunk is created.

The goal of this modification is to make it easier to track file
descriptors in the relay daemon, but it is also more efficient
overall (less opening of file descriptors) and will error-out during
the creation of a session rather than a trace chunk which is handled
more gracefully accross the toolchain.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I47e46ee253db646da1490380612def741c2f4102

4 years agoFix: relayd: fail to create session when trace chunk is not found
Jérémie Galarneau [Fri, 20 Dec 2019 05:59:56 +0000 (00:59 -0500)] 
Fix: relayd: fail to create session when trace chunk is not found

When a session is created by a peer with a trace chunk id already
set, it means that the session daemon has already created that
trace chunk at some point in the past. Hence, it should be found
in the sessiond trace chunk registry.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8c6d19371d322cf7079d7a01c4c24b585b4b3ea1

4 years agorelayd: track the health unix socket with the fd-tracker
Jérémie Galarneau [Wed, 27 Nov 2019 06:37:41 +0000 (01:37 -0500)] 
relayd: track the health unix socket with the fd-tracker

Open the health thread's unix socket through the fd-tracker to
track it as an unsuspendable file descriptor.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9638a91f8632063ac854489927fae1681723283f

4 years agorelayd: track the health thread's poll fd with fd-tracker
Jérémie Galarneau [Wed, 27 Nov 2019 06:36:34 +0000 (01:36 -0500)] 
relayd: track the health thread's poll fd with fd-tracker

Create the health thread's lttng_poll_event structure through
the fd-tracker to track the resulting file descriptor for
builds configured to use the epoll interface.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I81ba9cbe69d885dbdade03e581a4d69572de50eb

4 years agoLTTNG-RELAYD(8): document the --fd-pool-size option
Jérémie Galarneau [Thu, 5 Jul 2018 01:28:18 +0000 (21:28 -0400)] 
LTTNG-RELAYD(8): document the --fd-pool-size option

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie8d791d15ba4186dc862d048d20afff7d128cea3

4 years agorelayd: rename fd-cap parameter to fd-pool-size
Jérémie Galarneau [Wed, 27 Nov 2019 06:11:02 +0000 (01:11 -0500)] 
relayd: rename fd-cap parameter to fd-pool-size

Rename the fd-cap parameter and change its default behaviour.
The minimum number of file descriptor is raised to 100 and a
"reserve" amount of 10 fds is allowed to accomodate transient
fd uses that can't be tracked by the relay daemon.

The --fd-pool-size will accept parameters in the
[100, fileno soft limit] interval.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9c7bf344344901b4d6f0d95620210ebda5fd0196

4 years agorelayd: track the live client connections socket
Jérémie Galarneau [Wed, 27 Nov 2019 06:01:28 +0000 (01:01 -0500)] 
relayd: track the live client connections socket

Track all live client connection socket file descritptors through the
fd-tracker. Those file descriptors, being TCP connections, are
unsuspendable.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iacc958b0f8d168d13165e44ec8432ad29ef881f5

4 years agorelayd: track the control and data listener socket
Jérémie Galarneau [Wed, 27 Nov 2019 05:57:08 +0000 (00:57 -0500)] 
relayd: track the control and data listener socket

Create the control and data listener sockets through the create_sock()
wrapper in order to allow the fd tracker to track it as an
unsuspendable file descriptor.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I58e66386c195b78a44d88d3592d7b1d75ff091a3

4 years agorelayd: track the live listener socket
Jérémie Galarneau [Wed, 27 Nov 2019 05:42:00 +0000 (00:42 -0500)] 
relayd: track the live listener socket

Create the live listener socket through the create_sock()
wrapper in order to allow the fd tracker to track it as an
unsuspendable file descriptor.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I12c831967b0b33aa3d58c2319cdaf0dc3ccda7e3

4 years agorelayd: track stdio output file descriptors
Jérémie Galarneau [Wed, 27 Nov 2019 05:32:24 +0000 (00:32 -0500)] 
relayd: track stdio output file descriptors

Track the stdout and stderr file descriptors through the fd
tracker. These file descriptors are considered unsuspendable
since they can't be re-opened.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibd80fb1ba1b21ee152bae6047a5dd176d1d2c051

4 years agorelayd: track the live viewer worker thread's epoll fd
Jérémie Galarneau [Wed, 27 Nov 2019 05:30:24 +0000 (00:30 -0500)] 
relayd: track the live viewer worker thread's epoll fd

Create the live worker threads' epoll fd through the
fd_tracker_util_poll_create() util. This causes the resulting fd
(in epoll mode) to be tracked by the fd tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I60b386b90e274283c566d94cfd4abcf57e0c1985

4 years agorelayd: track the live listener thread's epoll fd
Jérémie Galarneau [Wed, 27 Nov 2019 05:28:51 +0000 (00:28 -0500)] 
relayd: track the live listener thread's epoll fd

Create the live listener threads' epoll fd through the
fd_tracker_util_poll_create() util. This causes the resulting fd
(in epoll mode) to be tracked by the fd tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If93fe5b1cc85d5d3950941edd47910697727ced9

4 years agorelayd: track the live_conn_pipe with the fd-tracker
Jérémie Galarneau [Wed, 27 Nov 2019 05:23:15 +0000 (00:23 -0500)] 
relayd: track the live_conn_pipe with the fd-tracker

Create the relayd live connection pipe through the
fd_tracker_util_pipe_open_cloexec() function which wraps
utils_create_pipe_cloexec(), but tracks the resulting file descriptor.

The close of the pipe is also performed through the fd tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I967c2fbecfb5dacfb8c41cad113604bad78dad65

4 years agorelayd: track listener's epoll fd using the fd-tracker
Jérémie Galarneau [Tue, 26 Nov 2019 23:22:29 +0000 (18:22 -0500)] 
relayd: track listener's epoll fd using the fd-tracker

This addresses the bogus fd report mentionned in a previous patch of
this series as the clean-up of the listener thread's epoll fd now
occurs through the fd-tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I56bdc7f0f7c43993e44bcfc220bc09af561ace56

4 years agorelayd: track worker thread's epoll fd using the fd-tracker
Jérémie Galarneau [Tue, 26 Nov 2019 23:14:57 +0000 (18:14 -0500)] 
relayd: track worker thread's epoll fd using the fd-tracker

This commit introduces an fd leak report (bogus) which is caused
by another thread using the same poll initialization functions as
the worker thread.

The fd is cleaned-up by that other thread, but the fd-tracker
is not aware of this, thus causing the report.

This is adressed in a follow-up patch.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I105fddcf3421373f9746c1d8f31016462af2448e

4 years agorelayd: track clients of the health unix socket with the fd-tracker
Jérémie Galarneau [Tue, 26 Nov 2019 23:20:35 +0000 (18:20 -0500)] 
relayd: track clients of the health unix socket with the fd-tracker

accept connections to the health unix socket through a new fd-tracker
wrapper, accept_unix_socket, which allows the fd-tracker to track the
newly-created file descriptor.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3d58b7fab15451cae404b13fd5d4b23a7c79988a

4 years agorelayd: track the health quit pipe with the fd-tracker
Jérémie Galarneau [Tue, 26 Nov 2019 22:10:02 +0000 (17:10 -0500)] 
relayd: track the health quit pipe with the fd-tracker

Create the relayd health thread quit pipe through the
fd_tracker_util_pipe_open_cloexec() function which wraps
utils_create_pipe_cloexec(), but tracks the resulting file descriptor.

The close of the pipe is also performed through the fd tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib82eabc0f152a706ac76a5042af2e3984d7e7f72

4 years agorelayd: track the relay_conn_pipe with the fd-tracker
Jérémie Galarneau [Tue, 26 Nov 2019 22:07:41 +0000 (17:07 -0500)] 
relayd: track the relay_conn_pipe with the fd-tracker

Create the relayd connection pipe through the
fd_tracker_util_pipe_open_cloexec() function which wraps
utils_create_pipe_cloexec(), but tracks the resulting file descriptor.

The close of the pipe is also performed through the fd tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6ed0d64c973a454de2e50c7cae006fd546299290

4 years agorelayd: track the quit pipe with the fd-tracker
Jérémie Galarneau [Tue, 26 Nov 2019 22:08:52 +0000 (17:08 -0500)] 
relayd: track the quit pipe with the fd-tracker

Create the relayd quit pipe through the
fd_tracker_util_pipe_open_cloexec() function which wraps
utils_create_pipe_cloexec(), but tracks the resulting file descriptor.

The close of the pipe is also performed through the fd tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia2a000030765e8df990e0ea3d35a8bf157630d9f

4 years agorelayd: Don't bypass the fd tracker when closing file descriptors
Jérémie Galarneau [Tue, 26 Nov 2019 20:41:26 +0000 (15:41 -0500)] 
relayd: Don't bypass the fd tracker when closing file descriptors

There is no reason to close all file descriptors at this point in the
relay daemon as we know for a fact that the only open fds are stdout
and stderr. If the relayd was to depend on a library that opens other
file descriptors, it would be unadvisable to perform this kind of bulk
closing of all possible file descriptors.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8ff134094b16dfb6c1aeb875431fdbd4f608eebd

4 years agorelayd: initialize the global fd tracker from fd_cap option
Jérémie Galarneau [Tue, 26 Nov 2019 20:15:33 +0000 (15:15 -0500)] 
relayd: initialize the global fd tracker from fd_cap option

Initialize the relay daemon's global fd tracker from the current
fd-cap configuration. This is in preparation for follow-up patches
which will introduce the tracking of the various file descriptor
backed resources to the relay daemon.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iaabb80f1fb4d24345b750503c90388f94025159d

4 years agorelayd: clean-up: reduce the number of exit paths in main()
Jérémie Galarneau [Wed, 27 Nov 2019 18:20:32 +0000 (13:20 -0500)] 
relayd: clean-up: reduce the number of exit paths in main()

The relay daemons's initialization and teardown relies on a large
number of goto/labels to clean-up on failure to launch.

All of the clean-up can be performed unconditionally by checking for
NULL or uninitialized file descriptors in relayd_cleanup(). This
reduces the number of possible tear-down paths and partly initialized
state to keep track of.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3195caf05b3dd04cc7e9c60dcb322261159fe0df

4 years agorelayd: add fd-cap option to limit the number of opened FDs
Jérémie Galarneau [Tue, 26 Nov 2019 20:08:01 +0000 (15:08 -0500)] 
relayd: add fd-cap option to limit the number of opened FDs

Add an --fd-cap option to the relay daemon in order to allow the
launch of the relay daemon with a maximal number of file descriptors
to be open at any given moment.

When the value of the --fd-cap parameter is left unset, the maximal
number of file descriptors is set to the system's NOFILE soft limit
(see GETRLIMIT(3P)).

A minimal number of file descriptors of 30 is imposed, mainly to
prevent absurd configurations (someone setting 1 fd) which would not
even allow one target to connect and stream traces. This also allows
a bit of leverage to open file descriptors that could be needed by
future changes without "breaking" an existing configuration.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibaf49b25ccf3e3a8013115c9478744ca3646e306

4 years agoFix: use lttng_tracker_id_status enum values
Jonathan Rajotte [Tue, 21 Jan 2020 19:23:07 +0000 (14:23 -0500)] 
Fix: use lttng_tracker_id_status enum values

This is probably a copy paste error. This should not be a problem in any
case since the final values for both enums are the same.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Ia1dc173a4eae8b7d9bff35a718c93331b714f5d6
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: update context types for Python bindings
Christophe Bedard [Sat, 18 Jan 2020 19:29:49 +0000 (14:29 -0500)] 
Fix: update context types for Python bindings

Fixes: #1214
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: lttng: placing probe on symbol starting with `_`
Francis Deslauriers [Fri, 17 Jan 2020 17:45:51 +0000 (12:45 -0500)] 
Fix: lttng: placing probe on symbol starting with `_`

Issue
=====
The lttng CLI tool does not parse `--probe` symbol name properly if the
name has an underscore at the beginning.
For example, the following command fails
  lttng enable-event -k --probe _do_fork my_do_fork_event

This happens because the `parse_probe_opts()` function looks if the
first character of the symbol field is an alphabetic character to
determine if a symbol was provided. The problem is that some kernel
symbols such as `_do_fork` start with an underscore.

Solution
========
check if the first character is an alphabetic character OR an
underscore.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I3ee6c26641ceee508ee78e895d372c6b09fe90fb
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: build failure with -fno-common
Michael Jeanson [Thu, 16 Jan 2020 19:34:47 +0000 (14:34 -0500)] 
Fix: build failure with -fno-common

GCC 10 will default to building with -fno-common, this inhibits the
linker from merging multiple tentative definitions of a symbol in an
archive.

I'm not sure I understand what happen with the symbols in mi-lttng.h
but a similar issue was adressed in:

  commit 4965f956f3ef47388fb4a1b2f8f504abfe31afe7
  Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
  Date:   Fri May 22 12:53:30 2015 -0400

    Fix: Mark MI and Config string declarations as extern

    This fixes a build issue with GCC 5.1 which would complain about
    these symbols being defined multiple times.

Make sure these symbols are extern and defined only in one compile unit.

For more information, see:
https://gcc.gnu.org/gcc-10/porting_to.html

Change-Id: I139c9695371836cb1011f9ce192080b602ed2fbc
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: Tests: missing stream redirect causes test failure
Francis Deslauriers [Thu, 16 Jan 2020 01:52:39 +0000 (20:52 -0500)] 
Fix: Tests: missing stream redirect causes test failure

The following commit enforced the use of options (instead of arguments)
in the `gen-ust-events` test application:
  commit 6c4a91d639747f260ab46decebc50998ef063712
  Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  Date:   Mon Aug 26 14:22:06 2019 -0400

      tests: gen-ust-events: use options instead of arguments

This makes tests exit (and abort since commit 56d4838) when arguments
are passed to the test application. It currently fails with the
following error:
  ./gen-ust-events -i 32 -w 21 \
    --sync-after-first-event /tmp/allo.hi \
    --sync-before-last-event /tmp/allo.bye /dev/null
  Error: takes long options only.
  zsh: abort (core dumped)  ./gen-ust-events -i 32 -w 21 --sync-after-first-event /tmp/allo.hi

The `/dev/null` at the end of the command line is not associated with an
option so it triggers the sanity check. The `/dev/null` most probably
meant to redirect STDOUT to `/dev/null`.

This commit adds the missing `>` so to overcome the sanity check
problem.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I3e4d4066079055a542438a63ef4df5c5c4c080cf
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: automatic enum value overwrites existing error code value
Jonathan Rajotte [Mon, 13 Jan 2020 20:40:15 +0000 (15:40 -0500)] 
Fix: automatic enum value overwrites existing error code value

Automatic enum value are generated using the last value and
incrementing it. Having backward compat assignation before the
LTTNG_ERR_NR would end up overwriting the error string since the
LTTNG_ERR_NR value would be LTTNG_ERR_PID_NOT_TRACKED + 1.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I4076866a28961fa49eed018e8249d2cd72979a84
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agodoc: Fix bind address example for lttng-relayd
Benjamin Poirier [Mon, 6 Jan 2020 05:19:54 +0000 (14:19 +0900)] 
doc: Fix bind address example for lttng-relayd

INADDR_ANY is 0.0.0.0

Fixes: c93eadade277 ("doc/man: use propagated default values in man pages")
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Benjamin Poirier <benjamin.poirier@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6e908adca66b829128ea31cf392bccad3f96d63d

4 years agoBuild fix: dist target builds fails due to missing header file
Jérémie Galarneau [Wed, 15 Jan 2020 00:33:21 +0000 (19:33 -0500)] 
Build fix: dist target builds fails due to missing header file

The path.h compatibility header is not distributed, causing builds
from tarballs to fail. Add it to the SOURCES variable.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib112c6016e9e682545572b8ab01728996c41ed52

4 years agoFix: track-untrack.c: regression of `--all --pid` option ordering
Francis Deslauriers [Tue, 7 Jan 2020 20:34:07 +0000 (15:34 -0500)] 
Fix: track-untrack.c: regression of `--all --pid` option ordering

Background
==========
The `tests/regression/kernel/test_callstack` test uses the PID tracker
to restrict what events end up in the trace. It does that by using the
following lttng command:
  lttng untrack -s $SESSION_NAME --all --pid -k

Issue
=====
A regression was introduced along with the UID tracker patch series that
makes the above command fail silently and return status 1. The bug is in
the argument parsing function that assumes that the tracker option
(`--pid` in this case) would appear before the `--all` option.

Where the above command fails, the one below works as expected:
  lttng untrack -s $SESSION_NAME --pid --all -k

Both ordering are valid and should be accepted.

Fix
===
When parsing the arguments, first record the fact that we encountered the
`--all` flag, and later check to what tracker it applies too.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I85f7a2fa8d6f67056aeff8edf3d12508f5ae0879
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agotrack-untrack.c: error out on unknown CLI options
Francis Deslauriers [Tue, 7 Jan 2020 23:09:46 +0000 (18:09 -0500)] 
track-untrack.c: error out on unknown CLI options

Issue
=====
At the moment, it's possible to have unknown options in the `track` and
`untrack` commands. They are silently ignored.

For example, the following command line is accepted without problem:
  lttng untrack HELLO -k --all --pid

This was witnessed in the `test_event_tracker` tests. The
`lttng_track()` and `lttng_untrack() functions in `tests/utils/util.sh`
are currently passing the `$1` bash variable of the function to the
`track` and `untrack` througth their "$@" variable.

The commands should not silently accept those unknown options.

Fix
===
1. After looping on all the known options, check if there is any leftover
  options and error out if it's the case.
2. Fix the `utils.sh` functions to that they don't pass the `$1` variable
  to the commands.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I822ba09c8ce1ffa8366c586e760a9257e8078e43
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoAdd test_event_tracker to the TESTS variable
Jérémie Galarneau [Tue, 14 Jan 2020 23:55:41 +0000 (18:55 -0500)] 
Add test_event_tracker to the TESTS variable

test_event_tracker is not run on `make check`. Adding it to the
TESTS variable so that it is picked-up by the TAP runner.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id6dda47ee96e6123b326edb5262e941a41cd591e

4 years agoAdd missing `test_event_tracker` to fast_regression
Francis Deslauriers [Tue, 7 Jan 2020 23:39:52 +0000 (18:39 -0500)] 
Add missing `test_event_tracker` to fast_regression

Those tests currently don't run on the CI because they aren't in any of
the `*_regression` files. This commit fixes that.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I9dfb87cc7b863c678ebc6419d6a39b7b964273d5
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoCleanup: track-untrack.c: declare all `int` on the same line
Francis Deslauriers [Tue, 7 Jan 2020 20:29:26 +0000 (15:29 -0500)] 
Cleanup: track-untrack.c: declare all `int` on the same line

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ic566fe9f33d67f7da750c478c6af0b41ec2a968b
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: relayd: hostname check is too restrictive
Jérémie Galarneau [Tue, 14 Jan 2020 22:08:13 +0000 (17:08 -0500)] 
Fix: relayd: hostname check is too restrictive

The check performed by the relay daemon on hostnames is too
restrictive. Since existing session daemons directly use the hostname
returned by gethostname(), the relay daemon must correctly handle FQDN
hostnames, which may contain dots.

This has been observed on the LTTng CI's RHEL8 nodes which report an
FQDN hostname.

The new function 'is_name_path_safe' is used for both session and host
names. It does not check for every problematic path names (reserved
names on Windows, per-platform illegal characters, etc.) Those
restrictions are assumed to be handled when open() and similar
syscalls fail.

However, the objective of this check is to prevent malicious (or at
least unexpected), but legal, names from being used, namely:
  - names that contain a path separator,
  - empty names,
  - hidden names (starting with a dot).

Ideally, illegal names would be automatically escaped in the future.
This is, however, beyond the scope of this fix.

Fixes #1212

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ieeb8b60d22c27b390b51ef7fb52cea0d0ac0f188

4 years agoCleanup: remove extra whitespace from include directive
Jérémie Galarneau [Tue, 14 Jan 2020 21:51:47 +0000 (16:51 -0500)] 
Cleanup: remove extra whitespace from include directive

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic91f07131aced6857ddbcef46f85c3cc3119f98f

4 years agoFix: skip start trace for app that are already started.
Jonathan Rajotte [Mon, 6 Jan 2020 16:46:21 +0000 (11:46 -0500)] 
Fix: skip start trace for app that are already started.

When using trackers, call to ust_app_global_update
results in a call to ust_app_start_trace even if the ust app
trace was already enabled.

This resulted in error message from the app (-1024) complaining that the
tracing was already active on the app side.

  Error: Error starting tracing for app pid: 329376 (ret: -1024)
  ok 211 - Track command with opts: 0 -u --vpid 329376

A solution to this is to keep the enabled state inside the ua_sess and
skip the start trace if already enabled.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Ie4198245627e9f0426948489bc9ce24d8c813b08
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: keep active session state on redundant start command
Jonathan Rajotte [Mon, 6 Jan 2020 18:26:54 +0000 (13:26 -0500)] 
Fix: keep active session state on redundant start command

Steps to reproduce problem:
  lttng create
  lttng enable-event -u -a
  lttng start
  lttng start
  lttng stop

Yield:

  Session auto-20200106-134455 created.
  Traces will be output to /home/joraj/lttng-traces/auto-20200106-134455
  All UST events are enabled in channel channel0
  Tracing started for session auto-20200106-134455
  Warning: Tracing already started for session auto-20200106-134455
  Warning: Tracing already stopped for session auto-20200106-134455

The "warning" on the "lttng stop" command is invalid.

This was introduced by commit

1f4962443 Fix: sessiond: no rotation performed from null chunk to new chunk

For cases where the session is already active, simply skip all the way to
the end without passing via the error handling path.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Iaf26090191d3eb940fa419848df8911758e0a6e3
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: build failures when `--without-lttng-ust`
Francis Deslauriers [Fri, 10 Jan 2020 00:34:16 +0000 (19:34 -0500)] 
Fix: build failures when `--without-lttng-ust`

The `--without-lttng-ust` configure option makes the build to fail due
to 2 bugs
1. Missing object file for session unit tests causes the following errors:
    CCLD     test_session
  ../../src/bin/lttng-sessiond/kernel.o: In function `kernel_track_id':
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:712: undefined reference to `lttng_tracker_id_lookup_string'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:723: undefined reference to `lttng_tracker_id_get_list'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:729: undefined reference to `lttng_tracker_list_add'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:810: undefined reference to `lttng_tracker_id_set_list'
  ../../src/bin/lttng-sessiond/kernel.o: In function `kernel_untrack_id':
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:826: undefined reference to `lttng_tracker_id_lookup_string'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:836: undefined reference to `lttng_tracker_id_get_list'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:841: undefined reference to `lttng_tracker_list_remove'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:925: undefined reference to `lttng_tracker_id_set_list'
  ../../src/bin/lttng-sessiond/kernel.o: In function `kernel_list_tracker_ids':
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:949: undefined reference to `lttng_tracker_id_get_list'
  ../../src/bin/lttng-sessiond/trace-kernel.o: In function `trace_kernel_create_session':
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:167: undefined reference to `lttng_tracker_list_create'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:171: undefined reference to `lttng_tracker_list_create'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:175: undefined reference to `lttng_tracker_list_create'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:179: undefined reference to `lttng_tracker_list_create'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:183: undefined reference to `lttng_tracker_list_create'
  ../../src/bin/lttng-sessiond/trace-kernel.o:/home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:187: more undefined references to `lttng_tracker_list_create' follow
  ../../src/bin/lttng-sessiond/trace-kernel.o: In function `trace_kernel_create_session':
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:199: undefined reference to `lttng_tracker_list_destroy'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:200: undefined reference to `lttng_tracker_list_destroy'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:201: undefined reference to `lttng_tracker_list_destroy'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:202: undefined reference to `lttng_tracker_list_destroy'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:203: undefined reference to `lttng_tracker_list_destroy'
  ../../src/bin/lttng-sessiond/trace-kernel.o:/home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:204: more undefined references to `lttng_tracker_list_destroy' follow
  collect2: error: ld returned 1 exit status
  Makefile:1062: recipe for target 'test_session' failed
  make[1]: *** [test_session] Error 1
  make[1]: Leaving directory '/home/frdeso/projets/lttng/tools/tests/unit'
  Makefile:1166: recipe for target 'all-recursive' failed
  make: *** [all-recursive] Error 1

2. An extra colon at the end of the `trace_ust_track_id()` stub
function gives this error:
    CC       utils.o
  In file included from ust-app.h:26:0,
                   from lttng-sessiond.h:31,
                   from utils.c:27:
  trace-ust.h:339:1: error: expected identifier or '(' before '{' token
   {
   ^
  trace-ust.h:336:19: warning: 'trace_ust_track_id' declared 'static' but never defined [-Wunused-function]
   static inline int trace_ust_track_id(enum lttng_tracker_type tracker_type,
                     ^~~~~~~~~~~~~~~~~~
  Makefile:729: recipe for target 'utils.o' failed

Both bugs are trivial to fix.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I66c57d206ad0142db057443374d28bbcf16c02f7
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoSync lttng-ust ABI version in ust-abi-internal.h
Jérémie Galarneau [Fri, 20 Dec 2019 21:26:17 +0000 (16:26 -0500)] 
Sync lttng-ust ABI version in ust-abi-internal.h

Bump LTTNG_UST_ABI_MINOR_VERSION to 1

Increment the minor version of lttng-ust ABI to 1, to take into
account that the "clear" command was added in this release cycle.

This will allow future LTTng-tools versions to check for this
capability.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I472eb11589547a9fa119d061a2c1886371b87f69

4 years agoSync lttng-modules ABI version in internal kernel-ioctl.h
Jérémie Galarneau [Fri, 20 Dec 2019 20:55:27 +0000 (15:55 -0500)] 
Sync lttng-modules ABI version in internal kernel-ioctl.h

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I67eafac24bc8db62831b6bc72497c706ff383a07

4 years agoFix: lttng-clear: invalid free of session name
Jérémie Galarneau [Fri, 20 Dec 2019 06:39:17 +0000 (01:39 -0500)] 
Fix: lttng-clear: invalid free of session name

Valgrind reports an invalid free of session_name when it is sourced
from the popt args. Only free it when it comes from the .lttngrc file.

This also caused spurious core dumps when running the tests on
one of my machines.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I194cd36147a1028aad503b4e5d3ea23732a30bc5

4 years agoFix: initialize var_data to NULL
Jonathan Rajotte [Wed, 20 Nov 2019 21:14:39 +0000 (16:14 -0500)] 
Fix: initialize var_data to NULL

Remove a false-positive from scan-build. Initialization of
var_data_len should have been enough but scan build is not smart
enough to understand this.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I90cb449f3092db432967a3f2ea5eedb0728b8678
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agotracker: update API documentation
Jonathan Rajotte [Wed, 20 Nov 2019 20:25:16 +0000 (15:25 -0500)] 
tracker: update API documentation

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I71f02c5cbebe7ed8e19aee6bc0d2af7741ed272f
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoCleanup: remove struct lttng_handle from tracker.h
Jonathan Rajotte [Wed, 20 Nov 2019 20:17:49 +0000 (15:17 -0500)] 
Cleanup: remove struct lttng_handle from tracker.h

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I8b9fd5c86200013cbd60c57505621cb851556b01
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoRefactoring: introduce lttng_tracker_ids_serialize
Jonathan Rajotte [Thu, 21 Nov 2019 03:02:09 +0000 (22:02 -0500)] 
Refactoring: introduce lttng_tracker_ids_serialize

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I0d43b85241b7097ac722724d9fef0ca352422495
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoRefactoring: move count to an output parameter
Jonathan Rajotte [Wed, 20 Nov 2019 19:40:22 +0000 (14:40 -0500)] 
Refactoring: move count to an output parameter

This mimics what is done for lttng_rotation_schedules_get_count.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I576d112de4a9bfa258a78cb52b8da8a5f25adefb
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoRefactoring: introduce lttng_tracker_ids data structure
Jonathan Rajotte [Wed, 20 Nov 2019 03:48:00 +0000 (22:48 -0500)] 
Refactoring: introduce lttng_tracker_ids data structure

This data structure is opaque to allow for back-end implementation change
in the future.

For now, only the following functions concerning lttng_tracker_ids are public:
    lttng_list_tracker_ids
    lttng_tracker_ids_get_count
    lttng_tracker_ids_get_at_index
    lttng_tracker_ids_destroy

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Iae1c10d0b578b402ab91378dd49f69f605b316b2
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoRefactoring: use an opaque lttng_tracker_id type
Jonathan Rajotte [Mon, 18 Nov 2019 02:38:21 +0000 (21:38 -0500)] 
Refactoring: use an opaque lttng_tracker_id type

Move the tracker and tracker id related API to tracker.h and
tracker-internal.h.

The use of an opaque object mimics the new API for rotation and trigger
etc.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I00b876c618d7dcb0dd940189e5250c3f3d64c7e0
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: Initialize ret to zero
Jonathan Rajotte [Fri, 8 Nov 2019 21:28:00 +0000 (16:28 -0500)] 
Fix: Initialize ret to zero

For the improbable case that the domain is unknown the return value ret
would not be initialized.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I22ae6b98bbbc4f4fe3e9c28985e2400f7c668525
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoUpdate track/untrack man page
Jonathan Rajotte [Wed, 6 Nov 2019 19:51:22 +0000 (14:51 -0500)] 
Update track/untrack man page

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Ie7092993034f2fb71fc3b1fad0ce5a6f61a31493
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoError early on invalid tracker type for UST domain
Jonathan Rajotte [Mon, 4 Nov 2019 22:35:27 +0000 (17:35 -0500)] 
Error early on invalid tracker type for UST domain

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Iea182575c99c1fcf84cb8c313af5904581b5023d
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoust-app: remove dead code
Jonathan Rajotte [Thu, 31 Oct 2019 21:20:43 +0000 (17:20 -0400)] 
ust-app: remove dead code

This code path is not possible since all callsite are fenced with a check
to "has_been_started". Hence, a session cannot be active at the same time.

Change-Id: I53785017989ed7afc8755a41428087d988e5ae88
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: Skip uid registry when metadata key value is 0
Jonathan Rajotte [Thu, 9 Aug 2018 21:21:40 +0000 (17:21 -0400)] 
Fix: Skip uid registry when metadata key value is 0

A value of 0 for the metadata key indicates that the metadata channel
was never created/pushed on the consumer side.

This can occur in scenario where a tracker(s) (vuid/vgid/vpid) is present.
The metadata channel might never be created/pushed since no applications
are actually tracing. Still, the uid registry exists due to the order
in which the sessiond received the client commands (create,
enable-channel, lttng track/untrack).

See included test for a complete reproducer.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Id7ef34ebc48333f47db4bdca907cf81911b60d1d
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agotrackers: bump MI version to 4.0
Mathieu Desnoyers [Thu, 5 Jul 2018 15:08:40 +0000 (11:08 -0400)] 
trackers: bump MI version to 4.0

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0a44262016cf90e0629be5cb7d8b5976462c62d9
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agotests: test uid/gid/pid/vuid/vgid/vpid trackers
Mathieu Desnoyers [Tue, 10 Jul 2018 18:12:07 +0000 (14:12 -0400)] 
tests: test uid/gid/pid/vuid/vgid/vpid trackers

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1b5ee95efc58a3969066e353cb30eeb3fd8eebb9
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agotrackers: update list/track/untrack commands
Jonathan Rajotte [Thu, 7 Nov 2019 23:01:06 +0000 (18:01 -0500)] 
trackers: update list/track/untrack commands

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I18e41d0e3c7826596ac0468eb5ef7bcc549c8f98
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agotrackers: support tracking feature
Jonathan Rajotte [Thu, 7 Nov 2019 21:18:10 +0000 (16:18 -0500)] 
trackers: support tracking feature

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I1629562f4c94947f5dd54a0cee6c0f8f7beb19fe
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agotrackers: add sessiond tracker list implementation
Mathieu Desnoyers [Thu, 5 Jul 2018 14:31:01 +0000 (10:31 -0400)] 
trackers: add sessiond tracker list implementation

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I28dbeac1f3db2df7e61911249a3250fbc17dc244
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agotrackers: update lttng-modules tracer ABI
Mathieu Desnoyers [Wed, 4 Jul 2018 20:15:07 +0000 (16:15 -0400)] 
trackers: update lttng-modules tracer ABI

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I27e1e552b13b5a541b43ff250d1d4839e399f1f3
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agotrackers: introduce new tracker types
Jonathan Rajotte [Thu, 7 Nov 2019 21:16:56 +0000 (16:16 -0500)] 
trackers: introduce new tracker types

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I749915124dbfe7cbe15d889a5dbcb648c17374dc
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agotrackers: change error code from "pid" to "id"
Mathieu Desnoyers [Wed, 4 Jul 2018 20:11:17 +0000 (16:11 -0400)] 
trackers: change error code from "pid" to "id"

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0ce03b23350a9f0da9d5f00ac3c6d0e824af9a98
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoformat: use AfterCaseLabel: true for switch case
Jonathan Rajotte [Wed, 6 Nov 2019 21:15:37 +0000 (16:15 -0500)] 
format: use AfterCaseLabel: true for switch case

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Ib0bb3c222441e7c6afcf7ea5c5c95bbf8413be57
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: sessiond: check for lttng-modules ABI 2.1 rather than 2.8
Jérémie Galarneau [Fri, 20 Dec 2019 03:13:10 +0000 (22:13 -0500)] 
Fix: sessiond: check for lttng-modules ABI 2.1 rather than 2.8

The clear patchset introduces a regression that breaks session
rotations when the kernel domain is used. The 2.8 lttng-modules ABI
does not exist yet.

The packet sequence number functionality was introduced in LTTng 2.8,
which introduced the 2.1 kernel tracer ABI.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ief97e7e25f6f0fcb5b5b97b39abb417c1eb327ec

4 years agoDoc: man page: lttng-relayd LTTNG_RELAYD_DISALLOW_CLEAR env. var.
Mathieu Desnoyers [Fri, 6 Dec 2019 13:31:47 +0000 (14:31 +0100)] 
Doc: man page: lttng-relayd LTTNG_RELAYD_DISALLOW_CLEAR env. var.

Describe the LTTNG_RELAYD_DISALLOW_CLEAR environment variable in the
lttng-relayd(8) man page.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I3573d0f220f8aa298935e01f62c89035a1966f77
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoDoc: lttng-clear(8) man page
Jonathan Rajotte [Mon, 11 Feb 2019 17:19:58 +0000 (12:19 -0500)] 
Doc: lttng-clear(8) man page

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I6d981a1e17a2a3fdd20a4c61b8c2216bc6517f3f
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agotests: mi for clear command
Jonathan Rajotte [Mon, 11 Feb 2019 16:45:27 +0000 (11:45 -0500)] 
tests: mi for clear command

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I769825ce10ce08cc1ae127821982d7ec3b1448ca
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
This page took 0.048197 seconds and 4 git commands to generate.