lttng-ust.git
3 years agoDecouple `struct lttng_session` from filter code
Francis Deslauriers [Thu, 28 Nov 2019 19:15:02 +0000 (14:15 -0500)] 
Decouple `struct lttng_session` from filter code

Use `struct lttng_ctx` directly so that the future event notifier
infrastructure, which will be outside any session, can use it.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I84109a0c01636bc5206f43e7abdceee27124c520

4 years agoport: FreeBSD 12.2 added pthread_setname_np
Michael Jeanson [Fri, 6 Nov 2020 19:49:10 +0000 (14:49 -0500)] 
port: FreeBSD 12.2 added pthread_setname_np

With a minor difference that it doesn't return an error when the name is
too long, add this check in the wrapper to have the same behavior on
all platforms.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id6fa0970b011867424a215e5d7ba69e9fe617389

4 years agoport: tests: Add a simple unit test for shm operations
Michael Jeanson [Thu, 5 Nov 2020 18:37:41 +0000 (13:37 -0500)] 
port: tests: Add a simple unit test for shm operations

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Idf347eb2985cac2216da0bb13aee5b09884c8b48

4 years agoport: fsync(2) on a POSIX shm fd returns EINVAL on FreeBSD
Michael Jeanson [Wed, 4 Nov 2020 20:42:15 +0000 (15:42 -0500)] 
port: fsync(2) on a POSIX shm fd returns EINVAL on FreeBSD

The POSIX shared memory object implementation on FreeBSD is not file
based and doesn't support fsync(2).

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie170254122aeab858a12c0522dc4e78075f243f9

4 years agoport: set shm size with ftruncate before writing
Michael Jeanson [Wed, 4 Nov 2020 15:00:31 +0000 (10:00 -0500)] 
port: set shm size with ftruncate before writing

According to POSIX, the size of shared memory object must be set with
ftruncate before writing to it. This happenen to work on Linux because
the implementation simply creates files on a tmpfs but on FreeBSD it is
implemented using actual shared memory objects and as such requires the
size to be set first.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I048f65104d7c34142025337ec1f6777650bfd62f

4 years agofix: pass the detected CFLAGS to the C++ compiler
Michael Jeanson [Thu, 29 Oct 2020 05:48:56 +0000 (01:48 -0400)] 
fix: pass the detected CFLAGS to the C++ compiler

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8f76c87c1acb772d93292ca36bd9b7d56a147b5e

4 years agoCleanup: silent rules are always available in automake >= 1.12
Michael Jeanson [Wed, 22 Jul 2020 18:51:36 +0000 (14:51 -0400)] 
Cleanup: silent rules are always available in automake >= 1.12

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ib0acb195594e1b788c8c6d1b2cd879c3c271aef3

4 years agoCleanup: Use pkg-config to detect liburcu
Michael Jeanson [Tue, 1 Sep 2020 19:19:08 +0000 (15:19 -0400)] 
Cleanup: Use pkg-config to detect liburcu

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iddfc721318e3ac06f2403876c1aa196da797d113

4 years agotests: Move tap-driver.sh out of the autotools aux directory
Michael Jeanson [Thu, 23 Jul 2020 16:27:13 +0000 (12:27 -0400)] 
tests: Move tap-driver.sh out of the autotools aux directory

We have made local modifications to this script, move it to the test
suite directory so it doesn't get overwritten by an updated version from
autotools.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie46f0c39fe4d196b2bab3978ac02c2b1fed883c7

4 years agoEnable autotools warnings as errors
Michael Jeanson [Wed, 22 Jul 2020 18:48:00 +0000 (14:48 -0400)] 
Enable autotools warnings as errors

Enable all autotools warnings and error out to help catch all the
wonderful, shall we say, pecularities of M4sh.

And fix some associated errors in configure.ac.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Icc693a1913a003f2c5b299e82084252c5735603f

4 years agoCleanup: separate tests between 'unit' and 'compile'
Michael Jeanson [Thu, 16 Jul 2020 19:09:45 +0000 (15:09 -0400)] 
Cleanup: separate tests between 'unit' and 'compile'

Change-Id: Ib4326540609dc464b9a89ba9b891cf9c410d902b
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoCleanup: Bump autoconf required version to 2.69
Michael Jeanson [Fri, 17 Jul 2020 19:15:55 +0000 (15:15 -0400)] 
Cleanup: Bump autoconf required version to 2.69

We already depend on automake 1.12 released in 2012, set the minimum
autoconf version to 2.69 which was released on the same year.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ib3c8bb5fccca3eacb80e78f361bc1b3fddbe00e1

4 years agoCleanup: Remove obsolete and unused tests
Michael Jeanson [Thu, 16 Jul 2020 18:24:44 +0000 (14:24 -0400)] 
Cleanup: Remove obsolete and unused tests

These tests have not been built in years and are not compatible with the
current API.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I6e18ba701d5deec72102e9b652ec9dfc9f08a9c2

4 years agofix: pthread_setname_np tests to match compat behavior
Michael Jeanson [Fri, 16 Oct 2020 19:45:43 +0000 (15:45 -0400)] 
fix: pthread_setname_np tests to match compat behavior

Adjust the test to expect an error when setting a thread name of more
than 16 bytes. Also don't override global AM_CPPFLAGS in
pthread_name/Makefile.am so that we get the proper include
configuration.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iee41d8ea845836d273f01e890ea4196ae2ed43ef

4 years agofix: pthread_setname_np fails on longer tread names
Michael Jeanson [Fri, 16 Oct 2020 19:44:36 +0000 (15:44 -0400)] 
fix: pthread_setname_np fails on longer tread names

When supplied with a thread name of more than 16 bytes including the
null terminating byte pthread_setname_np will fail with ERANGE,
replicate this behavior in the compat wrappers.

Change-Id: I91ac35a400a39c297e49fcab83b4f345b7ad92d0
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoNamespace lttng/align.h macros
Michael Jeanson [Thu, 15 Oct 2020 21:50:50 +0000 (17:50 -0400)] 
Namespace lttng/align.h macros

These macros are part of the API and should have been namespaced
initialy. Namespace them and add backwards compatibility defines, make
sure to include the relevant system headers first for platforms that
have conflicting defines.

Change-Id: If2929ec2202dbde896614a25440ab200514ef4ad
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoFix: remove redefinition of _GNU_SOURCE
Mathieu Desnoyers [Fri, 16 Oct 2020 14:26:39 +0000 (10:26 -0400)] 
Fix: remove redefinition of _GNU_SOURCE

Now that _GNU_SOURCE is defined by the compiler command line, no need to
redefine it.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I5a02dd945f0dfec778779a8c5806cc9f45960520

4 years agoAdd pthread_setname_np tests
Michael Jeanson [Thu, 15 Oct 2020 21:12:30 +0000 (17:12 -0400)] 
Add pthread_setname_np tests

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I5999ecddf62be9ad25cd67a61ff7315b48f3306a

4 years agoport: fix pthread_setname_np integration
Michael Jeanson [Thu, 15 Oct 2020 21:11:21 +0000 (17:11 -0400)] 
port: fix pthread_setname_np integration

The detection was broken and initialy went undetected because of the
failover code. Replace it with a hard fail and fix the detection for
each platform.

Also, replace the private LTTNG_UST_PROCNAME_LEN with
LTTNG_UST_ABI_PROCNAME_LEN from the public headers. The limit of 16
bytes does in fact include the terminating null byte contrary to what
was defined in LTTNG_UST_PROCNAME_LEN. This was not catched before since
the string is silently truncated if it exceeds 16 bytes.

Change-Id: I1ea95dfd882dfeb80fdc3d71ebec6618b1324a79
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoCleanup: standardise include path
Michael Jeanson [Fri, 17 Jul 2020 19:08:41 +0000 (15:08 -0400)] 
Cleanup: standardise include path

Use the same include setup as our other projects, set the default
includes globally in configure.ac by exporting AM_CPPFLAGS. Move the
local config.h to the include directory and include it by default on the
command line.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I28b48dc47cfc923d588a0033b97c2917a9c893a5

4 years agoport: no libnuma on FreeBSD
Michael Jeanson [Wed, 14 Oct 2020 17:27:41 +0000 (13:27 -0400)] 
port: no libnuma on FreeBSD

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1c5b376de188a8f23ae90c2a6ab72fb1ecc42ace

4 years agoport: use /bin/sh in test_ust_elf
Michael Jeanson [Tue, 13 Oct 2020 20:44:04 +0000 (16:44 -0400)] 
port: use /bin/sh in test_ust_elf

The script doesn't use any bash extensions, use the default shell.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I7f7c843087400938f1e4d0de140d5deaff4efcd9

4 years agoport: fix typo 'lttng_ust_safe_closefrom' -> 'lttng_ust_safe_closefrom_fd'
Michael Jeanson [Tue, 13 Oct 2020 20:43:44 +0000 (16:43 -0400)] 
port: fix typo 'lttng_ust_safe_closefrom' -> 'lttng_ust_safe_closefrom_fd'

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I6f9ddd4b46e83c379ed76dd435ce44c49393f7cf

4 years agoport: include limits.h first for CHAR_BIT
Michael Jeanson [Tue, 13 Oct 2020 20:43:13 +0000 (16:43 -0400)] 
port: include limits.h first for CHAR_BIT

On FreeBSD, CHAR_BIT is defined in limits.h, include it first so we
don't get redifinition errors.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I694cc906d801bcd9b1e82dcbcf1163cdb3c41100

4 years agoport: fix endian and byteswap compat on FreeBSD
Michael Jeanson [Tue, 13 Oct 2020 20:42:23 +0000 (16:42 -0400)] 
port: fix endian and byteswap compat on FreeBSD

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8edd89df2c99406b10b846eb1a8bcf959e8bbde4

4 years agoport: Silence macro redefinition warnings on FreeBSD
Michael Jeanson [Tue, 13 Oct 2020 20:41:00 +0000 (16:41 -0400)] 
port: Silence macro redefinition warnings on FreeBSD

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I32473a65116fd9e4120a852a8cbc5c145e9609f7

4 years agoport: fix pthread autoconf detection to support FreeBSD
Michael Jeanson [Tue, 13 Oct 2020 19:28:23 +0000 (15:28 -0400)] 
port: fix pthread autoconf detection to support FreeBSD

Use the same autoconf pthread code as lttng-tools to handle pthread
compat on FreeBSD.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I713446b1f5ec2eaab96cdfc7e9888ab543e8a67f

4 years agoSet version to 2.13-pre
Michael Jeanson [Thu, 23 Jul 2020 16:40:37 +0000 (12:40 -0400)] 
Set version to 2.13-pre

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id17c197aa437f0cf7a5d489f62f5f6b5cffb22e0

4 years agoFix: ustctl_release_object: eliminate double-close/free on error
Mathieu Desnoyers [Tue, 22 Sep 2020 20:38:51 +0000 (16:38 -0400)] 
Fix: ustctl_release_object: eliminate double-close/free on error

When ustctl_release_object returns an error, it is unclear to the caller
what close/free side effects were effectively performed and which were
not. So the only courses of action are to either leak file descriptors
or memory, or call ustctl_release_object again which can trigger double
close or double free.

Fix this by setting the file descriptors to -1 after successful close,
and pointers to NULL after successful free.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agotests: return the proper TAP exit code
Michael Jeanson [Mon, 13 Jul 2020 19:22:35 +0000 (15:22 -0400)] 
tests: return the proper TAP exit code

The C TAP library provides the 'exit_status()' function that will return
the proper exit code according to the number of tests that succeeded or
failed.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I786527dfa9cfe2d1a7c8bc80086d54186f60b4d9

4 years agoAdd userspace time namespace context
Michael Jeanson [Mon, 6 Jul 2020 15:48:16 +0000 (11:48 -0400)] 
Add userspace time namespace context

This was introduced in kernel v5.6.0, on a system running an older kernel,
zero will be returned.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1ea66a98c96a4de084c02521f6982e8c7d1b53bb

4 years agoUse libtool syntax in LDADD
Michael Jeanson [Thu, 26 Mar 2020 21:18:41 +0000 (17:18 -0400)] 
Use libtool syntax in LDADD

Use .la files to add link dependencies between libraries, linking
directly to the content of '.libs' is relying on an implementation
detail of libtool.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I6fe0157e23f13cd69c436111a2e743fa1c763d64

4 years agoAdd missing files to distribution
Michael Jeanson [Thu, 26 Mar 2020 20:49:45 +0000 (16:49 -0400)] 
Add missing files to distribution

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I5b0be9c7c87dc7fef1c6f46f15091d4e3c2a09a8

4 years agoFix: python agent: 'time' has no attribute 'clock'
Jonathan Rajotte [Wed, 17 Jun 2020 22:40:22 +0000 (18:40 -0400)] 
Fix: python agent: 'time' has no attribute 'clock'

The time.clock() function was removed in python 3.8 and is marked as
deprecated since python 3.3. See PEP 418 for more details [1].

Solution
=====

When the python version is greater than 3.2 use the
`time.perf_counter()` function [2]. Otherwise, fall back to
`time.clock()`.

Introduce a compat module to the lttngust agent package providing the
`_clock` function.

[1] https://www.python.org/dev/peps/pep-0418/
[2] https://docs.python.org/3/library/time.html#time.perf_counter

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I3d6d8b24309d45d43b634dc2a6b4d5dbc12da3aa

4 years agoFix: libc-wrapper: undef temporary token rather than value
Christophe Bedard [Mon, 1 Jun 2020 20:11:08 +0000 (16:11 -0400)] 
Fix: libc-wrapper: undef temporary token rather than value

The lttng-ust malloc wrapper defines pthread_mutex_lock/unlock
preprocessor tokens to ust_malloc_spin_lock/unlock around the definition
of a TLS variable, which uses pthread mutexes when relying on the
pthread key fallback. Undefining those tokens should be done on the
preprocessor token, rather than its value.

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I2053b79c88000e272c29b25ca105b1352ecfabd7

4 years agoFix: support compile units including 'sys/sdt.h' without defining SDT_USE_VARIADIC
Michael Jeanson [Fri, 26 Jun 2020 19:44:20 +0000 (15:44 -0400)] 
Fix: support compile units including 'sys/sdt.h' without defining SDT_USE_VARIADIC

Instead of using SDT_USE_VARIADIC from 'sys/sdt.h', use our own namespaced
macros since the instrumented application might already have included
'sys/sdt.h' without variadic support.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Idfece1a65a5296a90d33370bc8d73ea554c14b0f

4 years agoCleanup: have interpreter functions return _DISCARD instead of 0
Francis Deslauriers [Tue, 12 May 2020 15:38:15 +0000 (11:38 -0400)] 
Cleanup: have interpreter functions return _DISCARD instead of 0

It's easier to understand the meaning of the zero return value of these
function using the enum. It makes it obvious.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id8f199d82b17228fdc882e3ccbab8b3535840984

4 years agoCleanup: bytecode: typo: "s16" -> "u16"
Francis Deslauriers [Fri, 8 May 2020 18:52:20 +0000 (14:52 -0400)] 
Cleanup: bytecode: typo: "s16" -> "u16"

Signed-off-by: Francis Deslauriers <fdeslaur@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If3a0e0422ce91d26c33b2e040a1463879e8d8505

4 years agodoc: Explain `struct lttng_bytecode_runtime` layout restrictions
Francis Deslauriers [Mon, 20 Apr 2020 21:33:48 +0000 (17:33 -0400)] 
doc: Explain `struct lttng_bytecode_runtime` layout restrictions

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I875b11c644917a3b9f15bf88ab44098813e59db0

4 years agoFix: event probes attached before event enabled
Francis Deslauriers [Tue, 5 May 2020 15:51:58 +0000 (11:51 -0400)] 
Fix: event probes attached before event enabled

Background
==========
When userspace events with exclusions are enabled by the CLI user, the
session daemon enables the events in a 3-steps process using the
following ustctl commands:
1. `LTTNG_UST_EVENT` to create an event and get an handle on it,
2. `LTTNG_UST_EXCLUSION` to attach exclusions, and
3. `LTTNG_UST_ENABLE` to activate the tracing of this event.

Also, the session daemon uses the `LTTNG_UST_SESSION_START` to start the
tracing of events. In various use cases, this can happen before OR after
the 3-steps process above.

Scenario
========
If the`LTTNG_UST_SESSION_START` is done before the 3-steps process the
tracer will end up not considering the exclusions and trace all events
matching the event name glob pattern provided at step #1.

This is due to the fact that when we do step #1, we end up calling
`lttng_session_lazy_sync_enablers()`. This function will sync the event
enablers if the session is active (which it is in our scenario because
of the _SESSION_START).
Syncing the enablers will then match event name glob patterns provided
by the user to the event descriptors of the tracepoints and attach
probes in their corresponding callsite on matches.

All of this is done before we even received the exclusions in step #2.

Problem
=======
The problem is that we attach probes to tracepoints before being sure we
received the entire description of the events.
Step #2 may reduced the set of tracepoints to trace so we must wait
until exclusions are all received to attached probes to tracepoints.

Solution
========
Only match event names and exclusions (and ultimately, register probes)
on enabled enablers to ensure that no other modifications will be
applied to the event.

Event enablers are enabled when at step #3.

Note
====
Filters are not causing problems here because adding a filter won't
change what tracepoints are to be traced.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id984f266d976f346b001db81cd8a2b74965b5ef2

4 years agoFix: use underlying types for array and sequence assertion
Mathieu Desnoyers [Mon, 27 Apr 2020 07:12:11 +0000 (03:12 -0400)] 
Fix: use underlying types for array and sequence assertion

Based on https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html:

"Built-in Function: int __builtin_types_compatible_p (type1, type2)

[...] two types that are typedefed are considered compatible if
their underlying types are compatible."

This definition explains why listing all the {u,}intX_t types misses
the underlying type "long" on 32-bit architectures which rely on
"long long" for 64-bit integers. Therefore, list all the underlying
integer types.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoAdd compile time assertion that array and sequence have integer elements
Francis Deslauriers [Fri, 24 Apr 2020 16:30:22 +0000 (12:30 -0400)] 
Add compile time assertion that array and sequence have integer elements

Currently, LTTng-UST only supports ctf_arrays(and ctf_sequences) of
integers and chars but there is nothing preventing the user of compiling
an array of double. This is problematic because the resulting metadata
for that array will end up being erroneous.

This commit adds a new stage in the probe building process that asserts
that the element type of arrays or sequences are supported. This stage
adds a compile time static assertion, so the probes won't build if the
type is not supported.

Here is the error message the user will get when compiling with a C99
compiler:
  gcc -c -sdt=c99 -I. tp.c
    In file included from /usr/local/include/lttng/tracepoint-event.h:58:0,
       from tp.h:77,
       from tp.c:4:
    ././tp.h:71:9: error: size of array ‘lttng_static_assert_Non_integer_type__my_array__not_supported_as_element_of_CTF_ARRAY_or_CTF_SEQUENCE’ is negative
    ctf_array(double, my_array_for_double, my_array_for_double, 3)

Here is the error message the user will get when compiling with a C++ or
C11 compiler or above:
  g++ -c -std=c11 -I. tp.c
    In file included from /usr/local/include/lttng/tracepoint-event.h:58:0,
         from tp.h:77,
         from tp.c:4:
    ././tp.h:71:9: error: static assertion failed: Non-integer type `my_array` not supported as element of CTF_ARRAY or CTF_SEQUENCE
    ctf_array(double, my_array, my_array_for_double, 3)

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie958635a8dc6262793d45c5f7458d50a0fecf7ab

4 years agoImplement compile time assertion macro wrapper
Francis Deslauriers [Fri, 24 Apr 2020 19:58:26 +0000 (15:58 -0400)] 
Implement compile time assertion macro wrapper

Starting from C++11[1] and C11[2] both C++ and C standards implement the
`static_assert()` macro that allows the compile time evaluation of an
expression and emitting of a compiler error when the expression
evaluates to false.

This commit implements a wrapper for compile time assertions on C
compilers implementing C standards prior C11.

On such compilers, we emulate a static assert by typedef'ing an array of
negative size in case of predicate failure.

The downside of this method is that error messages are a bit cryptic as
it mentions the negative-sized array. We overcome this issue by using a
user-provided message as part of variable name that gets printed on
error. For this reason, we decide to require 2 different messages in
addition of the predicate.

Here is the signature of the macro:
  #define lttng_static_assert(predicate, msg, c_identifier_msg)

The first message, `msg`, is the used with C++/C11 compilers can be any
string. The second message, `c_identifier_msg`, is used with older
standards and MUST be a valid C identifier as it's will be concatenated
to a typedef name.

For example:
If the user uses the macro such as:
  lttng_static_assert(false, "My assert message", MY_ASSERT_MSG);

The C99 user will get an error looking like this:
 error: size of array ‘lttng_static_assert_MY_ASSERT_MSG’ is negative

The C11 or C++ user will get an error looking like this:
  error: static assertion failed: "My assert message"

[1] https://en.cppreference.com/w/cpp/language/static_assert
[2] https://en.cppreference.com/w/c/language/_Static_assert

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I725f6e77f1858b8d88ffae781b648ac5b5c64b28

4 years agoFix: agent: read: end of loop condition should exclude 0
Mathieu Desnoyers [Thu, 23 Apr 2020 16:51:40 +0000 (12:51 -0400)] 
Fix: agent: read: end of loop condition should exclude 0

Causes the agent to hang endlessly waiting for completion of the
loop.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agofix: Java examples CLASSPATH override
Michael Jeanson [Wed, 22 Apr 2020 20:32:51 +0000 (16:32 -0400)] 
fix: Java examples CLASSPATH override

Variables provided to make as arguments, called 'command variables' can't
be reassigned a new value in the Makefile. Since the CLASSPATH is now
passed this way in the glue between automake and the example makefiles,
use different names for the internal variables.

Change-Id: Id6289273f211f544a66d933a96f06df75243415f
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoAdd missing files to .gitignore
Michael Jeanson [Wed, 22 Apr 2020 18:07:46 +0000 (14:07 -0400)] 
Add missing files to .gitignore

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I5050772c58342d3eb956e0cbd56983fbb1ed3b70

4 years agofix: Add CLASSPATH to autoconf precious variables
Michael Jeanson [Wed, 22 Apr 2020 18:37:55 +0000 (14:37 -0400)] 
fix: Add CLASSPATH to autoconf precious variables

This will record the value of CLASSPATH in the autoconf cache and ensure
it's used when calling make even if it's not exported to the
environment.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia06070dd352f9d3b6956a1ec0f4eb1d024f73179

4 years agoFix: Java agent: close session daemon socket on error
Mathieu Desnoyers [Wed, 22 Apr 2020 18:05:41 +0000 (14:05 -0400)] 
Fix: Java agent: close session daemon socket on error

When catching an error, close the socket used to communicate with the
session daemon rather than leaking it, before retrying to connect.

Also, when sleep is interrupted, there is no point in printing
out the stack trace. Just retry connection immediately.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoJava agent: Use inequality for read bound check
Mathieu Desnoyers [Wed, 22 Apr 2020 18:14:36 +0000 (14:14 -0400)] 
Java agent: Use inequality for read bound check

Don't continue looping if bytesLeft becomes negative for unforeseen
reasons.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoFix: Java agent: handle partial payload read
Mathieu Desnoyers [Wed, 22 Apr 2020 17:30:40 +0000 (13:30 -0400)] 
Fix: Java agent: handle partial payload read

When reading from a TCP socket, there is no guarantee that the
read will return all the requested data. We need to loop and continue
reading until we gather all the expected data.

This fixes flakiness of the lttng-ust-java-tests.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoFix: incorrect field accounting for dynamic type
Mathieu Desnoyers [Wed, 22 Apr 2020 16:22:19 +0000 (12:22 -0400)] 
Fix: incorrect field accounting for dynamic type

Two field accounting issues were introduced by
commit 218deb69baab "tracepoint: Refactor representation of nested
types" which affect the dynamic types used by Java application contexts.

The structure types should account 1 for the structure per se, in
addition to the nested fields.

The atype_dynamic includes an implicit enumeration, which now has two
fields instead of 1.

This was causing memory corruption issues in the lttng-ust-java-tests.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoust-compiler.h: Allocate compound literals on heap with gcc <= 4.8
Mathieu Desnoyers [Mon, 20 Apr 2020 18:27:31 +0000 (14:27 -0400)] 
ust-compiler.h: Allocate compound literals on heap with gcc <= 4.8

g++ 4.8 and prior do not support C99 compound literals. Therefore,
force allocating those on the heap with these C++ compilers.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoRequire C++11 for building probe providers with C++ compiler
Mathieu Desnoyers [Mon, 20 Apr 2020 18:12:51 +0000 (14:12 -0400)] 
Require C++11 for building probe providers with C++ compiler

The __LTTNG_COMPOUND_LITERAL(), in C++, requires either that the
compiler supports C99 compound literals (which is not the case for
g++ 4.8), or that LTTNG_ALLOCATE_COMPOUND_LITERAL_ON_HEAP is
defined so the compiler allocates the compound literal on the
heap with "new", which is available since c++11.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agofilter: bytecode already in the list should go before
Francis Deslauriers [Thu, 16 Apr 2020 23:44:06 +0000 (19:44 -0400)] 
filter: bytecode already in the list should go before

Background
==========
This `seqnum` (sequence number) feature is currently unused. It was
designed so that the session daemon could tell the tracer the order in
which the bytecode should be run.

Issue
=====
The current implementation of the session daemon doesn't use this
feature so there is only ever a single bytecode to execute per callsite.

During work on an upcoming feature uses this `seqnum` became useful and
it was realized that the current bytecode linking code would reverse the
order in which the bytecode were executed when all bytecodes have the
same `seqnum` value.

This is due to the fact that the `cds_list_for_each_entry_reverse` loops
until it finds a `seqnum` smaller than the new one.

So if all bytecodes have the same `seqnum`, the new bytecode will be
added at the beginning of the list.

This is not technically a problem since it's the session daemon's job to
set the sequence number if it wants a particular ordering. Even
considering that, we found it counterintuitive that new bytecodes are
added at the beginning of the list in those cases.

Solution
========
This commit makes it so that on equality, the insertion is done after
the existing bytecodes.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie323b3ff5df346f222e22abfb9bbad6c5b7e4a27

4 years agoBump LTTNG_UST_ABI version from 8.1 to 9.0
Mathieu Desnoyers [Thu, 2 Apr 2020 20:57:48 +0000 (16:57 -0400)] 
Bump LTTNG_UST_ABI version from 8.1 to 9.0

Ensure an older liblttng-ust communicating with a newer liblttng-ust
will refuse the handshake, so older session daemon do not get to
interact with more recent lttng-ust which implements nested arrays and
sequences.

Introduce LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE to allow
liblttng-ust to be backward compatible with a range of major versions.
In this case, liblttng-ust ABI 9.0 is fully backward compatible with
8.x, given that none of the existing ABI in 8.x has changed in 9.0.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agotracepoint: Refactor representation of nested types
Mathieu Desnoyers [Thu, 2 Apr 2020 17:37:17 +0000 (13:37 -0400)] 
tracepoint: Refactor representation of nested types

Refactor enumeration, sequence, array, structure, and variant types.

Implement internal data structures to support nested types.

All probe providers using ctf_enum(), ctf_array*() and ctf_sequence*()
are switched to this new binary layout, and the prior enum, array and
sequence abstract types are kept only for backward compatibility with
probe providers generated by older lttng-ust headers.

Each of sequence, array, struct and variant gain a "alignment" property,
which is a feature which was needed in lttng-modules to express
alignment for an array or sequence of bits.

The ust-ctl protocol with session daemon is extended to support those
new types.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoRemove has_strcpy check following probe provider version bump
Mathieu Desnoyers [Thu, 2 Apr 2020 20:38:58 +0000 (16:38 -0400)] 
Remove has_strcpy check following probe provider version bump

Bumping the probe provider major version from 1 to 2 allows us to
remove a dynamic check within ctf_string() in the probe providers.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoBump LTTNG_UST_PROVIDER_MAJOR from 1 to 2
Mathieu Desnoyers [Thu, 2 Apr 2020 20:32:15 +0000 (16:32 -0400)] 
Bump LTTNG_UST_PROVIDER_MAJOR from 1 to 2

The introduction of nested arrays and sequences requires to bump the
provider major version from 1 to 2. Newer lttng-ust are backward
compatible with older probes, but newer probes cannot be used by
older lttng-ust versions.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoust-compiler.h: Implement __LTTNG_COMPOUND_LITERAL
Mathieu Desnoyers [Thu, 2 Apr 2020 17:29:45 +0000 (13:29 -0400)] 
ust-compiler.h: Implement __LTTNG_COMPOUND_LITERAL

Implement __LTTNG_COMPOUND_LITERAL to allow defining a compound literal
with static storage.

Compound literals with static storage are needed by LTTng to implement
nested arrays and sequences in TRACEPOINT_EVENT.

Compound literals are part of the C99 and C11 standards, but not
part of the C++ standards. However, those are supported by both g++ and
clang as C99 extensions when compiling C++ code.

Strict C++11 compliance can be obtained by defining
LTTNG_ALLOCATE_COMPOUND_LITERAL_ON_HEAP before including this header
to allocate those on the heap in C++.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoDocument dependency on liburcu >= 0.12
Mathieu Desnoyers [Thu, 9 Apr 2020 19:02:57 +0000 (15:02 -0400)] 
Document dependency on liburcu >= 0.12

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoconfigure: add check for DEFINE_URCU_TLS_INIT
Mathieu Desnoyers [Thu, 9 Apr 2020 15:40:55 +0000 (11:40 -0400)] 
configure: add check for DEFINE_URCU_TLS_INIT

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoCleanup: use DEFINE_URCU_TLS_INIT for all CONFIG_RCU_TLS configurations
Mathieu Desnoyers [Thu, 9 Apr 2020 15:33:48 +0000 (11:33 -0400)] 
Cleanup: use DEFINE_URCU_TLS_INIT for all CONFIG_RCU_TLS configurations

Introduce a dependency on DEFINE_URCU_TLS_INIT for all CONFIG_RCU_TLS
configurations.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoFix: namespace contexts !CONFIG_RCU_TLS variable initialization
Mathieu Desnoyers [Thu, 9 Apr 2020 15:29:18 +0000 (11:29 -0400)] 
Fix: namespace contexts !CONFIG_RCU_TLS variable initialization

The namespace contexts introduced in lttng-ust 2.12 require to
initialize TLS variable to nonzero values. However, in !CONFIG_RCU_TLS
(compatibility mode using pthread setspecific), this initialization
does not build.

Use the new DEFINE_URCU_TLS_INIT from liburcu when building
!CONFIG_RCU_TLS to fix this issue. Since this requires a dependency on
a new liburcu version, only !CONFIG_RCU_TLS adds this dependency in the
fix. A followup cleanup patch will use DEFINE_URCU_TLS_INIT as we add
a strict version dependency.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoRecord event as soon as one filters evaluates to TRUE
Francis Deslauriers [Fri, 20 Mar 2020 14:52:21 +0000 (10:52 -0400)] 
Record event as soon as one filters evaluates to TRUE

This is a tiny optimization but it can reduce tracing cost in cases
where multiple filters are attached to a probe.

Since we want to trace the event if any of its filter expressions
evaluates to TRUE, there is no need to keep on evaluating expression
once one is found to be TRUE.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I2bb8fafb3052fce02b10f541e025a9a74ffa1895

4 years agoCleanup: ust-tracepoint-event.h: extract `__num_fields` in a variable
Francis Deslauriers [Wed, 18 Mar 2020 21:29:36 +0000 (17:29 -0400)] 
Cleanup: ust-tracepoint-event.h: extract `__num_fields` in a variable

This makes it easier to understand what the `_TP_ARRAY_SIZE()` macro
expands to in this context.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I6b44e1e444df1dab0496282af4cea260ae895ca0

4 years agoFix: v.u.d might be uninitialized
Jonathan Rajotte [Mon, 9 Mar 2020 23:24:07 +0000 (19:24 -0400)] 
Fix: v.u.d might be uninitialized

lttng-filter-interpreter.c:301:17: warning: ‘v.u.d’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   ptr->u.d = v.u.d;

Indeed it seems that the value is never fetched if we compare to other
call sites and the dynamic call site further below.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I542d6db7514a2c39afe3613228577f34f194d672

4 years agoFix: Add missing vtracelog demo to make dist
Mathieu Desnoyers [Wed, 4 Mar 2020 16:33:26 +0000 (11:33 -0500)] 
Fix: Add missing vtracelog demo to make dist

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoFix: Add missing vtracef demo to make dist
Mathieu Desnoyers [Wed, 4 Mar 2020 16:32:52 +0000 (11:32 -0500)] 
Fix: Add missing vtracef demo to make dist

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoIntroduce vtracelog
Maxime Roussin-Belanger [Tue, 3 Mar 2020 23:10:31 +0000 (18:10 -0500)] 
Introduce vtracelog

vtracelog works the same as vtracef, but takes a log level
as a parameter and has the same limitations.

Signed-off-by: Maxime Roussin-Belanger <maxime.roussinbelanger@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoIntroduce vtracef
Maxime Roussin-Belanger [Tue, 3 Mar 2020 23:10:30 +0000 (18:10 -0500)] 
Introduce vtracef

vtracef accepts a va_list argument to simplify
tracing functions which use a va_list

Here's an example from wpa_supplicant that I wanted to
trace:

void wpa_debug(int level, const char* fmt, ...)
{
va_list ap;
va_start(ap, fmt);

...
// The call I want to easily trace with vtracef
vprintf(fmt, ap);

...
va_end(ap);
}

wpa_debug is used a fair amount and it would be annoying to
replace all the wpa_debug calls with tracef.

With vtracef, it simplifies the find and replace effort by
only changing it at one place.

Signed-off-by: Maxime Roussin-Belanger <maxime.roussinbelanger@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoFix: set FD_CLOEXEC on incoming FDs.
Jonathan Rajotte [Mon, 2 Mar 2020 19:21:33 +0000 (14:21 -0500)] 
Fix: set FD_CLOEXEC on incoming FDs.

The stream shm FDs are allocated by the consumer process, and then
passed to the applications over unix sockets. When opening those
file descriptors on reception, the FD_CLOEXEC flag is not set.

In a fork + exec scenario, parent process streams shm FDs and channel
wake FDs are present in the resulting child process.

Set FD_CLOEXEC on reception (ustcomm_recv_fds_unix_sock) to
prevent such scenario.

Change-Id: Id58077b272be9c1ab239846639ffd8103b3d50f1
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoFix: tracepoint.h: Disable address sanitizer on pointer array section variables
Mathieu Desnoyers [Tue, 18 Feb 2020 00:25:01 +0000 (19:25 -0500)] 
Fix: tracepoint.h: Disable address sanitizer on pointer array section variables

The tracepoint header declares pointer global variables meant to be
placed contiguously within the __tracepoints_ptrs section, and then used
as an array of pointers when loading an executable or shared object.

Clang Address Sanitizer adds redzones around each variable, thus leading to
detection of a global buffer overflow.

Those redzones should not be placed within this section, because it
defeats its purpose. Therefore, teach asan not to add redzones
around those variables with an attribute.

Note that there does not appear to be any issue with gcc (tested with
gcc-8 with address sanitization enabled), and gcc ignores the
no_sanitize_address attribute when applied to a global variable.

Fixes: #1238
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoFix: jhash.h: remove out-of-bound reads
Mathieu Desnoyers [Tue, 18 Feb 2020 00:31:41 +0000 (19:31 -0500)] 
Fix: jhash.h: remove out-of-bound reads

jhash.h implements "special" code for valgrind because it reads memory
out-of-bound (and then applies a mask) when reading strings.

Considering that lttng-ust does not use jhash.h in a fast-path, remove
this "optimization" and use the verifiable VALGRIND code instead. This
fixes an ASan splat.

Fixes: #1238
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoFix: generation of man pages with multiple refnames
Simon Marchi [Thu, 6 Feb 2020 15:06:45 +0000 (10:06 -0500)] 
Fix: generation of man pages with multiple refnames

In this proposed patch [1], we're trying to make a man page with two
command names in the NAME section, like this:

  tracef, vtracef - LTTng-UST printf(3)-like interface

Doing so causes the intermediary XML (what asciidoc outputs) to contain
this:

    <refnamediv>
      <refname>tracef, vtracef</refname>
      <refpurpose>LTTng-UST printf(3)-like interface</refpurpose>
    </refnamediv>

The refname is used by the docbook XSL to determine the output
filename.  This therefore results in an output file named
`tracef,_vtracef.3`, which is not desirable.

The problem is in the asciidoc pass, more specifically the part of
asciidoc.conf removed by this patch.  Is is there to override the
`source`, `version` and `manual` fields, but it also inadvertently
affects the refname generation.

Instead of playing with the asciidoc output template, this patch sets
the same `source`, `version` and `manual` attributes on the asciidoc
command line.  With the present patch applied, the XML output contains:

    <refnamediv>
        <refname>tracef</refname>
        <refname>vtracef</refname>
        <refpurpose>LTTng-UST printf(3)-like interface</refpurpose>
    </refnamediv>

The xmlto pass (docbook XML -> man page) then generates two files,
`tracef.3` and `vtracef.3`, where `vtracef.3` simply sources `tracef.3`
(which is what we want).

[1] https://lists.lttng.org/pipermail/lttng-dev/2020-February/029524.html

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoCleanup: remove trailing white spaces across project
Francis Deslauriers [Mon, 17 Feb 2020 15:46:45 +0000 (10:46 -0500)] 
Cleanup: remove trailing white spaces across project

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I15202338465ee56d33316cbc632d9e3bf44ee31e

4 years agoFix: lttng-ust-comm.c: return number of fd rather size of array
Francis Deslauriers [Tue, 26 Nov 2019 16:16:30 +0000 (11:16 -0500)] 
Fix: lttng-ust-comm.c: return number of fd rather size of array

There are two conflicting comments for this function. One says it
returns the size of the received data and the other says it returns the
number of fd received.

It's more useful to receive the number of fd.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I74084b461d396c3e623fa55100e6dd7e59dbea83

4 years agoliblttng-ust-comm: move `_unlock_fd_tracker()` after `close()` on error paths
Francis Deslauriers [Thu, 12 Dec 2019 14:32:00 +0000 (09:32 -0500)] 
liblttng-ust-comm: move `_unlock_fd_tracker()` after `close()` on error paths

Right now, receiving an error from `lttng_ust_add_fd_to_tracker()` means that
the fd was _not_ added to the fd set. So the `lttng_ust_safe_close_fd()`
(overriding `close()`) call will indeed close the fd as expected. So, it
doesn't matter if the `close()` is before or after the `_unlock_`.

Even considering that, I believe that it's clearer and more common to
have all related operations within the `_lock_` and  `_unlock_`
functions. Also, `lttng_ust_add_fd_to_tracker()` might be modified in
the future and fail for some other reason.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id29a6ab004cfd5ca601615e1a70c74cf754b12e2

4 years agoCleanup: liblttng-ust: change `int` flag to `bool`
Francis Deslauriers [Fri, 13 Dec 2019 22:24:25 +0000 (17:24 -0500)] 
Cleanup: liblttng-ust: change `int` flag to `bool`

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I78b35b6b99afe8a84aba6c836df3bce8d2532760

4 years agoliblttng-ust: exit loop early on event enabler match
Francis Deslauriers [Fri, 6 Dec 2019 22:49:35 +0000 (17:49 -0500)] 
liblttng-ust: exit loop early on event enabler match

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0fa3215f7cd6a2d32ac00d66cf5fc184abd14612

4 years agoCleanup: remove redundant memory barrier
Francis Deslauriers [Wed, 11 Dec 2019 22:14:43 +0000 (17:14 -0500)] 
Cleanup: remove redundant memory barrier

This memory barrier is redundant with the one already issued in
`rcu_assign_pointer()` function during the `set_tracepoint()` call.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I78decd9ae87a63d7663928ad99e03831155548f7

4 years agoCleanup: remove unused `lttng_bytecode_runtime::event` field
Francis Deslauriers [Fri, 13 Dec 2019 15:17:30 +0000 (10:17 -0500)] 
Cleanup: remove unused `lttng_bytecode_runtime::event` field

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id946b69e8cb4e79415d221f0be0889cfe707b439

4 years agoDocs: explain why unused `lttng_enabler::ctx` is kept around
Francis Deslauriers [Wed, 18 Dec 2019 21:46:21 +0000 (16:46 -0500)] 
Docs: explain why unused `lttng_enabler::ctx` is kept around

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I93cc035ced57e29f3d675c8c611d5319194e6cfb

4 years agoCleanup: remove unused `lttng_free_enabler_filter_bytecode()` func
Francis Deslauriers [Thu, 28 Nov 2019 19:26:20 +0000 (14:26 -0500)] 
Cleanup: remove unused `lttng_free_enabler_filter_bytecode()` func

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id9326aec2e6758ffffeb3eb9805bb0fa85d3076c

4 years agoCleanup: move unused function to deprecated symbol list
Francis Deslauriers [Thu, 28 Nov 2019 19:20:43 +0000 (14:20 -0500)] 
Cleanup: move unused function to deprecated symbol list

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I9c75feee029364ab17ef3783a6c8f0d45ff2948b

4 years agoCleanup: remove unused `__check_ust_safe_fmt()` function
Francis Deslauriers [Tue, 3 Dec 2019 21:53:47 +0000 (16:53 -0500)] 
Cleanup: remove unused `__check_ust_safe_fmt()` function

Usages of this function were removed by this commit:
  commit 5e96a46756a5dcd6e348afd84078b9e26438245d
  Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  Date:   Tue Aug 9 09:46:51 2011 -0400

      Add UST_DEBUG env. var. support

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I535028fc9338c0c2cef51a993bcab8f0e6c062c6

4 years agoCleanup: silence unused parameter `ps` warning
Francis Deslauriers [Tue, 3 Dec 2019 21:07:44 +0000 (16:07 -0500)] 
Cleanup: silence unused parameter `ps` warning

This function was copied here from one of the BSDs by this commit:
e5bc3b0f4d6c0407492ebdea863483925393e1bc with the /*ARGSUSED*/
lint-style comment to prevent any `unused` warning.

It seems clang doesn't support those lint-style comments, so it prints
this warning:
  CC       libustsnprintf_la-core.lo
  mbrtowc_sb.c:39:68: error: unused parameter 'ps' [-Werror,-Wunused-parameter]
  ust_safe_mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)

So mark that parameter as unused to prevent any warning.

We could also simply remove the unused parameter and change the
signature of the function.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I09f4fd3938058ed985c1525d8b9b06a27529691e

4 years agoCleanup: apply `include-what-you-use` guideline for `close()`
Francis Deslauriers [Thu, 5 Dec 2019 23:17:31 +0000 (18:17 -0500)] 
Cleanup: apply `include-what-you-use` guideline for `close()`

I saw that some files use the `close()` function but there are not
including a header for it. The `close()` function is defined by the
following header: <unistd.h>

So, to follow the best practice of including what is used in a file, I
added `#include <unistd.h>` in files using `close()`.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I07e104e957857c869576af7c2704e98584ecc763

4 years agoCleanup: apply `include-what-you-use` guideline for `uint*_t`
Francis Deslauriers [Tue, 3 Dec 2019 22:17:42 +0000 (17:17 -0500)] 
Cleanup: apply `include-what-you-use` guideline for `uint*_t`

I saw that some files use `uint*_t` types but there are not including a
header for it. The `uint*_t` types is defined by the following header:
  <stdint.h>

So, to follow the best practice of including what is used in a file, I
added `#include <stdint.h>` in files using `uint*_t`.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I5da13744858a57fc8c9bf6a6cf1b29299c2211cc

4 years agoCleanup: apply `include-what-you-use` guideline for `mbstate_t`
Francis Deslauriers [Tue, 3 Dec 2019 20:47:24 +0000 (15:47 -0500)] 
Cleanup: apply `include-what-you-use` guideline for `mbstate_t`

I saw that some files use the `mbstate_t` type but there are not including
a header for it. The `mbstate_t` type is defined by the following header:
  <wchar.h>

So, to follow the best practice of including what is used in a file, I
added `#include <wchar.h>` in files using `mbstate_t`.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I103d144ede1a8488d2662d3b8ba5337accafda99

4 years agoCleanup: apply `include-what-you-use` guideline for `fpos_t`
Francis Deslauriers [Tue, 3 Dec 2019 20:42:33 +0000 (15:42 -0500)] 
Cleanup: apply `include-what-you-use` guideline for `fpos_t`

I saw that some files use the `fpos_t` type but there are not including
a header for it. The `fpos_t` type is defined by the following header:
  <stdio.h>

So, to follow the best practice of including what is used in a file, I
added `#include <stdio.h>` in files using `fpos_t`.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I808ad0b23f04389fd56f89aa001095b771a327d6

4 years agoCleanup: apply `include-what-you-use` guideline for `size_t`
Francis Deslauriers [Tue, 3 Dec 2019 20:33:22 +0000 (15:33 -0500)] 
Cleanup: apply `include-what-you-use` guideline for `size_t`

I saw that some files use the `size_t` type but there are not including
a header for it. The `size_t` type is defined by the following headers:
  <stddef.h>
  <stdio.h>
  <stdlib.h>
  <string.h>
  <time.h>
  <wchar.h>

So, to follow the best practice of including what is used in a file, I
added `#include <stddef.h>` in files using `size_t` but did not include
any of the previously listed header.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ica1d82691335294decf13ffcdf4257e35d6a44c2

4 years agoCleanup: typo: column -> colon
Francis Deslauriers [Wed, 27 Nov 2019 19:14:24 +0000 (14:14 -0500)] 
Cleanup: typo: column -> colon

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I6873c94805ad02e4bba1431f7202ae0185d9698f

4 years agoAdd git-review config
Francis Deslauriers [Wed, 27 Nov 2019 20:16:06 +0000 (15:16 -0500)] 
Add git-review config

Add .gitreview for contributors wishing to use gerrit for patch
reviews.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I3ba853d0d68a660ac5d2d24c757e0f28b634977c

4 years agoVersion 2.12.0-rc1 v2.12.0-rc1
Mathieu Desnoyers [Wed, 5 Feb 2020 15:37:32 +0000 (10:37 -0500)] 
Version 2.12.0-rc1

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agoFix: build with -fno-common
Michael Jeanson [Thu, 16 Jan 2020 15:59:14 +0000 (10:59 -0500)] 
Fix: build 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. Keep only the declaration in the libustsnprintf.la convenience
library.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8fb7c72811ce7e62f10342f55fcabeeabfdd4c67

4 years agoBump LTTNG_UST_ABI_MINOR_VERSION to 1
Mathieu Desnoyers [Fri, 20 Dec 2019 15:49:20 +0000 (10:49 -0500)] 
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: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 years agolttng-clear: stop tracing required
Mathieu Desnoyers [Wed, 23 Oct 2019 16:57:47 +0000 (12:57 -0400)] 
lttng-clear: stop tracing required

Require that tracing is stopped when buffers are cleared. Update
comments and warning checks to that effect.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 years agodoc: fix build failure due to wrong whitespace character
Simon Marchi [Mon, 18 Nov 2019 18:44:14 +0000 (13:44 -0500)] 
doc: fix build failure due to wrong whitespace character

The previous, commit:

    54435b75df4c ("doc: reformat long lines in doc/examples/Makefile.am")

introduced the following build failure, when the support for JUL is
enabled:

    make[1]: Entering directory '/home/smarchi/build/lttng-ust/doc/examples/java-jul'
    javac -classpath "../../../liblttng-ust-java-agent/java/lttng-ust-agent-jul/lttng-ust-agent-jul.jar:../../../liblttng-ust-java-agent/java/lttng-ust-agent-common/lttng-ust-agent-common.jar:." -g Hello.java
    javac -classpath "../../../liblttng-ust-java-agent/java/lttng-ust-agent-jul/lttng-ust-agent-jul.jar:../../../liblttng-ust-java-agent/java/lttng-ust-agent-common/lttng-ust-agent-common.jar:." -g FilterChangeListenerExample.java
    javac -classpath "../../../liblttng-ust-java-agent/java/lttng-ust-agent-jul/lttng-ust-agent-jul.jar:../../../liblttng-ust-java-agent/java/lttng-ust-agent-common/lttng-ust-agent-common.jar:." -g ApplicationContextExample.java
    make[1]: *** No rule to make target ' '.  Stop.
    make[1]: Leaving directory '/home/smarchi/build/lttng-ust/doc/examples/java-jul'
    Makefile:979: recipe for target 'all-local' failed
    make: *** [all-local] Error 1

I inadvertently inserted a character that looks like a space, but that
is not a space.  make tries to interpret it as a target name, which
obviously fails.

Replace it with a proper space.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 years agodoc: reformat long lines in doc/examples/Makefile.am
Simon Marchi [Mon, 18 Nov 2019 17:07:51 +0000 (12:07 -0500)] 
doc: reformat long lines in doc/examples/Makefile.am

Format the long lines in the all-local target a bit like the "cmake"
target is formatted already.  I think it helps readability to have one
argument per line instead of very long lines.

At the same time, I removed the "cd .." at the end of parentheses.  The
parentheses start a new subshell, so it's unnecessary to do "cd .."
before the subshell exits.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 years agodoc: pass AR when building examples
Simon Marchi [Mon, 18 Nov 2019 17:07:50 +0000 (12:07 -0500)] 
doc: pass AR when building examples

As reported here [1], when cross-compiling lttng-ust, the
"hello-static-lib" example uses the ar tool made for the --build machine
instead of the prefixed one, for the --host machine.

The Makefiles in the subdirectories of doc/examples are written by hand,
so that they can be easily copied and modified by users.  They are
therefore not integrated in the automake build system, and any value
detected by configure must be passed explicitly when invoking it.
For example, the CC value is already explicitly passed, so that the
compiler value found by configure is passed down.  We just need to do
the same for AR.

This patch adds AM_PROG_AR in configure.ac, so that configure finds the
prefixed version of ar, if cross-compiling.

It then sets the AR variable in doc/examples/Makefile.am, when invoking
sub-Makefiles.  I don't think we really need it in the cmake case, but
it doesn't hurt to have it there.

[1] https://lists.lttng.org/pipermail/lttng-dev/2019-November/029388.html

Reported-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
This page took 0.046066 seconds and 4 git commands to generate.