lttng-ust.git
3 years agoHide new 'lttng_fixup_time_ns_tls' private symbol
Michael Jeanson [Thu, 17 Dec 2020 19:14:17 +0000 (14:14 -0500)] 
Hide new 'lttng_fixup_time_ns_tls' private symbol

Change-Id: Id058993bfa973e4f0c272388ef309b7a1167ade9
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoHide new 'lttng_counter_*' private symbols
Michael Jeanson [Thu, 17 Dec 2020 17:20:34 +0000 (12:20 -0500)] 
Hide new 'lttng_counter_*' private symbols

Change-Id: Ie2a1086e829fc2aacf8ba74a33ba0b87bbbb60fc
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoHide new 'lttng_ust_compat_futex_*' private symbols
Michael Jeanson [Thu, 17 Dec 2020 17:17:51 +0000 (12:17 -0500)] 
Hide new 'lttng_ust_compat_futex_*' private symbols

Change-Id: Ia71c7e07e0b44a69d8252200d2233ed73a6a3bfe
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoHide new 'lttng_ust_context_set_event_notifier_group_provider' private symbol
Michael Jeanson [Tue, 15 Dec 2020 19:29:52 +0000 (14:29 -0500)] 
Hide new 'lttng_ust_context_set_event_notifier_group_provider' private symbol

Change-Id: I1547e0c1b7ce83c1f01316b9e0a2daffaa274bb3
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoHide new 'lttng_bytecode_*' private symbols
Michael Jeanson [Tue, 15 Dec 2020 19:28:11 +0000 (14:28 -0500)] 
Hide new 'lttng_bytecode_*' private symbols

Change-Id: I467f6e8651e91e537301090f882f39d2eede1b84
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoHide new 'lttng_context_init_all' private symbol
Michael Jeanson [Tue, 15 Dec 2020 19:26:12 +0000 (14:26 -0500)] 
Hide new 'lttng_context_init_all' private symbol

Change-Id: Id709930e70f2b612ac93a97ee1091d6f64675d28
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoHide new 'lttng_counter_*' private symbols
Michael Jeanson [Tue, 15 Dec 2020 19:20:59 +0000 (14:20 -0500)] 
Hide new 'lttng_counter_*' private symbols

Change-Id: Ief9322ba0d0d2967f87deb058628e4eeac0d492a
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoHide mew 'lttng_msgpack_*' private symbols
Michael Jeanson [Tue, 15 Dec 2020 19:16:19 +0000 (14:16 -0500)] 
Hide mew 'lttng_msgpack_*' private symbols

Change-Id: Ib5a5aa2f3c84e723972742cb91f78495be086539
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoHide new 'patient_writev' private symbol
Michael Jeanson [Tue, 15 Dec 2020 19:14:04 +0000 (14:14 -0500)] 
Hide new 'patient_writev' private symbol

Change-Id: I708373d94cce6ae99dda82857b927d816edb86a7
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoRemove unused deprecated and backward compatibility fields
Mathieu Desnoyers [Tue, 23 Feb 2021 20:57:06 +0000 (15:57 -0500)] 
Remove unused deprecated and backward compatibility fields

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

3 years agoRemove backward compatibility for liburcu-bp
Mathieu Desnoyers [Tue, 23 Feb 2021 20:48:59 +0000 (15:48 -0500)] 
Remove backward compatibility for liburcu-bp

Now that the soname is bumped, there is no backward compatibility to
keep for tracepoint call sites using liburcu-bp for synchronization,
so this compatibility code can be removed.

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

3 years agoCleanup: Remove deprecated symbols following soname major version bump
Mathieu Desnoyers [Tue, 23 Feb 2021 20:40:42 +0000 (15:40 -0500)] 
Cleanup: Remove deprecated symbols following soname major version bump

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

3 years agoBump soname major to 1
Mathieu Desnoyers [Tue, 23 Feb 2021 20:31:48 +0000 (15:31 -0500)] 
Bump soname major to 1

The event notifier (trigger) feature required a significant rework of
public data structures which should never have been made public in the
first place.

Bump the soname major to 1, which will require applications and
tracepoint providers to rebuild against an updated lttng-ust to use it.

Old applications and tracepoint providers linked against libraries with
major soname 0 should be able to co-exist on the same system.

Now (before the next release) is a good time to eliminate LTTng-UST APIs
which were made public by accident.

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

3 years agoFix: memory and fd leaks in error counter
Mathieu Desnoyers [Tue, 15 Dec 2020 14:30:53 +0000 (09:30 -0500)] 
Fix: memory and fd leaks in error counter

Use a regular pattern for all commands:

If the command callback takes ownership of a pointer or file descriptor,
it sets them to NULL or -1. Therefore, the caller can always try to free
the pointer, or close it if it is greater or equal to 0.

This eliminates memory and fd leaks on error.

Change-Id: I4916920095526c166636c6a432b95fdd6fd1ca4b
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoCleanup: clarify bytecode ownership
Mathieu Desnoyers [Tue, 15 Dec 2020 14:24:30 +0000 (09:24 -0500)] 
Cleanup: clarify bytecode ownership

Use a regular pattern for all commands:

If the command callback takes ownership of a pointer or file descriptor,
it sets them to NULL or -1. Therefore, the caller can always try to free
the pointer, or close it if it is greater or equal to 0.

Change-Id: Ie155d3cff80930271417075d693aa4528decbfc3
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoCleanup: clarify ownership of excluder
Mathieu Desnoyers [Tue, 15 Dec 2020 14:21:10 +0000 (09:21 -0500)] 
Cleanup: clarify ownership of excluder

Use a regular pattern for all commands:

If the command callback takes ownership of a pointer or file descriptor,
it sets them to NULL or -1. Therefore, the caller can always try to free
the pointer, or close it if it is greater or equal to 0.

Change-Id: I3947721841222859f4f4eab15ae94856921eb09b
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoFix: event notifier group: fix fd leak on error
Mathieu Desnoyers [Tue, 15 Dec 2020 14:14:09 +0000 (09:14 -0500)] 
Fix: event notifier group: fix fd leak on error

Use a regular pattern for all commands:

If the command callback takes ownership of a pointer or file descriptor,
it sets them to NULL or -1. Therefore, the caller can always try to free
the pointer, or close it if it is greater or equal to 0.

This eliminates memory and fd leaks on error.

Change-Id: If5181a0c438f2e1ac73e5d4d63d5cde21cc97e52
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoFix: stream fd leaks on error
Mathieu Desnoyers [Tue, 15 Dec 2020 14:01:38 +0000 (09:01 -0500)] 
Fix: stream fd leaks on error

Use a regular pattern for all commands:

If the command callback takes ownership of a pointer or file descriptor,
it sets them to NULL or -1. Therefore, the caller can always try to free
the pointer, or close it if it is greater or equal to 0.

This eliminates memory and fd leaks on error.

Change-Id: I447129ab1672ce4fc6cf3c0baf18dbf27bfcfaf8
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoFix: channel leak on error
Mathieu Desnoyers [Tue, 15 Dec 2020 13:48:59 +0000 (08:48 -0500)] 
Fix: channel leak on error

Use a regular pattern for all commands:

If the command callback takes ownership of a pointer or file descriptor,
it sets them to NULL or -1. Therefore, the caller can always try to free
the pointer, or close it if it is greater or equal to 0.

This eliminates memory and fd leaks on error.

Change-Id: I0f9cba5fc0f4c095c8ec8f3e8970de8a10386876
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoFix: lttng_abi_map_channel should be static
Mathieu Desnoyers [Tue, 15 Dec 2020 14:04:16 +0000 (09:04 -0500)] 
Fix: lttng_abi_map_channel should be static

Change-Id: If0434525f083dc20b50a7628926dadb483d30c88
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoFix: Use default visibility for tracepoint provider symbol
Mathieu Desnoyers [Sun, 27 Dec 2020 19:48:46 +0000 (14:48 -0500)] 
Fix: Use default visibility for tracepoint provider symbol

When building a probe provider `someprobe` with -fvisibility=hidden into
a shared library, the `__tracepoint_provider_someprobe` symbol is hidden,
which does not allow tracepoint instrumentation to link to it.

Fix this by using the "default" visibility attribute.

For a shared library built with -fvisibility=hidden, this changes the
output of nm for that symbol from:

000000000000417c b __tracepoint_provider_someprobe

(local BSS symbol)

to

000000000000417c B __tracepoint_provider_someprobe

(global (external) BSS symbol)

Fixes: #1296
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I308374f6cac58cca86e8eb19c872286a3da21a75

3 years agoFix: configure: support Autoconf 2.70
Jérémie Galarneau [Mon, 11 Jan 2021 17:09:05 +0000 (12:09 -0500)] 
Fix: configure: support Autoconf 2.70

The newly-released autoconf 2.70 introduces a number of breaking
changes [1] and is being rolled-out by some distros.

Amongst those changes, the AC_PROG_CC_STDC macro is marked as obsolete
and was merged into AC_PROG_CC, which we already use. On 2.70, this
results in a warning which we handle as an error.

A version check is added to invoke the AC_PROG_CC_STDC macro only when
running a pre-2.70 version of autoconf, fixing the issue.

Also, the AX_PTHREAD macro makes use of the $as_echo built-in shell
variable which no longer exists in 2.70. A patch was submitted to the
GNU Autoconf archive in March, but there have been no signs of life
given since then [2].

As such, our local copy is updated to the latest version and the patch
(which looks fairly straight-forward / safe) is applied. This should
minimize changes once we go back to an "official" version of the macro.

[1] https://lwn.net/Articles/839395/
[2] https://savannah.gnu.org/patch/?9906

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I2f4eac788638924aa4960b54374d09de73957925

3 years agoFix: event notifier create protocol order issue
Mathieu Desnoyers [Fri, 18 Dec 2020 22:28:04 +0000 (17:28 -0500)] 
Fix: event notifier create protocol order issue

sessiond needs to send the additional command payload before awaiting
reply from UST.

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

3 years agoFix: lttng-ust 2.13 should not try to use notifiers from 2.12 or prior probes
Mathieu Desnoyers [Thu, 17 Dec 2020 19:36:54 +0000 (14:36 -0500)] 
Fix: lttng-ust 2.13 should not try to use notifiers from 2.12 or prior probes

Probe providers built against lttng-ust 2.12 or prior do not implement
the event notifier callback, and accessing desc->u.ext.event_notifier_callback
accesses beyond the size of struct lttng_event_desc.

Therefore, skip those older probe providers from the list of providers
considered for event notifications, and print an error when this
situation is encountered.

Currently, the error reporting of lttng-ust is performed through ERR(),
which is only observable on the console of the application when run with
LTTNG_UST_DEBUG=1.

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

3 years agoFix: UST comm protocol: event notifier command is too large
Mathieu Desnoyers [Thu, 17 Dec 2020 18:51:14 +0000 (13:51 -0500)] 
Fix: UST comm protocol: event notifier command is too large

The event notifier command is larger than the current largest command,
and we don't want to break the protocol between UST and tools
needlessly.

Therefore, pass the struct lttng_ust_event_notifier _after_ struct
ustcomm_ust_msg.

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

3 years agoFix: incorrect parameters passed to vtracelog
Mathieu Desnoyers [Wed, 16 Dec 2020 21:23:53 +0000 (16:23 -0500)] 
Fix: incorrect parameters passed to vtracelog

The vtracelog APIs should be called from the vtracelog instrumentation
rather than the "tracelog" APIs, because it passes a va_list rather than
a variable argument list (...).

This can be verified by tracing the demo program doc/examples/demo-tracelog/demo-vtracelog:

Issue (corrupted trace output):

16:17:26.686073539] (+0.000000530) thinkos lttng_ust_tracelog:TRACE_ERR: { cpu_id = 2 }, { line = 31, file = "demo-vtracelog.c", func = "print_err", _msg_length = 49, msg = "This is a \"\b\" formatted 638975520 error event d68" }

Fixed:

[16:23:33.538189343] (+0.000000600) thinkos lttng_ust_tracelog:TRACE_ERR: { cpu_id = 3 }, { line = 31, file = "demo-vtracelog.c", func = "print_err", _msg_length = 52, msg = "This is a \"mystring test\" formatted 4 error event 42" }

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

3 years agoevent-notifier: Initialize `_notifier_notification` struct to zero
Francis Deslauriers [Mon, 14 Dec 2020 19:56:19 +0000 (14:56 -0500)] 
event-notifier: Initialize `_notifier_notification` struct to zero

Valgrind reports the following use of uninitialized bytes:

  ==2233138== Syscall param writev(vector[...]) points to uninitialised byte(s)
  ==2233138==    at 0x4EA161D: __writev (writev.c:26)
  ==2233138==    by 0x4EA161D: writev (writev.c:24)
  ==2233138==    by 0x489A9EC: patient_writev (in /usr/local/lib/liblttng-ust.so.0.0.0)
  ==2233138==    by 0x48C2D5F: lttng_event_notifier_notification_send (in /usr/local/lib/liblttng-ust.so.0.0.0)
  ==2233138==    by 0x4033F3: __event_notifier_probe__tp___tptest (in /home/frdeso/projets/lttng/tools/tests/utils/testapp/gen-ust-events/gen-ust-events)
  ==2233138==    by 0x401D6E: main (in /home/frdeso/projets/lttng/tools/tests/utils/testapp/gen-ust-events/gen-ust-events)
  ==2233138==  Address 0x1ffeffedda is on thread 1's stack
  ==2233138==  in frame #2, created by lttng_event_notifier_notification_send (???:)
  ==2233138==

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

3 years agoAdd tests/unit/libmsgpack/test_msgpack to gitignore
Mathieu Desnoyers [Fri, 11 Dec 2020 16:05:34 +0000 (11:05 -0500)] 
Add tests/unit/libmsgpack/test_msgpack to gitignore

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

3 years agoustctl.h: use enumeration values 0, 1 for bitness
Mathieu Desnoyers [Fri, 11 Dec 2020 15:55:02 +0000 (10:55 -0500)] 
ustctl.h: use enumeration values 0, 1 for bitness

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

3 years agoust-abi: use 0, 1 for counter enumerations
Mathieu Desnoyers [Fri, 11 Dec 2020 15:51:36 +0000 (10:51 -0500)] 
ust-abi: use 0, 1 for counter enumerations

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoCleanup: ust-abi: BITNESS_{32,64}BITS -> BITNESS_{32,64}
Mathieu Desnoyers [Fri, 11 Dec 2020 15:43:08 +0000 (10:43 -0500)] 
Cleanup: ust-abi: BITNESS_{32,64}BITS -> BITNESS_{32,64}

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

3 years agoCleanup: use tabs in ust-abi.h
Mathieu Desnoyers [Fri, 11 Dec 2020 15:40:22 +0000 (10:40 -0500)] 
Cleanup: use tabs in ust-abi.h

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

3 years agoFix: add struct lttng_event_notifier forward declaration
Mathieu Desnoyers [Thu, 10 Dec 2020 17:39:42 +0000 (12:39 -0500)] 
Fix: add struct lttng_event_notifier forward declaration

Add struct lttng_event_notifier forward declaration in
lttng-tracer-core.h.

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

3 years agoFix: event notifier: notification send should be a callback
Mathieu Desnoyers [Thu, 10 Dec 2020 15:14:43 +0000 (10:14 -0500)] 
Fix: event notifier: notification send should be a callback

Turn notification send into a callback so probes compiled against
lttng-ust 2.13+ but executed in an environment with lttng-ust 2.12 or
prior don't trigger linker error due to missing
lttng_event_notifier_notification_send symbol.

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

3 years agoFix: ust-urcu: allow legacy applications without _LGPL_SOURCE
Mathieu Desnoyers [Thu, 10 Dec 2020 15:07:24 +0000 (10:07 -0500)] 
Fix: ust-urcu: allow legacy applications without _LGPL_SOURCE

Allow legacy instrumented applications without _LGPL_SOURCE to
use the legacy v1 tracepoint registration API without requiring
the liburcu-bp symbols to be present in the symbol table.

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

3 years agoFix: ust-tracepoint: make sure to expand tracepoint provider token
Christophe Bedard [Sun, 21 Jun 2020 17:54:30 +0000 (13:54 -0400)] 
Fix: ust-tracepoint: make sure to expand tracepoint provider token

Using a #defined TRACEPOINT_PROVIDER with the
TRACEPOINT_EVENT_{CLASS,INSTANCE}() macros led to compilation errors,
e.g.:

gcc -I/home/chris/lttng-mwe/app/../lib -c myapp.c
gcc -o myapp myapp.o -L/home/chris/lttng-mwe/app/../lib -Wl,-rpath=/home/chris/lttng-mwe/app/../lib -lmytps -ldl
/usr/bin/ld: /home/chris/lttng-mwe/app/../lib/libmytps.so: undefined reference to `__tracepoint_provider_mismatch_TRACEPOINT_PROVIDER'
collect2: error: ld returned 1 exit status
make: *** [Makefile:9: myapp] Error 1

Use intermediate TRACEPOINT_EVENT_{CLASS,INSTANCE}() macros to make sure
that the tracepoint provider name token gets expanded.

[ Mathieu: Adapt event notifier probes as well. ]

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

3 years agoFix: notifier: use store-release/load-acquire for error counter
Mathieu Desnoyers [Wed, 9 Dec 2020 14:30:23 +0000 (09:30 -0500)] 
Fix: notifier: use store-release/load-acquire for error counter

The "record_error" operation is executed concurrently with setting the
error counter in the notifier group without locking, so we need to
explicitly provide existance guarantees.

The only visible transition is from NULL -> !NULL, because the only
situation reverting the error counter back to NULL is on destruction of
the notification group, after an RCU synchronisation guarantees that no
record_error can observe this pointer anymore.

Use the stronger "cmm_smp_mb()" to provide store-release/load-acquire
semantics because the explicit store-release and load-acquire are not
implemented in the CMM model yet.

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

3 years agoFix: event-notifier: Groups may not have an error counter
Mathieu Desnoyers [Wed, 9 Dec 2020 14:15:46 +0000 (09:15 -0500)] 
Fix: event-notifier: Groups may not have an error counter

Issue
=====
If no error counter is attached to an event notifier group, calling
the `record_error()` function leads to a NULL pointer dereference.

Solution
========
Check if the error_counter field is allocated before dereferencing it.

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

3 years agoustctl: Initialize counter_conf struct to zero
Francis Deslauriers [Tue, 8 Dec 2020 23:28:32 +0000 (18:28 -0500)] 
ustctl: Initialize counter_conf struct to zero

Issue
=====
This struct is not initialize explicitly and is copied and sent through
a Unix socket to the application. This means we are currently sending
uninitialized data.

Valgrind reports the following:
  ==939806== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s)
  ==939806==    at 0x519412D: __libc_sendmsg (sendmsg.c:28)
  ==939806==    by 0x519412D: sendmsg (sendmsg.c:25)
  ==939806==    by 0x514D2BF: ustcomm_send_unix_sock (in /usr/local/lib/liblttng-ust-ctl.so.4.0.0)
  ==939806==    by 0x514C0BC: ustctl_send_counter_data_to_ust (in /usr/local/lib/liblttng-ust-ctl.so.4.0.0)
  ==939806==    by 0x4A0B14: send_counter_data_to_ust (event-notifier-error-accounting.c:237)
  ==939806==    by 0x4A046D: event_notifier_error_accounting_register_app (event-notifier-error-accounting.c:311)
  ==939806==    by 0x4B0831: ust_app_setup_event_notifier_group (ust-app.c:3956)
  ==939806==    by 0x495603: thread_dispatch_ust_registration (dispatch.c:394)
  ==939806==    by 0x487552: launch_thread (thread.c:66)
  ==939806==    by 0x5188608: start_thread (pthread_create.c:477)
  ==939806==    by 0x52E2292: clone (clone.S:95)
  ==939806==  Address 0x750fb8e is 46 bytes inside a block of size 228 alloc'd
  ==939806==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==939806==    by 0x514988C: ustctl_duplicate_ust_object_data (in /usr/local/lib/liblttng-ust-ctl.so.4.0.0)
  ==939806==    by 0x4A0426: event_notifier_error_accounting_register_app (event-notifier-error-accounting.c:307)
  ==939806==    by 0x4B0831: ust_app_setup_event_notifier_group (ust-app.c:3956)
  ==939806==    by 0x495603: thread_dispatch_ust_registration (dispatch.c:394)
  ==939806==    by 0x487552: launch_thread (thread.c:66)
  ==939806==    by 0x5188608: start_thread (pthread_create.c:477)
  ==939806==    by 0x52E2292: clone (clone.S:95)

Fix
===
Initialize it to zero.

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

3 years agocleanup: use <sys/syscall.h>
Michael Jeanson [Fri, 20 Nov 2020 21:05:25 +0000 (16:05 -0500)] 
cleanup: use <sys/syscall.h>

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

3 years agoport: fix futex_async wrapper namespacing on FreeBSD
Michael Jeanson [Mon, 30 Nov 2020 21:24:25 +0000 (16:24 -0500)] 
port: fix futex_async wrapper namespacing on FreeBSD

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

3 years agoport: use ust-endian.h compat
Michael Jeanson [Mon, 30 Nov 2020 21:21:08 +0000 (16:21 -0500)] 
port: use ust-endian.h compat

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

3 years agoFix: event-notifier: not propagating error counter indexes
Francis Deslauriers [Fri, 4 Dec 2020 22:39:37 +0000 (17:39 -0500)] 
Fix: event-notifier: not propagating error counter indexes

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

3 years agofix: undefined symbols for tracepoints in lgpl source
Michael Jeanson [Tue, 1 Dec 2020 16:02:41 +0000 (11:02 -0500)] 
fix: undefined symbols for tracepoints in lgpl source

Move the new internal 'urcu-ust' urcu flavor symbols to a separate
library named 'liblttng-ust-common.so' and link 'liblttng-ust.so' and
'liblttng-ust-tracepoint.so' on it.

Add this common library to the pkgconfig file which should handle the
transition for client code using it in its build system.

LGPL_SOURCE client code which doesn't use pkgconfig in its build system
will need to link with '-llttng-ust-common' instead of '-lurcu-bp' like
prior ust versions.

Change-Id: I807f997a2a94cb4f8d1bdf72002c1ae1b9fedf8d
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoRemove runtime dependency on liburcu shared objects
Mathieu Desnoyers [Wed, 11 Nov 2020 22:28:06 +0000 (17:28 -0500)] 
Remove runtime dependency on liburcu shared objects

Remove the runtime dependency on:

- liblurcu-bp.so
- liblurcu-cds.so
- compat futex code.

By integrating those into the lttng-ust project.

For rculfhash, only the minimum pieces needed by lttng-ust are
integrated (no auto-resize, no accounting).

lttng-ust still requires liburcu at build time for header dependencies.

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

3 years agoFix: handle default switch case with -EINVAL in __lttng_counter_add
Mathieu Desnoyers [Mon, 30 Nov 2020 19:09:15 +0000 (14:09 -0500)] 
Fix: handle default switch case with -EINVAL in __lttng_counter_add

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

3 years agoBump LTTNG_UST_EVENT_NOTIFIER_PADDING to 32 bytes
Francis Deslauriers [Fri, 27 Nov 2020 16:02:45 +0000 (11:02 -0500)] 
Bump LTTNG_UST_EVENT_NOTIFIER_PADDING to 32 bytes

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

3 years agoFix: memory leak in apply_context_reloc
Mathieu Desnoyers [Thu, 26 Nov 2020 20:50:45 +0000 (15:50 -0500)] 
Fix: memory leak in apply_context_reloc

Fixes commit b77aaa1b8edf2 ("Decouple `struct lttng_session` from filter code")

lttng_ust_add_app_context_to_ctx_rcu should be able to update the
session ctx field and not only the local ctx pointer.

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

3 years agoFix: libcounter bad compare
Mathieu Desnoyers [Thu, 26 Nov 2020 20:38:19 +0000 (15:38 -0500)] 
Fix: libcounter bad compare

Identified by Coverity.

>>>     CID 1437325:  Incorrect expression  (BAD_COMPARE)
>>>     Comparing pointer "counter_cpu_fds" against "NULL" using anything besides "==" or "!=" is likely to be incorrect.

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

3 years agoFix: remove dead code in msgpack.c
Mathieu Desnoyers [Thu, 26 Nov 2020 20:35:31 +0000 (15:35 -0500)] 
Fix: remove dead code in msgpack.c

Identified by Coverity. Comparing unsigned types < 0 is never true.

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

3 years agoFix: counter: cast UINT*_MAX to 64-bit signed type before negative
Mathieu Desnoyers [Thu, 26 Nov 2020 20:29:01 +0000 (15:29 -0500)] 
Fix: counter: cast UINT*_MAX to 64-bit signed type before negative

(long long)-UINT32_MAX leads to value 1 which is not what we expect.
This is due to implicit type promotion from unsigned to signed 32-bit
integer.

Apply this to 8-bit and 16-bit types as well even though they are
not affected by this issue to keep things regular.

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

3 years agoFix: libcounter: use LTTNG_UST_ALIGN
Mathieu Desnoyers [Thu, 26 Nov 2020 19:40:04 +0000 (14:40 -0500)] 
Fix: libcounter: use LTTNG_UST_ALIGN

ALIGN() on FreeBSD does not expect the same number of arguments.

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

3 years agoFix: ust-abi: clarify which command is used on which object descriptor
Mathieu Desnoyers [Thu, 26 Nov 2020 18:51:46 +0000 (13:51 -0500)] 
Fix: ust-abi: clarify which command is used on which object descriptor

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

3 years agoImplement event notifier error counter
Francis Deslauriers [Mon, 12 Oct 2020 16:24:49 +0000 (12:24 -0400)] 
Implement event notifier error counter

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

3 years agoImplement libcounter
Mathieu Desnoyers [Fri, 4 Sep 2020 15:29:47 +0000 (11:29 -0400)] 
Implement libcounter

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

3 years agoImplement capturing payload on event notifiers
Francis Deslauriers [Mon, 6 Apr 2020 18:59:08 +0000 (14:59 -0400)] 
Implement capturing payload on event notifiers

This commit allows the user to request a subset of payload fields of the
tracepoint to be captured when a event notifier is fired and sent back
the session daemon as part of the notification.

Captures are really similar to filter in the way they work. Like with
filters, the sessiond attaches to a event notifier one bytecode program
per field it wants to capture using the following function:

  int ustctl_set_capture(int sock, struct lttng_ust_capture_bytecode *bytecode,
         struct lttng_ust_object_data *obj_data);

The capture bytecode program is then validated and specialized for its
target tracepoint just like filter bytecode programs.

The major difference between filters and captures is with what they
return. Filters can only return _RECORD or _DISCARD for match and
no-match respectively. Captures also need to return captured values. For
this reason, we added an output parameter to the capture interpreter
function that value can be extracted.

Here is the signature of the capture interpreter function:
  uint64_t lttng_bytecode_capture_interpret(void *capture_data,
         const char *capture_stack_data,
         void *output)

When comes the time to send the notification, every capture bytecode
program is executed in turns and its output value is recorded to the
capture buffer to be sent back to the sessiond.

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

3 years agobytecode: handle all integer types of dynamic contexts
Francis Deslauriers [Tue, 26 May 2020 15:02:19 +0000 (11:02 -0400)] 
bytecode: handle all integer types of dynamic contexts

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

3 years agobytecode: initialize all contexts on event notifier group creation
Francis Deslauriers [Fri, 22 May 2020 22:02:06 +0000 (18:02 -0400)] 
bytecode: initialize all contexts on event notifier group creation

Rename `lttng_session_context_init()` to `lttng_context_init_all()` so
to reuse the code.

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

3 years agobytecode: Add `OBJECT_TYPE_{UN,}SIGNED_ENUM` type
Francis Deslauriers [Thu, 7 May 2020 20:41:18 +0000 (16:41 -0400)] 
bytecode: Add `OBJECT_TYPE_{UN,}SIGNED_ENUM` type

Enumerations are currently converted to their integer counterparts as
soon as they are encountered.

In order to use them in captures, we need to differentiate the
enumerations from integers for the entirety of the interpretation.

This commit adds the `OBJECT_TYPE_SIGNED_ENUM` and
`OBJECT_TYPE_UNSIGNED_ENUM` to keep track of these objects.

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

3 years agoGeneralize `lttng_enabler_link_bytecode()` bytecode list
Francis Deslauriers [Mon, 27 Apr 2020 21:21:25 +0000 (17:21 -0400)] 
Generalize `lttng_enabler_link_bytecode()` bytecode list

So it can be used for both filter and capture bytecode runtimes

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

3 years agoCleanup: rename `_lttng_filter_link_bytecode()` -> `link_bytecode()`
Francis Deslauriers [Mon, 27 Apr 2020 21:06:10 +0000 (17:06 -0400)] 
Cleanup: rename `_lttng_filter_link_bytecode()` -> `link_bytecode()`

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

3 years agoAdd `interpreter_funcs` to `lttng_bytecode_runtime`
Francis Deslauriers [Mon, 27 Apr 2020 19:11:38 +0000 (15:11 -0400)] 
Add `interpreter_funcs` to `lttng_bytecode_runtime`

Background
==========
The current filter interpreter function signature looks like this:

  uint64_t lttng_bytecode_filter_interpret(void *filter_data,
                  const char *filter_stack_data);

The upcoming capture interpreter function will need an output parameter
to extract the top of stack register. It will look like this:

  uint64_t lttng_bytecode_capture_interpret(void *capture_data,
                  const char *capture_stack_data,
                  struct output_register *output);

Problems
========
We can't reuse the same function pointer field in `struct
lttng_bytecode_runtime` as the two interpreter functions will have
different signatures.

We can't change the signature of this existing filter function because
it's used in the tracepoint probes.

Solution
========
Add a union of callbacks to hold both interpreter functions. This also
doesn't change the layout of the `struct lttng_bytecode_runtime`
objects.

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

3 years agobytecode: rename `lttng_filter_sync_state()` -> `lttng_bytecode_filter_sync_state()`
Francis Deslauriers [Mon, 27 Apr 2020 21:31:50 +0000 (17:31 -0400)] 
bytecode: rename `lttng_filter_sync_state()` -> `lttng_bytecode_filter_sync_state()`

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

3 years agoImplement enum and sequence capture serialization functions
Francis Deslauriers [Wed, 15 Apr 2020 20:45:07 +0000 (16:45 -0400)] 
Implement enum and sequence capture serialization functions

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

3 years agoExtract `handle_bytecode_recv()` function
Francis Deslauriers [Mon, 13 Apr 2020 19:25:20 +0000 (15:25 -0400)] 
Extract `handle_bytecode_recv()` function

A lot of this code will be reused for capture bytecode.

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

3 years agoRename filter bytecode types and files
Francis Deslauriers [Wed, 15 Apr 2020 15:03:53 +0000 (11:03 -0400)] 
Rename filter bytecode types and files

File renames:
- filter-bytecode.h -> bytecode.h
- lttng-filter-interpreter.c -> lttng-bytecode-interpreter.c
- lttng-filter-specialize.c -> lttng-bytecode-specialize.c
- lttng-filter-validator.c -> lttng-bytecode-validator.c
- lttng-filter.c -> lttng-bytecode.c
- lttng-filter.h -> lttng-bytecode.h

Function renames:
- `lttng_filter_interpret_bytecode_false()` -> `lttng_bytecode_filter_interpret_false()`
- `lttng_filter_interpret_bytecode()` -> `lttng_bytecode_filter_interpret()`
- `lttng_filter_specialize_bytecode()` -> `lttng_bytecode_specialize()`
- `lttng_filter_validate_bytecode()` -> `lttng_bytecode_validate()`

Type renames
- `filter_opcode_t` to `bytecode_opcode_t`

Enum renames:
- `enum filter_op` to `enum bytecode_op`
  - `FILTER_OP_*` to `BYTECODE_OP_*`
- `enum lttng_filter_ret` -> `enum lttng_bytecode_interpreter_ret`
  - `LTTNG_FILTER_DISCARD` -> `LTTNG_INTERPRETER_DISCARD`
  - `LTTNG_FILTER_RECORD_FLAG` -> `LTTNG_INTERPRETER_RECORD_FLAG`

Define renames:
- `FILTER_STACK_EMPTY` -> `INTERPRETER_STACK_EMPTY`
- `FILTER_STACK_LEN`-> `INTERPRETER_STACK_LEN`
- `FILTER_MAX_DATA_LEN` -> `BYTECODE_MAX_DATA_LEN`

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

3 years agobytecode: generalize `struct lttng_ust_filter_bytecode_node`
Francis Deslauriers [Mon, 13 Apr 2020 16:24:09 +0000 (12:24 -0400)] 
bytecode: generalize `struct lttng_ust_filter_bytecode_node`

Rename `struct lttng_ust_filter_bytecode_node` to `struct
lttng_ust_bytecode_node` so it can be used by capture bytecode as well.

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

3 years agoCleanup: Rename filter functions/fields to mention "filter"
Francis Deslauriers [Tue, 17 Mar 2020 14:55:43 +0000 (10:55 -0400)] 
Cleanup: Rename filter functions/fields to mention "filter"

This will be cleaner when we introduce the capture bytecode functions
and fields.

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

3 years agoAdd `patient_writev()` function
Francis Deslauriers [Mon, 30 Mar 2020 21:45:15 +0000 (17:45 -0400)] 
Add `patient_writev()` function

This function wraps the `writev()` function to make it EINTR-aware.

We are going to use this function to send multiple structs in a single
call when dealing with event notifier captures.

This function also supports partial writes even though this should never
happen with event notifier notification. We assert that the data sent is less
then PIPE_BUF in size so to take advantage of the POSIX guarantee for
write atomicity as explained in pipe(7).

The implementation was inspired by this stackoverflow.com post:
https://stackoverflow.com/questions/5853675/techniques-for-handling-short-reads-writes-with-scatter-gather

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

3 years agoAdd `libmsgpack` for serializing captures
Francis Deslauriers [Fri, 20 Mar 2020 16:12:30 +0000 (12:12 -0400)] 
Add `libmsgpack` for serializing captures

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

3 years agobytecode: allow interpreter to return any type
Francis Deslauriers [Mon, 27 Apr 2020 22:02:44 +0000 (18:02 -0400)] 
bytecode: allow interpreter to return any type

The bytecode interpreter when used by capture bytecode needs to return
types other than an integer or dynamic type.

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

3 years agobytecode: propagate `rev_bo` of element
Francis Deslauriers [Mon, 27 Apr 2020 21:59:58 +0000 (17:59 -0400)] 
bytecode: propagate `rev_bo` of element

When specializing and executing bytecode.

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

3 years agobytecode: set register type to `REG_PTR` even if not used
Francis Deslauriers [Tue, 14 Apr 2020 21:07:23 +0000 (17:07 -0400)] 
bytecode: set register type to `REG_PTR` even if not used

There was no need to set the field when using filter as the next
instruction would assume that the top of stack is a `REG_PTR`.

With the upcoming capture feature, we need to ensure this field is
consistent for extraction.

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

3 years agoAdd `lttng_bytecode_interpret_format_output()` for top of stack extraction
Francis Deslauriers [Wed, 18 Mar 2020 21:24:53 +0000 (17:24 -0400)] 
Add `lttng_bytecode_interpret_format_output()` for top of stack extraction

This new static function will be used to extract the register on the top of
stack after the execution of the bytecode. This is currently not used by the
filter bytecode but will be used by capture bytecode in the future.

The returned value is saved in a tagged union struct named `struct
lttng_interpreter_output` and can be used by the caller of the interpreter
function.

Typically, this struct will be allocated on the stack to avoid dynamic
allocation inside the tracepoint probes.

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

3 years agobytecode: add `REG_U64` interpreter register type
Mathieu Desnoyers [Mon, 23 Mar 2020 13:57:56 +0000 (09:57 -0400)] 
bytecode: add `REG_U64` interpreter register type

This will be used by the capture bytecode for unsigned integer
extraction.

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

3 years agoImplement event notifier
Francis Deslauriers [Fri, 29 Nov 2019 21:35:45 +0000 (16:35 -0500)] 
Implement event notifier

The event notifier feature allows the user to get notify through a pipe
that an callsite was reached. It's really similar to a regular UST event
in that firing can be controlled by filters and exclusions. It diverges
because firing a event notifier does not end up writing to the tracing
buffers. In fact, event notifiers live outside of any sessions (i.e. no
session is needed).

Definitions
===========
A `Event notifier` is defined as an event description (event name, log level,
etc.) and a unique event notifier token.

A `Event notifier group` is a set of event notifiers sharing the same
pipe to the liblttng-ust-ctl user.

Sequence of operations
======================
  event_notifier_group_handle = ustctl_create_event_notifier_group(notification_fd)
  event_notifier_handle = ustctl_create_event_notifier(event_notifier_group_handle, event_notifier_id);
  ustctl_set_filter(event_notifier_handle, filter)
  ustctl_set_exclusion(event_notifier_handle, exclusion)
  ustctl_enable(event_notifier_handle)
  ...
  ustctl_disable(event_notifier_handle)
  ustctl_release_object(event_notifier_handle)
  ustctl_release_object(event_notifier_group_handle)

Highlevel changes
=================
- Add the event notifier probe generation macros,
- Add event notifier enabling/disabling machinery,
- Add event notifier filter machinery,
- Add event notifier exclusion machinery,
- Expose ABI structures
- Expose ABI enums
- Expose ABI cmds
- Expose ustctl functions

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

3 years agoAdd token to `struct lttng_ust_event`
Francis Deslauriers [Tue, 17 Nov 2020 23:15:14 +0000 (18:15 -0500)] 
Add token to `struct lttng_ust_event`

This token is provided by the user when registering an event rule to
UST. It is going to used to identify messages from event notifiers in
the upcoming event notifier feature.

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

3 years agoCreate `_for_each` function to unregister probe providers
Francis Deslauriers [Tue, 17 Dec 2019 17:06:15 +0000 (12:06 -0500)] 
Create `_for_each` function to unregister probe providers

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

3 years agoCleanup: extract function to borrow hashlist bucket
Francis Deslauriers [Tue, 3 Dec 2019 22:52:36 +0000 (17:52 -0500)] 
Cleanup: extract function to borrow hashlist bucket

This is going to reused by the event notifier system.

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

3 years agoDecouple `struct lttng_event` from filter code
Francis Deslauriers [Fri, 29 Nov 2019 21:35:01 +0000 (16:35 -0500)] 
Decouple `struct lttng_event` from filter code

The filter infrastructure will be used by event notifiers and decoupling
this will allow for massive code reuse.

Of all `struct lttng_event`'s fields, filter code needs:
  1. The `const struct lttng_event_desc *desc` field,
  2. The `struct cds_list_head bytecode_runtime_head` list.

These fields are used to do the tracepoint field relocation
(`apply_field_reloc()` and `specialize_event_payload_lookup()`).

Given that only these two fields are needed, we can pass them directly
to these functions.

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

3 years agoCleanup: hide `lttng_ust_{filter_bytecode,excluder}_node`
Francis Deslauriers [Tue, 28 Apr 2020 20:19:24 +0000 (16:19 -0400)] 
Cleanup: hide `lttng_ust_{filter_bytecode,excluder}_node`

Those two structs are not used in the external API so we better hide
them in internal files.

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

3 years agoAbstract base `lttng_enabler` to support other types of enablers
Francis Deslauriers [Fri, 22 Nov 2019 21:44:28 +0000 (16:44 -0500)] 
Abstract base `lttng_enabler` to support other types of enablers

Future commits will introduce the concept of event notifier enablers
which are similar to the event enablers already present with a few
differences.

To prepare the ground, this commit moves event dependent fields from the
`struct lttng_enabler` struct to a specialized `struct
lttng_event_enabler`.

The `lttng_enabler_*()` functions cannot be renamed because they are
currently exported. These are only used internally, so we can stop using
them and add new `lttng_event_enabler_*()` functions marked as hidden
which won't be exported (see liblttng-ust/ust-events-internal.h).
`lttng_enabler_*()` functions are kept in the ust-events.h file but
moved to the bottom of the file with other deprecated symbols.

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

3 years agoRename `enum lttng_enabler_type` to `_format_type`
Francis Deslauriers [Fri, 13 Dec 2019 21:57:45 +0000 (16:57 -0500)] 
Rename `enum lttng_enabler_type` to `_format_type`

Currently, the `_type` field is used to express in what format the event
rule was provided, either the full event name or a glob pattern.

Future commit will introduce the concept event notifier enabler that
will be along side regular event enabler.
The use of the `_type` suffix might become confusing with this new class
of enablers.

So this commit rename the  `_type` field to `_format_type`.

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

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

This page took 0.047005 seconds and 4 git commands to generate.