lttng-tools.git
3 years agoFix: userspace-probe: unreported error on string copy error
Jérémie Galarneau [Mon, 4 Oct 2021 16:41:51 +0000 (12:41 -0400)] 
Fix: userspace-probe: unreported error on string copy error

Issue
=====

String copy errors, either due to the length or an allocation failure,
are not reported by
lttng_userspace_probe_location_tracepoint_create_from_payload
and don't log a clear error message.

This allowed truncation bugs like the one fixed in b45a296 to go
unnoticed.

Fix
===

Return an "invalid" status code and log a more descriptive error
message.

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

3 years agoFix: userspace-probe: truncating binary path for SDT
Francis Deslauriers [Fri, 1 Oct 2021 20:10:24 +0000 (16:10 -0400)] 
Fix: userspace-probe: truncating binary path for SDT

Issue
=====
This issue was uncovered when we enabled the testing of the SDT
userspace probe instrumentation on the CI, where the paths to file are
specially long.

The reported error is:
  -    rule: ma-probe-sdt (type: kernel:uprobe, location type: SDT, location: /root/workspace/dev_gerrit_lttng-tools_rootbuild/arch/amd64/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/node/amd64-rootnode/test_type/base/src/lttng-tools/tests/utils/testapp/userspace-probe-sdt-binary/.libs/userspace-probe-sdt-binary:foobar:tp1)
  +    rule: ma-probe-sdt (type: kernel:uprobe, location type: SDT, location: /root/workspace/dev_gerrit_lttng-tools_rootbuild/arch/amd64/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/node/amd64-rootnode/test_type/base/src/lttng-tools/tests/utils/testapp/userspace-probe-sdt-binary/.libs/userspace-probe-s:foobar:tp1)

The important part to notice is that the path to the binary is truncated
compared to was is expected by the test case.

The problem is caused by the
`lttng_userspace_probe_location_tracepoint_create_from_payload()`
function that strdup() the path string using the wrong defined value.

Fix
===
Use LTTNG_PATH_MAX rather then LTTNG_SYMBOL_NAME_LEN to copy the binary
path.

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

3 years agoClean-up: sessiond: remove unused ust_app_{lock, unlock}_list declarations
Jérémie Galarneau [Tue, 7 Sep 2021 21:37:37 +0000 (17:37 -0400)] 
Clean-up: sessiond: remove unused ust_app_{lock, unlock}_list declarations

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

3 years agoFix: lttng: add-trigger: don't provide a default event rule type
Jérémie Galarneau [Thu, 1 Jul 2021 19:50:47 +0000 (15:50 -0400)] 
Fix: lttng: add-trigger: don't provide a default event rule type

There is no reason for an event rule to have a default type. The
--type parameter is required.

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

3 years agoForce usage of assert() condition when NDEBUG is defined
Francis Deslauriers [Fri, 20 Aug 2021 19:26:01 +0000 (15:26 -0400)] 
Force usage of assert() condition when NDEBUG is defined

Reuse the BT2 approach to force the usage of the assertion condition
even when assert() are removed by the NDEBUG define.

See `BT_USE_EXPR()` macro and documentation in Babeltrace commit[0]:
  commit 1778c2a4134647150b199b2b57130817144446b0
  Author: Philippe Proulx <eeppeliteloop@gmail.com>
  Date:   Tue Apr 21 11:15:42 2020 -0400
  lib: assign a unique ID to each pre/postcond. and report it on failure

0: https://github.com/efficios/babeltrace/commit/1778c2a4134647150b199b2b57130817144446b0

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

3 years agoFix: statements with side-effects in assert statements
Francis Deslauriers [Thu, 19 Aug 2021 21:14:46 +0000 (17:14 -0400)] 
Fix: statements with side-effects in assert statements

Background
==========
When building with the NDEBUG definition the `assert()` statements are
removed.

Issue
=====
Currently, a few `assert()` statements in the code base contain
statements that have side effects and removing them changes the
behavior for the program.

Fix
===
Extract the statements with side effects out of the `assert()`
statements.

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

3 years agoFix: lttng_trace_archive_location_serialize is called on freed memory
Jonathan Rajotte [Thu, 16 Sep 2021 15:20:07 +0000 (11:20 -0400)] 
Fix: lttng_trace_archive_location_serialize is called on freed memory

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

The following backtrace have been reported [1].

 #0  __GI_raise (sig=sig@entry=6) at /usr/src/debug/glibc/2.31+gitAUTOINC+f84949f1c4-r0/git/sysdeps/unix/sysv/linux/raise.c:50
 #1  0x0000003123025528 in __GI_abort () at /usr/src/debug/glibc/2.31+gitAUTOINC+f84949f1c4-r0/git/stdlib/abort.c:79
 #2  0x0000000000419884 in lttng_trace_archive_location_serialize (location=0x7f1c9c001160, buffer=0x7f1cb961c320) at /usr/src/debug/lttng-tools/2.13.0-r0/lttng-tools-2.13.0/src/common/location.c:230
 #3  0x00000000004c8f06 in lttng_evaluation_session_rotation_serialize (evaluation=0x7f1cb000a7f0, payload=0x7f1cb961c320) at /usr/src/debug/lttng-tools/2.13.0-r0/lttng-tools-2.13.0/src/common/conditions/session-rotation.c:539
 #4  0x00000000004a80fa in lttng_evaluation_serialize (evaluation=0x7f1cb000a7f0, payload=0x7f1cb961c320) at /usr/src/debug/lttng-tools/2.13.0-r0/lttng-tools-2.13.0/src/common/evaluation.c:42
 #5  0x00000000004bc24f in lttng_notification_serialize (notification=0x7f1cb961c310, payload=0x7f1cb961c320) at /usr/src/debug/lttng-tools/2.13.0-r0/lttng-tools-2.13.0/src/common/notification.c:63
 #6  0x0000000000458b7d in notification_client_list_send_evaluation (client_list=0x7f1cb0008f90, trigger=0x7f1ca40113d0, evaluation=<optimized out>, source_object_creds=0x7f1cb000a874, client_report=0x475840 <client_handle_transmission_status>, user_data=0x7f1cb0006010) at /usr/src/debug/lttng-tools/2.13.0-r0/lttng-tools-2.13.0/src/bin/lttng-sessiond/notification-thread-events.c:4379
 #7  0x0000000000476586 in action_executor_generic_handler (item=0x7f1cb0009600, work_item=0x7f1cb000a820, executor=0x7f1cb0006010) at /usr/src/debug/lttng-tools/2.13.0-r0/lttng-tools-2.13.0/src/bin/lttng-sessiond/action-executor.c:696
 #8  action_work_item_execute (work_item=0x7f1cb000a820, executor=0x7f1cb0006010) at /usr/src/debug/lttng-tools/2.13.0-r0/lttng-tools-2.13.0/src/bin/lttng-sessiond/action-executor.c:715
 #9  action_executor_thread (_data=0x7f1cb0006010) at /usr/src/debug/lttng-tools/2.13.0-r0/lttng-tools-2.13.0/src/bin/lttng-sessiond/action-executor.c:797
 #10 0x0000000000462327 in launch_thread (data=0x7f1cb00060b0) at /usr/src/debug/lttng-tools/2.13.0-r0/lttng-tools-2.13.0/src/bin/lttng-sessiond/thread.c:66
 #11 0x0000003123408ea4 in start_thread (arg=<optimized out>) at /usr/src/debug/glibc/2.31+gitAUTOINC+f84949f1c4-r0/git/nptl/pthread_create.c:477
 #12 0x00000031230f8dcf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

This can be easily reproduced with the following session and trigger
configuration:

 lttng create test
 lttng enable-event -u -a
 lttng start
 # Register two similar triggers via a dummy C program since rotation
 # completed condition is not exposed on the CLI for now. Yielding the
 # following triggers:
 lttng list-triggers
 - name: trigger0
   owner uid: 1000
   condition: session rotation completed
     session name: test
     errors: none
  action:notify
   errors: none
 - name: trigger1
   owner uid: 1000
   condition: session rotation completed
     session name: test
     errors: none
  action:notify
   errors: none

  lttng rotate <- abort happens here.

Cause
=====

The problem lies in how the location (`lttng_trace_archive_location`)
object is assigned to the `lttng_evaluation` objects. A single location
object can end up being shared between multiple `lttng_evaluation` objects
since we iterate over all triggers and create an `lttng_evaluation` object
with the location each time as needed.

See `src/bin/lttng-sessiond/notification-thread-events.c:1956`.

The location object is then freed when the first notification is
completely serialized. The second serialization end up having a
reference to a freed `lttng_trace_archive_location` object.

Solution
========

Implement ref counting for the lttng_trace_archive_location object.

Note
=======

This also fixes a leak that was present in `cmd_destroy_session_reply`.

The location is created by `session_get_trace_archive_location` and is
never `destroyed`/`put`.

Known drawbacks
=========

None.

References
==========

[1] https://bugs.lttng.org/issues/1325

Fixes: #1325
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I99dc595ee5b0288c727b193ed061f5273752bd24
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoFix: sessiond: ust session is inactive during ust_app_global_update
Jonathan Rajotte [Mon, 13 Sep 2021 20:49:48 +0000 (16:49 -0400)] 
Fix: sessiond: ust session is inactive during ust_app_global_update

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

The following scenario leads to an abort of lttng-sessiond.

 lttng-sessiond (with kernel tracing available)
 lttng create system-trace --snapshot -U /tmp/snapshot
 lttng enable-channel -k system-trace --subbuf-size=4k --num-subbuf=256
 lttng enable-event -c system-trace -k 'sched_wak*' -s system-trace
 lttng start system-trace

 lttng enable-event -u -a

Fails as expected with:
 Error: Events: The command tried to enable an event in a new domain for
 a session that has already been started once. (channel channel0,
 session system-trace)

Launch any ust app such as easy_ust from the lttng-ust repository.

The following backtrace is generated:

 (gdb) bt
 #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
 #1  0x00007ffff7af0859 in __GI_abort () at abort.c:79
 #2  0x00007ffff7af0729 in __assert_fail_base (fmt=0x7ffff7c86588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55555564b765 "usess->active", file=0x555555649a60 "ust-app.c", line
 #3  0x00007ffff7b01f36 in __GI___assert_fail (assertion=0x55555564b765 "usess->active", file=0x555555649a60 "ust-app.c", line=5123, function=0x55555564ecf0 <__PRETTY_FUNCTION__.14199> "ust_
 #4  0x00005555555d1f5e in ust_app_global_update (usess=0x7fffe001fb90, app=0x7fffac000b80) at ust-app.c:5123
 #5  0x00005555555b60d4 in update_ust_app (app_sock=82) at dispatch.c:71
 #6  0x00005555555b7025 in thread_dispatch_ust_registration (data=0x5555556a07f0) at dispatch.c:409
 #7  0x00005555555ad5ab in launch_thread (data=0x5555556a0810) at thread.c:65
 #8  0x00007ffff7ce6609 in start_thread (arg=<optimized out>) at pthread_create.c:477
 #9  0x00007ffff7bed293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

This also happens for the track command. You can replace the `lttng
enable-event -u -a` with `lttng track --userspace --vuid=0` then launch
an app and the same backtrace gets generated.

Cause
=====

During `process_client_msg` the `create_ust_session` function is called
and a ust session is assigned to the "system_trace" session with a
state of `active` set to 0 (false). This is not a problem.

The problem seems to lie with a single call site for
`ust_app_global_update` in `update_ust_app`. The status of the ust
session is not checked before calling the `ust_app_global_update`. It is
important to note that all `ust_app_global_update_all` callsites guard
the call with a check against the status of the session.

Solution
========

Guard the call to `ust_app_global_update` with a check of the ust
session active state.

Known drawbacks
=========

None.

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

3 years agoFix: common: error query for trigger action protocol error
Jonathan Rajotte [Tue, 14 Sep 2021 20:10:36 +0000 (16:10 -0400)] 
Fix: common: error query for trigger action protocol error

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

When listing a trigger with a single non-list action the CLI reports an
error in the protocol resulting in an output with no error accounting
for the action.

 $ lttng list-triggers
  - name: trigger0
    owner uid: 1000
    condition: session rotation ongoing
      session name: test
      errors: none
   action:notify
  Error: Failed to query errors of trigger 'trigger0' (owner uid: 1000): Protocol error occurred

Cause
=====

The `action_path` associated with the query has an index count of 0 as
it should considering that the single root element action element is not
a `list` object.

Inside `lttng_action_path_create_from_payload` a payload view is
initialized with a `len` of 0 since `header->index_count` is 0 as it
should.

The payload view is then validated and is considered invalid since the
validation check for `len` > 0. The error then bubbles up.

Solution
========

Since that the payload view is considered invalid when it is equal to
zero simply handle this special case and call directly
`lttng_action_path_create` with the appropriate parameter.

Known drawbacks
=========

None.

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

3 years agoFix: common: un-hide two rate policy functions
Simon Marchi [Tue, 21 Sep 2021 14:31:55 +0000 (10:31 -0400)] 
Fix: common: un-hide two rate policy functions

These functions are part of the liblttng-ctl API/ABI, they should not be
hidden.

Change-Id: Ic04bb4e7a0bfd0c7d661228b7ccf5d17dccfd9ba
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoFix: include: remove unneeded declaration of lttng_session_descriptor_get_session_name
Simon Marchi [Tue, 21 Sep 2021 13:30:09 +0000 (09:30 -0400)] 
Fix: include: remove unneeded declaration of lttng_session_descriptor_get_session_name

There is a declaration of lttng_session_descriptor_get_session_name in
both session-descriptor.h and session-descriptor-internal.h.  Since this
is a function exposed by the API, the one in -internal.h is not needed,
remove it.

Since the removed declaration had LTTNG_HIDDEN, this has the effect of
making the lttng_session_descriptor_get_session_name symbol of
liblttng-ctl exported / part of the ABI. I think it was a mistake that
it wasn't previously exported.

Change-Id: I79d383f012d161a6df42240c6849b1b3af109def
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoFix: Tests: race condition in test_ns_contexts_change
Francis Deslauriers [Wed, 8 Sep 2021 14:16:23 +0000 (10:16 -0400)] 
Fix: Tests: race condition in test_ns_contexts_change

Issue
=====
The test script doesn't wait for the test application to complete before
stopping the tracing session. The race is that depending on the
scheduling the application is not always done generating events when the
session is stopped.

Fix
===
Make the test script wait for the termination of the test app before
stopping the session.

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

3 years agoFix: Tests: race condition in test_event_tracker
Francis Deslauriers [Tue, 7 Sep 2021 21:10:31 +0000 (17:10 -0400)] 
Fix: Tests: race condition in test_event_tracker

Background
==========
The `test_event_tracker` file contains test cases when the event
generating app in executed in two distinct steps. Those two steps are
preparation and execution.
  1. the preparation is the launching the app in the background, and
  2. the execution is actually generating the event that should or
     should not be traced depending on the test case.

This is useful to test the tracker feature since we want to ensure that
already running apps are notified properly when changing their tracking
status.

Issue
=====
The `test_event_vpid_track_untrack` test case suffers from a race
condition that is easy to reproduce on Yocto.

The issue is that sometimes events are end up the trace when none is
expected.

This is due to the absence of synchronization point at the launch of the
app which leads to the app being scheduled in-between the track-untrack
calls leading to events being recorded to the trace.

It's easy to reproduce this issue on my machine by adding a `sleep 5`
between the track and untrack calls and setting the `NR_USEC_WAIT`
variable to 1.

Fix
===
Using the testapp `--sync-before-last-event-touch` flag to make the app
create a file when all but the last event are executed. We then have the
app wait until we create a file (`--sync-before-last-event`) to generate
that last event. This way, we are sure no event will be generated when
running the track and untrack commands.

Notes
=====
- This issue affects other test cases in this file.
- This commit fixes a typo in the test header.
- This commit adds `diag` calls to help tracking to what test the output
  relates to when reading the log.

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

3 years agotests: tap: remove semicolons in pass / fail definitions
Simon Marchi [Fri, 20 Aug 2021 19:36:50 +0000 (15:36 -0400)] 
tests: tap: remove semicolons in pass / fail definitions

I wanted to write something like this in a test:

    if (cond)
      fail("message 1");
    else
      fail("message 2");

And was met with

      CC       test_action.o
    /home/simark/src/lttng-tools/tests/unit/test_action.c: In function ‘main’:
    /home/simark/src/lttng-tools/tests/unit/test_action.c:544:9: error: ‘else’ without a previous ‘if’
      544 |         else
          |         ^~~~

I then remembered that it was in our coding style to use braces:

    if (cond) {
      fail("message 1");
    } else {
      fail("message 2");
    }

... which avoids the error.  But still, the former form should work.
Fix this by removing the semi-colons in the pass and fail definitions, I
don't think they belong there.  Doing so finds a spot in ini_config.c
where a semi-colon is missing, add it.

Change-Id: I6ff09d496a0b12f34baa6f993cffc69eef611df0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoconfigure: add -Wno-gnu-folding-constant
Simon Marchi [Mon, 23 Aug 2021 18:01:17 +0000 (14:01 -0400)] 
configure: add -Wno-gnu-folding-constant

When building with clang 12, I get:

  CC       tp.o
    In file included from /home/simark/src/lttng-tools/tests/utils/testapp/gen-ust-events/tp.c:10:
    In file included from /home/simark/src/lttng-tools/tests/utils/testapp/gen-ust-events/./tp.h:75:
    In file included from /tmp/lttng/include/lttng/tracepoint-event.h:69:
    In file included from /tmp/lttng/include/lttng/ust-tracepoint-event.h:1021:
    /home/simark/src/lttng-tools/tests/utils/testapp/gen-ust-events/./tp.h:30:1: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant]
    TRACEPOINT_EVENT(tp, tptest,
    ^
    /tmp/lttng/include/lttng/tracepoint.h:791:27: note: expanded from macro 'TRACEPOINT_EVENT'
    #define TRACEPOINT_EVENT                LTTNG_UST_TRACEPOINT_EVENT
                                            ^
    /tmp/lttng/include/lttng/ust-tracepoint-event.h:84:2: note: expanded from macro 'LTTNG_UST_TRACEPOINT_EVENT'
            LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name,             \
            ^
    /tmp/lttng/include/lttng/ust-tracepoint-event.h:940:10: note: expanded from macro 'LTTNG_UST__TRACEPOINT_EVENT_CLASS'
                    size_t __dynamic_len[__num_fields];                           \
                           ^

From what I understand, this warning simply says that the compiler did
figure out that __num_fields could be known at compile-time, so
__dynamic_len ends up as a regular static array and not a variable
length array (which is what we want).  And it warns us that this
behavior is not standard C, but an extension that originated from GNU.

So I think it's fine to ignore it, as it simply warns us that the
behavior we want happens.

Change-Id: Ib7273e7f86c6b04742f8463f925cdbb1fa14041d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoFix: man: lttng-rotate: trace file count/size limitation does not apply
Jérémie Galarneau [Fri, 13 Aug 2021 15:15:15 +0000 (11:15 -0400)] 
Fix: man: lttng-rotate: trace file count/size limitation does not apply

Reported-by: Zach Kramer <Zach.Kramer@cognex.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I337fd06a12d145bdd97c14b4b1894e3676945f63

3 years agoFix: runas: less-than-zero comparison of an unsigned value
Francis Deslauriers [Fri, 6 Aug 2021 13:40:20 +0000 (09:40 -0400)] 
Fix: runas: less-than-zero comparison of an unsigned value

Fixes two defects found by Coverity related to unsigned integers being
treated as signed.

Reported by Coverity:
    CID 1461333:  Control flow issues  (NO_EFFECT)
    This less-than-zero comparison of an unsigned value is never true. "buf_size < 0UL".

    CID 1461332:  Integer handling issues  (NEGATIVE_RETURNS)
    "buf_size" is passed to a parameter that cannot be negative.

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

3 years agorun-as: clean-up: handle_one_cmd: mark initial uid/gid as const
Jérémie Galarneau [Thu, 5 Aug 2021 21:30:28 +0000 (17:30 -0400)] 
run-as: clean-up: handle_one_cmd: mark initial uid/gid as const

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

3 years agoFix: runas: supplementary groups are ignored on lttng save
Francis Deslauriers [Fri, 23 Jul 2021 20:27:00 +0000 (16:27 -0400)] 
Fix: runas: supplementary groups are ignored on lttng save

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

On `lttng save` the following is reported to the user:

 $ sudo -u my_user lttng save -o /tmp/my_dir my_session_name
 Error: Permission denied

Note that:
  * the running lttng-sessiond is root,
  * "my_user" is part of the tracing group,
  * "my_user" primary group is "my_user" and is part of group "my_dummy_group"
  * The "/tmp/my_dir" has the following permissions:

    drwxrwx--- 2 root my_dummy_group 4096 Jul 26 16:39 /tmp/my_dir/

Cause
=====

The supplementary groups are not initialized when the run-as process
demote itself to the user "my_user" to perform the recursive mkdir
required by the `lttng save` command.

From the point of the view the kernel, at the moment of performing the
mkdir call the permissions looks like this:

 euid: uid of "my_user"
 egid: primary gid of "my_user"
 supplementary group list: "root"

Note that the kernel does not treat the presence of the root group in
the supplementary group list in any special way. Since "root gid" !=
"my_dummy_group gid" the directory creation is refused.

Solution
========

Use initgroups(3) to initialize the supplementary group list.

Known drawbacks
=========

None.

Signed-off-by: Francis Deslauriers <francis.deslauriers@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: I58656a3107e4f7b59a2391a4759988401cad7a2b

3 years agoDocs: lttng-event-rule(7): --exclude does not exist, use --exclude-name
Jérémie Galarneau [Tue, 3 Aug 2021 18:27:03 +0000 (14:27 -0400)] 
Docs: lttng-event-rule(7): --exclude does not exist, use --exclude-name

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

3 years agosessiond: logging typo: {triger, triggger} -> trigger
Francis Deslauriers [Thu, 8 Jul 2021 19:46:02 +0000 (15:46 -0400)] 
sessiond: logging typo: {triger, triggger} -> trigger

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

3 years agoFix: lttng: free sessions in cmd_destroy
Simon Marchi [Mon, 2 Aug 2021 01:02:39 +0000 (21:02 -0400)] 
Fix: lttng: free sessions in cmd_destroy

When doing `lttng destroy`, I get:

    Direct leak of 4385 byte(s) in 1 object(s) allocated from:
        #0 0x7f74ae025459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
        #1 0x7f74add4129a in zmalloc /home/simark/src/lttng-tools/src/common/macros.h:45
        #2 0x7f74add42b9d in recv_sessiond_optional_data /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl.c:494
        #3 0x7f74add42f9a in lttng_ctl_ask_sessiond_fds_varlen /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl.c:596
        #4 0x7f74add41714 in lttng_ctl_ask_sessiond_varlen_no_cmd_header /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl-helper.h:58
        #5 0x7f74add41747 in lttng_ctl_ask_sessiond /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl-helper.h:78
        #6 0x7f74add4a922 in lttng_list_sessions /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl.c:2105
        #7 0x56472bcbdf80 in cmd_destroy /home/simark/src/lttng-tools/src/bin/lttng/commands/destroy.c:330
        #8 0x56472bd00764 in handle_command /home/simark/src/lttng-tools/src/bin/lttng/lttng.c:237
        #9 0x56472bd01218 in parse_args /home/simark/src/lttng-tools/src/bin/lttng/lttng.c:426
        #10 0x56472bd0151a in main /home/simark/src/lttng-tools/src/bin/lttng/lttng.c:475
        #11 0x7f74ad963b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)

This is due to cmd_destroy not free'ing the result of
lttng_list_sessions. Fix that.

Change-Id: Iff2e75e6ec1cdcd0bdfdbbc3d5099422e592905b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoFix: lttng: free domains and channels in get_session_stats_str
Simon Marchi [Mon, 2 Aug 2021 00:33:23 +0000 (20:33 -0400)] 
Fix: lttng: free domains and channels in get_session_stats_str

When doing `lttng stop`, I get:

    Direct leak of 656 byte(s) in 1 object(s) allocated from:
        #0 0x7f970719e459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
        #1 0x7f9706eba29a in zmalloc /home/simark/src/lttng-tools/src/common/macros.h:45
        #2 0x7f9706ebbb9d in recv_sessiond_optional_data /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl.c:494
        #3 0x7f9706ebbf9a in lttng_ctl_ask_sessiond_fds_varlen /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl.c:596
        #4 0x7f9706eba714 in lttng_ctl_ask_sessiond_varlen_no_cmd_header /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl-helper.h:58
        #5 0x7f9706eba747 in lttng_ctl_ask_sessiond /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl-helper.h:78
        #6 0x7f9706ec4604 in lttng_list_channels /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl.c:2262
        #7 0x55837235c4e7 in get_session_stats_str /home/simark/src/lttng-tools/src/bin/lttng/utils.c:499
        #8 0x55837235bf73 in print_session_stats /home/simark/src/lttng-tools/src/bin/lttng/utils.c:445
        #9 0x55837231cc12 in stop_tracing /home/simark/src/lttng-tools/src/bin/lttng/commands/stop.c:138
        #10 0x55837231d062 in cmd_stop /home/simark/src/lttng-tools/src/bin/lttng/commands/stop.c:229
        #11 0x55837235e63e in handle_command /home/simark/src/lttng-tools/src/bin/lttng/lttng.c:237
        #12 0x55837235f0f2 in parse_args /home/simark/src/lttng-tools/src/bin/lttng/lttng.c:426
        #13 0x55837235f3f4 in main /home/simark/src/lttng-tools/src/bin/lttng/lttng.c:475
        #14 0x7f9706adcb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)

    Direct leak of 308 byte(s) in 1 object(s) allocated from:
        #0 0x7f970719e459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
        #1 0x7f9706eba29a in zmalloc /home/simark/src/lttng-tools/src/common/macros.h:45
        #2 0x7f9706ebbb9d in recv_sessiond_optional_data /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl.c:494
        #3 0x7f9706ebbf9a in lttng_ctl_ask_sessiond_fds_varlen /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl.c:596
        #4 0x7f9706eba714 in lttng_ctl_ask_sessiond_varlen_no_cmd_header /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl-helper.h:58
        #5 0x7f9706eba747 in lttng_ctl_ask_sessiond /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl-helper.h:78
        #6 0x7f9706ec421c in lttng_list_domains /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl.c:2220
        #7 0x55837235c3d3 in get_session_stats_str /home/simark/src/lttng-tools/src/bin/lttng/utils.c:484
        #8 0x55837235bf73 in print_session_stats /home/simark/src/lttng-tools/src/bin/lttng/utils.c:445
        #9 0x55837231cc12 in stop_tracing /home/simark/src/lttng-tools/src/bin/lttng/commands/stop.c:138
        #10 0x55837231d062 in cmd_stop /home/simark/src/lttng-tools/src/bin/lttng/commands/stop.c:229
        #11 0x55837235e63e in handle_command /home/simark/src/lttng-tools/src/bin/lttng/lttng.c:237
        #12 0x55837235f0f2 in parse_args /home/simark/src/lttng-tools/src/bin/lttng/lttng.c:426
        #13 0x55837235f3f4 in main /home/simark/src/lttng-tools/src/bin/lttng/lttng.c:475
        #14 0x7f9706adcb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)

This is due to the get_session_stats_str function not free'ing the
results of lttng_list_channels and lttng_list_domains.  Fix that.

Change-Id: I4c200d3df41bf09bdce8eadb000abbff7fe5a751
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoTests fix: unix socket: leaked socket of connection to child
Jérémie Galarneau [Mon, 19 Jul 2021 21:21:17 +0000 (17:21 -0400)] 
Tests fix: unix socket: leaked socket of connection to child

The child_connection socket is only used by the parent in the
credentials passing test. The teardown assumes the reverse which causes
the socket to be leaked.

1458471 Resource leak

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

In test_creds_passing: 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: I2ead9abbfc189ffbdd71a27f6376d0b001cdc2a3

3 years agoFix: sessiond: notification: missing unlock on client skip
Jérémie Galarneau [Mon, 19 Jul 2021 21:17:39 +0000 (17:17 -0400)] 
Fix: sessiond: notification: missing unlock on client skip

Skipping a client must be performed by using the dedicated "skip_client"
label which will unlock the client's lock before continuing the loop
rather than using 'continue' directly.

Currently, a client will remain locked when an hidden trigger emits
a notification to which it is subscribed.

1458230 Missing unlock

May result in deadlock if there is another attempt to acquire the lock.

In notification_client_list_send_evaluation: Missing a release of a lock
on a path (CWE-667)

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

3 years agoliblttng-ctl: hide logger_thread_name
Jérémie Galarneau [Fri, 16 Jul 2021 18:47:53 +0000 (14:47 -0400)] 
liblttng-ctl: hide logger_thread_name

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

3 years agoliblttng-ctl: hide MI trigger command variables
Jérémie Galarneau [Fri, 16 Jul 2021 18:42:24 +0000 (14:42 -0400)] 
liblttng-ctl: hide MI trigger command variables

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

3 years agoCleanup: rename `get_domain_str()` -> `lttng_domain_type_str()`
Francis Deslauriers [Tue, 25 May 2021 19:57:59 +0000 (15:57 -0400)] 
Cleanup: rename `get_domain_str()` -> `lttng_domain_type_str()`

Both functions currently exist in the code base and accomplish the same
goal. Let's keep only one of them.

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

3 years ago.gitignore: Add hidden trigger test
Jérémie Galarneau [Fri, 16 Jul 2021 17:29:07 +0000 (13:29 -0400)] 
.gitignore: Add hidden trigger test

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

3 years agoTest: unix socket: test credential passing
Jérémie Galarneau [Thu, 15 Jul 2021 00:44:44 +0000 (20:44 -0400)] 
Test: unix socket: test credential passing

Since the credential passing over UNIX sockets now makes use of the pid,
the compatiblity wrappers have become more complex as each platform
appears to define its own way of accessing this information.

This new test:
  - creates a named unix socket,
  - forks,
  - gets the parents and child to connect,
  - sends the child's credentials as a data payload and as credentials
    verified by the kernel
  - the parent checks that the two sets of credentials are equal.

This is more of a sanity check for the compatibility wrappers used on
non-Linux platforms.

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

3 years agoBuild fix: retrieve unix socket peer PID on non-unix platforms
Jérémie Galarneau [Wed, 14 Jul 2021 19:19:15 +0000 (15:19 -0400)] 
Build fix: retrieve unix socket peer PID on non-unix platforms

The previous attempt at extending the credential retrieval wrapper was
broken and didn't build on FreeBSD, macOS, and cygwin.

A platform-specific way of retrieving the PID of a unix peer is
implemented for FreeBSD (getsockopt using LOCAL_PEERCRED, note that the
cr_pid field is only available from FreeBSD 13 and up),
macOS (getsockopt using LOCAL_PEERPID, macOS 10.8+), and
Solaris (getpeerucreds).

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

3 years agoFix: sessiond: notification: find_tracer_event_source returns NULL
Jérémie Galarneau [Mon, 12 Jul 2021 22:42:57 +0000 (18:42 -0400)] 
Fix: sessiond: notification: find_tracer_event_source returns NULL

Due to a bad edit of the original patch (my bad!)
find_tracer_event_source_element always returns NULL.

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

3 years agoTests: MI: add `diag` statements to test functions
Francis Deslauriers [Thu, 8 Jul 2021 16:35:58 +0000 (12:35 -0400)] 
Tests: MI: add `diag` statements to test functions

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

3 years agoCleanup: fix comments in `duplicate_{stream,channel}_object()`
Francis Deslauriers [Thu, 21 Jan 2021 17:00:03 +0000 (12:00 -0500)] 
Cleanup: fix comments in `duplicate_{stream,channel}_object()`

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

3 years agoTests: add hidden trigger visibility test
Jérémie Galarneau [Fri, 9 Jul 2021 17:00:48 +0000 (13:00 -0400)] 
Tests: add hidden trigger visibility test

Add a regression test for the previous commit that verifies that
internal triggers used by the session daemon to implement various
features (automatic session rotations based on their consumed size, in
this instance) are not visible to users of liblttng-ctl.

The test is written in C to use the library directly. This is needed
since the `lttng` client filters-out anonymous triggers and thus, would
not allow us to see those triggers since they are anonymous by default.

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

3 years agoFix: sessiond: list-triggers: don't return internal triggers
Jérémie Galarneau [Fri, 9 Jul 2021 17:00:56 +0000 (13:00 -0400)] 
Fix: sessiond: list-triggers: don't return internal triggers

The session daemon uses triggers internally. For instance, the trigger
and notification subsystem is used to implement the automatic rotation
of sessions based on a size threshold.

Currently, a user of the C API will see those internal triggers if it is
running as the same user as the session daemon. This can be unexpected
by user code that assumes it will be alone in creating triggers.
Moreover, it is possible for external users to unregister those triggers
which would cause bugs.

As the triggers gain more capabilities, it is likely that the session
daemon will keep using them to implement features internally. Thus,
an internal "is_hidden" property is introduced in lttng_trigger.

A "hidden" trigger is a trigger that is not returned by the listings.
It is used to hide triggers that are used internally by the session
daemon so that they can't be listed nor unregistered by external
clients.

This is a property that can only be set internally by the session
daemon. As such, it is not serialized nor set by a
"create_from_buffer" constructor.

The hidden property is preserved by copies.

Note that notifications originating from an "hidden" trigger will not
be sent to clients that are not within the session daemon's process.

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

3 years agounix: receive pid on non-linux platforms
Jérémie Galarneau [Thu, 8 Jul 2021 21:57:45 +0000 (17:57 -0400)] 
unix: receive pid on non-linux platforms

Add a `pid` to the lttng_sock_cred structure definition used on
non-Linux platforms and receive the peer's PID when receiving
credentials.

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

3 years agoClean-up: sessiond: return an lttng_error_code from list_triggers
Jérémie Galarneau [Thu, 8 Jul 2021 18:39:59 +0000 (14:39 -0400)] 
Clean-up: sessiond: return an lttng_error_code from list_triggers

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

3 years agonotification-thread: remove fd from pollset on LPOLLHUP and friends
Francis Deslauriers [Wed, 26 May 2021 20:05:16 +0000 (16:05 -0400)] 
notification-thread: remove fd from pollset on LPOLLHUP and friends

When an app dies, it's possible that the notification thread gets an
epoll event (`LPOLLHUP`) that the socket was closed before it gets the
_REMOVE_TRACER_SOURCE command for that source.

In such cases, the notification thread should simply remove the file
descriptor from the pollset and drain the notification on that file
descriptor. It should _not_ remove the _source_element object from the
list.

The removal from the list should only be done when it receives the
_REMOVE_TRACER_SOURCE command.

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

3 years agoTests: fix: list triggers: bc missing on system
Jérémie Galarneau [Wed, 7 Jul 2021 18:59:02 +0000 (14:59 -0400)] 
Tests: fix: list triggers: bc missing on system

`bc` is not part of the test suite's dependancies and can be replaced,
in this instance, by a use of `printf`.

This use of `bc` caused a number of failures on the CI's Lava workers.

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

3 years agoClean-up: event-expr: remove unreachable code
Jérémie Galarneau [Mon, 5 Jul 2021 18:25:40 +0000 (14:25 -0400)] 
Clean-up: event-expr: remove unreachable code

1452699 Logically dead code

The indicated dead code may have performed some action; that action will
never occur.

In lttng_event_expr_array_field_element_create: Code can never be
reached because of a logical contradiction (CWE-561)

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

3 years agoFix: lttng: remove-trigger: null dereference on MI initialization error
Jérémie Galarneau [Mon, 5 Jul 2021 18:21:19 +0000 (14:21 -0400)] 
Fix: lttng: remove-trigger: null dereference on MI initialization error

Failures to create an MI writer instance will result in a dereference of
the MI writer when attempting to close the command's output element.

1457842 Dereference after null check

Either the check against null is unnecessary, or there may be a null
pointer dereference.

In cmd_add_trigger: 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: I0bc71bf6c83df7d9d938cf93a12d5f6cf6d7ae36

3 years agoFix: lttng: list-trigger: leak of error query in query callbacks
Jérémie Galarneau [Mon, 5 Jul 2021 18:18:27 +0000 (14:18 -0400)] 
Fix: lttng: list-trigger: leak of error query in query callbacks

1457841 Resource leak

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

In mi_error_query_trigger_callback: 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: I4e2cde41d77e5299d1758e8c9387b0a1c63efd17

3 years agoFix: lttng: add-trigger: null dereference on MI initialization error
Jérémie Galarneau [Mon, 5 Jul 2021 18:16:00 +0000 (14:16 -0400)] 
Fix: lttng: add-trigger: null dereference on MI initialization error

Failures to create an MI writer instance will result in a dereference of
the MI writer when attempting to close the command's output element.

1457842 Dereference after null check

Either the check against null is unnecessary, or there may be a null
pointer dereference.

In cmd_add_trigger: 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: I98b844d2f1c7abd43bd42ee472759de57b34484e

3 years agolttng: add-trigger: print generated trigger name
Jérémie Galarneau [Wed, 30 Jun 2021 22:41:24 +0000 (18:41 -0400)] 
lttng: add-trigger: print generated trigger name

Print the generated trigger name when `add-trigger` succeeds.

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

3 years agosessiond: generate trigger name: name triggers with the 'trigger' prefix
Jérémie Galarneau [Wed, 30 Jun 2021 22:47:52 +0000 (18:47 -0400)] 
sessiond: generate trigger name: name triggers with the 'trigger' prefix

Generated trigger names currently have the form TN, where N is the
number of generated trigger names over the lifetime of the session
daemon.

The form 'triggerN' seems more in line with autogenerated names such
as channel names (e.g. 'channel0').

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

3 years agoRevert "lttng: add-trigger: print generated trigger name"
Jérémie Galarneau [Thu, 1 Jul 2021 13:12:21 +0000 (09:12 -0400)] 
Revert "lttng: add-trigger: print generated trigger name"

This reverts commit 8310270a50784aced2af5b21ab23bc7bd9dee47f.

This change is still under review.

Change-Id: If75aa02e2e5daa0bfbcf30bea0a2b54c4aca1fd4
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agolttng: add-trigger: print generated trigger name
Jérémie Galarneau [Wed, 30 Jun 2021 22:41:24 +0000 (18:41 -0400)] 
lttng: add-trigger: print generated trigger name

Print the generated trigger name when `add-trigger` succeeds. Also,
no message is emited when a trigger is successfully registered as
the command will print an error message if any error occurs.

There is also no need to parrot the trigger's name if it was specified
by the user.

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

3 years agoMI: xsd: bump to 4.1
Jonathan Rajotte [Mon, 7 Jun 2021 22:11:01 +0000 (18:11 -0400)] 
MI: xsd: bump to 4.1

No breaking change were done to the xsd. Only objects related to
triggers, event-rules, actions, condition, and error-query were added.
They do not interfere with the current MI.

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

3 years agoTests: trigger: mi: use utils.sh xsd versions for xml diff
Jonathan Rajotte [Mon, 7 Jun 2021 22:03:17 +0000 (18:03 -0400)] 
Tests: trigger: mi: use utils.sh xsd versions for xml diff

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

3 years agoTests: utils: regroup xml utils to utils.sh
Jonathan Rajotte [Mon, 7 Jun 2021 21:56:37 +0000 (17:56 -0400)] 
Tests: utils: regroup xml utils to utils.sh

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

3 years agoTests: MI: {add, list, remove}-trigger
Jonathan Rajotte [Wed, 26 May 2021 22:08:14 +0000 (18:08 -0400)] 
Tests: MI: {add, list, remove}-trigger

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

3 years agoMI: xsd: add objects type definition related to trigger
Jonathan Rajotte [Thu, 27 May 2021 01:53:19 +0000 (21:53 -0400)] 
MI: xsd: add objects type definition related to trigger

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

3 years agoMI: xsd: sort output_type
Jonathan Rajotte [Thu, 27 May 2021 01:51:26 +0000 (21:51 -0400)] 
MI: xsd: sort output_type

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

3 years agoMI: xsd: sort command_string_type
Jonathan Rajotte [Thu, 27 May 2021 01:48:20 +0000 (21:48 -0400)] 
MI: xsd: sort command_string_type

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

3 years agoAdd pretty_xml utils
Jonathan Rajotte [Wed, 26 May 2021 21:17:02 +0000 (17:17 -0400)] 
Add pretty_xml utils

This util reads on stdin and outputs an indented/formatted xml.
It is equivalent to "xmllint --format -".

It will be used for MI trigger testing. For testing we will essentially
diff the output of the command against the expected output. While a
nicely formatted multi-line output is not necessary for a machine to
do the diff, the human that will have to debug it will surely appreciate
it.

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

3 years agoMove xml utils from mi subfolder to xml-utils folder
Jonathan Rajotte [Wed, 26 May 2021 20:39:12 +0000 (16:39 -0400)] 
Move xml utils from mi subfolder to xml-utils folder

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

3 years agoFix: lttng_triggers count is not equal to the size of the sorted trigger array
Jonathan Rajotte [Fri, 28 May 2021 18:32:37 +0000 (14:32 -0400)] 
Fix: lttng_triggers count is not equal to the size of the sorted trigger array

Since anonymous triggers can be present in the original lttng_triggers
and that we do not add them to the sorting list, the count to be used
while iterating on the sorted list must be the size of the list itself
and not that of lttng_triggers.

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

3 years agoMI: {add, list, remove} trigger
Jonathan Rajotte [Wed, 26 May 2021 17:04:41 +0000 (13:04 -0400)] 
MI: {add, list, remove} trigger

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

3 years agoMI: implement all objects related to trigger machine interface
Jonathan Rajotte [Fri, 7 May 2021 01:26:17 +0000 (21:26 -0400)] 
MI: implement all objects related to trigger machine interface

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

3 years agoMove event-expr-to-bytecode to event-expr
Jonathan Rajotte [Thu, 11 Feb 2021 15:40:39 +0000 (10:40 -0500)] 
Move event-expr-to-bytecode to event-expr

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

3 years agoMove event-expr from liblttng-ctl to libcommon
Jonathan Rajotte [Thu, 11 Feb 2021 15:18:38 +0000 (10:18 -0500)] 
Move event-expr from liblttng-ctl to libcommon

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

3 years agoMI: support double element
Jonathan Rajotte [Thu, 4 Feb 2021 20:57:56 +0000 (15:57 -0500)] 
MI: support double element

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

3 years agoFix: rotation client example: leak of handle on error
Jérémie Galarneau [Wed, 16 Jun 2021 19:08:21 +0000 (15:08 -0400)] 
Fix: rotation client example: leak of handle on error

1452927 Resource leak

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

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

CID 1452927 (#1 of 1): Resource leak (RESOURCE_LEAK)8. leaked_storage:
Variable chan_handle going out of scope leaks the storage it points to

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

3 years agoSilence warnings on GCC 4.8 with -Wmaybe-uninitialized
Michael Jeanson [Mon, 14 Jun 2021 15:18:19 +0000 (11:18 -0400)] 
Silence warnings on GCC 4.8 with -Wmaybe-uninitialized

We still build on SLES12 with GCC 4.8 in which '-Wmaybe-uninitialized'
doesn't seem to be the sharpest tool in the shed. Add explicit
initialization of 'ret' to silence the warnings.

Change-Id: I1f9de535b6be48357735af106ff555ab9eceb730
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agodoc/man/common-footer.txt: add missing non-breaking space
Philippe Proulx [Tue, 15 Jun 2021 03:07:32 +0000 (23:07 -0400)] 
doc/man/common-footer.txt: add missing non-breaking space

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibefd4e7448920f0f346697eea5e1b5d250a93d1f

3 years agoRename "tracing session" -> "recording session"
Philippe Proulx [Tue, 15 Jun 2021 02:52:02 +0000 (22:52 -0400)] 
Rename "tracing session" -> "recording session"

Starting from LTTng 2.13, _tracing_ is defined as attempting to execute
one or more actions when emitting an event, which is very close to the
trigger definition.

To highlight that a tracing session is only about event recording,
rename this concept to _recording session_.

This patch mostly changes the manual pages, although I also updated some
C source and other files which contain user-facing text to use the new
term.

I didn't update logging messages because debugging scripts could still
refer to "tracing sessions".

The lttng-concepts(7) manual page mentions that the "recording session"
term was "tracing session" before LTTng 2.13.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I620d6b6be9e0f1dac14c0bc5e26094c3b3711c75

3 years agodoc/man: use double quotes when referring to internal section
Philippe Proulx [Mon, 14 Jun 2021 17:05:37 +0000 (13:05 -0400)] 
doc/man: use double quotes when referring to internal section

This patch adds double quotes to all the manual page internal section
references using their full name. Those references often have the
following AsciiDoc form:

    See the <<id,Full section name>> section below.

With this patch, this would be converted to:

    See the ``<<id,Full section name>>'' section below.

In the rendered manual page, before this patch:

    See the Full section name section below.
            ¯¯¯¯ ¯¯¯¯¯¯¯ ¯¯¯¯
With this patch:

    See the “Full section name” section below.

The purpose of this patch is, thanks to the change in
`doc/man/manpage.xsl`, to remove the italic style for the text of
internal links. Because there's no way to create dynamic internal links
in a manual page, this style causes internal links to look weird when
they're not a full section name, for example:

    Note that the trigger doesn't need to [...]
                  ¯¯¯¯¯¯¯
The HTML rendering of LTTng-tools manual pages can still benefit from
internal links. This patch makes it possible to add more internal links
without degrading the visual style of manual pages when rendered in a
terminal.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1a5ef7eab7ff1e66c137e16b51a9c9074e43f583

3 years agodoc/man: update type/domain options for common event rule spec.
Philippe Proulx [Tue, 18 May 2021 14:14:47 +0000 (10:14 -0400)] 
doc/man: update type/domain options for common event rule spec.

This patch updates manual pages to follow the recent `--type` and
`--domain` option changes of the lttng-add-trigger(1) command, which
accepts the common event rule specification options of
lttng-event-rule(7).

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6064734534e773bf4f03b5f1e849b57134583039

3 years agoFix: use of uninitialised bytes valgrind warning
Francis Deslauriers [Wed, 16 Jun 2021 16:10:42 +0000 (12:10 -0400)] 
Fix: use of uninitialised bytes valgrind warning

Issue
=====

Valgrind reports usage of uninitialised stack allocated memory:
  ==2961363== Thread 9 Client manageme:
  ==2961363== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s)
  ==2961363==    at 0x521418D: __libc_sendmsg (sendmsg.c:28)
  ==2961363==    by 0x521418D: sendmsg (sendmsg.c:25)
  ==2961363==    by 0x53411B: lttcomm_send_unix_sock (unix.c:294)
  ==2961363==    by 0x48AA8C: send_unix_sock (client.c:896)
  ==2961363==    by 0x484F45: thread_manage_clients (client.c:2865)
  ==2961363==    by 0x480FB4: launch_thread (thread.c:66)
  ==2961363==    by 0x5208608: start_thread (pthread_create.c:477)
  ==2961363==    by 0x5346292: clone (clone.S:95)
  ==2961363==  Address 0x7575389 is 25 bytes inside a block of size 16,384 alloc'd
  ==2961363==    at 0x483DFAF: realloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==2961363==    by 0x4EB618: lttng_dynamic_buffer_set_capacity (dynamic-buffer.c:166)
  ==2961363==    by 0x4EB52C: lttng_dynamic_buffer_append (dynamic-buffer.c:55)
  ==2961363==    by 0x48CBA1: setup_lttng_msg (client.c:125)
  ==2961363==    by 0x48AD70: setup_lttng_msg_no_cmd_header (client.c:860)
  ==2961363==    by 0x489825: process_client_msg (client.c:2253)
  ==2961363==    by 0x484A97: thread_manage_clients (client.c:2807)
  ==2961363==    by 0x480FB4: launch_thread (thread.c:66)
  ==2961363==    by 0x5208608: start_thread (pthread_create.c:477)
  ==2961363==    by 0x5346292: clone (clone.S:95)
  ==2961363==  Uninitialised value was created by a stack allocation
  ==2961363==    at 0x485FE4: process_client_msg (client.c:928)

After some digging, I found that this warning was caused by the padding
of the `struct lttng_session_list_schedules_return` during the
`LTTNG_SESSION_LIST_ROTATION_SCHEDULES` command.

All the fields are of the stack allocated struct are initialised by the
designated initializer but the padding is not.

These padding bytes are reported by Valgrind as being used
uninitialised.

Fix
===

Remove the padding by adding the LTTNG_PACKED attribute to the nested
structs in `struct lttng_session_list_schedules_return`.

Notes
=====

In light of the actual root cause, this is stacktrace is not really
useful.

The realloc call to grow the buffer makes it hard to find what is the
actual uninitialised stack allocation because Valgrind reports the
realloc call as the problematic site.

I was able to track this issue by adding a "consuming" step in the
`lttng_dynamic_buffer_append()` function. This consuming step would sum
all the bytes of the `buf` parameter so as to force Valgrind to check
each byte and not wait until the `sendmsg()` call. This way, I was able
to get a more precise location of the root cause of the issue.

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

3 years agoFix: build: libcommon fd-tracker dependency is not available
Jonathan Rajotte [Mon, 7 Jun 2021 18:21:06 +0000 (14:21 -0400)] 
Fix: build: libcommon fd-tracker dependency is not available

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

A build configured with:

  ./configure -disable-bin-lttng --disable-bin-lttng-crash --disable-bin-lttng-sessiond --disable-bin-lttng-relayd

Fails at build time with:

  make[3]: *** No rule to make target '../../src/common/fd-tracker/libfd-tracker.la', needed by 'libcommon.la'.  Stop.
  make[3]: *** Waiting for unfinished jobs....
  CC       lttng-elf.lo

Cause
=====

fd-tracker is required by libcommon. This is introduced by commit
8bb66c3cd60938352927ee865759433387324250 [1]

Build of libfd-tracker is disabled at the configure level by
build_lib_fd_tracker which in turn is enabled/disabled by the
--enable/disable-bin-* options.

For the observed issue, the --enable-bin-lttng-consumerd alone does not
enable the build of libfd-tracker.

Solution
========

All dependencies for libcommon are now always built. All bins require
libcommon to be present anyway.

This patch also fix a problem where the examples under the doc are build
even if liblttng-ctl is not built.

Known drawbacks
=========

None.

References
==========

[1]
http://git.lttng.org/?p=lttng-tools.git;a=commit;h=8bb66c3cd60938352927ee865759433387324250

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

3 years agoClean-up: mark lttng_error_query communication header as const
Jérémie Galarneau [Wed, 9 Jun 2021 22:04:28 +0000 (18:04 -0400)] 
Clean-up: mark lttng_error_query communication header as const

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

3 years agoAdd condition-targeting error query
Jérémie Galarneau [Wed, 9 Jun 2021 21:58:45 +0000 (17:58 -0400)] 
Add condition-targeting error query

Notifications discarded by the tracers are reported at the level of a
trigger. As those errors are specific to triggers with an "event-rule
matches" condition, they should be reported through a condition-specific
error query.

Note that a condition error query is created from a trigger: there is no
ambiguity since, unlike actions, conditions cannot be nested.

Given the proximity of the final 2.13 release, the code which populated
trigger error query results is simply used to populate the condition
error query results when the condition is of type "event-rule matches".

No trigger-scope errors can be reported for the moment. However, such
error reports will be added in the future.

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

3 years agoaction list: missing renames from previous name "group"
Francis Deslauriers [Tue, 8 Jun 2021 21:21:30 +0000 (17:21 -0400)] 
action list: missing renames from previous name "group"

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

3 years agoCleanup: ust-app: simplify ust_app_synchronize() error paths
Francis Deslauriers [Tue, 8 Jun 2021 20:14:49 +0000 (16:14 -0400)] 
Cleanup: ust-app: simplify ust_app_synchronize() error paths

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

3 years agoFix: double mutex_unlock() if session is deleted
Francis Deslauriers [Tue, 8 Jun 2021 19:15:00 +0000 (15:15 -0400)] 
Fix: double mutex_unlock() if session is deleted

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

3 years agoFix: out of sync lttng_ust_ctl_sigbug_handle() prototype
Francis Deslauriers [Fri, 28 May 2021 16:40:07 +0000 (12:40 -0400)] 
Fix: out of sync lttng_ust_ctl_sigbug_handle() prototype

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

3 years agoFix: appending unallocated data from beyond exclusion entries
Francis Deslauriers [Fri, 28 May 2021 20:06:09 +0000 (16:06 -0400)] 
Fix: appending unallocated data from beyond exclusion entries

Issue
=====
If an exclusion string is smaller than the `LTTNG_SYMBOL_NAME_LEN`
integer, the `lttng_dynamic_buffer_append()` call will append
unallocated data to the buffer.

Fix
===
Use the `exclusion_len` value to copy the actual exclusion and pad the
remaining bytes with zeros.

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

3 years agoTests: remove leftover temporary files
Francis Deslauriers [Wed, 2 Jun 2021 19:28:24 +0000 (15:28 -0400)] 
Tests: remove leftover temporary files

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

3 years agolttng-disable-channel(1): fix typo
Philippe Proulx [Thu, 10 Jun 2021 21:45:29 +0000 (17:45 -0400)] 
lttng-disable-channel(1): fix typo

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I37f733bd48d17f2e6de75038918cabd95375e4e2

3 years agolttng-concepts(7): remove reference to the section it's in
Philippe Proulx [Thu, 10 Jun 2021 14:24:08 +0000 (10:24 -0400)] 
lttng-concepts(7): remove reference to the section it's in

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I09319ec4849e854d6a4881ab7895cffc551be58a

3 years agolttng-concepts(7): fix typo
Philippe Proulx [Thu, 10 Jun 2021 14:23:48 +0000 (10:23 -0400)] 
lttng-concepts(7): fix typo

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ief92d1f4a56f5263a2fed5c70e2b26d660d6d81d

3 years agoReset codename and description
Michael Jeanson [Tue, 8 Jun 2021 18:40:07 +0000 (14:40 -0400)] 
Reset codename and description

Change-Id: I6827fec291a8a1e18922508dabc67a04e13346c5
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoSet version to 2.14-pre
Jérémie Galarneau [Tue, 8 Jun 2021 18:33:04 +0000 (14:33 -0400)] 
Set version to 2.14-pre

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

3 years agoBuild fix: build without lttng-ust
Michael Jeanson [Tue, 8 Jun 2021 14:55:19 +0000 (10:55 -0400)] 
Build fix: build without lttng-ust

Add conditionnal inclusion of ust-sigbus to the tests modified by:

  commit e207fe73b58787c6077ec5d49254e12ff1a82b51
  Author: orbea <orbea@riseup.net>
  Date:   Sat May 29 11:07:41 2021 -0700

    build: Add missing DEFINE_LTTNG_UST_SIGBUS_STATE();

    Fixes:

      liblttng-ust-ctl.so: undefined reference to `lttng_ust_sigbus_state'

Change-Id: If4af7ada6d94ee67603156d151575dcc57baad05
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agobuild: Add missing DEFINE_LTTNG_UST_SIGBUS_STATE();
orbea [Sat, 29 May 2021 18:07:41 +0000 (11:07 -0700)] 
build: Add missing DEFINE_LTTNG_UST_SIGBUS_STATE();

Fixes:

  liblttng-ust-ctl.so: undefined reference to `lttng_ust_sigbus_state'

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

3 years agobuild: Pass --no-as-needed directly to the linker
orbea [Thu, 13 May 2021 18:10:56 +0000 (11:10 -0700)] 
build: Pass --no-as-needed directly to the linker

This is not a libtool argument, but rather a linker argument.
GNU libtool will silently ignore arguments it doesn't understand
in many cases while slibtool does not.

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

3 years agobuild: Use liblttng-sessiond-common.la instead of LIVE
orbea [Thu, 13 May 2021 18:07:58 +0000 (11:07 -0700)] 
build: Use liblttng-sessiond-common.la instead of LIVE

This allow correctly linking live_test with slibtool.

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

3 years agobuild: Use liblttng-sessiond-common.la instead of SESSIOND_OBJS
orbea [Thu, 13 May 2021 17:47:06 +0000 (10:47 -0700)] 
build: Use liblttng-sessiond-common.la instead of SESSIOND_OBJS

This allows correctly linking test_session and test_ust_data
with slibtool.

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

3 years agobuild: Add the liblttng-sessiond-comm.la convenience library
orbea [Thu, 13 May 2021 17:16:58 +0000 (10:16 -0700)] 
build: Add the liblttng-sessiond-comm.la convenience library

This allows correctly linking test_kernel_data with slibtool.

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

3 years agolttng-concepts(7): add missing "commands" word
Philippe Proulx [Tue, 18 May 2021 14:18:41 +0000 (10:18 -0400)] 
lttng-concepts(7): add missing "commands" word

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib555c944c37b983a40f963ea3597bafeba6c4da2

3 years agoTests: crash: remove redundant directory test
Francis Deslauriers [Thu, 27 May 2021 16:53:12 +0000 (12:53 -0400)] 
Tests: crash: remove redundant directory test

The presence of the `$shm_session_path/ust/pid` path is already tested
a few line above. No need to test it again.

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

3 years agoFix: bump minimal urcu dependency to 0.11
Jérémie Galarneau [Wed, 2 Jun 2021 15:52:59 +0000 (11:52 -0400)] 
Fix: bump minimal urcu dependency to 0.11

cds_lfht_destroy is used from within RCU read-side critical sections
which is only allowed for urcu >= 0.10 (see userspace-rcu commit
d0ec0ed2f).

Such uses were introduced as part of the 2.11 release (contemporary to
urcu 0.10).

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

3 years agocondition: buffer usage: validation does not check for ratio and bytes threshold
Jonathan Rajotte [Thu, 4 Feb 2021 20:46:27 +0000 (15:46 -0500)] 
condition: buffer usage: validation does not check for ratio and bytes threshold

Buffer usage condition do not support having both ratio and bytes
threshold set.

Using `!usage->threshold_ratio.set && !usage->threshold_bytes.set` does
not error out for `threshold_ratio.set == 1` and
`usage->threshold_bytes.set == 1`

0 0 : 1
0 1 : 0
1 0 : 0
1 1 : 0

We want to check for a xnor (`usage->threshold_ratio.set == usage->threshold_bytes.set`)

0 0 : 1
0 1 : 0
1 0 : 0
1 1 : 1

We could also do 2 error check one for not set and one validating that
both are not set.

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

3 years agoRemove LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION
Jonathan Rajotte [Tue, 18 May 2021 18:57:05 +0000 (14:57 -0400)] 
Remove LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION

It is not supported for 2.13.

Change-Id: If42b18115cc61da9ee17f281390280b21fdc35a6
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoRemove lttng_event_rule_tracepoint
Jonathan Rajotte [Wed, 12 May 2021 07:20:51 +0000 (03:20 -0400)] 
Remove lttng_event_rule_tracepoint

lttng_event_rule_tracepoint is "exploded" in:
   lttng_event_rule_user_tracepoint
   lttng_event_rule_kernel_tracepoint
   lttng_event_rule_jul_logging
   lttng_event_rule_python_logging
   lttng_event_rule_log4j_logging

On the CLI front, the `--domain` option for the add-trigger is removed
since for each event rule type the domain is implicit based on the type.

`--type` accepts the following:
   kernel
   kernel:tracepoint
   kernel:kprobe
   kernel:uprobe
   syscall
     syscall:entry
     syscall:exit
     syscall:entry+exit
     syscall:*
   kernel:syscall
     kernel:syscall:entry
     kernel:syscall:exit
     kernel:syscall:entry+exit
     kernel:syscall:*
   user
   user:tracepoint
   python
   python:logging
   jul
   jul:logging
   log4j
   log4j:logging
   kprobe
   function

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

3 years agoTest log level for newly introduced event rule type (*_logging, user_tracepoint)
Jonathan Rajotte [Wed, 12 May 2021 05:35:53 +0000 (01:35 -0400)] 
Test log level for newly introduced event rule type (*_logging, user_tracepoint)

This is in prevision to lttng_event_rule_tracepoint removal.

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

3 years agoIntroduce lttng_event_rule_python_logging
Jonathan Rajotte [Wed, 12 May 2021 05:10:41 +0000 (01:10 -0400)] 
Introduce lttng_event_rule_python_logging

A following patch will remove lttng_event_rule_tracepoint.

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

3 years agoIntroduce lttng_event_rule_log4j_logging
Jonathan Rajotte [Wed, 12 May 2021 05:01:19 +0000 (01:01 -0400)] 
Introduce lttng_event_rule_log4j_logging

A following patch will remove lttng_event_rule_tracepoint.

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

3 years agoIntroduce lttng_event_rule_jul_logging
Jonathan Rajotte [Wed, 12 May 2021 03:38:17 +0000 (23:38 -0400)] 
Introduce lttng_event_rule_jul_logging

A following patch will remove lttng_event_rule_tracepoint.

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

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