lttng-tools.git
5 years agoFix: leak of lookup_method_name in uprobe load
Jérémie Galarneau [Mon, 27 Aug 2018 21:58:28 +0000 (17:58 -0400)] 
Fix: leak of lookup_method_name in uprobe load

Eliminate string copies in uprobe loading code, which fixes
a memory leak of lookup_method_name reported by Coverity.

Reported-by: Coverity Scan (1395215 Resource leak)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoDocs: distinction between function and tracepoint probe locations
Jérémie Galarneau [Mon, 27 Aug 2018 21:57:31 +0000 (17:57 -0400)] 
Docs: distinction  between function and tracepoint probe locations

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: abort on unknown location type in destructor
Jérémie Galarneau [Mon, 27 Aug 2018 20:30:50 +0000 (16:30 -0400)] 
Fix: abort on unknown location type in destructor

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoClean-up: location lookup destroy can be type-agnostic
Jérémie Galarneau [Mon, 27 Aug 2018 20:30:03 +0000 (16:30 -0400)] 
Clean-up: location lookup destroy can be type-agnostic

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: hide internal uprobe configuration symbols
Jérémie Galarneau [Mon, 27 Aug 2018 19:44:14 +0000 (15:44 -0400)] 
Fix: hide internal uprobe configuration symbols

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: event copy constructor frees original event on error
Jérémie Galarneau [Fri, 24 Aug 2018 20:32:12 +0000 (16:32 -0400)] 
Fix: event copy constructor frees original event on error

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: userspace probe accessors are not const-correct
Jérémie Galarneau [Fri, 24 Aug 2018 20:29:01 +0000 (16:29 -0400)] 
Fix: userspace probe accessors are not const-correct

The accessors of userspace probe locations and lookup methods
should be const. This commit marks them as such and modifies the
code using those functions to be, in turn, const-correct.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoCleanup: use lttng_* string utility functions
Francis Deslauriers [Thu, 23 Aug 2018 16:12:52 +0000 (12:12 -0400)] 
Cleanup: use lttng_* string utility functions

Some systems don't have all the 'modern' string utility functions used
in the project. For those cases, we reimplemented those functions using
inline lttng_* functions so let's use those directly to avoid future
problems.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoSilence macro redefinition warnings on macOS
Francis Deslauriers [Mon, 20 Aug 2018 17:23:28 +0000 (13:23 -0400)] 
Silence macro redefinition warnings on macOS

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: lttng-save command producing wrong XML fields
Francis Deslauriers [Thu, 5 Jul 2018 22:14:54 +0000 (18:14 -0400)] 
Fix: lttng-save command producing wrong XML fields

Saving a session configuration with a probe or a function event would
generate a XML file considered invalid by the lttng-load command.

This is due to the fact that for a probe event lttng-save would the
following xml event type field:
  <type>KPROBE</type>
but lttng-load command would be expecting the following field:
  <type>PROBE</type>.

As a fix, the lttng-save command now rightfully outputs the PROBE field.
Given that this usecase never worked, changing the field is not a
breaking change.

Also, the save command was wrongfully using FUNCTION xml event type for
the LTTNG_KERNEL_FUNCTION event type when it is in fact the
FUNCTION_ENTRY xml event type.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoError out if filter expression is attached to unsupported event types
Francis Deslauriers [Wed, 4 Jul 2018 22:21:57 +0000 (18:21 -0400)] 
Error out if filter expression is attached to unsupported event types

Attaching a filter on a probe event, a function event or an
userspace-probe event is not supported by the LTTng kernel tracer. So we
do an early sanity check in the lttng-enable-event and warn the user if
the filtering is not supported.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoImplement userspace-probe regression tests
Francis Deslauriers [Fri, 29 Jun 2018 20:09:15 +0000 (16:09 -0400)] 
Implement userspace-probe regression tests

This adds regression testcases for the following userspace probe
features and should-fail scenarios.

Features:
  * ELF function location tracing works,
  * ELF C++ mangled function and method location tracing works,
  * SDT tracepoint location tracing works,
  * Implicit location type defaults to ELF location,
  * Binary found $PATH,
  * Binary found using full path,
  * Binary with colon in file name,
  * Disabling of all location types,
  * Listing of all location types,
  * Saving and loading of all location types,
  * SDT probe with one or more callsites,
  * SDT probe with arguments,
  * SDT probe in shared object,
  * SDT probe in dlopen()ed and ldpreload()ed shared object.
Should-fail:
  * Target binary does not exist,
  * Target binary not ELF file,
  * ELF symbol not found in target binary,
  * ELF symbol not a function,
  * SDT provider name not found,
  * SDT probe name not found,
  * SDT probe guarded by a semaphore.

We also make sure to disable testcases when the necessary files/tools
for them are not found:
  * Disables C++ testcases if no C++ compiler is found.
  * Disables SDT testcases if the Systemtap header files are not found.
    This is tested by trying to compile a simple C program with a SDT
    probe. If it fails, it will only disable the testcases and not the
    feature since the SDT userspace probe feature does not use this header
    for parsing.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Erica Bugden <ebugden@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoImplement lttng-mi for userspace-probe
Francis Deslauriers [Fri, 29 Jun 2018 20:04:20 +0000 (16:04 -0400)] 
Implement lttng-mi for userspace-probe

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoImplement lttng-save and lttng-load for userspace-probe
Francis Deslauriers [Fri, 29 Jun 2018 20:03:37 +0000 (16:03 -0400)] 
Implement lttng-save and lttng-load for userspace-probe

Here are examples of both ELF function and SDT tracepoint XML
descriptions:
```
<event>
<name>userspace_probe_test_event_elf</name>
<enabled>true</enabled>
<type>USERSPACE_PROBE</type>
<attributes>
<userspace_probe_function_attributes>
<lookup_method>ELF</lookup_method>
<binary_path>/tmp/tmp.3fN5FYk6Zc/bin_elf_symlink</binary_path>
<function_name>test_function</function_name>
</userspace_probe_function_attributes>
</attributes>
</event>

```
```
<event>
<name>userspace_probe_test_event_sdt</name>
<enabled>true</enabled>
<type>USERSPACE_PROBE</type>
<attributes>
<userspace_probe_tracepoint_attributes>
<lookup_method>SDT</lookup_method>
<binary_path>/tmp/tmp.h4b4Itao8v/bin_sdt_symlink</binary_path>
<provider_name>foobar</provider_name>
<probe_name>tp1</probe_name>
</userspace_probe_tracepoint_attributes>
</attributes>
</event>
```

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoImplement lttng-list for userspace-probe
Francis Deslauriers [Fri, 29 Jun 2018 19:28:30 +0000 (15:28 -0400)] 
Implement lttng-list for userspace-probe

Here is an example of the output of the list command for a ELF function
userspace probe:
```
Event rules:
  userspace_probe_test_event (type: userspace-probe) [enabled]
    Type: Function
    Binary path:   /home/frdeso/projets/lttng/tools/tests/utils/testapp/userspace-probe-elf-binary/userspace-probe-elf-binary
    Function:      test_function()
    Lookup method: ELF
```

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd --userspace-probe kernel event type
Francis Deslauriers [Fri, 29 Jun 2018 19:22:36 +0000 (15:22 -0400)] 
Add --userspace-probe kernel event type

This commit wires up all the elements necessary to use the
userspace-probe feature.

This event type is defined by the user with --userspace-probe option. At
the moment, probing location can be specified by the user using two
location types: ELF function and STD probe.

It's important to note that userspace-probes are traced by the kernel
tracer and the generated events will thus be recorded in the kernel
trace. This is due to the fact that this feature uses the uprobe kernel
interface to instrument binaries. A root session daemon is needed to
load the kernel modules necessary to use this feature.

To ensure that the file pointed by the provided path does not change
while processing the user command, we use a fd-passing scheme. It
consist of calling open of the executable path early on in the
enable-event command and passing that file descriptor to the sessiond
for ELF parsing and the kernel to do the instrumentation. This ensures
that the inode backing that file is not reused for another file in the
case of a file deletion-and-reuse race.

Command syntax:
* The syntax to enable an ELF function userspace probe is the following:
  `--userspace-probe=elf:/path/to/executable:my_target_symbol`

  Omitting the first element of the colon-separated list would also work
  as the ELF function location is the default location type.

  Here are two equivalent usage examples of this location type:
    lttng enable-enable --kernel --userspace-probe=/path/to/executable:my_symbol event_name
    lttng enable-enable --kernel --userspace-probe=elf:/path/to/executable:my_symbol event_name

* SDT probes are DTrace-style tracepoint distributed in multiple
  libraries and applications. This implementation supports tracing of
  SDT probes that are NOT guarded by semaphore.

  The syntax to enable an SDT tracepoint userspace probe is the following:
  `--userspace-probe=sdt:/path/to/executable:provider:probe`
  Here is an usage example:
    lttng enable-enable --kernel --userspace-probe=sdt:/path/to/executable:provider:probe event_name

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoImplement $PATH binary searching function for userspace-probe
Francis Deslauriers [Fri, 29 Jun 2018 19:25:09 +0000 (15:25 -0400)] 
Implement $PATH binary searching function for userspace-probe

This is needed to allow the user to simply provide the name of a
executable present in the $PATH for the current shell.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd userspace location in ltt_kernel_event structure
Francis Deslauriers [Fri, 29 Jun 2018 19:04:06 +0000 (15:04 -0400)] 
Add userspace location in ltt_kernel_event structure

Account for new userspace location field in {append,
increment}_extended_info functions used to send listing information back
to the client.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoImplement userspace probe location extraction and registration
Francis Deslauriers [Fri, 29 Jun 2018 18:33:37 +0000 (14:33 -0400)] 
Implement userspace probe location extraction and registration

These functions use run_as commands to extract the offsets in the binary
where the instrumentation should be placed and pass these offsets
to the kernel tracer along with the FD to complete the registration of
userspace probe events using the two-step registration process.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoImplement 2-step registration of userspace probe events
Francis Deslauriers [Fri, 29 Jun 2018 18:16:25 +0000 (14:16 -0400)] 
Implement 2-step registration of userspace probe events

Userspace-probe registration is implemented in a 2-step process. The two
steps registration is necessary because a userspace-probe event can have
an arbitrary number of call sites.

The first step is registering the event through the existing
LTTNG_KERNEL_EVENT command on the channel ioctl FD. This creates an
event with no callsites and thus no instrumentation at all.

The second step is attaching callsites to the event. It's done through
the new LTTNG_KERNEL_ADD_CALLSITE command on the event ioctl FD
received during the first step.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoUse lttng_event_{create, destroy} to manage lttng_event struct
Francis Deslauriers [Fri, 29 Jun 2018 15:43:42 +0000 (11:43 -0400)] 
Use lttng_event_{create, destroy} to manage lttng_event struct

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: remove unnecessary stderr output on expected behaviour
Francis Deslauriers [Thu, 28 Jun 2018 20:16:35 +0000 (16:16 -0400)] 
Fix: remove unnecessary stderr output on expected behaviour

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agotrace_ust_create_event() now returns an error code
Francis Deslauriers [Thu, 28 Jun 2018 19:51:55 +0000 (15:51 -0400)] 
trace_ust_create_event() now returns an error code

To be consistent with similar changes made to the
trace_kernel_create_event function.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agotrace_kernel_create_event() now returns an error code
Francis Deslauriers [Thu, 28 Jun 2018 19:43:50 +0000 (15:43 -0400)] 
trace_kernel_create_event() now returns an error code

The created kernel event is returned via an out parameter. The error
code specifies the reason of a potential failure of the creation of the
event.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agorun_as: add extract SDT probe offsets command
Francis Deslauriers [Thu, 28 Jun 2018 18:33:10 +0000 (14:33 -0400)] 
run_as: add extract SDT probe offsets command

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Erica Bugden <ebugden@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agorun_as: add extract ELF symbol offset command
Francis Deslauriers [Thu, 28 Jun 2018 16:38:46 +0000 (12:38 -0400)] 
run_as: add extract ELF symbol offset command

We use a run_as command for this work because the input is controlled by
the user and it should be parsed using the permission of that user.
Also, parsing ELF files is tricky and doing it in a run_as process
has the benefit of isolating potential crashes.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agorun_as: adapt run_as implementation to support complex payloads
Francis Deslauriers [Thu, 28 Jun 2018 15:39:30 +0000 (11:39 -0400)] 
run_as: adapt run_as implementation to support complex payloads

This commits changes 4 elements of the run_as implementation:
  1. Allow for commands with complex return types,
  2. Detect worker crashes and restart it,
  3. Enable commands that take FD as input.
  4. Define master-worker protocol

In the past, run_as commands were simple and were all returning int
values (e.g. open(), mkdir()). With the introduction of the future, more
complex run_as commands such as the one to extract elf symbol offsets
for the userspace-probe instrumentation, we need to allow arbitrary
return types such as long and arrays. Creating a return type abstraction
allows to add new return types. To implement this new abstraction, this
commit adds the passing of the run_as_ret structure as parameter to the
command functions that are responsible to set the errno and the return
value according to their semantics. The run_as_ret struct now contains
an union of return types.

More complex run_as commands are more prone to crashes, we thus make the
master process restart the worker process if it detects it has exited.

Enable passing FD to worker process for commands that take file
descriptor as input.

Rework data and FD sending and receiving functions for both side of the
master-worker control channel and add comments describing each steps of
the protocol.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd SDT userspace probe location
Francis Deslauriers [Thu, 28 Jun 2018 14:06:23 +0000 (10:06 -0400)] 
Add SDT userspace probe location

SDT userspace probe location is of the tracepoint location type.
Tracepoint locations describe an instrumentation location using a
provider name and a probe name.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd lttng_event copy constructor
Francis Deslauriers [Thu, 28 Jun 2018 13:47:51 +0000 (09:47 -0400)] 
Add lttng_event copy constructor

Since the lttng_event structure now has an extended_ptr to store
additional data, such as a userspace probe location, we can't simply
memcpy the struct to duplicate it.
This commit introduces a lttng_event_copy function that allocates a new
lttng_event struct and copies the content of both the struct and its
extended_ptr.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoImplement SDT probe description parsing function
Francis Deslauriers [Wed, 27 Jun 2018 21:26:25 +0000 (17:26 -0400)] 
Implement SDT probe description parsing function

This commit adds the lttng_elf_get_sdt_probe_offsets function to find
the SDT probe matching the received arguments and parses the SDT ELF note
section to return the number of callsite for this probe as well their
offsets in the binary.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Erica Bugden <ebugden@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd lttng_userspace_probe_location copy constructor
Francis Deslauriers [Wed, 27 Jun 2018 20:22:58 +0000 (16:22 -0400)] 
Add lttng_userspace_probe_location copy constructor

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoCleanup: move session saving of K(ret)probe and function tracing to dedicated functions
Francis Deslauriers [Wed, 27 Jun 2018 19:23:59 +0000 (15:23 -0400)] 
Cleanup: move session saving of K(ret)probe and function tracing to dedicated functions

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoImplement ELF function offset extraction function
Francis Deslauriers [Wed, 27 Jun 2018 15:35:42 +0000 (11:35 -0400)] 
Implement ELF function offset extraction function

Add lttng_elf_get_symbol_offset function to compute the offset of
given symbol in a given binary.

This function parses the ELF file backing the file descriptor received.
We first find the symbol table section to cross-reference it with the
string table section to find the symbol with the name matching the named
received from the caller. Once we finds the symbol, we use its virtual
address to find the offset of the function from the beginning of the
file on disk.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd utils_expand_path_keep_symlink fonction
Francis Deslauriers [Wed, 27 Jun 2018 14:47:41 +0000 (10:47 -0400)] 
Add utils_expand_path_keep_symlink fonction

This function mimics the behaviour of utils_expand_path() but omits to
expand symbolic links. This is useful to keep the full path to a
user-provided path, which can contain a symlink.

We will use this of the lttng-save of sessions containing
userspace-probe.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: kernel adds creds on recv with SO_PASSCRED unix socket option
Francis Deslauriers [Tue, 27 Jun 2017 21:21:35 +0000 (17:21 -0400)] 
Fix: kernel adds creds on recv with SO_PASSCRED unix socket option

When a Unix socket is configured with the SO_PASSCRED option, the caller
of recv() will receive a credential control message even if the sender
did not manually include it.
This caused problem with the old implementation of the
lttcomm_recv_fds_unix_sock function since it was expecting only one
control message for the fd passing. With the SO_PASSCRED, the kernel
will add a credential(SCM_CREDENTIALS) control message before the fd
passing(SCM_RIGHTS) control message (function scm_recv() [1]).

As a fix, make the receiver have a large enough before to include both
types of message and ignore the credential control message.

[1]: include/net/scm.h:111

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agolttng-ctl: implement listing of userspace probe locations
Jérémie Galarneau [Tue, 17 Oct 2017 21:22:43 +0000 (17:22 -0400)] 
lttng-ctl: implement listing of userspace probe locations

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd invalid userspace probe location error
Jérémie Galarneau [Tue, 17 Oct 2017 21:24:41 +0000 (17:24 -0400)] 
Add invalid userspace probe location error

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: memory is not zeroed on first set_capacity
Jérémie Galarneau [Tue, 17 Oct 2017 21:22:02 +0000 (17:22 -0400)] 
Fix: memory is not zeroed on first set_capacity

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd a util to create a buffer view from a raw buffer
Jérémie Galarneau [Tue, 17 Oct 2017 21:18:14 +0000 (17:18 -0400)] 
Add a util to create a buffer view from a raw buffer

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: dynamic buffer mishandles setting capacity to 0
Jérémie Galarneau [Tue, 17 Oct 2017 03:48:21 +0000 (23:48 -0400)] 
Fix: dynamic buffer mishandles setting capacity to 0

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agolttng-ctl: send userspace probe location on enable_event
Jérémie Galarneau [Mon, 16 Oct 2017 19:40:42 +0000 (15:40 -0400)] 
lttng-ctl: send userspace probe location on enable_event

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agolttng-ctl: locate extended event attributes at reception
Jérémie Galarneau [Mon, 16 Oct 2017 16:18:17 +0000 (12:18 -0400)] 
lttng-ctl: locate extended event attributes at reception

Locate the lttng_event's extended attributes at the time of
reception instead of locating them on access. This is mostly
preparation work for the addition of userspace probe locations
to the protocol.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd utils to send file descriptors to the sessiond
Francis Deslauriers [Sun, 15 Oct 2017 21:06:49 +0000 (17:06 -0400)] 
Add utils to send file descriptors to the sessiond

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agolttng-ctl: add accessors of userspace probe location to lttng_event
Jérémie Galarneau [Sun, 15 Oct 2017 20:31:07 +0000 (16:31 -0400)] 
lttng-ctl: add accessors of userspace probe location to lttng_event

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agolttng-ctl: add userspace probe location interface
Jérémie Galarneau [Sun, 15 Oct 2017 20:14:29 +0000 (16:14 -0400)] 
lttng-ctl: add userspace probe location interface

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agoAdd lttng_dynamic_buffer_get_capacity_left util
Jérémie Galarneau [Tue, 17 Oct 2017 21:21:10 +0000 (17:21 -0400)] 
Add lttng_dynamic_buffer_get_capacity_left util

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd ALIGN_TO util to macros.h
Jérémie Galarneau [Tue, 17 Oct 2017 21:18:36 +0000 (17:18 -0400)] 
Add ALIGN_TO util to macros.h

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agolttng-ctl: add an lttng_event_extended distinct from communication structures
Jérémie Galarneau [Sun, 15 Oct 2017 20:12:35 +0000 (16:12 -0400)] 
lttng-ctl: add an lttng_event_extended distinct from communication structures

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agolttng-ctl: move lttng_event functions to a new file
Jérémie Galarneau [Sun, 15 Oct 2017 20:07:29 +0000 (16:07 -0400)] 
lttng-ctl: move lttng_event functions to a new file

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: possible NULL dereference in rotation notification test
Jérémie Galarneau [Fri, 24 Aug 2018 18:09:52 +0000 (14:09 -0400)] 
Tests: possible NULL dereference in rotation notification test

Reported-by: Coverity Scan (1395166 Dereference after null check)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoClean-up: remove dead code from rotation test
Jérémie Galarneau [Fri, 24 Aug 2018 18:06:55 +0000 (14:06 -0400)] 
Clean-up: remove dead code from rotation test

Reported-by: Coverity Scan (1395165 Logically dead code)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: size of concrete class used in memcpy of base class
Jérémie Galarneau [Fri, 24 Aug 2018 01:51:25 +0000 (21:51 -0400)] 
Fix: size of concrete class used in memcpy of base class

session rotation condition and evaluation objects' base
class is initialized from a template to set the various
method's function pointers to the functions implementing
their interface.

The memcpy() erroneously uses the "derived" class' size through
sizeof(*obj) rather than the size of the base class through
sizeof(obj->parent).

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: add a session rotation ongoing/completed notification test
Jérémie Galarneau [Fri, 17 Aug 2018 17:26:07 +0000 (13:26 -0400)] 
Tests: add a session rotation ongoing/completed notification test

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoClean-up: remove useless check of event name
Jérémie Galarneau [Fri, 24 Aug 2018 01:13:48 +0000 (21:13 -0400)] 
Clean-up: remove useless check of event name

'name' in the lttng_event structure is a fixed-size array, which
will cause this condition to always evaluate to true.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: mix of lttng_error_code and cmd_error_code enums
Jérémie Galarneau [Fri, 24 Aug 2018 01:10:28 +0000 (21:10 -0400)] 
Fix: mix of lttng_error_code and cmd_error_code enums

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd notification session rotation hooks
Jérémie Galarneau [Fri, 24 Aug 2018 00:35:58 +0000 (20:35 -0400)] 
Add notification session rotation hooks

Add hooks to inform the notification subsystem of session rotation
state changes (ongoing or completed). This allows the notification
system to track the rotation state and inform clients that are
subscribed to those conditions.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoImplement rotation command handlers in notification system
Jérémie Galarneau [Thu, 23 Aug 2018 23:08:40 +0000 (19:08 -0400)] 
Implement rotation command handlers in notification system

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: return 0 on successful location serialization
Jérémie Galarneau [Thu, 23 Aug 2018 23:06:15 +0000 (19:06 -0400)] 
Fix: return 0 on successful location serialization

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: return size from location deserialization function
Jérémie Galarneau [Thu, 23 Aug 2018 23:05:52 +0000 (19:05 -0400)] 
Fix: return size from location deserialization function

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd a trace archive location accessor to the session API
Jérémie Galarneau [Thu, 23 Aug 2018 23:03:54 +0000 (19:03 -0400)] 
Add a trace archive location accessor to the session API

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: notification channel not released on error path
Jérémie Galarneau [Thu, 23 Aug 2018 22:55:38 +0000 (18:55 -0400)] 
Fix: notification channel not released on error path

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoImplement rotation ongoing/completed commands
Jérémie Galarneau [Tue, 21 Aug 2018 19:48:36 +0000 (15:48 -0400)] 
Implement rotation ongoing/completed commands

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: remove session_info from sessions_ht on destruction
Jérémie Galarneau [Sat, 18 Aug 2018 03:10:22 +0000 (23:10 -0400)] 
Fix: remove session_info from sessions_ht on destruction

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoBind newly registered triggers to session or channel objects
Jérémie Galarneau [Fri, 17 Aug 2018 19:37:54 +0000 (15:37 -0400)] 
Bind newly registered triggers to session or channel objects

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoDocs: clarify the contents of channel_infos_ht
Jérémie Galarneau [Fri, 17 Aug 2018 17:26:04 +0000 (13:26 -0400)] 
Docs: clarify the contents of channel_infos_ht

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd a hashing function for session rotation conditions
Jérémie Galarneau [Fri, 17 Aug 2018 17:26:01 +0000 (13:26 -0400)] 
Add a hashing function for session rotation conditions

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoBuild a list of triggers applying to a given session on creation
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:58 +0000 (13:25 -0400)] 
Build a list of triggers applying to a given session on creation

A hash table associating session names (which are unique) to
a lttng_session_trigger_list object is added to the notification
subsystem. This hash table is populated on the creation of a
session and a list is initialized with matching triggers known
at that time.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd a comment clarifying the ownership of triggers
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:56 +0000 (13:25 -0400)] 
Add a comment clarifying the ownership of triggers

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: use condition's type to compute its hash
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:53 +0000 (13:25 -0400)] 
Fix: use condition's type to compute its hash

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoCleanup: enforce const-correctness in notification thread
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:51 +0000 (13:25 -0400)] 
Cleanup: enforce const-correctness in notification thread

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: add session_info object to sessions_ht
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:49 +0000 (13:25 -0400)] 
Fix: add session_info object to sessions_ht

The notification subsystem currently does not add the session_info
structures it uses to account for session consumed sizes to its
sessions_ht. This means that a new internal session is created
for every channel, resulting in an incorrect accounting of
session consumed sizes, and thus delayed rotations.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd session rotation ongoing/completed notification commands
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:46 +0000 (13:25 -0400)] 
Add session rotation ongoing/completed notification commands

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd session rotation ongoing/completed conditions
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:44 +0000 (13:25 -0400)] 
Add session rotation ongoing/completed conditions

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: use the correct condition type in logging statements
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:41 +0000 (13:25 -0400)] 
Fix: use the correct condition type in logging statements

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd a by-address equality short-circuit to condition comparison
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:39 +0000 (13:25 -0400)] 
Add a by-address equality short-circuit to condition comparison

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: assume that conditions are valid before being compared
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:36 +0000 (13:25 -0400)] 
Fix: assume that conditions are valid before being compared

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoCleanup: remove superfluous argument to consumed size create
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:33 +0000 (13:25 -0400)] 
Cleanup: remove superfluous argument to consumed size create

5 years agoDocs: prefer 'release' to 'free' in API documentation
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:27 +0000 (13:25 -0400)] 
Docs: prefer 'release' to 'free' in API documentation

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd trace archive location serialization/deserialization methods
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:21 +0000 (13:25 -0400)] 
Add trace archive location serialization/deserialization methods

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: add notap versions of start/stop tracing helpers
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:16 +0000 (13:25 -0400)] 
Tests: add notap versions of start/stop tracing helpers

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: typo in notification test case description
Jérémie Galarneau [Wed, 22 Aug 2018 20:26:27 +0000 (16:26 -0400)] 
Tests: typo in notification test case description

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoUse the dynamic buffer to serialize notification objects
Jérémie Galarneau [Tue, 21 Aug 2018 20:56:19 +0000 (16:56 -0400)] 
Use the dynamic buffer to serialize notification objects

The objects of the notification/trigger APIs are currently
serialized by calling their serialization functions with a NULL
buffer, returning the expected size, and then calling the
serialization function with a sufficiently-large buffer.

This code predates the dynamic buffer utility which can now be
used to perform serialization operations in one pass.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: consumers don't honor protocol on rotate pending relay command
Jérémie Galarneau [Mon, 20 Aug 2018 21:32:46 +0000 (17:32 -0400)] 
Fix: consumers don't honor protocol on rotate pending relay command

The payload of a command should not be sent to the sessiond if
its execution failed. The sessiond reports an error as soon as
the return code of the command is returned and will never consume
the payload, resulting in a protocol error down the line.

Moreover, the ust-consumer's implementation doesn't check for
errors as it stores the return value of
lttng_consumer_rotate_pending_relay() to an unsigned variable and
checks for negative values.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: client_list_element leak on failure to evaluate a condition
Jérémie Galarneau [Mon, 20 Aug 2018 21:14:06 +0000 (17:14 -0400)] 
Fix: client_list_element leak on failure to evaluate a condition

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: possible NULL dereference in uri_parse_str_urls()
Jérémie Galarneau [Mon, 20 Aug 2018 20:45:09 +0000 (16:45 -0400)] 
Fix: possible NULL dereference in uri_parse_str_urls()

The data_url parsing of uri_parse_str_urls assumes that a ctrl
URL was provided to check that both URLs point to the same
destination. A check for 'ctrl_uris != NULL' is added, but this
function needs to be refactored at some point at it is not clear
what its role is (i.e. it's probably doing too much).

Reported-by: Coverity Scan (1378214 Explicit null dereferenced)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTypo fix in uri parsing error logging
Jérémie Galarneau [Mon, 20 Aug 2018 20:37:46 +0000 (16:37 -0400)] 
Typo fix in uri parsing error logging

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: unchecked return value of cds_lfht_destroy
Jérémie Galarneau [Mon, 20 Aug 2018 19:54:57 +0000 (15:54 -0400)] 
Fix: unchecked return value of cds_lfht_destroy

The sessiond should assert that cds_lfht_destroy returns 0 when
tearing down the 'pending rotate channel' hash table as a non-zero
value would indicate a leak.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: clean-up sessiond condig structure on initialization error
Jérémie Galarneau [Mon, 20 Aug 2018 19:50:48 +0000 (15:50 -0400)] 
Fix: clean-up sessiond condig structure on initialization error

The sessiond configuration structure's initialization may fail,
leaving some fields allocated and others to NULL. On error, the
structure should be cleaned-up to prevent a leak.

This allows the rest of the code to assume that all configuration
options are not NULL.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: unchecked return value in sessiond path configuration
Jérémie Galarneau [Mon, 20 Aug 2018 19:22:53 +0000 (15:22 -0400)] 
Fix: unchecked return value in sessiond path configuration

The return values of the functions setting the sessiond's
base paths are not checked.

Reported-by: Coverity Scan (1382768 and 1382769, Unused value)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: path leak on formatting error
Jérémie Galarneau [Mon, 20 Aug 2018 19:17:05 +0000 (15:17 -0400)] 
Fix: path leak on formatting error

'tmp_path' is leaked if 'snprintf()' reports an error.

Reported-by: Coverity Scan (1387044 Resource leak)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: use of uninitialized 'nb_pipes_fd'
Jérémie Galarneau [Mon, 20 Aug 2018 19:12:13 +0000 (15:12 -0400)] 
Fix: use of uninitialized 'nb_pipes_fd'

nb_pipes_fd can be used uninitialized in the consumers' data polling
threads if 'consumer_data.need_update' is false.

In practice, this is not a problem as 'consumer_data.need_update'
is true on the first execution of the thread's loop.

Reported-by: Coverity Scan (1387046 Uninitialized scalar variable)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoClean-up: useless assert that unsigned value is >= 0
Jérémie Galarneau [Mon, 20 Aug 2018 19:05:13 +0000 (15:05 -0400)] 
Clean-up: useless assert that unsigned value is >= 0

Reported-by: Coverity Scan (1387048 Macro compares unsigned to 0)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTest fix: size schedule leaked in a schedule API test case
Jérémie Galarneau [Mon, 20 Aug 2018 18:57:04 +0000 (14:57 -0400)] 
Test fix: size schedule leaked in a schedule API test case

Reported-by: Coverity Scan (1395071 and 1395073 Resource leak)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: unreported error on rotate timer stop failure
Jérémie Galarneau [Mon, 20 Aug 2018 18:51:45 +0000 (14:51 -0400)] 
Fix: unreported error on rotate timer stop failure

A missing 'goto end' causes errors occuring when stopping
the sessiond's rotate timer to be ignored as the switch-case's
case breaks and the 'ret' value is set to LTTNG_OK.

Reported-by: Coverity Scan (1395074 Unused value)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agosave/load: support session rotation schedule descriptors
Jérémie Galarneau [Fri, 17 Aug 2018 02:41:49 +0000 (22:41 -0400)] 
save/load: support session rotation schedule descriptors

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agomi: serialize relay rotation locations
Jérémie Galarneau [Fri, 17 Aug 2018 00:48:28 +0000 (20:48 -0400)] 
mi: serialize relay rotation locations

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: use negative code for errors in enum
Jérémie Galarneau [Fri, 17 Aug 2018 00:47:42 +0000 (20:47 -0400)] 
Fix: use negative code for errors in enum

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd rotate-client to .gitignore
Jérémie Galarneau [Thu, 16 Aug 2018 20:01:11 +0000 (16:01 -0400)] 
Add rotate-client to .gitignore

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoDocs: adapt the rotation client example to the API changes
Jérémie Galarneau [Wed, 15 Aug 2018 20:42:43 +0000 (16:42 -0400)] 
Docs: adapt the rotation client example to the API changes

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoRemove generic error reporting from the lttng client
Jérémie Galarneau [Wed, 8 Aug 2018 21:48:24 +0000 (17:48 -0400)] 
Remove generic error reporting from the lttng client

Unsuccessful command results are reported by the lttng client
which often results in strange error messages of the form:

Error: Could not rotate ...
Error: Command error

Considering that most commands correctly report their errors,
it is safe to remove those generic error reports.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
This page took 0.04431 seconds and 5 git commands to generate.