lttng-tools.git
3 years agoTests: notification: use get_next_notification() and a validator
Jonathan Rajotte [Mon, 11 May 2020 16:01:54 +0000 (12:01 -0400)] 
Tests: notification: use get_next_notification() and a validator

This allows for multiple validators to be used against one notification.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7253b3a21a5891da880c0b48509b13adfadd0d3f
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: notification: Makefile.am formatting
Jonathan Rajotte [Wed, 27 May 2020 20:36:40 +0000 (16:36 -0400)] 
Tests: notification: Makefile.am formatting

One file per line and sorted.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I0cd3c0ef299782f78e94bd9e2226b524ee6aed79
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: remove duplicate notification multi-app test
Jonathan Rajotte [Tue, 17 Mar 2020 17:24:41 +0000 (13:24 -0400)] 
Tests: remove duplicate notification multi-app test

tools/notification/test_notification_multi_app is already present in the
list.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic9e3fdbe3570b5837f3efd24a7b5dcd3f327a1d1
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: triggers: `start-session` and `stop-session` actions
Francis Deslauriers [Thu, 5 Mar 2020 17:23:45 +0000 (12:23 -0500)] 
Tests: triggers: `start-session` and `stop-session` actions

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1c740bcb2a7fa8a14fb1591893e8c7ea7655faac
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: triggers: Add syscall event rule condition filter tests
Francis Deslauriers [Fri, 14 Feb 2020 03:51:57 +0000 (22:51 -0500)] 
Tests: triggers: Add syscall event rule condition filter tests

This test has limited value as it's impossible to distinguish events
from buggy filtering from the ones that went through the filter
successfully.

Keep that test case anyway, as it exercises those code paths.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1b1f9ecb29b7e09b4b8f66034e8911a645aabe3c
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: triggers: Add userspace-probe event rule condition kernel tests
Francis Deslauriers [Thu, 13 Feb 2020 18:41:17 +0000 (13:41 -0500)] 
Tests: triggers: Add userspace-probe event rule condition kernel tests

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4b948e67bc71c4cfe898927ca045f7a48ddda39a
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: triggers: Add syscall event rule condition kernel tests
Francis Deslauriers [Wed, 12 Feb 2020 23:19:29 +0000 (18:19 -0500)] 
Tests: triggers: Add syscall event rule condition kernel tests

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I38eb7d1789f40b112ce1c92bf51d1c05a9f3398c
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agotestapp: gen-syscall-events: use dynamic paths provided via args
Jonathan Rajotte [Wed, 6 May 2020 00:08:34 +0000 (20:08 -0400)] 
testapp: gen-syscall-events: use dynamic paths provided via args

This is to try and mitigate the limitation found here:
https://bugs.lttng.org/issues/1261

Using an argument ensures that the path is not in the .rodata section of
the executable and reduces the chance that the kernel tracer incurs a
page fault when attempting to serialize the path argument.

The path is pre-faulted to mitigate the problem described in #1261.

Fixes #1261

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6b6173ee5d8b33dcdf1cc391db9d1eafe00f90b9
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: gen-syscall-events: generate 2 events of each type for filtering
Francis Deslauriers [Thu, 13 Feb 2020 20:44:02 +0000 (15:44 -0500)] 
Tests: gen-syscall-events: generate 2 events of each type for filtering

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4803fb2e465d1865f0130b7546ee871b6752a226
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: triggers: Add kprobe event rule condition kernel tests
Francis Deslauriers [Wed, 12 Feb 2020 00:27:54 +0000 (19:27 -0500)] 
Tests: triggers: Add kprobe event rule condition kernel tests

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Icc941c594374326eded1c8a10b32187cdb98d4df
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: triggers: Add event rule condition exclusion tests
Francis Deslauriers [Tue, 11 Feb 2020 22:13:15 +0000 (17:13 -0500)] 
Tests: triggers: Add event rule condition exclusion tests

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibb323a636d5829725776d8332f5c22da63b7a35f
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: triggers: Add event rule condition filter tests
Francis Deslauriers [Tue, 11 Feb 2020 03:18:14 +0000 (22:18 -0500)] 
Tests: triggers: Add event rule condition filter tests

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ieb751c648502c7aca2ca87942fe359ad8945824f
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: triggers: Add basic event rule condition tests
Francis Deslauriers [Fri, 7 Feb 2020 23:37:34 +0000 (18:37 -0500)] 
Tests: triggers: Add basic event rule condition tests

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Idc9fa6e04be41ba7dea3466b9328d618a7774cbc
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: notification: regroup event generators utils in a single file
Jonathan Rajotte [Tue, 5 May 2020 20:56:05 +0000 (16:56 -0400)] 
Tests: notification: regroup event generators utils in a single file

Regroup all "event generator" utils under a single util file to be
sourced.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4f2598097fba4cd34161a42a7daa5b49ba457293
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: notification.c: add `test_scenario` parameter
Francis Deslauriers [Tue, 11 Feb 2020 20:44:21 +0000 (15:44 -0500)] 
Tests: notification.c: add `test_scenario` parameter

This parameter signifies what test cases to run. Test cases are grouped
by test scenario requirements (e.g. what test app to run).

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic94bc8e08ada7ed3c9b6ec36f89b57d0becde9d3
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: Cleanup: notification: `assert()` that `app_pid` is set
Francis Deslauriers [Wed, 12 Feb 2020 20:30:16 +0000 (15:30 -0500)] 
Tests: Cleanup: notification: `assert()` that `app_pid` is set

According to the kill(2) manpage:
  If pid equals -1, then sig is sent to every process for which the
  calling  process  has  permission  to  send  signals,  except for
  process 1 (init),

Since our current default value is -1, if we call the
`{suspend,resume}_application()` functions before setting the `app_pid`
we end up sending a signal to all processes owned by the user which can
be pretty dramatic.

If we are about to call `kill()` with -1, it's a logic error so we can
assert().

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I211f75d44e6cfdd2f2e35ef342b930eb683dbbe5
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: Cleanup: rename test_notification_channel()
Francis Deslauriers [Fri, 7 Feb 2020 20:45:49 +0000 (15:45 -0500)] 
Tests: Cleanup: rename test_notification_channel()

Rename test_notification_channel() to
test_buffer_usage_notification_channel().

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I609f1b3ecd0fbb7cb7d37a6f0b28fccb18174602
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: Cleanup: create `test_subscription_twice()` function
Francis Deslauriers [Fri, 7 Feb 2020 05:36:32 +0000 (00:36 -0500)] 
Tests: Cleanup: create `test_subscription_twice()` function

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I27f6b9a129d8659cefb9d753567723b5a0dab11c
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: Cleanup: add `register_buffer_usage_notify_trigger()` util function
Francis Deslauriers [Fri, 7 Feb 2020 17:01:40 +0000 (12:01 -0500)] 
Tests: Cleanup: add `register_buffer_usage_notify_trigger()` util function

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I0ebfb41e3faf5ec468852f90fff51cbfb739fde3
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: Cleanup: create `test_invalid_channel_subscription()` function
Francis Deslauriers [Thu, 6 Feb 2020 20:43:34 +0000 (15:43 -0500)] 
Tests: Cleanup: create `test_invalid_channel_subscription()` function

No behavior changes intented.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I137ca2ef90ed5a5c572592f2538165c42ca9ca4b
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: test_notification_ust: reduce number of event generated
Francis Deslauriers [Fri, 14 Feb 2020 16:26:55 +0000 (11:26 -0500)] 
Tests: test_notification_ust: reduce number of event generated

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie5f05a7b3d2d9ff2b990e0d1f5e59a350a854b30
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: notification: make testcases manage the test app
Francis Deslauriers [Tue, 11 Feb 2020 03:37:03 +0000 (22:37 -0500)] 
Tests: notification: make testcases manage the test app

Each testcase should resume the application if needed. They must ensure
they suspend it before returning.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5d4f5f43886af676163ab6190b90181bfb575170
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: Cleanup: apply coding style to `test_notification_channel()`
Francis Deslauriers [Thu, 6 Feb 2020 17:37:24 +0000 (12:37 -0500)] 
Tests: Cleanup: apply coding style to `test_notification_channel()`

I also ran clang-format on this patch.

No behavior changes intented.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7089a288b626e94bed2543f5b13de0537b4d5e4d
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: Cleanup: extract duplicated code to `setup_buffer_usage_condition()`
Francis Deslauriers [Thu, 6 Feb 2020 17:24:08 +0000 (12:24 -0500)] 
Tests: Cleanup: extract duplicated code to `setup_buffer_usage_condition()`

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I401751d6ae92fb96b532972257a9a8127919778d
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoFix: lttng: add-trigger: leak of argpar state
Jérémie Galarneau [Fri, 26 Feb 2021 19:09:16 +0000 (14:09 -0500)] 
Fix: lttng: add-trigger: leak of argpar state

1447049 Resource leak

The system resource will not be reclaimed and reused, reducing the future availability of the resource.

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

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

3 years agoFix: lttng: add-trigger: leak of error string
Jérémie Galarneau [Fri, 26 Feb 2021 19:06:57 +0000 (14:06 -0500)] 
Fix: lttng: add-trigger: leak of error string

argpar_state_parse_next allocates an error string on
`ARGPAR_STATE_PARSE_NEXT_STATUS_ERROR_UNKNOWN_OPT` which we choose not
to handle as an error. Still, the error must be free'd.

1447048 Resource leak

The system resource will not be reclaimed and reused, reducing the future availability of the resource.

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

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

3 years agoFix: lttng: add-trigger: leak of max_size_arg argument
Jérémie Galarneau [Fri, 26 Feb 2021 19:02:55 +0000 (14:02 -0500)] 
Fix: lttng: add-trigger: leak of max_size_arg argument

1447046 Resource leak

The system resource will not be reclaimed and reused, reducing the future availability of the resource.

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

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

3 years agoFix: lttng: add-trigger: leak of source argument
Jérémie Galarneau [Fri, 26 Feb 2021 19:02:06 +0000 (14:02 -0500)] 
Fix: lttng: add-trigger: leak of source argument

1447045 Resource leak

The system resource will not be reclaimed and reused, reducing the future availability of the resource.

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

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

3 years agoClean-up: uri_parse_str_urls: assert on invalid uri_parse() return values
Jérémie Galarneau [Fri, 26 Feb 2021 18:58:16 +0000 (13:58 -0500)] 
Clean-up: uri_parse_str_urls: assert on invalid uri_parse() return values

uri_parse() can only ever return values [-1, 2] and callers only handle
those values. This causes Coverity to report possible leaks and other
errors when analyzing callers.

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

3 years agoFix: lttng: add-trigger: leak of argpar_item
Jérémie Galarneau [Fri, 26 Feb 2021 18:47:22 +0000 (13:47 -0500)] 
Fix: lttng: add-trigger: leak of argpar_item

1447047 Resource leak

The system resource will not be reclaimed and reused, reducing the future availability of the resource.

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

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

3 years agoFix: lttng: add-trigger: erroneous null check
Jérémie Galarneau [Fri, 26 Feb 2021 18:43:42 +0000 (13:43 -0500)] 
Fix: lttng: add-trigger: erroneous null check

1447042 Dereference before null check

There may be a null pointer dereference, or else the comparison against null is unnecessary.

In parse_kernel_probe_opts: All paths that lead to this null pointer comparison already dereference the pointer earlier (CWE-476)

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

3 years agoFix: lttng: include lttng-list-trigger missing an 's'
Anders Wallin via lttng-dev [Wed, 3 Mar 2021 08:38:01 +0000 (09:38 +0100)] 
Fix: lttng: include lttng-list-trigger missing an 's'

Signed-off-by: Anders Wallin <wallinux@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I107aae3adf2b0f1ad7b211c39dc5dfc10c2c2db0

3 years agoClean-up: lttng: logging: use ARRAY_SIZE macro
Jérémie Galarneau [Tue, 16 Feb 2021 20:47:28 +0000 (15:47 -0500)] 
Clean-up: lttng: logging: use ARRAY_SIZE macro

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

3 years agosessiond: notification-thread: Use lttng_domain_type_str()
Jonathan Rajotte [Wed, 3 Jun 2020 20:14:28 +0000 (16:14 -0400)] 
sessiond: notification-thread: Use lttng_domain_type_str()

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic283da234f9fb38bbd570f331080f098881a97bb

3 years agolttng: Add remove-trigger command
Simon Marchi [Mon, 20 Jan 2020 21:39:56 +0000 (16:39 -0500)] 
lttng: Add remove-trigger command

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I323ddc181c9214dcf4ae66e23a382451f6582fff
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agolttng: Add list-triggers command
Simon Marchi [Mon, 20 Jan 2020 22:25:19 +0000 (17:25 -0500)] 
lttng: Add list-triggers command

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I901264798baa81626d8e212a40774570100dc4f9
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoDocs: document --condition and --action in add-trigger's OPTIONS section
Simon Marchi [Fri, 14 Feb 2020 17:42:15 +0000 (12:42 -0500)] 
Docs: document --condition and --action in add-trigger's OPTIONS section

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Icfedfa3986eb0788ecea42318d48233e7859fa6d
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoDocs: Add lttng-add-trigger man page
Simon Marchi [Fri, 17 Jan 2020 19:06:39 +0000 (14:06 -0500)] 
Docs: Add lttng-add-trigger man page

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8539813b0c145632641f315217048c970c0f20f5
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agolttng: Add add-trigger command
Simon Marchi [Tue, 3 Dec 2019 21:05:21 +0000 (16:05 -0500)] 
lttng: Add add-trigger command

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibacbaba8f6d4ef84cd8b846a6d9abbd6c39e6ebf
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: Add add-trigger CLI tests
Jonathan Rajotte [Thu, 29 Oct 2020 17:59:05 +0000 (13:59 -0400)] 
Tests: Add add-trigger CLI tests

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I30e463084a9a664aabe98f84e8e07eea1007cc2e
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: add raw perf test to the test list when building with libpfm support
Jérémie Galarneau [Tue, 16 Feb 2021 16:33:48 +0000 (11:33 -0500)] 
Tests: add raw perf test to the test list when building with libpfm support

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

3 years agoClean-up: lttng: only include lttng.h
Jérémie Galarneau [Wed, 24 Feb 2021 19:59:49 +0000 (14:59 -0500)] 
Clean-up: lttng: only include lttng.h

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

3 years agolttng.h: add missing public headers and sort them
Jérémie Galarneau [Wed, 24 Feb 2021 19:49:16 +0000 (14:49 -0500)] 
lttng.h: add missing public headers and sort them

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

3 years agoClean-up: lttng: replace manual string comparison code by strcasecmp
Jérémie Galarneau [Thu, 18 Feb 2021 22:04:46 +0000 (17:04 -0500)] 
Clean-up: lttng: replace manual string comparison code by strcasecmp

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

3 years agoFix: lttng-ctl: appending to dynamic buffer invalidates its data member
Jérémie Galarneau [Thu, 18 Feb 2021 23:13:19 +0000 (18:13 -0500)] 
Fix: lttng-ctl: appending to dynamic buffer invalidates its data member

`lttng_register_trigger` samples the address of the lsm header in the
message payload. However, it does so before calling
`lttng_trigger_serialize()` which may increase the underlying buffer's
size (and cause a realloc()).

Most of the time the message buffer is large enough _or_ its realloc
yields the same address which hid the problem. However, I stumbled on
a case (a trigger which snapshots to a long location) where the realloc
ends-up returning a completely different address, causing invalid data
to be sent to the session daemon.

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

3 years agoImplement list_cmd_options_argpar
Jonathan Rajotte [Thu, 27 Aug 2020 19:56:43 +0000 (15:56 -0400)] 
Implement list_cmd_options_argpar

Small utility allowing the printing of argpar options.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic39ce6f7eebfc3cb1d3fb12873862e9edd563dc6

3 years agoCLI: Import argpar
Simon Marchi [Thu, 5 Dec 2019 19:12:16 +0000 (14:12 -0500)] 
CLI: Import argpar

This patch imports the argpar code into lttng-tools.  At first, it will
be used to implement the create-trigger command, but if it proves
useful, it could help to implement all other commands too.

Synced with the upstream argpar code as of 1ae22b5e.

Change-Id: I26daed2e50e78e093d6d5d26320193193d907dd5
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoImplement utils_parse_unsigned_long_long
Jonathan Rajotte [Thu, 27 Aug 2020 19:39:26 +0000 (15:39 -0400)] 
Implement utils_parse_unsigned_long_long

To be used for trigger creation.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id7d9f76f3b9a29c9657eaa0daf3eb112fee54b09

3 years agolttng: move parse_userspace_probe_opts to a common util
Jonathan Rajotte [Thu, 27 Aug 2020 19:07:06 +0000 (15:07 -0400)] 
lttng: move parse_userspace_probe_opts to a common util

parse_userspace_probe_opts will be reused for trigger creation.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I377e0a59786794a74a9b0a7787b6f9a221245df1

3 years agoClean-up: lttng: silence bogus warning
Jérémie Galarneau [Fri, 12 Feb 2021 18:34:47 +0000 (13:34 -0500)] 
Clean-up: lttng: silence bogus warning

clang warns that `name_search_ret` may be used unitiliazed if the domain
is none of {ust, python, log4j, jul}. However, those branches are only
accessible when one of these domains is used.

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

3 years agolttng: move log level name to numerical value conversions to a common util
Jérémie Galarneau [Thu, 27 Aug 2020 19:16:29 +0000 (15:16 -0400)] 
lttng: move log level name to numerical value conversions to a common util

Move the utils used by the `enable-event` command to convert log level
names (textual) to their values (entries in their respective enums).

Since these utils will be used by other commands in the future, the code
is cleaned-up, notably to maintain type-safety by returning specific
enums rather than casting to `int`.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3f655bed6cd5b12cae1e93421f9d1c41ab1b6247

3 years agosessiond: action-executor: log trigger name rather than its address
Jérémie Galarneau [Thu, 11 Feb 2021 16:43:51 +0000 (11:43 -0500)] 
sessiond: action-executor: log trigger name rather than its address

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

3 years agoFix: action-executor: address of trigger name logged instead of trigger name
Jérémie Galarneau [Thu, 11 Feb 2021 16:42:10 +0000 (11:42 -0500)] 
Fix: action-executor: address of trigger name logged instead of trigger name

The "%p" was left in place when some logging statements of action
executor were changed to log trigger names rather than their address.

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

3 years agosessiond: docs: document action_executor_enqueue() parameter ownership
Jérémie Galarneau [Thu, 11 Feb 2021 16:37:33 +0000 (11:37 -0500)] 
sessiond: docs: document action_executor_enqueue() parameter ownership

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

3 years agosessiond: defer tracer notification jobs to the action executor
Jonathan Rajotte [Fri, 24 Jan 2020 22:37:54 +0000 (17:37 -0500)] 
sessiond: defer tracer notification jobs to the action executor

Create an event rule evaluation and enqueue a job to execute the
actions associated with the corresponding trigger on the action executor
work queue.

Clients are notified that a notification was dropped if the action
executor queue is full at the time of invocation.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7b36af2553a4ca9404b58f185e9a12f3900a1d35
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoFix: consumer: timer: uninitialized sigevent fields
Jérémie Galarneau [Thu, 11 Feb 2021 15:28:54 +0000 (10:28 -0500)] 
Fix: consumer: timer: uninitialized sigevent fields

Coverity reports:
1445769 Uninitialized scalar variable
The variable will contain an arbitrary value left from earlier computations.
In consumer_channel_timer_start: Use of an uninitialized variable (CWE-457)

CID 1445769 (#1 of 1): Uninitialized scalar variable (UNINIT)7.
uninit_use_in_call: Using uninitialized value sev. Field sev._sigev_un
is uninitialized when calling timer_create.

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

3 years agoFix: sessiond: notification: unreachable code in switch-case
Jérémie Galarneau [Wed, 10 Feb 2021 22:24:21 +0000 (17:24 -0500)] 
Fix: sessiond: notification: unreachable code in switch-case

A copy paste error introduced in bc8daafb causes the initialization
of the session credentials to not be initialized.

Reported-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I50af722a498892bec764e115cfa6e9ca64302e05

3 years agoFix: sessiond: client: leak of trigger object on invalid client message
Jérémie Galarneau [Wed, 10 Feb 2021 19:33:11 +0000 (14:33 -0500)] 
Fix: sessiond: client: leak of trigger object on invalid client message

Coverity reports:
1445927 Resource leak
The system resource will not be reclaimed and reused, reducing the future availability of the resource.
In receive_lttng_trigger: Leak of memory or pointers to system resources (CWE-404)

lttng_trigger_create_from_payload() can return a trigger (positive
return value) that doesn't match the advertised trigger size. In that
case, a trigger reference was still returned and must be released.

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

3 years agoFix: sessiond: timer: unitiliazed sigevent fields
Jérémie Galarneau [Wed, 10 Feb 2021 19:25:57 +0000 (14:25 -0500)] 
Fix: sessiond: timer: unitiliazed sigevent fields

Coverity reports:
1445773 Uninitialized scalar variable
The variable will contain an arbitrary value left from earlier computations.
In timer_start: Use of an uninitialized variable (CWE-457)

CID 1445773 (#1 of 1): Uninitialized scalar variable (UNINIT)2.
uninit_use_in_call: Using uninitialized value sev. Field sev._sigev_un
is uninitialized when calling timer_create

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

3 years agoFix: sessiond: ust-registry: dereference of NULL pointer on allocation failure
Jérémie Galarneau [Wed, 10 Feb 2021 19:20:34 +0000 (14:20 -0500)] 
Fix: sessiond: ust-registry: dereference of NULL pointer on allocation failure

Coverity reports:
1445771 Dereference after null check
Either the check against null is unnecessary, or there may be a null pointer dereference.
In ust_registry_channel_add: Pointer is checked against null but then dereferenced anyway (CWE-476)

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

3 years agoFix: sessiond: kernel: leak of notifier rule on failure to init notifier
Jérémie Galarneau [Wed, 10 Feb 2021 19:08:55 +0000 (14:08 -0500)] 
Fix: sessiond: kernel: leak of notifier rule on failure to init notifier

Coverity reports:
1445768 Resource leak
The system resource will not be reclaimed and reused, reducing the future availability of the resource.
In kernel_create_event_notifier_rule: Leak of memory or pointers to system resources (CWE-404)

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

3 years agolttng-ctl: health: remove unreachable condition
Jérémie Galarneau [Wed, 10 Feb 2021 19:04:09 +0000 (14:04 -0500)] 
lttng-ctl: health: remove unreachable condition

Coverity reports:
1442789 Logically dead code
The indicated dead code may have performed some action; that action will never occur.
In lttng_health_create_relayd: Code can never be reached because of a logical contradiction (CWE-561)

`path` is already checked for NULL before reaching the lttng_strncpy
call.

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

3 years agoFix: sessiond: uninitialized credentials set for unbound trigger
Jérémie Galarneau [Wed, 10 Feb 2021 18:59:48 +0000 (13:59 -0500)] 
Fix: sessiond: uninitialized credentials set for unbound trigger

The bound-object credentials should be left unset when the trigger
doesn't have to bind to an object.

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

3 years agobuffer-view: improve logging on creation failure
Jérémie Galarneau [Tue, 9 Feb 2021 22:09:37 +0000 (17:09 -0500)] 
buffer-view: improve logging on creation failure

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

3 years agoFix: sessiond: leak of trigger on registration error
Jérémie Galarneau [Tue, 9 Feb 2021 22:08:45 +0000 (17:08 -0500)] 
Fix: sessiond: leak of trigger on registration error

The caller of cmd_register_trigger assumes that no triggers are returned
on error. This causes a leak of the reference to the returned trigger.

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

3 years agosessiond: kernel: misleading log message on event rule creation failure
Jérémie Galarneau [Tue, 9 Feb 2021 21:10:18 +0000 (16:10 -0500)] 
sessiond: kernel: misleading log message on event rule creation failure

A logging message referring to "triggers" is emitted when failing to
create an event notifier rule in the kernel domain.

The name trigger was left-over since the terminology used to refer to
those internal objects changed.

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

3 years agoFix: sessiond: trace-kernel: function return code overwritten
Jérémie Galarneau [Tue, 9 Feb 2021 21:04:05 +0000 (16:04 -0500)] 
Fix: sessiond: trace-kernel: function return code overwritten

A string copy, performed using `lttng_strncpy` is performed at the end
of trace_kernel_init_event_notifier_from_event_rule() and its return
value is stored in the function's `ret` variable, which is of type `enum
lttng_error_code`.

Since LTTNG_OK is not == 0, the return value is interpreted as an error,
which causes the registration of kernel-domain on-event-hit triggers
to fail.

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

3 years agosessiond: convert invalid command return codes to LTTNG_ERR_UNK
Jérémie Galarneau [Tue, 9 Feb 2021 23:36:16 +0000 (18:36 -0500)] 
sessiond: convert invalid command return codes to LTTNG_ERR_UNK

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

3 years agolttng-ctl: convert invalid command return codes to LTTNG_ERR_UNK
Jérémie Galarneau [Tue, 9 Feb 2021 23:36:30 +0000 (18:36 -0500)] 
lttng-ctl: convert invalid command return codes to LTTNG_ERR_UNK

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

3 years agoClean-up: ust-consumer: replace manual metadata cache buffer allocation
Jérémie Galarneau [Tue, 9 Feb 2021 00:01:15 +0000 (19:01 -0500)] 
Clean-up: ust-consumer: replace manual metadata cache buffer allocation

Replace the hand-rolled buffer allocation management code of the
metadata cache by the lttng_dynamic_buffer utility.

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

3 years agoClean-up: ust-consumer: pass metadata cache to its write method
Jérémie Galarneau [Mon, 8 Feb 2021 23:04:20 +0000 (18:04 -0500)] 
Clean-up: ust-consumer: pass metadata cache to its write method

The consumer_metadata_cache_write function doesn't need access to the
metadata channel; it can operate on the metadata cache itself and
doesn't need to access its channel.

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

3 years agoFix: ust-consumer: metadata thread not woken-up after version change
Jérémie Galarneau [Mon, 8 Feb 2021 19:40:33 +0000 (14:40 -0500)] 
Fix: ust-consumer: metadata thread not woken-up after version change

Issue observed
==============

The metadata regeneration test fails, very rarely, in the "streaming"
case on the CI. The interesting part of the test boils down to:
  1) start session
  2) launch an app tracing one event
  3) stop session
  4) delete metadata file
  5) start session
  6) regenerate metadata
  7) stop session
  8) destroy session
  9) read trace: babeltrace fails on an invalid metadata file.

The problem is hard to capture, but modifying the test allows us to see
that there appears to be a short window between steps 7 and 8 where the
metadata file is empty or doesn't exist.

Cause
=====

When metadata is regenerated, its version is bumped and the metadata
cache is "reset". In some cases, such as in this test, the new metadata
will have exactly the same size as it had prior as nothing happened to
change that (e.g. no new apps/probes were registered).

When this occurs, the metadata thread is not woken-up by
consumer_metadata_cache_write() as it sees that max_offset of the
metadata cache didn't change; the data was replaced but it has the same
size.

The metadata consumption thread also checks for version bumps and
resets the amount of consumed metadata. Hence, if the "cache write"
operation woke up the metadata consumption thread, the stream's
"ust metadata pushed" state would be reset and the new contents would
be consumed.

Solution
========

The metadata stream's "ust metadata pushed" position is directly reset
to zero when a metadata version change is detected by the metadata
cache. The metadata poll thread is also woken up to resume the
consumption of the newly-available data.

It is unclear why the change to the consumption position was only done
on the metadata consumption thread's code path and not directly by the
session daemon command handling.

Note that a session rotation will also result in a reset of the pushed
position and a wake-up of the metadata poll thread from the command
handling thread. I am speculating that this couldn't be done due to the
design of the locking at the time of the original
implementation (I haven't checked).

In implementing this change, the metadata reception code path is
untangled a bit to separate the logic that affects the metadata stream
from the logic that manages the metadata cache. I suspect the original
error stems from a mix-up/confusion between both concerns.

When a metadata version change happens, the metadata cache resets its
'max_offset' (in other words, it's current size) and notifies the
caller. The caller then resets the "ust pushed metadata" position to
zero and wakes-up the metadata thread to consume the new contents of the
metadata cache.

Known drawbacks
===============

None.

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

3 years agoFix: ust-consumer: metadata cache lock not taken when sampling max offset
Jérémie Galarneau [Mon, 8 Feb 2021 18:03:20 +0000 (13:03 -0500)] 
Fix: ust-consumer: metadata cache lock not taken when sampling max offset

Found by inspecting the code while searching for an unrelated problem.
The 'max_offset' field is probably only accessed by the sessiond
poll thread, but this isn't a documented (nor reasonably maintainable)
guarantee.

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

3 years agoClean-up: ust-consumer: simplify metadata cache unlock on error path
Jérémie Galarneau [Mon, 8 Feb 2021 18:00:56 +0000 (13:00 -0500)] 
Clean-up: ust-consumer: simplify metadata cache unlock on error path

The metadata cache lock can be released directly after the call to
consumer_metadata_cache_write() since nothing depends on the cache
being locked after.

This simplifies the unlocking of the metadata cache by removing an
extra "unlock" that is specific to an error path.

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

3 years agoFix: sessiond: acquire session list lock when updating event notifiers
Jérémie Galarneau [Thu, 4 Feb 2021 23:18:32 +0000 (18:18 -0500)] 
Fix: sessiond: acquire session list lock when updating event notifiers

Registering triggers with an on-event hit condition affects event
notifiers, imposing a synchronization of enablers with the user space
tracers.

As noted in the comments of session.h, the session list lock protects
those updates and is, ultimately, ill-named. The comment is adjusted to
mention "tracer configurations" rather than "session configurations"
since event notifiers are not part of a session, making the comment
imprecise.

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

3 years agosessiond: agent: enable events matching event notifiers
Jonathan Rajotte [Tue, 11 Feb 2020 20:59:02 +0000 (15:59 -0500)] 
sessiond: agent: enable events matching event notifiers

Per event notifier domain agents
--------------------------------

A `struct agent` instance encapsulates the agent events of an agent
domain for a given session. In the context of event notifiers, there is
no session involved to scope the agent instance.

Hence, per-domain instances are maintained to control event-notifiers
enabled by triggers.

Agent event enable count
------------------------

Agents act as a pre-filter on user space tracer events. In order to
honor triggers use event notifiers (on-event-hit conditions), the
register/unregister trigger commands are modified to ensure 'agent'
domain events are created and enabled/disabled suitably for the user
space tracer to be invoked.

Note that since agent events are a "filter" before event enablers, an
event-rule targetting a ring buffer and an identical event-rule
targetting an event notifier can be enabled. The action to take when the
event is hit is completely opaque to the agents. In such cases, the same
agent event instance needs to be enabled and the current implementation
doesn't allow duplicate agent events.

Hence, `struct agent_event`'s enabled state is now a counter which
accounts for all enabled event-rules that require this agent event to be
enabled. The agent event is enabled when one or more event rules
matching it are enabled and it is disabled when that count reached zero.

To ensure no code checks for the agent_event's enabled state by
comparing to '1', a new `AGENT_EVENT_IS_ENABLED` macro is introduced.
The existing code using the `enabled` attribute directly is modified to
use it.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I363db1e4bd7d7d73c75b8576c6323ee41e31aa00
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 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 <jeremie.galarneau@efficios.com>
Change-Id: I74a90150ec2b0914784fb187517025a9a3019cfb

3 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 <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I10ce8911372a6926b7aa234b9d1595a5052d4a0e

3 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 <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7a05c8055f2bb2e09e274a7f4d8f9ecd3e5509fc

3 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 <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie3069ad3d81d460646c71923f0f396cf18980540

3 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 <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If419fd24b3bf6532f2c75a728a9ec395e365c626

3 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().

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
initialized.

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

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

3 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 <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id2cb2a93c0c6be9f44f9dcd07b9803acbcb6b3c3
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 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 <jeremie.galarneau@efficios.com>
Change-Id: Ib24b4c2934655573965f06fa7998859335053083

3 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 <jeremie.galarneau@efficios.com>
Change-Id: Ic8f016bc4cdd3dce2d7ea8ac9cccb53e3b69c5b0

3 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 <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3d94431051015c69785ec256095135746e3972ce

3 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 <jeremie.galarneau@efficios.com>
Change-Id: Ie821c5162c2fbe9c3d6705f464224c50ae9df1c8

3 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 <jeremie.galarneau@efficios.com>
Change-Id: Iaee6c54590e259ce053d368494ff0c8b356a36a1

3 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 <jeremie.galarneau@efficios.com>
Change-Id: Ic2a731b36467f898402ff5e19e329e5734e2da69

3 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 <jeremie.galarneau@efficios.com>
Change-Id: I7b5ebf90b868faded47a4e9675e01e1fb2b77a70

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

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I20127f655018260e45566d09d11c2852cd3b3f97
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 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 <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Idd3983c594ffecff0a20b71b7cd3d297e77446a1
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 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 <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9449e895b1eb88eb6db47dc3f8eb2864a2eb816d
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 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 <jeremie.galarneau@efficios.com>
Change-Id: I0048b60bee3969d2fa2b9ed94b6fb24d3b5ae659

3 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 <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I2ca8f72c023132c341193bf626c0dac20b89e1f2

3 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 <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I2cde2b3d2530e2114bff99b1b26ac6d83f575ad9
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 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 <jeremie.galarneau@efficios.com>
Change-Id: Icca5f4c2490c6796b451999d7694db8597bae719

3 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 <jeremie.galarneau@efficios.com>
Change-Id: I65d6bd46208dc7b62a83e4600a52a6669fd99d55

3 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 <jeremie.galarneau@efficios.com>
Change-Id: I951feeed92b346e79e34bec45a14f8b226283ae4

3 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 <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3e4aab84e3270ddef1f50f72f946a4d80b3f36e0
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

This page took 0.04823 seconds and 5 git commands to generate.