Simon Marchi [Mon, 6 Apr 2020 20:47:08 +0000 (16:47 -0400)]
common: introduce lttng_event_expr_to_bytecode
This function converts an event expression object in the appropriate
bytecode to capture the value described by that event expression.
Change-Id: I81c8f4ad40312e0d9f1a805a7e965a9d513cdde8
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
Simon Marchi [Mon, 6 Apr 2020 20:43:09 +0000 (16:43 -0400)]
common: add more bytecode helpers
The common/bytecode/bytecode.c file already contains some helper
functions that are used build bytecode. A following patch will require
helpers for a few more operations. This patch factors them out of the
filter-visitor-generate-bytecode.c file.
No functional changes intended.
Change-Id: I013e0dad3e0264d062e3e8733c05f7fbb4bda70c
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
Simon Marchi [Mon, 6 Apr 2020 18:20:05 +0000 (14:20 -0400)]
common: rename filter bytecode types
The filter bytecode is going to be used for implementing capture
expressions, so it's not going to be specific to filter. This patch
renames the types related to bytecode to remove "filter" from their
names.
All the changes start in bytecode/bytecode.h, the changes in the other
files are only fallouts.
- `enum filter_op` is renamed `enum bytecode_op`.
- `FILTER_OP_*` enumerators are renamed `BYTECODE_OP_*`.
- The `filter_opcode_t` typedef is renamed `bytecode_opcode_t`.
- `struct lttng_filter_bytecode_alloc` is renamed `struct lttng_bytecode_alloc`.
- `struct lttng_filter_bytecode` is renamed `struct lttng_bytecode`.
Change-Id: Iefdc667f3fbf715f868926c90108c6a5580b6f25
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
Simon Marchi [Wed, 8 Apr 2020 20:38:19 +0000 (16:38 -0400)]
common: move copy_filter_bytecode to bytecode.c and rename it
Since there's now a file dedicated to bytecode stuff, that is
independent of filters, move copy_filter_bytecode there. Rename it to
`bytecode_copy`.
Change-Id: I61a7a7fa1a04d39fbaf367f6bf8147b323aa8b27
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
Simon Marchi [Fri, 3 Apr 2020 17:50:57 +0000 (13:50 -0400)]
common: move bytecode utilities from filter to its own file
We'll want to re-use the filter bytecode to implement the trigger event
rule condition field captures. This is a preparatory patch that moves
some filter bytecode code in a location that is not filter-specific, so
it can be used for both filters and captures.
The content of common/filter/filter-bytecode.h is moved to
common/bytecode/bytecode.h. Some declarations for the various bytecode
helpers are added to that file. The implementation for these helpers is
moved from common/filter/filter-visitor-generate-bytecode.c to
common/bytecode/bytecode.c.
The content of src/common/bytecode is built as a library, so it can be
used by the filter-grammar-test program.
A following patch renames the content of bytecode/bytecode.h to remove
the "filter" part.
The rest of the changes is just to adapt the code to the changes
mentioned above.
Change-Id: Id602c9046bdc76791026c5b5a928387145d18e43
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479
Simon Marchi [Wed, 18 Mar 2020 16:11:18 +0000 (12:11 -0400)]
CLI: add-trigger: add --capture option to `on-event` condition
This patch adds a `--capture` option to the `on-event` condition, to
allow specifying the values of payload or context fields to capture.
The filter parser is re-used, as the syntax of the capture expression is
a subset of the filter expression syntax. Allowed forms are:
- payload field name: foo
- context field name: $ctx.foo
- app-specific field name: $app.foo:bar
After any of these, array indexing can be used. For example,
`$ctx.foo[2]`.
Change-Id: I6246148634053b32294956d1f7a03f2798fd1d71
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479
Francis Deslauriers [Thu, 10 Dec 2020 20:41:29 +0000 (15:41 -0500)]
notification-thread: drain all tracer notification on removal
We also force the restart of the poll loop to ensure a valid poll set
state on handle_notification_thread_command_remove_tracer_event_source.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I0c6b94309ddcf690d2e7603d5c718076e213095c
Francis Deslauriers [Tue, 2 Jun 2020 22:15:19 +0000 (18:15 -0400)]
Implements `lttng_event_notifier_notification_{create,destroy}()`
Capture payload will be later added to the lttng_event_notifier_notification object.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I404984c522cdf46c0df7c6ffbbe340d2f56cda2d
Depends-on: lttng-ust: I8423c510bf6af2f9bf85256e8d6f931d36f7054b
Philippe Proulx [Tue, 31 Mar 2020 01:26:09 +0000 (21:26 -0400)]
lttng-ctl: add capture descriptor feature to event rule condition API
This patch makes it possible to add capture descriptors to an event rule
condition.
A capture descriptor describes a value to be captured by an LTTng tracer
when an event occurs and to be attached to the corresponding condition's
evaluation.
The lttng_condition_event_rule_append_capture_descriptor() function
appends a capture descriptor to an event rule condition. The capture
descriptor is an event expression object of which the ownership is moved
to the condition object. The verb "append" here indicates that the order
of the condition's capture descriptors is significant: indeed, when
liblttng-ctl gets an upgrade to the "event rule hit" condition
evaluation API in the future to make its user read the captured values,
such values will be ordered the same way, therefore sharing the same
numeric indexes.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I68f163e6eb011e690f648d9ff8ea3eb89af004ff
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479
Philippe Proulx [Tue, 31 Mar 2020 01:23:25 +0000 (21:23 -0400)]
lttng-ctl: add event expression API
This new API having the prefix `lttng_event_expr` makes it possible to
create event expressions.
An event expression is an expression which can be evaluated by an LTTng
when an event occurs. An LTTng event filter expression, for example, is
an event expression, although the current interface to specify an event
filter expression is to use the string version, while this new API
offers functions to build an expression tree.
Currently, the event expressions API offers functions to create the
following types of expressions:
Event payload field expression:
The named payload field of an event.
Equivalent CLI string example:
next_prio
Channel context field:
The named per-channel context field of an event.
Equivalent CLI string example:
$ctx.vpid
Application-specific context field:
The named application-specific context field of an event.
Equivalent CLI string example:
$app.iga:active-clients
Array field element:
The element of an array field.
Equivalent CLI string examples:
my_field[4]
$ctx.some_context[5]
The attentive reader will have discovered that you cannot create all the
expressions needed to create any supported filter expression. This is
because the goal of this patch is to pave the way for the capture
descriptor feature of notify trigger actions, which, for the moment,
only need the expressions above. However, the event expression API can
be extended to support all the filtering subexpressions in the future.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I34770fa8900f0bfb90bb2cbf4a7de59a1645b738
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479
Jonathan Rajotte [Mon, 11 May 2020 17:33:30 +0000 (13:33 -0400)]
testapp: gen-ust-events: augment captured fields
Adds:
- negative integer,
- enums,
- escaped string,
- network array,
- network sequence,
- long sequence.
This partly bridges the gap between the event used for kernel testing
and the event used for userspace testing.
Bitfield array/sequence are not supported by the userspace tracer.
Change-Id: I027b9acfdcea2643201020c6c7907483cbbb2151
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479
Jérémie Galarneau [Fri, 5 Mar 2021 16:10:38 +0000 (11:10 -0500)]
spawn-viewer: silence bogus warning on gcc 5.4.0 PPC32
gcc 5.4.0 warns that saveptr is used uninitialized, but the use here
with strtok_r is fine, as documented in STRTOK(3). `saveptr` is merely
used as a return value when `str` is non-NULL.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1e47cb633f09978ebf9159f07dfacb8bef27a616
Jérémie Galarneau [Fri, 5 Mar 2021 13:09:18 +0000 (08:09 -0500)]
Tests: fix: leak of probe location in uprobe notification test
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I98fbde07949a3f60d4268d45c5ae6f8f4e62e8d4
Jérémie Galarneau [Fri, 5 Mar 2021 13:01:21 +0000 (08:01 -0500)]
Clean-up: uri_parse_str_urls: skip allocation when no uris are parsed
Meant as a way to silence a bogus Coverity warning. Skip the allocation
if both the ctrl and data uri parsing fails.
Coverity is confused and reports that uri_parse_str_urls() can return
a negative value after allocating the returned URIs (I don't see how,
and the path it reports is contradictory: 0 + 0 < 0.
I take the opportunity to rename the oddly--named "*_size" variables
which are not a "size", but rather a count of returned uris.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I79a82316ebd49d9fbbc5a8e67da64e44b789e2a7
Jérémie Galarneau [Fri, 5 Mar 2021 12:50:18 +0000 (07:50 -0500)]
Fix: lttng: add-trigger: erroneous null check on location return
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)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8202319d7f664bc20b2d6444ad296c03ed7dd628
Jérémie Galarneau [Fri, 5 Mar 2021 02:00:21 +0000 (21:00 -0500)]
Tests: remove test_notification_kernel from root_regression
test_notification_kernel no longer exists; its content was spread
into other notification tests. Remove it from the root_regression
test list.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I69027df4640f4d1265c6f3d82dea7734b3f421c7
Jérémie Galarneau [Thu, 4 Mar 2021 16:53:11 +0000 (11:53 -0500)]
Tests: kernel buffer usage: skip proper amount of tests when not root
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib7dba18bb8985c6a5d22d8b3d3e311c7b6e56b43
Jérémie Galarneau [Mon, 1 Mar 2021 23:41:00 +0000 (18:41 -0500)]
Tests: notification: use lttng.h instead of individual headers
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I71f2094ba6daaa6f013569618b7afd43929f1b6e
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
This page took 0.047724 seconds and 5 git commands to generate.