2 years agoFix: sessiond: assertion fails when getting name of trigger
Jérémie Galarneau [Wed, 3 Feb 2021 22:00:06 +0000 (17:00 -0500)] 
Fix: sessiond: assertion fails when getting name of trigger

Left-over debug code assumes that a trigger is named and logs
registration/unregistration failures as errors, resulting in a spammy
sessiond output.

Reduce the logging verbodity of those statements to DBG and handle
unnamed triggers.

Signed-off-by: Jérémie Galarneau <>
Change-Id: I74a90150ec2b0914784fb187517025a9a3019cfb

2 years agosessiond: client commands: print command enum as a string
Francis Deslauriers [Thu, 22 Oct 2020 15:32:15 +0000 (11:32 -0400)] 
sessiond: client commands: print command enum as a string

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I10ce8911372a6926b7aa234b9d1595a5052d4a0e

2 years agoCleanup: add `notification_command_type_str()`
Francis Deslauriers [Mon, 14 Dec 2020 22:37:42 +0000 (17:37 -0500)] 
Cleanup: add `notification_command_type_str()`

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I7a05c8055f2bb2e09e274a7f4d8f9ecd3e5509fc

2 years agoFix: lttng-sessiond: Taking sizeof of a pointer
Francis Deslauriers [Wed, 13 Jan 2021 17:04:49 +0000 (12:04 -0500)] 
Fix: lttng-sessiond: Taking sizeof of a pointer

Reported by clang-tidy:
  bugprone-sizeof-expression: Suspicious usage of `sizeof(A*)`

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Ie3069ad3d81d460646c71923f0f396cf18980540

2 years agoUse MT-safe strtok_r in spawn viewer library helper
Mathieu Desnoyers [Wed, 3 Feb 2021 15:26:03 +0000 (10:26 -0500)] 
Use MT-safe strtok_r in spawn viewer library helper

Even though its current callers are all in single-threaded context
(lttng view and lttng-crash commands), it is a good practice to use
MT-safe APIs in library functions, in case those are ever used within a
multithreaded context in the future.

Signed-off-by: Mathieu Desnoyers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: If419fd24b3bf6532f2c75a728a9ec395e365c626

2 years agoFix: use MT-safe strtok_r in multithreaded context
Mathieu Desnoyers [Wed, 3 Feb 2021 15:21:42 +0000 (10:21 -0500)] 
Fix: use MT-safe strtok_r in multithreaded context

append_list_to_probes uses the non-multithread-safe "strtok" while in
multithreaded context.

It is called by modprobe_lttng_data(), which is called from

init_kernel_tracer is used from main() after other threads are created,
and also from process_client_msg() when a user attempts to interact with
the kernel domain if the kernel tracer has not yet been successfully

Fixed by using the MT-safe strtok_r() instead.

Signed-off-by: Mathieu Desnoyers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Ic3f81551b8508451e0f9733c5de56a4d4407b813

2 years agosessiond: synchronize event notifiers for UST tracers and the kernel tracer
Jonathan Rajotte [Fri, 10 Jan 2020 20:29:52 +0000 (15:29 -0500)] 
sessiond: synchronize event notifiers for UST tracers and the kernel tracer

Synchronize event notifiers when registering or unregistering a trigger
which has a condition that implies the use of an event notifier.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Id2cb2a93c0c6be9f44f9dcd07b9803acbcb6b3c3
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

2 years agoFix: sessiond: ust-app: account for the event notification pipes fds
Jérémie Galarneau [Thu, 21 Jan 2021 17:30:38 +0000 (12:30 -0500)] 
Fix: sessiond: ust-app: account for the event notification pipes fds

The file descriptors of the event notifier group's event pipe are not
accounted by the lttng_fd_*() module, which tracks the use the file
descriptors by the userspace tracer.

Add the necessary lttng_fd_*() uses to account for the pipe's file
descriptors over their lifetime.

Signed-off-by: Jérémie Galarneau <>
Change-Id: Ib24b4c2934655573965f06fa7998859335053083

2 years agosessiond: ust-app: close the event notifier group's pipe write-end
Jérémie Galarneau [Thu, 21 Jan 2021 17:28:59 +0000 (12:28 -0500)] 
sessiond: ust-app: close the event notifier group's pipe write-end

The write-end of the event notifier group's pipe can be closed after
it is passed to the application. This reduces the amount of file
descriptors used by the session daemon on a per-application basis.

Signed-off-by: Jérémie Galarneau <>
Change-Id: Ic8f016bc4cdd3dce2d7ea8ac9cccb53e3b69c5b0

2 years agosessiond: notification: receive incoming notifications from tracers
Jonathan Rajotte [Tue, 31 Mar 2020 18:33:18 +0000 (14:33 -0400)] 
sessiond: notification: receive incoming notifications from tracers

Receive and discard notifications received by tracers. This simply puts
in place the basic tracer notification reception mechanisms.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I3d94431051015c69785ec256095135746e3972ce

2 years agosessiond: unregister triggers during clean-up on shutdown
Jérémie Galarneau [Tue, 26 Jan 2021 23:15:15 +0000 (18:15 -0500)] 
sessiond: unregister triggers during clean-up on shutdown

Triggers should be unregistered on sessiond clean-up. This allows the
kernel and user space tracer control code to assume that all event
notifiers have already been destroyed on tear-down and that any
remaining event notifier is the result of a leak.

Moreover, it simplifies the tear down as it is simply handled in the
way a regular trigger unregistration would be.

Signed-off-by: Jérémie Galarneau <>
Change-Id: Ie821c5162c2fbe9c3d6705f464224c50ae9df1c8

2 years agosessiond: trigger: decouple reception of triggers from commands
Jérémie Galarneau [Tue, 26 Jan 2021 23:13:11 +0000 (18:13 -0500)] 
sessiond: trigger: decouple reception of triggers from commands

The trigger to register/unregister is received in the body of the
register and unregister commands.

Isolate the reception of the trigger from the command payload in
a util in client.c (receive_lttng_trigger()) which allows the commands
to only operate on fully-formed objects.

Signed-off-by: Jérémie Galarneau <>
Change-Id: Iaee6c54590e259ce053d368494ff0c8b356a36a1

2 years agosessiond: clean-up: trigger to unregister can be 'const'
Jérémie Galarneau [Tue, 26 Jan 2021 21:14:33 +0000 (16:14 -0500)] 
sessiond: clean-up: trigger to unregister can be 'const'

Signed-off-by: Jérémie Galarneau <>
Change-Id: Ic2a731b36467f898402ff5e19e329e5734e2da69

2 years agoFix: sessiond: double free on duplicate removal of tracer source
Jérémie Galarneau [Thu, 28 Jan 2021 19:39:37 +0000 (14:39 -0500)] 
Fix: sessiond: double free on duplicate removal of tracer source

An unrelated bug (fixed in a separate commit) can cause an event source
to be removed from the notification thread's monitored sources twice.

The event source removal starts by searching for the source to remove
based on the source pipe's read-end fd number and assumes that it will
always be found. After iterating on the list, an assertion that
`source_element` is not NULL is done in the assumption that NULL would
mean that the source was not found.

This is incorrect since, if the source is not found, `source_element`
will simply point to the last element of the list, causing the assertion
to succeed.

Then, the last source in the list is torn down, but not removed from the
list. This causes that event source to be free'd twice when it is
actually removed later on.

The assumption that an event source can always be found does not hold
for the moment. For instance, when an application can exit, closing its
end of the notification pipe, the notification thread could wake-up
before the application management thread.

In that case, the notification thread will react to the event by
removing the application's source from its monitored sources. Then, when
the application management thread wakes up, it will ask the notification
thread to (again) remove the event source, which will fail as it will
not be found.

Signed-off-by: Jérémie Galarneau <>
Change-Id: I7b5ebf90b868faded47a4e9675e01e1fb2b77a70

2 years agosessiond: kernel triggers: add infrastructure to create event notifiers
Jonathan Rajotte [Mon, 23 Mar 2020 21:09:18 +0000 (17:09 -0400)] 
sessiond: kernel triggers: add infrastructure to create event notifiers

Add the infrastructure to initialize the kernel tracer event notifier
group and individual event notifiers from event rules issued from

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I20127f655018260e45566d09d11c2852cd3b3f97
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

2 years agokernel: event notifier: kernel-ctl interface
Jonathan Rajotte [Mon, 23 Mar 2020 21:03:37 +0000 (17:03 -0400)] 
kernel: event notifier: kernel-ctl interface

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Idd3983c594ffecff0a20b71b7cd3d297e77446a1
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

2 years agokernel: load lttng-ring-buffer-event-notifier-client module
Jonathan Rajotte [Mon, 3 Feb 2020 19:03:25 +0000 (14:03 -0500)] 
kernel: load lttng-ring-buffer-event-notifier-client module

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I9449e895b1eb88eb6db47dc3f8eb2864a2eb816d
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

2 years agosessiond: kernel: make modules required/optional property per-module
Jérémie Galarneau [Tue, 19 Jan 2021 19:56:49 +0000 (14:56 -0500)] 
sessiond: kernel: make modules required/optional property per-module

Modules are considered required or optional based on their
category (control or data probes). Make the load policy per-probe since
optional control probes will be introduced in a follow-up change.

No change in behaviour is intended by this change.

Signed-off-by: Jérémie Galarneau <>
Change-Id: I0048b60bee3969d2fa2b9ed94b6fb24d3b5ae659

2 years agoFix: add rcu_barrier() after sessiond_cleanup()
Francis Deslauriers [Mon, 14 Dec 2020 22:30:12 +0000 (17:30 -0500)] 
Fix: add rcu_barrier() after sessiond_cleanup()

This is to ensure that tracer event source (event notifier socket) are
removed from the notification thread list.

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I2ca8f72c023132c341193bf626c0dac20b89e1f2

2 years agoust-app: implement event notifier support
Jonathan Rajotte [Mon, 13 Jan 2020 18:59:39 +0000 (13:59 -0500)] 
ust-app: implement event notifier support

Event notifier support mostly resemble how it is done for regular event.

We end up implementing ust_app_synchronize_event_notifier_rules which is
used in a similar fashion to ust_app_synchronize minus the dependency on
a ltt_ust_session session.

The lttng_event_rule_generate_bytecode interface is modified to return a
status code since it could fail (return NULL) for reasons other than not
having exclusions (e.g. an allocation failure).

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I2cde2b3d2530e2114bff99b1b26ac6d83f575ad9
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

2 years agoFix: liblttng-ctl: unreported truncations when copying strings
Jérémie Galarneau [Tue, 12 Jan 2021 22:41:54 +0000 (17:41 -0500)] 
Fix: liblttng-ctl: unreported truncations when copying strings

gcc 10.2 reports a large number of string truncation warning in
liblttng-ctl. Replace the uses of lttng_ctl_copy_string() util by
lttng_strncpy() (handling the null source case when applicable) and
report the truncations when they occur.

Example gcc warning:
  lttng-ctl.c:86:3: warning: ‘strncpy’ output may be truncated copying 254 bytes from a string of length 254 [-Wstringop-truncation]

Signed-off-by: Jérémie Galarneau <>
Change-Id: Icca5f4c2490c6796b451999d7694db8597bae719

2 years agoFix: sessiond: event name truncation during listing
Jérémie Galarneau [Tue, 12 Jan 2021 22:08:56 +0000 (17:08 -0500)] 
Fix: sessiond: event name truncation during listing

The use of strncpy can lead to silently-truncated event names. Replace
its use by the internal lttng_strncpy which fails on truncation.

Signed-off-by: Jérémie Galarneau <>
Change-Id: I65d6bd46208dc7b62a83e4600a52a6669fd99d55

2 years agoClean-up: replace erroneous of empty parameter list by void
Jérémie Galarneau [Tue, 12 Jan 2021 20:36:00 +0000 (15:36 -0500)] 
Clean-up: replace erroneous of empty parameter list by void

Signed-off-by: Jérémie Galarneau <>
Change-Id: I951feeed92b346e79e34bec45a14f8b226283ae4

2 years agosessiond: setup event notifier group for registering app
Jonathan Rajotte [Fri, 10 Jan 2020 21:05:48 +0000 (16:05 -0500)] 
sessiond: setup event notifier group for registering app

Create a pipe for each application and setup an event notifier group
associated with that pipe. Transfer the write side to the app, and
transfer the read side to the notification thread as an application
event source ([...]_ADD_TRACER_EVENT_SOURCE)

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I3e4aab84e3270ddef1f50f72f946a4d80b3f36e0
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

2 years agoFix: configure: support Autoconf 2.70
Jérémie Galarneau [Mon, 11 Jan 2021 23:11:46 +0000 (18:11 -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.

A single use of the AC_HELP_STRING macro is replaced by AS_HELP_STRING
as the former was marked as obsolete.

The AC_PROG_LEX now takes an argument, and the argument-less version is
marked as obsolete. The macro is invoked with the `noyywrap` option, as
recommended in the documentation.

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.


Signed-off-by: Jérémie Galarneau <>
Reviewed-by: Michael Jeanson <>
Change-Id: Ie949de73442770f60cbef55300265205527731c6

2 years agoFix: different pthread_getname_np signature() on macOS causes build failure
Michael Jeanson [Wed, 16 Dec 2020 17:40:53 +0000 (12:40 -0500)] 
Fix: different pthread_getname_np signature() on macOS causes build failure

macOS likes to be special so it has pthread_setname_np() without a
thread id parameter, but a pthread_getname_np() with it. Split the
detection macro in two and modifiy the compat layer to handle it.

Change-Id: I8034c54057d68eef59546960c75afe8fbe07f5ad
Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
2 years agolttng-ust abi: sync _UST_CMD() values
Francis Deslauriers [Fri, 18 Dec 2020 22:00:40 +0000 (17:00 -0500)] 
lttng-ust abi: sync _UST_CMD() values

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Ieacee6ecab41855cebae7113e7c512d4d684eb98

2 years agohashtable: silence -fsanitize=address warning for `hashlittle()` function
Francis Deslauriers [Fri, 4 Dec 2020 18:47:32 +0000 (13:47 -0500)] 
hashtable: silence -fsanitize=address warning for `hashlittle()` function

The code of this function triggers the following heap-buffer-overflow
warning when compiled with `-fsanitize=address` in specific situation:

  ==247225==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000001310 at pc 0x5559db6c575a bp 0x7f193e6faeb0 sp 0x7f193e6faea0
  READ of size 4 at 0x602000001310 thread T4 (Notification)
      #0 0x5559db6c5759 in hashlittle /home/frdeso/projets/lttng/tools/src/common/hashtable/utils.c:315
      #1 0x5559db6c6df4 in hash_key_str /home/frdeso/projets/lttng/tools/src/common/hashtable/utils.c:490
      #2 0x5559db5e3282 in hash_trigger_by_name_uid /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:378
      #3 0x5559db5ecbe3 in trigger_name_taken /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:2333
      #4 0x5559db5ecd7c in generate_trigger_name /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:2362
      #5 0x5559db5ed6e0 in handle_notification_thread_command_register_trigger /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:2491
      #6 0x5559db5ef967 in handle_notification_thread_command /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:2927
      #7 0x5559db5ddbb7 in thread_notification /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread.c:693
      #8 0x5559db60e56d in launch_thread /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/thread.c:66
      #9 0x7f19456ec608 in start_thread /build/glibc-ZN95T4/glibc-2.31/nptl/pthread_create.c:477
      #10 0x7f1945602292 in __clone (/lib/x86_64-linux-gnu/

Given that the `k` pointer used in this loop is a `uint32_t *` we might
read bytes outside of the allocated key if the key is less than 4 bytes
long. As the comment about Valgrind explains, this is not a real problem
because memory protections are typically word bounded.

I tried to use the `__SANITIZE_ADDRESS__` define to select the
Valgrind implementation of this code when building with AddressSanitizer
but that still triggers the same head-buffer-overflow warning.

Why wasn't that a problem before?
The trigger feature will use small default names like "T0".

Exclude this function from the sanitizing using the compiler attribute

This removes our sanitizing coverage for this function.

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I82d0d3539916ed889faa93871f9b700064f2c52a

2 years agoTests: Fail test if sessiond is not running when it should
Francis Deslauriers [Wed, 9 Dec 2020 03:05:22 +0000 (22:05 -0500)] 
Tests: Fail test if sessiond is not running when it should

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I9b39bfe6bfb9f404fe2a32c27de0276386a36212

2 years agoCleanup: erroneous use of CDS_INIT_LIST_HEAD() on node
Francis Deslauriers [Thu, 10 Dec 2020 20:42:22 +0000 (15:42 -0500)] 
Cleanup: erroneous use of CDS_INIT_LIST_HEAD() on node

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I6caf957af4d3e325e9f2086441d0552d64a77db5

2 years agoUST: update ABI for event notifier
Jonathan Rajotte [Fri, 10 Jan 2020 22:03:05 +0000 (17:03 -0500)] 
UST: update ABI for event notifier

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Ia3088ebdf0fe64e57e93c2bec02625176460ffc9

2 years agouserspace-probe: Decouple `userspace_probe_add_callsite()` from event and session
Francis Deslauriers [Wed, 22 Jan 2020 16:15:10 +0000 (11:15 -0500)] 
userspace-probe: Decouple `userspace_probe_add_callsite()` from event and session

Currently this function takes event and session pointers:
  - The event is used to get the location type of the probe,
  - the session is used to get the uid and gid of the user to used them
    with the `run_as_*()` functions.

With the incoming trigger support, we want to reuse this function to add
trigger userspace-probe callsites.

This commit extracts what will be common in both event and trigger
implementations by creating a specialized
`userspace_probe_event_add_callsite()` function that uses a generalized

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Ia3b90050a7bd227a30af0c11395dcdf5aca13583
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

2 years agoGeneralize disable_ust_event to support multiple types of ust object
Jonathan Rajotte [Mon, 23 Mar 2020 15:56:05 +0000 (11:56 -0400)] 
Generalize disable_ust_event to support multiple types of ust object

This will allow us to pass a trigger object later.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I2d2632c80c9bcb2d2ca6966e080d0fa5d3422796

2 years agoGeneralize enable_ust_event to support multiple types of ust object
Jonathan Rajotte [Fri, 10 Jan 2020 19:47:30 +0000 (14:47 -0500)] 
Generalize enable_ust_event to support multiple types of ust object

This will allow us to pass a trigger object later.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I594c3eb0437345406e3a24fcbfbf4b7a8162908b

2 years agoGeneralize set_ust_event_exclusion to support multiple types of ust object
Jonathan Rajotte [Mon, 16 Dec 2019 21:01:03 +0000 (16:01 -0500)] 
Generalize set_ust_event_exclusion to support multiple types of ust object

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Ibe8f6b2c459afc698971b23b3f1a72d0a45e036f

2 years agoGeneralize set_ust_event_filter to support multiple types of ust object
Jonathan Rajotte [Mon, 16 Dec 2019 20:48:40 +0000 (15:48 -0500)] 
Generalize set_ust_event_filter to support multiple types of ust object

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Iab5bc94b8895b6470c4c3339a691f71c5e9a2e3c

2 years agonotification: mark tracer source element as out of poll set
Jérémie Galarneau [Fri, 18 Dec 2020 21:15:18 +0000 (16:15 -0500)] 
notification: mark tracer source element as out of poll set

Mark the tracer source element as being out of the notification thread's
poll set once it has been removed. This has no effect right now, but it
is less error-prone considering future changes to this function.

Signed-off-by: Jérémie Galarneau <>
Change-Id: Ia4d08dabd6b07ec455fe3120b7188e414232536e

2 years agoIntroduce trigger hash table with tracer token as key
Jonathan Rajotte [Mon, 13 Jan 2020 18:52:51 +0000 (13:52 -0500)] 
Introduce trigger hash table with tracer token as key

This will allow easy lookup on reception of the tracer token coming
from the tracer.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Iee42539f0a664ead5ca03534549c6bbd5e505953

2 years agonotification: add/remove tracer event source
Jonathan Rajotte [Wed, 25 Mar 2020 22:49:32 +0000 (18:49 -0400)] 
notification: add/remove tracer event source

The notification thread will be responsible of consuming the tracer
notification event coming from the UST tracers and kernel tracer.

On a 'add' operation, the tracer event source (i.e read side of a pipe)
is added to the notification poll set. Book-keeping is also done via a
list for later lookup.

On 'remove', the event source is removed from the pollset and from the

On cleanup (notification_thread_handle_destroy), it is expected that all
added tracer event sources be removed by their respective "adder". No
bulk cleanup is performed.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I23679922a58849c9bc86f30b2aae17b39fa2e222

2 years agoDBG: add debug statement for trigger not bound to any object
Jonathan Rajotte [Mon, 17 Aug 2020 22:24:35 +0000 (18:24 -0400)] 
DBG: add debug statement for trigger not bound to any object

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I2c21c8c702017daf38648bcb835e711335a8fd77

2 years agosessiond: Extract condition hashing functions
Francis Deslauriers [Wed, 9 Sep 2020 21:36:12 +0000 (17:36 -0400)] 
sessiond: Extract condition hashing functions

Extract these functions so it can be used by other files.

The lttng_condition hashing code is kept in this (rather than
common/condition/condition.c) since it makes use of GPLv2 code
(hashtable utils), which we don't want to link in liblttng-ctl.

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Iaafe1402b2d198a00920d939502004038e78fff0

2 years agoCleanup: misplaced white space in `ERR()` statement
Francis Deslauriers [Wed, 9 Dec 2020 13:43:58 +0000 (08:43 -0500)] 
Cleanup: misplaced white space in `ERR()` statement

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I44291907c9973394c3edaf9b470230c59bb75eec

2 years agoAdd base support for event rule hit
Jonathan Rajotte [Mon, 17 Aug 2020 22:23:27 +0000 (18:23 -0400)] 
Add base support for event rule hit

Add some of the scafolding to support event-rule hit conditions.
This includes the hashing of event rule conditions and, consequently,
of event rules and the various probe location types.

The kernel module ABI is checked to verity that the kernel tracer
supports event notifiers.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Iab4db4fc7e9f0c5a7206106fa6a4781b6b95d306

2 years agosessiond: return 'invalid protocol' error on reception error
Jérémie Galarneau [Thu, 26 Nov 2020 20:36:03 +0000 (15:36 -0500)] 
sessiond: return 'invalid protocol' error on reception error

Signed-off-by: Jérémie Galarneau <>
Change-Id: I15758543ae51dd2ce30b40d88a05ef0492ce0e51

2 years agoOnly perform notification related unregistering when action is notify
Jonathan Rajotte [Mon, 17 Aug 2020 22:19:47 +0000 (18:19 -0400)] 
Only perform notification related unregistering when action is notify

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Id89eaf1c8f550e20adbd0b0d82462f6bf0b8ba21

2 years agoUse lttng_trigger_is_equal when iterating over the trigger ht
Jonathan Rajotte [Mon, 13 Jan 2020 18:40:12 +0000 (13:40 -0500)] 
Use lttng_trigger_is_equal when iterating over the trigger ht

Since a trigger can now have other type of actions then the notify one,
we must account for it. We use lttng_trigger_equal to perform that task.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I3300b0fff66e760152c1f7065d8fbfb945cce48e

2 years agoGenerate bytecodes related to the trigger on reception
Jonathan Rajotte [Mon, 23 Mar 2020 21:26:47 +0000 (17:26 -0400)] 
Generate bytecodes related to the trigger on reception

The compositing objects of a trigger might need to generate internal
bytecode. Doing it at the registration step allows an early validation
of the filter expressions.

There is no need to generate it for the unregister command since
bytecodes are not used for comparison and are for internal use only.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Ia1282d55f028e6b056e8ff3877790894c582acdb

2 years agokernel: Add token field to `struct lttng_kernel_event`
Francis Deslauriers [Fri, 13 Nov 2020 21:27:59 +0000 (16:27 -0500)] 
kernel: Add token field to `struct lttng_kernel_event`

This field will be used by event notifier and counters features.

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I48d71a240150355d80b5a325717ca695467c5451

2 years agokernel: Add `struct lttng_kernel_syscall` to ABI
Francis Deslauriers [Wed, 25 Nov 2020 17:06:38 +0000 (12:06 -0500)] 
kernel: Add `struct lttng_kernel_syscall` to ABI

This struct is now used by the kernel tracer to allow to selectively
turn on and off syscalls event firing.

This way, the sessiond can decide to turn on only syscall entries,
exits, or both.

This will be used by the upcoming event notifier features to only
generate a notification on syscall entry.

This new struct doesn't change the layout of the `lttng_kernel_event`

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I478de30b91b415f517e9d0ac0686f3130f79d86b

2 years agoExtras: Perl 5.26 requires { to be escaped by \
Anders Wallin via lttng-dev [Wed, 25 Nov 2020 08:31:40 +0000 (09:31 +0100)] 
Extras: Perl 5.26 requires { to be escaped by \

Unescaped literal "{" characters in regular expression patterns are no
longer permissible

Signed-off-by: Anders Wallin <>
Signed-off-by: Jérémie Galarneau <>
2 years agoFix: sessiond: metadata not created on app unregistration during start
Jérémie Galarneau [Tue, 1 Dec 2020 21:51:23 +0000 (16:51 -0500)] 
Fix: sessiond: metadata not created on app unregistration during start

Issue observed

A test for an incoming feature (trigger actions on on-event conditions)
hangs. While this problem was discovered using this test, it exercises a
scenario that is problematic as of this fix.

The destruction of a session can hang if a single application being
traced unregisters (dies) during the 'start' of a session.


When a per-uid session is started, its buffers (channels and streams)
are allocated only if an instrumented application is registered to the
session daemon at that moment.

For historical reasons, the 'data' and 'metadata' buffers are allocated
in separate code paths. The 'data' buffers are allocated in
ust_app_synchronize() and the 'metadata' buffers are allocated in
ust_app_start_trace(). Both functions perform their own look-up for an
application session and will gracefully fail if an application session
can't be found; it typically means the application has exited.

This leaves a race window open where ust_app_synchronize() can succeed
in looking-up the application session, and ust_app_start_trace() can
fail following the death of the application.

When this occurs, the session is left with 'data' buffers allocated and
unallocated ''metadata' buffers. This is an unexpected state and results
in the rotation code attempting to rotate a partially initialized
metadata stream.

The rotation of this partially initialized metadata stream never
completes which, in turn, never allows the session to complete its
implicit rotation on destruction.

This race window is fairly narrow, but can be reproduced by sleep()-ing
at the beginning of ust_app_start_trace() and killing an application
that is being traced during the sleep period.


The creation of the metadata channel is performed as part of
ust_app_synchronize() if the application look-up succeeds. When it
fails, both 'data' and 'metadata' streams will fail to be created
resulting in an expected and valid state.

Known drawbacks


Signed-off-by: Jérémie Galarneau <>
Change-Id: Ice0ec16734a39a6bb885986d3ad70d20cd2618e0

2 years agotest: utils: lttng_pgrep performs lookup on non-existing pid
Jonathan Rajotte [Mon, 30 Nov 2020 18:54:14 +0000 (13:54 -0500)] 
test: utils: lttng_pgrep performs lookup on non-existing pid

Observed issue

 # Killing (signal SIGTERM) lttng-sessiond and lt-lttng-sessiond pids: 20962 20963
 ./tests/regression/tools/trigger/start-stop//../../../../utils/ line 103: /proc/20963/cmdline: No such file or directory


lttng_pgrep performs a two step search/validation for the pattern. Since
lttng_pgrep is used during tear-down of process (staged termination
signalling) a process returned by pgrep might exit before the second


Simply silence the error. The code flow already acknowledges the
possibility of failure here.

Known drawbacks



Fixes: #1292
Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I82cb9fd4754c10a5104af495a8a959f4fbd92664

2 years agoFix: missing `_mutex_lock()` before signaling a condition variable
Francis Deslauriers [Mon, 30 Nov 2020 19:54:18 +0000 (14:54 -0500)] 
Fix: missing `_mutex_lock()` before signaling a condition variable

According to the PTHREAD_COND(3) man page, a condition variable
signaling and broadcast should alway be protected with a mutex.

This commit fixes two calls to `pthread_cond_signal()` function without
holding the right lock.

This commit also adds an assertion right before two calls to
`pthread_cond_broadcast()` where it's less obvious from the surrounding
code that the mutex is held. This documents the code and may be useful
for future debugging.

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Iebf5a8b2e4251bd1ff4cd462e548cd3486c6cb75

2 years agoCleanup: use `modprobe --remove` rather than `rmmod`
Francis Deslauriers [Tue, 15 Sep 2020 16:10:18 +0000 (12:10 -0400)] 
Cleanup: use `modprobe --remove` rather than `rmmod`

According to the rmmod(8) man page:
  rmmod is a trivial program to remove a module (when module unloading
  support is provided) from the kernel. Most users will want to use
  modprobe(8) with the -r option instead.

`rmmod` simply unloads the provided module and decrements the refcount
of the modules it depended on but doesn't unload those dependencies if
their refcount is zero.

With the following scenario we can end up if modules with a zero
refcount still loaded in the kernel:
  modprobe lttng-test
  ... (test case) ...
  ctrl+c sessiond
  rmmod lttng-test

When we teardown the lttng-sessiond, some modules are kept in the kernel
because the `lttng-test` module depends on them. So unloading
`lttng-test` using `rmmod` keeps those dependencies in the kernel.

Use `modprobe --remove` to unload modules and their now unused

From the modprobe(8) man page:
  -r, --remove
     This option causes modprobe to remove rather than insert a module.
     If the modules it depends on are also unused, modprobe will try to
     remove them too. Unlike insertion, more than one module can be
     specified on the command line

This commit also replaces existing uses of `modprobe -r` to `modprobe
--remove` for consistency.

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I7be83a645097e1eddd478cfbb717906b971f04ea

2 years agotrigger: consider domain on register and unregister
Jonathan Rajotte [Mon, 10 Feb 2020 01:33:55 +0000 (20:33 -0500)] 
trigger: consider domain on register and unregister

This allows the sessiond to inform the client if a trigger that requires a
particular domain (event rule based condition, for example) is at all

This is useful to fail early when a trigger being registered requires an
unavailable tracer.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I660937e64b294f6239ba15faeef705438a93a41a

2 years agotrigger: lttng_trigger_get_underlying_domain_type_restriction
Jonathan Rajotte [Wed, 25 Mar 2020 14:41:17 +0000 (10:41 -0400)] 
trigger: lttng_trigger_get_underlying_domain_type_restriction

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I5fe156a09e4e4c833f84a0fe9027c838b73fe728

2 years agoaction-executor: missing include of internal event-rule header
Jonathan Rajotte [Thu, 24 Sep 2020 19:36:43 +0000 (15:36 -0400)] 
action-executor: missing include of internal event-rule header

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: If541bb203f1d851750ee485fe9bd1a12d9963774

2 years agoTests: unit: lttng_condition_event_rule
Jonathan Rajotte [Wed, 4 Dec 2019 19:30:38 +0000 (14:30 -0500)] 
Tests: unit: lttng_condition_event_rule

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I281df3b2267d6ddf3b0591d181b7f276802d8963

2 years agocondition: implement event rule based condition
Jonathan Rajotte [Tue, 3 Dec 2019 20:57:08 +0000 (15:57 -0500)] 
condition: implement event rule based condition

An event rule condition is met when a tracer hit an event matching the
associated event rule.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I550903c231d83cb3852e8ef8aee2abafe9069b10

2 years agoMove conditions source files to src/common/conditions directory
Jonathan Rajotte [Tue, 3 Dec 2019 21:07:34 +0000 (16:07 -0500)] 
Move conditions source files to src/common/conditions directory

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I43165eacf82a1bf537e7187313664e32ca2833a9

2 years agotrigger: implement listing of registered trigger
Jonathan Rajotte [Thu, 23 Jan 2020 19:13:11 +0000 (14:13 -0500)] 
trigger: implement listing of registered trigger

Each client have visibility over triggers matching its user id (uid).

The root user have visibility over all registered triggers.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I3e5ae75939214ed85c376bea12f1e4b307d78976

2 years agoApply policy on channel sampling
Jonathan Rajotte [Tue, 4 Feb 2020 20:14:34 +0000 (15:14 -0500)] 
Apply policy on channel sampling

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Id755b73c1f976a5a7d7a188656a1de21bd703143

2 years agotrigger: introduce firing policies
Jonathan Rajotte [Thu, 23 Jan 2020 19:14:14 +0000 (14:14 -0500)] 
trigger: introduce firing policies

A firing policy controls the rate of firing of a trigger.

Two firing policy mode are implemented:
       The triggers's actions are executed every N times the
       condition occurs.
       The triggers's actions are executed once the condition was met N

Firing policies will be moved to the specific `action` objects
in a follow-up commit as not all actions can implement the firing

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Ifaeeaaec7b6f2bed57d0d5f4ed8546762ec02e8d

2 years agoFix: lttng-ctl: deserialize on orderly shutdown of sessiond
Francis Deslauriers [Mon, 16 Nov 2020 21:50:41 +0000 (16:50 -0500)] 
Fix: lttng-ctl: deserialize on orderly shutdown of sessiond

The `recv_data_sessiond()` function may return zero if the socket peer
has shutdown orderly. This happens if the session daemon is killed while
the client is blocked on the `recv_data_sessiond()` call. Currently,
when this happens, the client simply goes on to decode the uninitialized
reply buffer.

This bug was witnessed while developing the upcoming event-notifier
feature where complex objects are received from sessiond and attempts to
deserialize these objects resulted in segmentation faults.

Return -LTTNG_ERR_NO_SESSIOND when `recvmsg()` returns zero. This way,
the client can simply tell the user that the session daemon is no longer

Signed-off-by: Francis Deslauriers <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Ib2387526c4101e3bae706e38181bfeb25da26fa3

2 years agoFix: trigger: erroneous check for success of trigger creation
Jérémie Galarneau [Wed, 18 Nov 2020 22:12:45 +0000 (17:12 -0500)] 
Fix: trigger: erroneous check for success of trigger creation

6808ef55e added a check for `ret == 0` to determine if a trigger
could be created from a payload. The function returns >= 0 on
success, leading to crashes when a trigger is de-serialized.

Signed-off-by: Jérémie Galarneau <>
Change-Id: Icd769dcb04f7637aa1877436e9a5570e7f20b63b

2 years agoFix: trigger: leak of trigger on failure to set name
Jérémie Galarneau [Wed, 18 Nov 2020 19:14:02 +0000 (14:14 -0500)] 
Fix: trigger: leak of trigger on failure to set name

lttng_trigger_create_from_payload() leaks its newly-created
trigger when it fails to set the trigger's name. Drop
the reference to the new trigger whenever the function fails.

Signed-off-by: Jérémie Galarneau <>
Change-Id: I9dbf91d404fd67e4b79f2af550f3768680d6d4ec

2 years agoClean-up: trigger: use condition and action put
Jérémie Galarneau [Wed, 18 Nov 2020 19:04:03 +0000 (14:04 -0500)] 
Clean-up: trigger: use condition and action put

Use the internal *_put() functions to discard condition and
action references rather than the public *_destroy() functions
as they may cause confusion.

Signed-off-by: Jérémie Galarneau <>
Change-Id: Idfdfda3ea2289315408245074f7cc0de6541167a

2 years agoDocs: payload/buffer view: validate is missing an argument description
Jérémie Galarneau [Wed, 18 Nov 2020 16:55:24 +0000 (11:55 -0500)] 
Docs: payload/buffer view: validate is missing an argument description

Signed-off-by: Jérémie Galarneau <>
Change-Id: I3d575dcda6c3e6820e911ab3c4e28b18d29f045c

2 years agoFix: unchecked buffer size for communication header
Jérémie Galarneau [Sat, 14 Nov 2020 02:39:36 +0000 (21:39 -0500)] 
Fix: unchecked buffer size for communication header

A number of object de-serialization functions rely on a
fixed-size communication header to create an object from
a payload.

A large number of those functions assume that the initial
header fits in the provided buffer or payload view. Also,
the functions that do validate that the header fits do so
in different ways:
  - checking the view's size,
  - creating a new fixed-size view and checking the 'data' pointer.

To harmonize all of those checks, the following utils are added:
  - lttng_buffer_view_is_valid()
  - lttng_payload_view_is_valid()

These functions should be used whenever a fixed-size view is
created (not passing -1 as the length parameter).

The checks are added and/or harmonized to:
  - create a new 'header' view,
  - validate it with the corresponding *_is_valid() function,
  - initialize the header pointer using the header view.

Signed-off-by: Jérémie Galarneau <>
Change-Id: I763946feac714ecef4fc5bd427dab2d3fe5dc1a4

2 years agorelayd: logging of `trace chunk exists` command refers to the wrong command
Jérémie Galarneau [Mon, 16 Nov 2020 21:10:09 +0000 (16:10 -0500)] 
relayd: logging of `trace chunk exists` command refers to the wrong command

Signed-off-by: Jérémie Galarneau <>
Change-Id: I6e2bf4eee379f4e1d42333779dfeaf8f087d8217

2 years agotrigger: lttng_triggers: implement a container for multiple triggers
Jonathan Rajotte [Tue, 21 Jan 2020 19:22:37 +0000 (14:22 -0500)] 
trigger: lttng_triggers: implement a container for multiple triggers

This container is exposed for the listing of triggers.

We also plan on using it internally in the sessiond for inter-thread

The current implementation is backed by a lttng_dynamic_pointer_array.

Caller of lttng_triggers_add is responsible for managing ownership via
ref-counting of the lttng_trigger object.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Ib541027a6d7d856daa746de5aa49f0002bbe036f

2 years agoaction-executor: evaluated object credentials are optional
Jonathan Rajotte [Wed, 23 Sep 2020 20:13:37 +0000 (16:13 -0400)] 
action-executor: evaluated object credentials are optional

Use the is_set member instead of the LTTNG_OPTIONAL_GET_PTR macro
which asserts whenever an optional member is unset.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Ia00e4a7f5f9b8198061a742bf6bd750c721908cf

2 years agotrigger: generate and add tracer token on registration
Jonathan Rajotte [Wed, 9 Sep 2020 21:16:53 +0000 (17:16 -0400)] 
trigger: generate and add tracer token on registration

Assign a unique tracer token to a trigger.

This token will be used as the unique id that will be communicated back
to the sessiond by the tracers for tracer notification.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I2033dcaa4c5536b29dd4d7c57933e1aa686082cd

2 years agoaction-executor: add trigger name to debugging output
Jonathan Rajotte [Thu, 24 Sep 2020 19:14:47 +0000 (15:14 -0400)] 
action-executor: add trigger name to debugging output

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I73f8fda4b7fee331700988ea73471e3cb1516ed6

2 years agotrigger: implement trigger naming
Jonathan Rajotte [Mon, 23 Mar 2020 22:27:59 +0000 (18:27 -0400)] 
trigger: implement trigger naming

A trigger can now have an optional name on the client side.

If no name is provided the sessiond will generate a name and return a
trigger object to populate the client side object.

For now, the name generation code generate the following pattern: TN

Where `N` is incremented each time a name has to be generated. If a
collision occurs, we increment `N` as needed.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I5f303610713c049177e53937bfc9824cd61501e4

2 years agoport: run namespace tests only on Linux
Michael Jeanson [Tue, 13 Oct 2020 23:19:10 +0000 (19:19 -0400)] 
port: run namespace tests only on Linux

Change-Id: I574d6e7419715e191fb9102e4cfc916ea0e529aa
Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
2 years agoport: FreeBSD does support fchown and fchmod on a shm fd
Michael Jeanson [Wed, 4 Nov 2020 15:04:12 +0000 (10:04 -0500)] 
port: FreeBSD does support fchown and fchmod on a shm fd

Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Iadff886d593ae3f77a4e96dfbfe02d1c1ea45f1e

2 years agoport: Add pthread_setname_np FreeBSD compat
Michael Jeanson [Thu, 29 Oct 2020 10:09:41 +0000 (06:09 -0400)] 
port: Add pthread_setname_np FreeBSD compat

Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I7ca8334c4ce28bc240c898aeb5a6857ff951143b

2 years agoport: only enable userspace callstack context on Linux
Michael Jeanson [Wed, 14 Oct 2020 14:32:14 +0000 (10:32 -0400)] 
port: only enable userspace callstack context on Linux

Change-Id: I55402a7058f7d0bbe11d4c59197197130fe88665
Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
2 years agotrigger: implement is_equal
Jonathan Rajotte [Tue, 24 Mar 2020 15:32:08 +0000 (11:32 -0400)] 
trigger: implement is_equal

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I646c13e7fb26fda66b888ce90253e87567b2cab8

2 years agotrigger: expose trigger owner uid
Jonathan Rajotte [Fri, 18 Sep 2020 20:37:50 +0000 (16:37 -0400)] 
trigger: expose trigger owner uid

To facilitate behavior management for the root user and to allow
duplicate trigger names across users, enforce the usage of the trigger
owner user id.

The root user will be able to register and unregister triggers on behalf
of other users. The root user will also have visibility on triggers of
other users.

Only the root user can use the `lttng_trigger_set_owner_uid` function
successfully. As indicated in the comments, this function performs
a client-side validation steps to catch mis-uses, but this is
properly enforced on the sessiond's end in the register/unregister
trigger commands.

With the future addition of a trigger name (id), the owner id and the
name will act as a key tuple allowing identicaly named triggers across

We plan on exposing the `--user` switch in the upcoming command line
(add-trigger, remove-trigger).

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Ifca3c41b7ffd97b67e16fb80c18472b667cb2f56

2 years agoClean-up: action-executor: typo and missing tab
Jonathan Rajotte [Fri, 22 May 2020 15:27:37 +0000 (11:27 -0400)] 
Clean-up: action-executor: typo and missing tab

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I5646fae2db98a3c8ffa0ba92aff9815f4ce0cf53

2 years agoTests: Fix: 99% fill ratio for high buffer usage is too high for larger events
Jonathan Rajotte [Thu, 28 May 2020 01:29:05 +0000 (21:29 -0400)] 
Tests: Fix: 99% fill ratio for high buffer usage is too high for larger events

If the event being registered is bigger than 1% of a subbuffer, the 99%
ratio cannot be achieved since the "last event" necessary to go over 99%
will always be dropped by the tracer.

  DBG1 - 19:31:07.665963875 [Notification]: [notification-thread] High buffer usage condition being evaluated: threshold = 16220, highest usage = 16196 (in evaluate_buffer_usage_condition() at notification-thread-events.c:3733)

We use a ratio of 90% to keep a little headroom.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I06180735e0b5e88209b888e51cc83b4ac7d98193

2 years agoFix: action: invalid header offset used when serializing snapshot action
Jonathan Rajotte [Wed, 8 Jul 2020 02:51:27 +0000 (22:51 -0400)] 
Fix: action: invalid header offset used when serializing snapshot action

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I77f5fab214f6721773147968ea3b85dddfea8d62

2 years agoport: FreeBSD has no ENODATA, alias it to ENOATTR
Michael Jeanson [Tue, 13 Oct 2020 21:33:44 +0000 (17:33 -0400)] 
port: FreeBSD has no ENODATA, alias it to ENOATTR

According to 'the internet' ENOATTR is used in a similar fashion to
ENODATA on the BSDs and we used it internally only anyway.

Change-Id: Ia4e77fd6d28c9dfb43f99ddba6c32369384827f0
Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
2 years agoport: tests: /proc/self/fd is Linux only, use /dev/fd on other Unices
Michael Jeanson [Tue, 20 Oct 2020 19:02:45 +0000 (15:02 -0400)] 
port: tests: /proc/self/fd is Linux only, use /dev/fd on other Unices

Change-Id: I2be8120c7dce3f12daaf12a190810a145afa50b6
Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
2 years agoCleanup: Use pkg-config to detect liburcu
Michael Jeanson [Fri, 30 Oct 2020 06:48:08 +0000 (02:48 -0400)] 
Cleanup: Use pkg-config to detect liburcu

Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I88d3f853c8ee0e14a38a462ce24626800e0a4caf

2 years agoClean-up: sessiond: silence negative index warning
Jérémie Galarneau [Thu, 29 Oct 2020 15:43:35 +0000 (11:43 -0400)] 
Clean-up: sessiond: silence negative index warning

Coverity warns that `lttng_action_get_type()` can return
a negative index (LTTNG_ACTION_TYPE_UNKNOWN). This scenario
is not reachable, but a check is added to silence the analyzer.

Original report:
  1435955 Negative array index read

  A memory location at a negative offset from the beginning of the array
  will be read, resulting in incorrect values.

  In get_action_name: Negative value used to index an array in a read
  operation (CWE-129)

Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <>
Change-Id: I5952096a1d29f0d4a3c4350a2a842874d5f3973b

2 years agocredentials: uid and gid now use LTTNG_OPTIONAL
Jonathan Rajotte [Fri, 25 Sep 2020 20:35:28 +0000 (16:35 -0400)] 
credentials: uid and gid now use LTTNG_OPTIONAL

The triggers will only use the uid element.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Ia96e7def5ab560d9af1476920426635fc49f92ef

2 years agoport: Add missing sock_cred macros on FreeBSD
Michael Jeanson [Tue, 13 Oct 2020 23:06:09 +0000 (19:06 -0400)] 
port: Add missing sock_cred macros on FreeBSD

Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I71f51ef61bf659c758edba6fd27faeef56654acf

2 years agoport: use compat lttng_fls()
Michael Jeanson [Tue, 13 Oct 2020 22:55:23 +0000 (18:55 -0400)] 
port: use compat lttng_fls()

Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I698b31a24c5b442a00fe570a0ac53e23bb817bec

2 years agoport: FreeBSD has no LOGIN_NAME_MAX, use sysconf instead
Michael Jeanson [Tue, 13 Oct 2020 22:44:40 +0000 (18:44 -0400)] 
port: FreeBSD has no LOGIN_NAME_MAX, use sysconf instead

Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: Id058e15608ce0332500343ce389365a6fb1a40cc

2 years agoport: no eventfd support on FreeBSD
Michael Jeanson [Tue, 13 Oct 2020 22:44:19 +0000 (18:44 -0400)] 
port: no eventfd support on FreeBSD

It's only used in the tests to create dummy fds, use fcntl to duplicate
the stdout fd instead.

Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I401f2bfe6a2375a9bf4d895956071f74e5684783

2 years agooptional: Add LTTNG_OPTIONAL_INIT_VALUE
Jérémie Galarneau [Fri, 2 Oct 2020 21:25:11 +0000 (17:25 -0400)] 

Add helper to initialize an optional field to a 'set' value.

Signed-off-by: Jérémie Galarneau <>
Change-Id: I439302ebec2433abcf7edb6167bf5b02db5a9a55

2 years agoaction: Mark parameter of lttng_action_get_type as const
Jonathan Rajotte [Wed, 23 Sep 2020 18:34:59 +0000 (14:34 -0400)] 
action: Mark parameter of lttng_action_get_type as const

Remove lttng_action_get_type_const as it is no longer needed.

Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I1525bc2c89eb37ab3e75d915c6ff50bd2a7f5d21

2 years agoIntroduce lttng_domain_type_str utility
Jonathan Rajotte [Tue, 29 Sep 2020 15:46:24 +0000 (11:46 -0400)] 
Introduce lttng_domain_type_str utility

Change-Id: I1d2c7be968da6658e93407cdba26a6042177badd
Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Jérémie Galarneau <>
2 years agoport: no HOST_NAME_MAX on FreeBSD, use LTTNG_HOST_NAME_MAX
Michael Jeanson [Tue, 13 Oct 2020 21:54:27 +0000 (17:54 -0400)] 

Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I83cc40a123539a668c25828144905b628df9fdef

2 years agoport: ELF_ST_TYPE is defined in elf.h on FreeBSD
Michael Jeanson [Tue, 13 Oct 2020 21:54:04 +0000 (17:54 -0400)] 
port: ELF_ST_TYPE is defined in elf.h on FreeBSD

No need to alias ELF32_ST_TYPE to ELF_ST_TYPE.

Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I8afa2fb9d96b81d994b90c8291f2f457a037a525

2 years agoport: posix_fadvise is available in FreeBSD >= 10.0
Michael Jeanson [Tue, 13 Oct 2020 21:32:14 +0000 (17:32 -0400)] 
port: posix_fadvise is available in FreeBSD >= 10.0

Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: I85f823ad7be94a5860ce0104c20e5a49ce030eda

2 years agoport: fix compat/endian.h on FreeBSD
Michael Jeanson [Tue, 13 Oct 2020 21:32:00 +0000 (17:32 -0400)] 
port: fix compat/endian.h on FreeBSD

Signed-off-by: Michael Jeanson <>
Signed-off-by: Jérémie Galarneau <>
Change-Id: If591ed8d1cf50c1914a613976e9e285c3647906c

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