lttng-tools.git
3 years agoTests: Implement trigger capture test cases
Jonathan Rajotte [Thu, 7 May 2020 15:08:34 +0000 (11:08 -0400)] 
Tests: Implement trigger capture test cases

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

3 years agoman: lttng-add-trigger: document --capture option
Jonathan Rajotte [Wed, 27 May 2020 18:31:13 +0000 (14:31 -0400)] 
man: lttng-add-trigger: document --capture option

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

3 years agoCLI: make list-triggers command print capture expressions
Simon Marchi [Thu, 21 May 2020 02:42:00 +0000 (22:42 -0400)] 
CLI: make list-triggers command print capture expressions

When printing an event rule condition, in the `list-triggers` command,
print the capture expressions associated with that condition.

The result looks like:

    - id: T1
      condition: event rule hit
        rule: allo (type: tracepoint, domain: ust)
        captures:
          - $ctx.foo
      actions:
        notify
    - id: T2
      condition: event rule hit
        rule: allo (type: tracepoint, domain: ust)
        captures:
          - $app.iga:active_clients
      actions:
        notify

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

3 years agoSupport capture for kernel tracer
Jonathan Rajotte [Wed, 13 May 2020 23:02:43 +0000 (19:02 -0400)] 
Support capture for kernel tracer

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

3 years agolttng: Capture is only supported by tracepoint and syscall event-rules
Jonathan Rajotte [Wed, 13 May 2020 20:24:23 +0000 (16:24 -0400)] 
lttng: Capture is only supported by tracepoint and syscall event-rules

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

3 years agosessiond: notification-thread: Missing action executor status handling
Jonathan Rajotte [Wed, 23 Sep 2020 20:14:40 +0000 (16:14 -0400)] 
sessiond: notification-thread: Missing action executor status handling

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

3 years agosessiond: notification-thread: Missing domain internal header
Jonathan Rajotte [Wed, 23 Sep 2020 20:14:17 +0000 (16:14 -0400)] 
sessiond: notification-thread: Missing domain internal header

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

3 years agosessiond: action-executor: Missing notify header
Jonathan Rajotte [Wed, 23 Sep 2020 20:08:05 +0000 (16:08 -0400)] 
sessiond: action-executor: Missing notify header

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

3 years agoMake captured field values available to event rule cond. evaluation
Philippe Proulx [Fri, 1 May 2020 20:33:26 +0000 (16:33 -0400)] 
Make captured field values available to event rule cond. evaluation

liblttng-ctl:
    Add the public lttng_evaluation_get_captured_values() function.

    This function returns an array event field value which contains
    the captured field values as requested by the evaluation's
    condition's capture descriptors.

    This array event field value contains as many elements as returned
    by lttng_condition_event_rule_get_capture_descriptor_count() for the
    evaluation's condition. However,
    lttng_event_field_value_array_get_element_at_index() could return
    `LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE` for some or all indexes
    if there was no such field to capture at tracing time.

Common:
    Internally, an event rule evaluation now contains a captured field
    value payload (CFVP) as well as the array event field value to be
    returned by lttng_evaluation_get_captured_values().

    The CFVP is MessagePack-encoded.

    When you create an event rule evaluation with
    lttng_evaluation_event_rule_create(), you must pass the CFVP as well
    as the `decode_capture_payload` option parameter. If
    `decode_capture_payload` is `true`,
    lttng_evaluation_event_rule_create() creates the array event field
    value from the CFVP thanks to msgpack-c.

    lttng_evaluation_event_rule_create() also accepts the event rule
    condition now because it relies on the capture descriptors to create
    the event field values if `decode_capture_payload` is `true`.

    When an event rule evaluation is serialized:
        Only its CFVP is serialized (as is).

    When an event rule evaluation is deserialized:
        lttng_evaluation_event_rule_create() is called with the
        `decode_capture_payload` parameter set to `true`.

Session daemon:
    action_executor_notify_handler() calls
    lttng_evaluation_event_rule_create() with the
    `decode_capture_payload` parameter set to `false` to send the
    evaluation to the clients with the CFVP.

    This CFVP directly comes from the tracer.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib2ae39dae005ad555eb8309e0bfd53f746d5e8dd
Depends-on: lttng-ust: I8423c510bf6af2f9bf85256e8d6f931d36f7054b

3 years agonotification: fetch capture payload on notification reception
Jonathan Rajotte [Mon, 8 Mar 2021 20:59:01 +0000 (15:59 -0500)] 
notification: fetch capture payload on notification reception

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

3 years agoFix: set_ust_capture: missing ABI rename
Mathieu Desnoyers [Mon, 15 Mar 2021 19:58:13 +0000 (15:58 -0400)] 
Fix: set_ust_capture: missing ABI rename

struct lttng_ust_object_data has become struct
lttng_ust_abi_object_data. It gives a compiler warning.

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

3 years agotests: perf: UNHALTED_REFERENCE_CYCLES might not be actionable on a host
Jonathan Rajotte [Mon, 15 Mar 2021 15:25:07 +0000 (11:25 -0400)] 
tests: perf: UNHALTED_REFERENCE_CYCLES might not be actionable on a host

This patch does NOT address the root problem and only addresses the
validation of the context to be added during the test suite.

Observed issue
==============

The system_tests jobs for master hangs on the perf event test suites.

Cause
=====

The hang is caused by a cleanup problem (reference counting of the trace
chunk on session destroy/rotation) when the activation of a context
fails on a ust app channel.

This patch does NOT address the root problem and only addresses the
validation of the context to be added during the test suite. In all
cases we need to handle when a context fail, but for this test we need
to validate that the context can be added and skip the tests as
necessary based on the host.

The perf tests depend on the presence and accessibility of the
UNHALTED_REFERENCE_CYCLES PMU counter. This test suite was previously
run "manually" and since it required the presence and access to that
PMU. Since that the perf test suite is now run on `make check` when
libpfm is present, we need to automate the discovery of
UNHALTED_REFERENCE_CYCLES and validate that we can access it.

There are three major scenarios were we want to skip the tests.

1) UNHALTED_REFERENCE_CYCLES is simply not present in the PMU sets for
that hosts.

2) UNHALTED_REFERENCE_CYCLES is present in the PMU sets but not
actionable. This can happen on qemu guests.

3) UNHALTED_REFERENCE_CYCLES is present but not accessible. This can be
happen if the `/proc/sys/kernel/perf_event_paranoid` prevents the usage
of the PMU.

Solution
========

Two problems were found with `find_event.c`.

 1) It took the first event matching the passed name even if it was in a
 PMU not supported by the host. In our use case it worked since the only
 platform that does not use `r300` is not currently in our testing set.

 -> = PMU set currently choosen
 -* = The correct PMU set

 e.g:
 -> Intel Core
      r300
    Intel Atom
      r300
    Intel Nehalem
      r300
    Intel Nehalem EX
      r300
    Intel X86 architectural PMU
      r13c
    ...
 -* Intel Skylake
     r300

 On my system only the following are "detected" as per libpfm example
 found here [1].

   [18, ix86arch, "Intel X86 architectural PMU"]
   [51, perf, "perf_events generic PMU"]
   [110, rapl, "Intel RAPL"]
   [114, perf_raw, "perf_events raw PMU"]
   [200, skl, "Intel Skylake"]

 Hence the `skl` PMU set should be used.

 2) libpfm does not perform any validation as to if the event is actually
 usable or not.

To fix those two problems, we use pfm_get_os_event_encoding and
perf_event_open.

pfm_get_os_event_encoding [2] is responsible for performing the query
across valid PMU sets and encoding it to the perf struct format.

perf_event_open is used to validate that the event can be used. It tests
the availability on the running host and the accessibility of the PMU.

Based on the result of `find_event` the tests are skipped or failed as
necessary.

Known drawbacks
========

The only drawback is that the tests, albeit having libpfm as a
dependency, are not guarantee to run on all hosts. There is not much we
can do here. We can only validate that it is indeed run on our CI, most
probably using lava hardware-based workers.

References
==========

[1] https://sourceforge.net/p/perfmon2/libpfm4/ci/288483932c3eb83202b0d8762aa0ed8534982c3f/tree/examples/check_events.c
[2] https://man7.org/linux/man-pages/man3/pfm_get_os_event_encoding.3.html
[3] https://man7.org/linux/man-pages/man2/perf_event_open.2.html

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

3 years agoFix: tests: missing LOG_DRIVER and LOG_DRIVER_FLAGS
Jonathan Rajotte [Mon, 15 Mar 2021 17:13:37 +0000 (13:13 -0400)] 
Fix: tests: missing LOG_DRIVER and LOG_DRIVER_FLAGS

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

3 years agoAdapt to lttng-ust ust-abi.h naming prefix update
Mathieu Desnoyers [Fri, 12 Mar 2021 21:52:42 +0000 (16:52 -0500)] 
Adapt to lttng-ust ust-abi.h naming prefix update

LTTng-UST updates all its ust-abi.h symbols and defines to use the
lttng_ust_abi_ and LTTNG_UST_ABI_ prefixes. Adapt lttng-tools
accordingly.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ifde8b73604c84ee37e9123f5dd912e7a806deb38
Depends-on: lttng-ust: I1273be9615846304266206769700e799bde4e51f

3 years agoUse bytecode seqnum to force the evaluation ordering of capture bytecode
Jonathan Rajotte [Thu, 16 Apr 2020 20:31:16 +0000 (16:31 -0400)] 
Use bytecode seqnum to force the evaluation ordering of capture bytecode

This ensure that the resulting payload is ordered as expected.

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

3 years agosessiond: ust-app: set capture bytecode on event notifier on creation
Jonathan Rajotte [Thu, 9 Apr 2020 01:40:41 +0000 (21:40 -0400)] 
sessiond: ust-app: set capture bytecode on event notifier on creation

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

3 years agosessiond: ust-app: add utils to add a capture bytecode to a ust object
Jonathan Rajotte [Tue, 28 Apr 2020 14:37:55 +0000 (10:37 -0400)] 
sessiond: ust-app: add utils to add a capture bytecode to a ust object

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

3 years agoUST abi: add `struct lttng_ust_capture_bytecode`
Jonathan Rajotte [Thu, 14 May 2020 16:44:38 +0000 (12:44 -0400)] 
UST abi: add `struct lttng_ust_capture_bytecode`

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

3 years agoFix: sessiond: off-by-one poll check when draining an event notifier
Jérémie Galarneau [Fri, 12 Mar 2021 19:54:52 +0000 (14:54 -0500)] 
Fix: sessiond: off-by-one poll check when draining an event notifier

When an event source is removed (on the death of an application), the
notification thread "drains" any remaining notifications from the
event notifier pipe.

In doing so, it creates a new poll set containing the event source to
check if messages are left in the event notification pipe.

The invocation of `LTTNG_POLL_GETEV(&events, 1)` means to check the
events pending for the first (and only) fd in the poll set. This check
is off by one since `0` should be used.

For some reason, this worked everywhere except when using a 32-bit
userland on a 64-bit kernel (on x86_64).

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

3 years agolttng-ctl: add event field value API
Philippe Proulx [Fri, 1 May 2020 20:31:01 +0000 (16:31 -0400)] 
lttng-ctl: add event field value API

This patch adds a new read-only event field value API to liblttng-ctl.
It also adds the internal functions to create such objects.

As of this patch, an event field value is one of:

* An unsigned integer (64-bit).
* A signed integer (64-bit).
* An unsigned enumeration (64-bit).
* A signed enumeration (64-bit).
* A real number (double precision).
* A string (UTF-8).
* An array of zero or more event field values.

The first purpose of this API will be to access the captured field
values of a notification's trigger condition evaluation.

An enumeration event field value conceptually is an integer event field
value, therefore lttng_event_field_value_unsigned_int_get_value() works
for an unsigned enumeration and
lttng_event_field_value_signed_int_get_value() works for a signed
enumeration.

The compound event field values (array only, as of this patch) can
return the `LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE` status when you
access a contained event field value. This indicates that there is no
field at this location. For the captured field value use case, it means
the event did not have any field at that position considering the
condition's capture descriptors. Internally, call
lttng_event_field_value_array_append_unavailable() to append an
unavailable event field value to an array field value.

The lttng_event_field_value_array_get_element_at_index() function can
also return an event field value of which the type, as returned by
lttng_event_field_value_get_type(), is
`LTTNG_EVENT_FIELD_VALUE_TYPE_UNKNOWN`. This is different from the
`LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE` status: the event field
value exists (which is why there's a valid
`struct lttng_event_field_value *`), but its type is unknown by this
version of the library. This makes it possible to add new event field
value types in the future while remaining forward compatible.

Note that enumeration labels will not visible to clients since the
kernel tracer does not make their content accessible to the session
daemon.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I04d327d9f50ff6c6e2ad1f5a1e56c3af25c92c15
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoCleanup: sessiond: fix comments to match with behavior
Francis Deslauriers [Thu, 11 Mar 2021 16:18:40 +0000 (11:18 -0500)] 
Cleanup: sessiond: fix comments to match with behavior

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

3 years agoFix: sessiond: return _OK on _SET_SESSION_SHM_PATH command success
Francis Deslauriers [Thu, 11 Mar 2021 16:06:53 +0000 (11:06 -0500)] 
Fix: sessiond: return _OK on _SET_SESSION_SHM_PATH command success

Issue
=====
When running the `test_crash` tests, I witness the following warning:
  Warning: Command returned an invalid status code, returning unknown error: command type = 40, ret = 0

The `cmd_set_session_shm_path()` function is returning 0 on success
instead of the expected LTTNG_OK which leads to this warning being
printed.

Fix
===
Return LTTNG_OK.

Side note
=========
I added the string version of the command name in the warning printing
for easier debugging.

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

3 years agoGenerate capture bytecode on trigger reception
Jonathan Rajotte [Thu, 9 Apr 2020 00:03:06 +0000 (20:03 -0400)] 
Generate capture bytecode on trigger reception

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

3 years agoImplement lttng_condition_event_rule_get_capture_bytecode_at_index
Jonathan Rajotte [Tue, 3 Nov 2020 23:04:34 +0000 (18:04 -0500)] 
Implement lttng_condition_event_rule_get_capture_bytecode_at_index

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

3 years agocondition: implement lttng_condition_event_rule_generate_capture_descriptor_bytecode
Jonathan Rajotte [Wed, 8 Apr 2020 21:51:52 +0000 (17:51 -0400)] 
condition: implement lttng_condition_event_rule_generate_capture_descriptor_bytecode

Generate the bytecode related to the tracer notification capture
feature.

The bytecode is stored alongside the lttng_event_expr in an internal
lttng_capture_descriptor object.

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

3 years agocondition: implement lttng_condition_event_rule_get_internal_capture_descriptor_at_index
Jonathan Rajotte [Wed, 29 Apr 2020 19:36:00 +0000 (15:36 -0400)] 
condition: implement lttng_condition_event_rule_get_internal_capture_descriptor_at_index

The lttng_capture_descriptor object is only exposed internally. A
getter is necessary to allow more control on the
lttng_capture_descriptor object. This will be reused to set the bytecode
later in the patchset.

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

3 years agoFix: lttng: add-trigger: payload capture fields specified as contexts
Jérémie Galarneau [Thu, 11 Mar 2021 20:26:01 +0000 (15:26 -0500)] 
Fix: lttng: add-trigger: payload capture fields specified as contexts

ir_op_load_expr_to_event_expr() re-uses the same `load_expr_op` variable
to traverse the IR. A check for the type of the original load expression
is performed after `load_expr_op->next` is assigned to load_expr_op
which is expected to have remained the same.

The original event_expr child type is sampled at the start of the
function and re-used as needed.

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

3 years agoFix: event-expr-to-bytecode: use after free in logging on error
Jérémie Galarneau [Tue, 9 Mar 2021 21:39:11 +0000 (16:39 -0500)] 
Fix: event-expr-to-bytecode: use after free in logging on error

1448709 Use after free

This could cause an immediate crash or incorrect values might be read
subsequently resulting in incorrect computations.

In event_expr_to_bytecode_recursive: A pointer to freed memory is
dereferenced, used as a function argument, or otherwise used (CWE-416)

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

3 years agomsgpack: silence uninitialized msg_pack_object warning
Jérémie Galarneau [Tue, 9 Mar 2021 21:23:37 +0000 (16:23 -0500)] 
msgpack: silence uninitialized msg_pack_object warning

Present in the upstream msgpack code. I couldn't find a problematic use,
but this will silence Coverity and is cleaner.

Nothing should access 'via' when the type of a msg_pack_object is NIL.

Coverity report:

1448708 Uninitialized scalar variable

The variable will contain an arbitrary value left from earlier
computations.

In template_callback_root: Use of an uninitialized variable (CWE-457)

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

3 years agoFix: lttng: add-trigger: erroneous null check on location return
Jérémie Galarneau [Tue, 9 Mar 2021 21:21:11 +0000 (16:21 -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)

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

3 years agocondition: introduce lttng_capture_descriptor struct
Jonathan Rajotte [Wed, 8 Apr 2020 14:45:40 +0000 (10:45 -0400)] 
condition: introduce lttng_capture_descriptor struct

The capture_index corresponds to the index at which the capture is
expected on reception of the trigger payload from the tracer.

This field will be populated on reception of the trigger on the sessiond
side and is internal use only.

This is necessary due to the fact that a single condition can have
multiple capture actions associated to it with capture descriptor
duplicate. We plan on forming an ordered set of these capture
descriptors and configure only the set for the enabler. This ensures
that we capture only what is required on the tracer side. On reception,
each capture descriptor will know the index at which the payload field
it corresponds to is situated.

In retrospect this is purely an optimization to prevent the tracer from
doing unnecessary work.

Initially this complexity was planned to be contained to the
lttng-sessiond, but since we now transfer the msgpack payload all the
way to liblttngctl we now have to carry this index all the way to
liblttng-ctl.

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

3 years agosessiond: Add msgpack-c 3.3.0 to the tree
Jérémie Galarneau [Fri, 25 Sep 2020 17:08:51 +0000 (13:08 -0400)] 
sessiond: Add msgpack-c 3.3.0 to the tree

Add a copy of the msgpack-c v3.3.0 release to the tree. Only the files
of the 'C' version of the library are included and the only
modifications are to add the 'vendor/' prefix to the includes to make
sure we don't interact with a system installed version of msgpack and
the addition of lttng-config.h to glue in our endianess compat code.

Currently, the project is built against the system's libmsgpack-c.
However, this isn't viable for release since the library has had
breaking changes (sometimes without bumping the major version) every
year since its initial release.

Given the variety of distribution versions we have to support, I don't
feel comfortable commiting to support all possible versions of this
library.

Nonetheless, this appears to be the most robust C msgpack implementation
and it is permissively licensed, so it is simply easier to add a copy to
the tree.

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

3 years agoust-app: pass down trigger object instead of event-rule
Jonathan Rajotte [Wed, 8 Apr 2020 14:43:55 +0000 (10:43 -0400)] 
ust-app: pass down trigger object instead of event-rule

This is necessary since the conditions can contain capture descriptor
related to the event rule. The trigger object allows for access to both
conditions and actions.

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

3 years agoClean-up: bytecode: harmonize storage-class specifier placement
Jérémie Galarneau [Mon, 8 Mar 2021 22:41:37 +0000 (17:41 -0500)] 
Clean-up: bytecode: harmonize storage-class specifier placement

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

3 years agoClean-up: bytecode: hide file-local bytecode_reserve util
Jérémie Galarneau [Mon, 8 Mar 2021 22:40:45 +0000 (17:40 -0500)] 
Clean-up: bytecode: hide file-local bytecode_reserve util

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

3 years ago.gitignore: add notification-client and test_event_expr_to_bytecode
Jérémie Galarneau [Mon, 8 Mar 2021 21:57:24 +0000 (16:57 -0500)] 
.gitignore: add notification-client and test_event_expr_to_bytecode

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

3 years agocommon: introduce lttng_event_expr_to_bytecode
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

3 years agocommon: add more bytecode helpers
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

3 years agocommon: rename filter bytecode types
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

3 years agocommon: move copy_filter_bytecode to bytecode.c and rename it
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

3 years agocommon: move bytecode utilities from filter to its own file
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

3 years agoCLI: add-trigger: add --capture option to `on-event` condition
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

3 years agonotification-thread: drain all tracer notification on removal
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

3 years agoImplements `lttng_event_notifier_notification_{create,destroy}()`
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

3 years agolttng-ctl: add capture descriptor feature to event rule condition API
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

3 years agolttng-ctl: add event expression API
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

3 years agotestapp: gen-ust-events: augment captured fields
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

3 years agospawn-viewer: silence bogus warning on gcc 5.4.0 PPC32
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

3 years agoTests: fix: leak of probe location in uprobe notification test
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

3 years agoClean-up: uri_parse_str_urls: skip allocation when no uris are parsed
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

3 years agoFix: lttng: add-trigger: erroneous null check on location return
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

3 years agoTests: remove test_notification_kernel from root_regression
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

3 years agoTests: kernel buffer usage: skip proper amount of tests when not root
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

3 years agoTests: notification: use lttng.h instead of individual headers
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

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

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