The default behavior, for AC_CHECK_LIB when the `action-if-found` is NOT
defined, is to prepend the library to LIBS. [1]
"
If action-if-found is not specified, the default action prepends
-llibrary to LIBS and defines ‘HAVE_LIBlibrary’ (in all capitals).
"
It is important to note that the LIBS variable is used for ALL linking.
This is normally not a problem for most distribution since they force
the use of `--as-needed` at the toolchain level (gcc specs) (for example
debian [2]). One could also pass the `--as-needed` flag manually but
libtool reorganize flags in the case of shared object creation [3].
In our case, we always explicitly state the dependencies via the *_LIBADD
automake clause. We do not rely on the LIBS variable.
Simply force the define of HAVE_LIBNUMA to prevent the prepending to
LIBS.
Michael Jeanson [Thu, 2 Dec 2021 21:11:21 +0000 (16:11 -0500)]
fix: Allow disabling some abi compat tests
Allow disabling ABI compat tests that rely on a library using a symbol from
the global offset table even if it provides its own copy, which is the
default behavior on Linux.
This situation happens when using the '-Bsymbolic-functions' linker flag
which binds references to public symbols in a library to the definition
within the library, bypassing the global offset table.
To disable those tests when running the test suite, set the
UST_TESTS_LD_SYMBOLIC_FUNC environment variable to any value, for
example :
make check UST_TESTS_LD_SYMBOLIC_FUNC=1
Change-Id: I1ed23d90bbe1b174ab7b4fccfb40b701b291c074 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: generate probe registration constructor as a C++ constuctor
Observed issue
==============
Applications which transitively dlopen() a library which, in turn,
dlopen() providers crash when they are compiled with clang or
if LTTNG_UST_ALLOCATE_COMPOUND_LITERAL_ON_HEAP is defined.
Core was generated by `././myapp.exe'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007fa94f860bc2 in check_event_provider (probe_desc=<optimized out>) at lttng-probes.c:153
153 if (!check_type_provider(field->type)) {
[Current thread is 1 (Thread 0x7fa94fcbc740 (LWP 511754))]
(gdb) bt
#0 0x00007fa94f860bc2 in check_event_provider (probe_desc=<optimized out>) at lttng-probes.c:153
#1 lttng_ust_probe_register (desc=0x7fa94fe9dc80 <lttng_ust__probe_desc___embedded_sys>)
at lttng-probes.c:242
#2 0x00007fa94fe9ba3c in lttng_ust__tracepoints__ptrs_destroy ()
at /usr/include/lttng/tracepoint.h:590
#3 0x00007fa94fedfe2e in call_init () from /lib64/ld-linux-x86-64.so.2
#4 0x00007fa94fedff1c in _dl_init () from /lib64/ld-linux-x86-64.so.2
#5 0x00007fa94fdf7d45 in _dl_catch_exception () from /usr/lib/libc.so.6
#6 0x00007fa94fee420a in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
#7 0x00007fa94fdf7ce8 in _dl_catch_exception () from /usr/lib/libc.so.6
#8 0x00007fa94fee39bb in _dl_open () from /lib64/ld-linux-x86-64.so.2
#9 0x00007fa94fe8d36c in ?? () from /usr/lib/libdl.so.2
#10 0x00007fa94fdf7ce8 in _dl_catch_exception () from /usr/lib/libc.so.6
#11 0x00007fa94fdf7db3 in _dl_catch_error () from /usr/lib/libc.so.6
#12 0x00007fa94fe8db99 in ?? () from /usr/lib/libdl.so.2
#13 0x00007fa94fe8d3f8 in dlopen () from /usr/lib/libdl.so.2
#14 0x00007fa94fecc647 in mon_constructeur () at mylib.cpp:20
#15 0x00007fa94fedfe2e in call_init () from /lib64/ld-linux-x86-64.so.2
#16 0x00007fa94fedff1c in _dl_init () from /lib64/ld-linux-x86-64.so.2
#17 0x00007fa94fdf7d45 in _dl_catch_exception () from /usr/lib/libc.so.6
#18 0x00007fa94fee420a in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
#19 0x00007fa94fdf7ce8 in _dl_catch_exception () from /usr/lib/libc.so.6
#20 0x00007fa94fee39bb in _dl_open () from /lib64/ld-linux-x86-64.so.2
#21 0x00007fa94fe8d36c in ?? () from /usr/lib/libdl.so.2
#22 0x00007fa94fdf7ce8 in _dl_catch_exception () from /usr/lib/libc.so.6
#23 0x00007fa94fdf7db3 in _dl_catch_error () from /usr/lib/libc.so.6
#24 0x00007fa94fe8db99 in ?? () from /usr/lib/libdl.so.2
#25 0x00007fa94fe8d3f8 in dlopen () from /usr/lib/libdl.so.2
#26 0x00005594f478c18c in main ()
Cause
=====
Building tracepoint instrumentation as C++ using clang causes
LTTNG_UST_ALLOCATE_COMPOUND_LITERAL_ON_HEAP to be defined due to a
compiler version detection problem addressed by another patch.
However, building with LTTNG_UST_ALLOCATE_COMPOUND_LITERAL_ON_HEAP
defined still results in the crash.
When LTTNG_UST_ALLOCATE_COMPOUND_LITERAL_ON_HEAP is defined, the
lttng_ust_event_field lttng_ust__event_fields__[...] structure is
initialized by dynamically-allocating field structures for the various
fields.
As the initialization can't be performed statically, it is performed at
run-time _after_ the execution of the library constructors has
completed.
Moreover, the generated initialization
function of the provider (lttng_ust__events_init__[...]) is declared as being a library
constructor. Hence, this causes it to run before the
tracepoint fields structures has a chance to be initialized.
This all results in a NULL pointer dereference during the validation of
the fields.
Solution
========
When building providers as C++, the initialization function is defined
as the constructor of a class. This class is, in turn, instantiated in
an anonymous namespace.
For the purposes of this patch, the use of an anonymous namespace is
equivalent to declaring the instance as 'static', but it is preferred in
C++11.
Known drawbacks
===============
None.
References
==========
A reproducer is available:
https://github.com/jgalar/ust-clang-reproducer
Problem initially reported on dotnet/runtime's issue tracker:
https://github.com/dotnet/runtime/issues/62398
The pthread cancelstate disable performed to ensure threads are not
cancelled while holding mutexes which are used in library destructors
does not currently support that those mutexes may be nested. It
generates error messages when using the fork and fd helpers when running
with LTTNG_UST_DEBUG=1. The effect of this is that the pthread
cancelstate can be re-enabled too soon when the first unlock is
performed (in a nested lock scenario), thus allowing the thread to be
cancelled while still holding a lock, and causing a deadlock on
application exit.
Fix: abort on decrement_sem_count during concurrent tracing start and teardown
Observed issue
==============
The following backtrace has been reported:
#0 __GI_raise (sig=sig@entry=6)
at /usr/src/debug/glibc/2.31/git/sysdeps/unix/sysv/linux/raise.c:50
#1 0x0000007f90b3fdd4 in __GI_abort () at /usr/src/debug/glibc/2.31/git/stdlib/abort.c:79
#2 0x0000007f90b4bf50 in __assert_fail_base (fmt=0x7f90c3da98 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
assertion=assertion@entry=0x7f9112cb90 "uatomic_read(&sem_count) >= count",
file=file@entry=0x7f9112cb30 "/usr/src/debug/lttng-ust/2_2.13.0-r0/lttng-ust-2.13.0/src/lib/lttng-ust/lttng-ust-comm.c",
line=line@entry=664, function=function@entry=0x7f911317e8 <__PRETTY_FUNCTION__.10404> "decrement_sem_count")
at /usr/src/debug/glibc/2.31/git/assert/assert.c:92
#3 0x0000007f90b4bfb4 in __GI___assert_fail (assertion=assertion@entry=0x7f9112cb90 "uatomic_read(&sem_count) >= count",
file=file@entry=0x7f9112cb30 "/usr/src/debug/lttng-ust/2_2.13.0-r0/lttng-ust-2.13.0/src/lib/lttng-ust/lttng-ust-comm.c",
line=line@entry=664, function=function@entry=0x7f911317e8 <__PRETTY_FUNCTION__.10404> "decrement_sem_count")
at /usr/src/debug/glibc/2.31/git/assert/assert.c:101
#4 0x0000007f910e3830 in decrement_sem_count (count=<optimized out>)
at /usr/src/debug/lttng-ust/2_2.13.0-r0/lttng-ust-2.13.0/src/lib/lttng-ust/lttng-ust-comm.c:664
#5 0x0000007f910e5d28 in handle_pending_statedump (sock_info=0x7f9115c608 <global_apps>)
at /usr/src/debug/lttng-ust/2_2.13.0-r0/lttng-ust-2.13.0/src/lib/lttng-ust/lttng-ust-comm.c:737
#6 handle_message (lum=0x7f8dde46d8, sock=3, sock_info=0x7f9115c608 <global_apps>)
at /usr/src/debug/lttng-ust/2_2.13.0-r0/lttng-ust-2.13.0/src/lib/lttng-ust/lttng-ust-comm.c:1410
#7 ust_listener_thread (arg=0x7f9115c608 <global_apps>)
at /usr/src/debug/lttng-ust/2_2.13.0-r0/lttng-ust-2.13.0/src/lib/lttng-ust/lttng-ust-comm.c:2055
#8 0x0000007f90af73e0 in start_thread (arg=0x7fc27a82f6)
at /usr/src/debug/glibc/2.31/git/nptl/pthread_create.c:477
#9 0x0000007f90bead5c in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78
It turns out that the main thread is at that point iterating over the
libraries destructors:
Thread 3 (LWP 1983):
#0 0x0000007f92a68a0c in _dl_fixup (l=0x7f9054e510, reloc_arg=432)
at /usr/src/debug/glibc/2.31/git/elf/dl-runtime.c:69
#1 0x0000007f92a6ea3c in _dl_runtime_resolve () at ../sysdeps/aarch64/dl-trampoline.S:100
#2 0x0000007f905170f8 in __do_global_dtors_aux () from <....>/crash/work/rootfs/usr/lib/libbsd.so.0
#3 0x0000007f92a697f8 in _dl_fini () at /usr/src/debug/glibc/2.31/git/elf/dl-fini.c:138
#4 0x0000007f90b54864 in __run_exit_handlers (status=0, listp=0x7f90c65648 <__exit_funcs>,
run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true)
at /usr/src/debug/glibc/2.31/git/stdlib/exit.c:108
#5 0x0000007f90b549f4 in __GI_exit (status=<optimized out>)
at /usr/src/debug/glibc/2.31/git/stdlib/exit.c:139
#6 0x0000000000404c98 in a_function_name (....) at main.c:152
#7 0x0000000000404a98 in main (argc=3, argv=0x7fc27a8858, env=0x7fc27a8878) at main.c:97
Cause
=====
An enable command is processed at the same time that the lttng-ust
destructor is run. At the end of the command handling,
`handle_pending_statedump` is called. Multiple variables from the
`sock_info` struct are checked outside the UST lock at that point.
lttng-ust-comm.c +1406:
/*
* Performed delayed statedump operations outside of the UST
* lock. We need to take the dynamic loader lock before we take
* the UST lock internally within handle_pending_statedump().
*/
handle_pending_statedump(sock_info);
`statedump_pending` is set during the enable command
(`lttng_session_statedump`, lttng-events.c +631) in the same thread.
As for `registration_done` and `initial_statedump_done` they are invariant
from the registration of the app until `lttng_ust_cleanup` is called.
`cleanup_sock_info` called by `lttng_ust_cleanup`, itself called by
`lttng_ust_exit` resets the `registration_done` and
`initial_statedump_done` fields. Note that these operations are done
outside of the listener thread.
Note that by that point `lttng_ust_exit` expects all "getters" on
`sock_info` to fail while trying to acquire the UST lock due to
`lttng_ust_comm_should_quit` set to 1. Note that the listener threads
can still exist because we do not join them, we only execute
pthread_cancel which is async.
Clearly we are missing mutual exclusion provided by locking
when accessing `registration_done` and `initial_statedump_done`.
Solution
========
Here we can do better and simply not require any mutual exclusion based on locking.
`registration_done` and `initial_statedump_done` only need to be reset
to zero when we are not actually exiting (`lttng_ust_after_fork_child`).
In this case, no concurrent listener thread exists at that point
that could access those fields during the reset. Hence we can move the
reset to only the non-exiting code path and alleviate the current
situation.
Known drawbacks
===============
None.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I45ba3eaee20c49a3988837a87fa680ce0a6ed953
Michael Jeanson [Mon, 6 Dec 2021 20:05:59 +0000 (15:05 -0500)]
fix: allocating C++ compound literal on heap with Clang
Exclude Clang from the GCC version macro check for <= 4.8 since most
versions of Clang seem to identify themselves as GCC 4.2 which in this
case forces the allocation of C++ compound literals on the heap which
is only supported starting with Clang >= 6.0.
The macro was also broken for GCC <= 4.8 in C mode, add missing
parentheses around the 'or' statement to properly distinguish between C
and C++.
Also document the minimal supported version of Clang 4.0 to build C++
probe providers.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I62eea00381b7dc5958a09b13044ad9e7f7caf2ab
Michael Jeanson [Wed, 8 Dec 2021 20:54:53 +0000 (15:54 -0500)]
Check for C++11 when building C++ probe providers
The compiler used to build probe providers might differ from the one
used to build lttng-ust, make sure that when a probe provider is built
by a C++ compiler, it supports C++11.
Change-Id: I2a17e923316ff87c023d8e50c53efdbe35386a21 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Tue, 9 Mar 2021 17:38:06 +0000 (12:38 -0500)]
fix: liblttng-ust-fd async-signal-safe close()
"close(2)" is documented as async-signal-safe (see signal-safety(7)) and
as such our override function should also be. This means we shouldn't do
lazy initialization of the function pointer to the original libc close
symbol in the override function.
If we move the initialization of the function pointer in the library
constructor we risk breaking other constructors that may run before ours
and call close().
A compromise is to explicitly do the initialization in the constructor
but keep a lazy init scheme if close() is called before it is executed.
The dlsym call is now done only once, if it fails the wrappers will
return -1 and set errno to ENOSYS.
Change-Id: I05c66d2f5d51b2022c6803ca215340fb9c00f5a8 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tracepoints: print debug message when lttng-ust-tracepoint.so is not found
Rather than silently disable tracepoints when lttng-ust-tracepoint.so is
not found in the library search path, print a debug message when either
the compile unit including tracepoint.h has defined LTTNG_UST_DEBUG, or
when the LTTNG_UST_DEBUG environment variable is set.
gcc 4.8 introduces support for C11, and gcc 4.6 introduces support for
_Static_assert. Therefore, using _Static_assert when C11 is detected is
always OK.
However, using static_assert in C11 depends on glibc >= 2.16. Even
though the minimum version requirement for glibc is not documented in
the README.md file, make a best effort to keep compatibility with older
glibc.
Fix: combined tracing of lttng-ust 2.12/2.13 generates corrupted traces
Observed issue
==============
When tracing applications linked against lttng-ust 2.12 and lttng-ust
2.13 in parallel with a lttng-tools 2.13 into the same per-uid buffers,
with the "procname" context enabled, babeltrace fails with "Event id NN
is outside range" when reading the trace:
[14:51:58.717006865] (+5.927872956) x lttng_ust_statedump:start: { cpu_id = 1 }, { procname = "sample-2.13-ust" }, { }
[error] Event id 41984 is outside range.
[error] Reading event failed.
Error printing trace.
Cause
=====
Inspection of the trace reveals that the layout of the procname context
field changed from 17 bytes to 16 bytes between 2.12 and 2.13. This is
an issue when applications share a per-uid ring buffer, because context
fields are associated with channels, and need to have the same layout
across all processes tracing into a given channel.
The layout of the procname field described by the trace metadata is that
of the first application which happens to register that channel in the
session lifetime.
Therefore, the procname context field length is part of the LTTng-UST
ABI and cannot be changed without breaking the LTTng-UST ABI (bumping
LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE), which is unwanted
between 2.12 and 2.13. Keeping compatibility for combined use by
different applications between lttng-ust 2.12 and 2.13 is a required
feature for this release, because lttng-ust 2.13 introduces a library
ABI break (soname bump).
An example scenario leading to this issue:
1) trace created for per-uid buffers,
2) add procname context
3) start tracing
4) Application [a] linked against lttng-ust 2.13 registers the channel to
lttng-sessiond, sending its context descriptions with a 16-byte
procname context field,
5) Application [b] linked against lttng-ust 2.12 registers the same channel
to lttng-sessiond,
6) Application [b] traces an event with the procname context, followed
by an event payload with a single "string" field.
7) A trace viewer will observe the procname context, followed by an
extra null character, and thus mistakenly consider the event payload
to be an empty string. Reading the next event header will fail
because the string payload will be expected to contain an event ID.
Solution
========
Revert the procname context field size to 17 bytes to stay compatible
with lttng-ust 2.12.
In an abundance of caution, also revert the size of the
lttng_ust_statedump:procname "procname" field to 17, so there won't be
duplicated event IDs for this event when applications linked against
lttng-ust 2.12 and 2.13 are traced concurrently for the same user ID
in per-uid tracing.
History
=======
This issue was introduced by commit 0db3d6ee9be ("port: fix
pthread_setname_np integration") within the 2.13 development cycle.
Known drawbacks
===============
Applications currently running which are linked against a liblttng-ust
2.13 without this fix should be restarted after upgrading the library to
liblttng-ust 2.13 with this fix.
Michael Jeanson [Mon, 19 Jul 2021 17:42:55 +0000 (13:42 -0400)]
Add 'pid' to socket peercred on FreeBSD
The 'pid' of the socket peer was added to xucred in FreeBSD 12.
Lttng-tools doesn't yet have full support for FreeBSD but once it's
merged the baseline should be either FreeBSD 12 or 13 so we can get away
with no compat code.
Change-Id: I238baef7eedb3a909fb3804e6fd2cca4db84b21a Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Documentation: clarify API backward compatibility comment
Considering that the ABI (soname major version) and API version can
evolve independently in the future, remove references to the soname
major version from the API compatibility documentation.
Philippe Proulx [Wed, 9 Jun 2021 19:39:25 +0000 (15:39 -0400)]
doc/man: only mention `-llttng-ust-common` in synopses (conditionally)
LTTng-UST only requires that you link your application or tracepoint
provider package with `-llttng-ust-common` if you define
`_LGPL_SOURCE` before you include, directly or indirectly,
`<lttng/tracepoint.h>`.
The `_LGPL_SOURCE` definition is specific to the EfficiOS/LTTng
projects.
Because defining `_LGPL_SOURCE` is not considered the typical scenario,
remove instructions to link with `-llttng-ust-common` throughout the
manual pages, except in synopses, to make such instructions more
readable/light.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I460a2f746d5e2904660a11b3151d0d01776361db
Philippe Proulx [Wed, 9 Jun 2021 19:26:01 +0000 (15:26 -0400)]
doc/man: remove vtracef() and vtracelog() manual pages
Following 2268c76f ("Remove vtracelog and vtracef from v0 compat API"),
this patch removes the manual pages of vtracef() and vtracelog() which
don't exist.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1a07c74b330015ee74bb92235db2171066751503
vtracelog and vtracef were introduced between lttng-ust 2.12 and 2.13
(not released yet). They are replaced by lttng_ust_vtracelog and
lttng_ust_vtracef in the v1 API, newly introduced in lttng-ust 2.13.
Therefore, there is no need to expose a v0 compat API for the vtracelog
and vtracef macros which were never officially part of any release
other than the 2.13 release candidates.
Michael Jeanson [Wed, 3 Mar 2021 16:56:49 +0000 (11:56 -0500)]
Add serialized ABI definition files
This commit contains the serialized ABI definitions for a typical build
of the lttng-ust librairies. This information is extracted using
libabigail (https://sourceware.org/libabigail/).
The artefacts used to generate these were built with CFLAGS="-O0 -ggdb"
and all optional configure switches enabled.
You can compare the serialized ABI with a shared object to check for
changes. For example, here we compare an in-tree built version of
liblttng-ust.so with the serialized ABI of stable-2.13 :
Philippe Proulx [Tue, 25 May 2021 17:06:56 +0000 (13:06 -0400)]
doc/man: document LTTng-UST 2.13
Significant changes:
* Prefix all macro/definition names with `LTTNG_UST_` or `lttng_ust_`
where needed.
* Prefix all log level definitions with `LTTNG_UST_TRACEPOINT_LOGLEVEL`.
* lttng-ust(3):
* Add "Compatibility with previous APIs" section to explain
the new `LTTNG_UST_COMPAT_API_VERSION` definition.
* Document the new tracepoint class provider name parameter of
`LTTNG_UST_TRACEPOINT_EVENT_INSTANCE()`.
Update examples accordingly.
* Mention `liblttng-ust-common` where missing.
* tracef(3), vtracef(3), tracelog(3), and vtracelog(3) now indicate that
the macros are part of version 0 of the LTTng-UST API, albeit still
available, and point to lttng_ust_tracef(3), lttng_ust_vtracef(3),
lttng_ust_tracelog(3), and lttng_ust_vtracelog(3).
* New lttng_ust_do_tracepoint(3), lttng_ust_tracepoint(3),
and lttng_ust_tracepoint_enabled(3) manual pages which source
lttng-ust(3).
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I07d6ace0d6f219c36d7c99a455726bbf4b0736a2
LTTng-UST 2.13 bumps the accepted probe provider major version to 3,
therefore we can remove the lttng_ust_probe_supports_event_notifier
version check, which requires that the probe provider major version is
>= 2, because it is now useless.
Michael Jeanson [Mon, 17 May 2021 15:24:47 +0000 (11:24 -0400)]
fix: disable some abi conflict tests on FreeBSD
On FreeBSD, symbol resolution when dlopening a shared object will always
favor symbols local to this shared object and thus our canary function will
never be called which breaks our abi conflict detection when abi1 is loaded
first.
Disable the test cases with this scenario on FreeBSD as we have no way
to fix this at the moment.
Change-Id: Ic0451ce61e21f94ece55429b41bf76db3ad74b3a Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: ustcomm: application name uses the '-ust'-suffixed thread name
During the 2.13 development cycle, the compatibility pthread_setname_np
compatibility layer was fixed (see 0db3d6ee). Unfortunately, this had a
detrimental effect.
Upon the registration of an application to the session daemon, its name
is sent as part of the 'struct lttng_ust_ctl_reg_msg' registration
message. The application name is sampled using lttng_pthread_getname_np
during the preparation of the message.
However, when the listener thread is launched, its name is changed
early-on to add a '-ust' suffix (see 01f0e40c). This suffixed name is
sampled and sent to the session daemon. Since, until recently, the
pthread_setname_np had no effect on most configurations, this had no
consequence.
I noticed that this has a ripple-effect in the generation of some
path names. For instance, in per-pid mode, snapshots end-up with the
following hierarchy:
Notice how the 'hello' application presents itself with the '-ust'
prefix. For such a short application name, it doesn't really matter
much beyond repeating the 'ust' unnecessarily. However, longer
application names quickly become less readable as we lose four of
the 16 precious allowed characters for a process name.
The procname sampled during the execution of the constructors is
reused. My understanding is that the procname stored in the sock_info
is already used for the 'procname' context.
Michael Jeanson [Thu, 13 May 2021 22:41:35 +0000 (18:41 -0400)]
Add critical log level
Rename the unused BUG() macro to CRIT() to signify an error that can't
be recovered from. Add a new environment variable
LTTNG_UST_ABORT_ON_CRITICAL that when set will abort() on a critical log
statement.
Change-Id: Ib3384a66b7efa4004677b3c153f86cb97b06a091 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: lttng-ust control protocol handling of variable length command data
The scheme for sending variable length data and file descriptors after
the command message causes irrecoverable "unknown commands" errors when
communicating with older versions of lttng-ust, because the receiver
(lttng-ust in applications) does not know that it needs to consume the
variable length data on the communication socket.
For the new commands introduced in the 2.13 cycle, we can change the
protocol on both ends (liblttng-ust-ctl and liblttng-ust) now to add
a reply to the fixed-size part of the command before sending the
variable length data and file descriptors.
For pre-existing commands sending variable length data and file
descriptors right after the fixed-size command, handle this
irrecoverable "unknown command" error by doing a socket shutdown from
liblttng-ust-ctl.
Also document the protocol for each command sending variable length data
and file descriptors after the fixed-size command structure.
Implement socket shutdown API to allow the ust-ctl library to shutdown
the communication socket when it cannot recover from errors which make
the sender and receiver out-of-sync.
Fix: add missing fields in struct lttng_ust_abi_channel_config
struct lttng_ust_abi_channel_config is meant to have the same binary
layout as struct lttng_channel in lttng-ust 2.12. Some fields were
removed (and should not be).
Fix: liblttng-ust-ctl: keep using lttng-ust-sock-8 and lttng-ust-wait-8 filenames
commit 6a359b8a4006 ("Bump LTTNG_UST_ABI version from 8.1 to 9.0")
attempted to ensure that a session daemon linked against an old
lttng-ust-ctl (2.12) would not attempt to interact with newer
applications.
This was done by increasing the major ABI version number, but
introducing LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE (set to 8) as
a mean to allow session daemon to accept both major versions 8 and 9.
Unfortunately, changing LTTNG_UST_ABI_MAJOR_VERSION means the filenames
used for communication changed as well, meaning that applications linked
against older lttng-ust 2.12 cannot interact with lttng sessiond linked
against lttng-ust-ctl 2.13, which is unintended.
Therefore, go back to using the previous filenames: lttng-ust-sock-8,
and lttng-ust-wait-8 for communication.
There is an issue with the security model of lib ring buffer (lttng-ust)
vs SIGBUS handling by consumer daemon. We do not handle SIGBUS in the
consumer daemon. An application using ftruncate on a ring buffer shm
could cause the consumer to be killed with SIGBUS.
Expose the relevant APIs to allow consumer daemon to handle SIGBUS.
It requires the user application (consumerd) to define the TLS sigbus
state with DEFINE_LTTNG_UST_SIGBUS_STATE(), and to invoke
lttng_ust_ctl_sigbus_handle() when a SIGBUS is received, passing the
address causing the SIGBUS (siginfo->si_addr) as parameter.
Internally, liblttng-ust-ctl uses sigsetjmp and siglongjmp to recover
from SIGBUS, and track all accesses to shared memory ranges within the
library.
This modifies the API of liblttng-ust-ctl, and requires the user
application to define the TLS sigbus state with
DEFINE_LTTNG_UST_SIGBUS_STATE(). It therefore needs to be introduced in
locked-step between lttng-ust and lttng-tools.
It requires a major version bump of liblttng-ust-ctl soname.
Fix: Java application context: pass application context argument to callbacks
The callbacks require the complete application context field names to
compare against the tables received from the TLS area.
We also need to free memory allocated by for the context event field and
context name in a destroy callback.
Therefore, allocate a data structure for each application context, and
use that data structure as private data. This allows callback to reach
the context name, and a destroy callback to free the allocated memory.
Add probe descriptor field to enum and event class
If future event instances can refer to event classes located in
different probe providers, the tracer needs to be able to query the
major/minor version of the probe provider containing the class.
Refactoring: tracepoint: allow explicit tracepoint instance provider name
Add a template_provider argument to LTTNG_UST_TRACEPOINT_EVENT_INSTANCE
to allow a tracepoint instance to refer to a tracepoint class from
another provider within the same compile unit.
Also introduce struct lttng_ust_tracepoint_class to clearly split the
event instance from the class, thus allowing the event instance to refer
to the class through a single symbol. This removes the need to rely on
LTTNG_UST__TP_ARRAY_SIZE() to calculate the size of the event field
array (part of the class) from within the event instance. This
refactoring opens the door to have event class and instance not only in
different providers, but also in providers emitted within different
compile units and shared objects in the future.
For instance, if a .c includes the following headers:
This is a localized API-breaking change introduced very early in the
2.13-rc cycle.
This changes the ABI exposed by the probe providers, so bump the probe
provider major version, and make newer lttng-ust reject old incompatible
major. We can do this because it is very early in the 2.13-rc cycle.
sequence type: use previous field for length if length_name is NULL
A common use-case for sequences is to use the field located immediately
prior to the sequence as sequence length.
The fact that the sequence type needs to explicitly contain its length
name ties the sequence type to where it is placed within the structure
fields, preventing re-use of the sequence type.
In order to reduce the memory footprint of the field descriptions and
allow re-use of common field types, special-case the NULL length_name to
use the field prior to the sequence as length.
This allows more efficient type descriptions without reducing the
overall flexibility of sequence layout.
Michael Jeanson [Thu, 22 Apr 2021 22:36:47 +0000 (18:36 -0400)]
Move the ringbuffer and counter clients to 'src/common/'
The clients are used by both liblttng-ust and liblttng-ust-ctl, now that
the clock and getcpu plugins on which they depend have been moved to
liblttng-ust-common, they can be extracted from liblttng-ust-ctl and
move to common convenience libraries.
Change-Id: I8384570007950ca18d00759790cb5264b7c3b528 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Thu, 22 Apr 2021 16:48:52 +0000 (12:48 -0400)]
Make futex compat internal to liblttng-ust
This compat header originated in userspace RCU where it's used across
multiple shared objects hence the need to have the mutexes as public
weak symbols, in our case it's only used internally by liblttng-ust so
we can hide them.
If we end up using this compat header in another library in this project
we will have to use the same scheme, but in the meantime, don't expose
those symbols in the ABI.
Move the code to the liblttng-ust directory to make sure it's not used
by other libraries.
Change-Id: Ibfaef9448eeaf6247b42f71d6b6d8de234d79a3c Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 21 Apr 2021 22:31:54 +0000 (18:31 -0400)]
Namespace liblttng-ust-ctl symbols
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Rename all liblttng-ust-ctl symbols from
'ustctl_' to 'lttng_ust_ctl_'.
Change-Id: Ic2b9da019e7776b24b98824ae63d16b86c5a5742 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Introduce a "probe context" to allow passing the "ip" context from the
probe function to the get_value callback used by the bytecode
interpreter. This enables the "ip" context to be used from the filter
bytecode and from the capture bytecode.
Also fix signedness of the return type of the get_value context
callbacks for cases where the type is unsigned.
Fix: move compat macros for tracepoint probes to ust-tracepoint-event.h
Do not pollute the compile units with API=0 defines for applications
instrumented with tracepoint.h but keeping the probe provider in a
separate compile unit.
Michael Jeanson [Wed, 21 Apr 2021 21:44:07 +0000 (17:44 -0400)]
Tracepoint API namespacing ctf_enum
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I377d89338735a6cc3b2b436e69fefd2e81f39e9a Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 21 Apr 2021 21:27:39 +0000 (17:27 -0400)]
Tracepoint API namespacing ctf_unused
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I41531d9e69604f1809d035147779c8ceeed2add7 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 21 Apr 2021 21:04:19 +0000 (17:04 -0400)]
Tracepoint API namespacing ctf_string
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I5ca6f4574a10b62c397af2f20312e309f6b59563 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 21 Apr 2021 20:56:54 +0000 (16:56 -0400)]
Tracepoint API namespacing ctf_sequence
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I6c8596313ce806dd401d41b9b24e228aad39cfe5 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 21 Apr 2021 20:03:42 +0000 (16:03 -0400)]
Tracepoint API namespacing ctf_array
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: Ib1c3694d054cba2b6d27bd62a3db2b64eca27c3f Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 21 Apr 2021 19:50:19 +0000 (15:50 -0400)]
Tracepoint API namespacing ctf_float
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: Ia34bb89dff2542b8d67f2221353ea2e01ed0e0e8 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 21 Apr 2021 19:37:36 +0000 (15:37 -0400)]
Tracepoint API namespacing ctf_integer
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I361286079a409226287eb0c401231f4d147e08a4 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 21 Apr 2021 18:33:28 +0000 (14:33 -0400)]
Tracepoint API namespacing tracepoint-rcu
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: Ia07f15d7dd01c6d1e86033c83d329888bb52553f Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 21 Apr 2021 16:42:21 +0000 (12:42 -0400)]
Tracepoint API namespacing ust-endian
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: Iaab4a3630f3cd75adf540e4e849fb374076d87b4 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 21 Apr 2021 15:19:16 +0000 (11:19 -0400)]
Tracepoint API namespacing tracelog
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I60a6f7838ddf60ef43c3017a50ed24c8bf188a43 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 21 Apr 2021 15:07:58 +0000 (11:07 -0400)]
Tracepoint API namespacing tracef
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I1a16b9af1dfabb9483cdf3e5225ebe50fe691935 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Tue, 20 Apr 2021 21:15:16 +0000 (17:15 -0400)]
Tracepoint API namespacing '__lttng_ust_events_exit'
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I150273940c94f4b0c86b87adcad724befd480158 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Tue, 20 Apr 2021 21:11:55 +0000 (17:11 -0400)]
Tracepoint API namespacing '__lttng_ust_events_init'
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I2918a0974bd0c7d0c44a4d383d2092d586a20892 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Tue, 20 Apr 2021 21:08:05 +0000 (17:08 -0400)]
Tracepoint API namespacing '__lttng_ust_probe_register_cookie'
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I8ef2e31d57a37f1f3519c566767aac56ee20bf66 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Tue, 20 Apr 2021 21:06:10 +0000 (17:06 -0400)]
Tracepoint API namespacing '__probe_register'
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I7fa206f7730802b73c441901572c0f3986d9566a Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Tue, 20 Apr 2021 21:05:05 +0000 (17:05 -0400)]
Tracepoint API namespacing '__probe_desc'
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: Iabbb87406d25a0fce4371e44d6ead8b6452ebf5f Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Tue, 20 Apr 2021 21:01:33 +0000 (17:01 -0400)]
Tracepoint API namespacing '_TP_EXTRACT_STRING'
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I6e2f65e3510cb0c0bce14b792f1e3fb280a1754d Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Tue, 20 Apr 2021 21:00:10 +0000 (17:00 -0400)]
Tracepoint API namespacing '__get_dynamic_len'
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: Id3c3f0d08439c6149f835ced5a575f2507b74ef1 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Tue, 20 Apr 2021 20:57:45 +0000 (16:57 -0400)]
Tracepoint API namespacing 'TP_IP_PARAM'
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: Ie01946b463b9b7a517699b3d7063ef97da134a43 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Tue, 20 Apr 2021 20:50:17 +0000 (16:50 -0400)]
Tracepoint API namespacing 'TP_SESSION_CHECK'
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I7c68548f40594250ba10defcdd0775cdb1a3172e Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Tue, 20 Apr 2021 20:28:58 +0000 (16:28 -0400)]
Tracepoint API namespacing '__tp_stringify'
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I98e1265e8f9118a27df89e6142ba59fcdd5ae131 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Tue, 20 Apr 2021 19:05:29 +0000 (15:05 -0400)]
Tracepoint API namespacing '__event_'
The ABI bump gives us the opportunity to namespace all public symbols
under the 'lttng_ust_' prefix. Namespace all API symbols and macros
under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep
compatibility with the previous API.
Change-Id: I49ba4ed31dff075d66eb4c4deec878243c0080b5 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>