deliverable/lttng-ust.git
3 years agocleanup: use <sys/syscall.h> liburcu-removal
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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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>
3 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

3 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

3 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

3 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>
3 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>
3 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

3 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

3 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>
3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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>
3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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>
3 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

3 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

3 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>
3 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>
3 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

3 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

3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
This page took 0.045718 seconds and 5 git commands to generate.