Jérémie Galarneau [Fri, 31 Aug 2018 18:49:24 +0000 (14:49 -0400)]
Missing kernel test files in dist target
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Fri, 31 Aug 2018 15:59:56 +0000 (11:59 -0400)]
elf: support dynamic symbol table lookup
Background
==========
There may be two symbol tables in a shared object or executable. The
normal symbol table (.symtab) and the dynamic symbol table (.dynsym).
The normal symbol table contains lots of information, such as static
linking data, but none of it is used at runtime. This is why some
shared libraries are 'stripped', reducing the final size of the file.
Stripping an object file removes the entire .symtab section of the elf
file, amongst other things.
The dynamic symbol table contains symbols that are needed for dynamic
linking of the shared object. The symbols in that section form a subset
of the symbols contained in the normal symbol section (before
stripping). The .dynsym section is left untouched when stripping a file
as it is needed at runtime.
Current limitation
==================
The current elf parsing implementation looks for the normal symbol
section (.symtab) to find the target symbol. If the .symtab is not
found, the parsing stops and returns that the symbol was not found. As
explained in the section above, a shared library might be stripped from
its normal symbol table, but still have a dynamic symbol table (.dynsym)
containing the information of the target symbol. For example, on
distributions where libc is stripped, the malloc symbol can only be
found in the .dynsym section
Solution
========
Look for the normal symbol section first and, if it's found, use it to
find the symbol, as was previously done. If the .symtab is absent,
try to use the dynamic symbol section instead.
This commit also adds a testcase for this feature.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 31 Aug 2018 17:56:04 +0000 (13:56 -0400)]
Fix: leak of event attributes on copy failure
Reported-by: Coverity Scan (1243042 Resource leak)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 31 Aug 2018 17:47:36 +0000 (13:47 -0400)]
Test fix: check length of input string
Reported-by: Coverity Scan (395327 Unbounded source buffer)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 31 Aug 2018 17:41:00 +0000 (13:41 -0400)]
Test cleanup: wrong indentation style in test_ust_data.c
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 31 Aug 2018 17:39:50 +0000 (13:39 -0400)]
Test fix: leak of exclusions on allocation error
Reported-by: Coverity Scan (1395328 Resource leak)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 31 Aug 2018 17:33:51 +0000 (13:33 -0400)]
Fix: runas check fd value before calling close()
A bug could cause an 'open' command to return no FD in which
case the initial value of '-1' would be used in the call to
close().
Reported-by: Coverity Scan (1395329 Improper use of negative value)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 20:21:42 +0000 (16:21 -0400)]
Docs: multiple rotation schedules can be active
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 20:19:53 +0000 (16:19 -0400)]
Docs: immadiate rotations can be performed with active schedules
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 19:42:41 +0000 (15:42 -0400)]
Fix: ret variable is used instead of cmd_ret in disable-rotation
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 19:39:30 +0000 (15:39 -0400)]
Cleanup: unused assignation on rotation error
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 19:37:51 +0000 (15:37 -0400)]
Cleanup: unused assignation on rotation already pending
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 19:36:38 +0000 (15:36 -0400)]
Fix: unchecked writer open element return value
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 18:51:52 +0000 (14:51 -0400)]
Remove unused session current_archive_location accessor
This function was replaced by
lttng_rotation_handle_get_archive_location() which requires
an lttng_rotation_handle to be used, making its use less
error-prone.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 18:49:29 +0000 (14:49 -0400)]
Fix: incorrect error message on regenerate missing argument
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 18:45:23 +0000 (14:45 -0400)]
Fix: incorrect error message on metadata missing argument
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 18:32:10 +0000 (14:32 -0400)]
Fix: snapshot command mishandles missing arguments
The snapshot command does not print explicit errors when
arguments are missing. This commit introduces more error
reporting and ensures that lttng_error_code and cmd_error_code
values are not freely mixed.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 17:45:40 +0000 (13:45 -0400)]
Cleanup: improve readability of filter expression condition
In this situation, a logical inequality '!=' is equivalent to the
binary xor '^' that was used.
However, while it is equivalent, mixing logical ('!') and bitwise
operators ('^') makes this code harder to read than it needs to be.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 17:36:37 +0000 (13:36 -0400)]
Fix: potential use of NULL path in stat() use
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 17:21:50 +0000 (13:21 -0400)]
Cleanup: unused assignment of curr_data_ptr in lttng_elf
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 17:14:33 +0000 (13:14 -0400)]
Fix: uninitialized data/ret in runas offset commands
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 17:10:40 +0000 (13:10 -0400)]
Fix: uninitialized fd value used in runas
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 17:00:53 +0000 (13:00 -0400)]
Fix: report setegid()/seteuid() failure in runas
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Aug 2018 16:57:04 +0000 (12:57 -0400)]
Fix: leak of binary path on location creation error
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 29 Aug 2018 22:47:44 +0000 (18:47 -0400)]
Fix: missing return value check in notification serialization
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 29 Aug 2018 22:28:17 +0000 (18:28 -0400)]
Fix: possible leak of path in _utils_expand_path
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 29 Aug 2018 22:12:43 +0000 (18:12 -0400)]
Fix: silent truncation in _utils_expand_path
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 29 Aug 2018 22:06:25 +0000 (18:06 -0400)]
Cleanup: unused assignment of ret_code in ROTATE_CHANNEL
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 29 Aug 2018 21:28:36 +0000 (17:28 -0400)]
Fix: passing null to closedir() on error
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 29 Aug 2018 21:25:04 +0000 (17:25 -0400)]
Fix: unchecked access to pids array
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 29 Aug 2018 21:23:38 +0000 (17:23 -0400)]
Fix: missing jump to error on allocation failure
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 29 Aug 2018 21:22:44 +0000 (17:22 -0400)]
Cleanup: unused assignation of ret value
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 29 Aug 2018 21:21:14 +0000 (17:21 -0400)]
Cleanup: unused assignation of ELF parsing error
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 29 Aug 2018 21:17:03 +0000 (17:17 -0400)]
Fix: leak of probe_locs on error
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 29 Aug 2018 21:10:25 +0000 (17:10 -0400)]
Fix: leak on agent event listing error
Jumping to the 'error' label after allocating tmp_events results
in a memory leak.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 29 Aug 2018 21:06:48 +0000 (17:06 -0400)]
Fix: possible null dereference on communication error
lttng_ctl_ask_sessiond_fds_varlen() can return a positive
error code and NULL buffers if the sessiond uses a command
return code that is already negative.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 29 Aug 2018 20:56:52 +0000 (16:56 -0400)]
Fix: returned pids may be uninitialized
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Wed, 29 Aug 2018 12:37:48 +0000 (08:37 -0400)]
Fix: invalid destruction of lookup_method
When passing the lookup_method to the location create function we give
it the ownership of that structure. By setting our pointer to NULL, we
make sure the _destroy function won't free it.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 28 Aug 2018 21:09:48 +0000 (17:09 -0400)]
Fix: unused value in SDT probe description parsing
Reported-by: Coverity (1395199) Unused value
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 28 Aug 2018 20:54:31 +0000 (16:54 -0400)]
Fix: use of uninitialized variable in C++ userspace-probe testapp
Reported-by: Coverity (1395206) Uninitialized scalar variable
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 28 Aug 2018 20:43:12 +0000 (16:43 -0400)]
Fix: use of uninitialized value in error path
Reported-by: Coverity (1395212) Uninitialized pointer read
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 28 Aug 2018 20:12:40 +0000 (16:12 -0400)]
Fix: leaking string by setting pointer to NULL before freeing it
Reported-by: Coverity (1395200) Resource leak
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 28 Aug 2018 20:01:02 +0000 (16:01 -0400)]
Fix: passing negative param to dup(2) on error
Reported-by: Coverity (1395195)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 28 Aug 2018 19:38:22 +0000 (15:38 -0400)]
Fix: use-after-free in UST test case
Create a copy of the exclusion structure to be able to compare both
struct after the event is created.
Reported-by: Coverity (1395194) Read from pointer after free
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 28 Aug 2018 19:10:12 +0000 (15:10 -0400)]
Fix: leak in error handling of userspace param parsing
Reported-by: Coverity Scan (1395217 Resource leak)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 28 Aug 2018 15:25:01 +0000 (11:25 -0400)]
Fix: Remove dead code in fd passing function
Found by Coverity:
CID
1395190 (#1 of 1): Logically dead code (DEADCODE)
dead_error_begin: Execution cannot reach this statement: fprintf(stderr,
"Error: Inv...
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Mon, 27 Aug 2018 21:13:07 +0000 (17:13 -0400)]
Cleanup: avoid duplicating userspace-probe desc twice
In userspace probe location _copy functions, we duplicate the strings
(e.g. function name, provider name, etc.) before passing those new
strings to the *_create_no_check function. But this function also duplicates
those strings.
To remove this double duplication, we remove the calls to lttng_strndup() in
the _copy functions and pass the pointers to those strings directly to
the _create_no_check functions.
Also, we now don't call open() needlessly when calling the
_create_no_check functions from the _copy functions as we need to
manually set a duplicated fd (using dup(2)) to avoid file unlink race.
Fixes Coverity resource leak issues:
1395196,
1395192,
1395205,
1395211
and
1395214
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Mon, 27 Aug 2018 20:28:26 +0000 (16:28 -0400)]
Fix: memory leak in userspace probe param parsing
Found by Coverity:
CID
1395217: (RESOURCE_LEAK)
Variable "real_target_path" going out of scope leaks the storage it
points to.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Mon, 27 Aug 2018 20:11:02 +0000 (16:11 -0400)]
Fix: missing error handling goto statement in runas
Found by Coverity:
CID
1395218: Code maintainability issues (UNUSED_VALUE)
Assigning value "-1" to "ret" here, but that stored value is overwritten
before it can be used.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Mon, 27 Aug 2018 19:41:51 +0000 (15:41 -0400)]
Fix: use-after-free on error of lttng_event creation and copy
Found by Coverity:
>>> CID
1395219: Memory - illegal accesses (USE_AFTER_FREE)
>>> Using freed pointer "new_event".
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 28 Aug 2018 23:05:25 +0000 (19:05 -0400)]
Add function instrumentation type accessors to function location type
Since the uprobe instrumentation is currently limited to function
entries, and since support for the instrumentation function return
is planned to be introduced at some point, it makes sense
to introduce an "instrumentation type" attribute on function
locations.
Currently, the only available instrumentation type is
"entry", which matches what is supported by the kernel tracer as of
2.11.
In the future, a RETURN and ENTRY_RETURN/BOTH instrumentation type
could be added without changing the default behavior of rules
such a userspace probe.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 28 Aug 2018 21:23:51 +0000 (17:23 -0400)]
Docs fix: probe location description is erroneous
A 'FUNCTION' probe location type does not trace function returns.
The current implementation only traces function entries.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 28 Aug 2018 16:15:03 +0000 (12:15 -0400)]
Fix: event leak during event load
The currently processed lttng_event is now created using
its constructor rather than allocating the structure on the function's
stack. The destructor must thus be used.
Reported-by: Coverity Scan (1395210 Resource leak)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 28 Aug 2018 16:13:43 +0000 (12:13 -0400)]
Hide lttng_event_copy symbol
lttng_event_copy()'s only caller is internal. It is hidden to
reduce the API surface, but could be made public at some point
to accomodate lttng-ctl users.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 28 Aug 2018 16:06:59 +0000 (12:06 -0400)]
Docs: document new lttng_event methods
Add documentation for the new lttng_event methods introduced as
part of the uprobe work.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
This page took 0.043723 seconds and 4 git commands to generate.