Michael Jeanson [Thu, 25 Mar 2021 17:07:21 +0000 (13:07 -0400)]
fix: int8_t is not considered an integer
Add 'signed char' to the list of types we consider integers. Since 'char'
being signed or unsigned is implementation dependant, we have to
explicitly list 'char', 'signed char' and 'unsigned char' as integer
types.
Change-Id: I3aace2621f14f54e5d88d43de509a6cffde66c5b Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 3 Mar 2021 17:10:20 +0000 (12:10 -0500)]
Python agent lib soname major bump
Make the python agent library follow the main library soname for
co-installability with previous versions. Also use the value provided by
the build system instead of manually synchronizing it.
Change-Id: Ieef9b9ca6dcfd08b7834e5faafef3935a6a1a232 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Thu, 18 Mar 2021 20:50:27 +0000 (16:50 -0400)]
Introduce SONAME defines
Folowing the refactor of the autotools code, the major soname number of each
library is now available as a define in 'lttng/ust-version.h'. Use them
instead of literal value that have to be synchronized manually.
Change-Id: I7d777d32c2a710708c1ac2546111458c281fce13 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tracepoint probe refactoring: Move provider name to provider descriptor
The provider name is currently repeated for each event name as:
<provider name>:<event name>
This repetition requires that each event embeds the provider name within
its own name.
Use this ABI break to clean this up: instead, each event descriptor has
a pointer to its probe descriptor, and each probe descriptor has a
provider name.
Implement name size validation and event name formatting internal
helpers, and use them across the tracer.
API cleanup: Remove handle from struct lttng_ust_channel_buffer
Now that the handle is fetched from struct lttng_ust_lib_ring_buffer_channel
by the ring buffer client callbacks, there is no need to keep it around
in the public API struct lttng_ust_channel_buffer.
The ring buffer handle is available in the struct lttng_ust_lib_ring_buffer_channel,
therefore passing it through the ring buffer context is redundant.
ring buffer context: cpu number becomes an output of reserve
In order to facilitate eventual integration of a ring buffer scheme
based on Restartable Sequences (sys_rseq), change the ownership of the
ring buffer context "cpu" field so it is now populated by the ring
buffer reserve operation. This means a rseq-based reserve could retry
on a new current cpu after a rseq-cmpxchg fails to reserve and then a
migration occurs.
Fix: truncation of text array and sequences by NULL terminator
The recent refactor does not take into account that text array and text
sequence types behave like Pascal Strings and not C strings, which means
the NULL terminator is optional, and the string size is delimited by the
array or sequence length.
Introduce a new lib_ring_buffer_pstrcpy() to handle copying into a ring
buffer Pascal String, and use it for array and sequence of text.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Fixes: 2792781482a5 ("ABI refactoring: sequence and array of text: copy input as string") Fixes: #1301
Change-Id: Idcc13f061d5229496476f42dce84c2f395b7f6e6
Michael Jeanson [Tue, 23 Mar 2021 18:20:21 +0000 (14:20 -0400)]
fix: Group Targets requires GNU Make >= 4.3
Group Targets requires GNU Make >= 4.3 released in 2020, with older Make
release the syntax only results in a warning and most of the time it
will work fine since the rule is called and generates both files.
However it breaks the dependencies across files and makes the man pages
generation racy.
Use a less elegant workaround that is compatible with all Make
implementations.
Change-Id: I46a0488c6ff61082f641d8ee55ad2802c0bfa046 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
clock override: introduce getter API for lttng tools
Currently, the lttng session daemon reimplements its own copy of
struct lttng_trace_clock, which is pretty bad as ABI go.
Implement getter functions for each of the clock callback instead. This
refactoring needs to be introduced with a matching commit to use the new
ABI in LTTng tools.
Move the implementation of the clock frequency, uuid, name and
description default callbacks (for monotonic clock) to lttng-ust.
This allow to hide the previously exposed "lttng_trace_clock" public
symbol. Rename this internal symbol to lttng_ust_trace_clock for prefix
consistency. Rename struct lttng_trace_clock to struct
lttng_ust_trace_clock for similar reasons.
Michael Jeanson [Tue, 23 Mar 2021 16:09:49 +0000 (12:09 -0400)]
fix: use configured python when building the examples
Prior to the refactoring of the autotools setup we used different python
detection mechanisms for the python agent feature and the example code.
The example code detection was flawed as it would only work with a
python binary named exactly 'python'. Wire the detected python binary in
the examples Makefile integration.
Change-Id: I07b9222a8869ff154073e5b72fb2ac0d70f14896 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
ABI refactoring: sequence and array of text: copy input as string
Within the lttng-modules writeback instrumentation, which exposes a
tracepoint probe API similar to LTTng-UST, we had a long standing issue
where a fixed-size array of text was used to copy a string input into
the trace.
This is fine as long as the input string is actually backed by a
fixed-size array, but if the input string is variable-size, and may be
smaller than the array size, this led to out-of-bound memory reads
beyond the input string NULL terminating character.
Change the behavior of the array/sequence of text to stop copying the
input as soon as the array/sequence size limit (-1) or the input's NULL
terminating character is found, and add zeroed padding for the rest of
the array/sequence within the ring buffer.
Michael Jeanson [Mon, 22 Mar 2021 17:29:58 +0000 (13:29 -0400)]
Introduce AE_FEATURE to manage configure features
The new AE_FEATURE set of macros are wrappers over autoconf's
AC_ARG_ENABLE. The main objective is to make the m4sh code more readable
to the less seasoned autotools enthusiast among us and reduce the
duplication of code with its associated bugs.
The AE prefix was chosen to mean "Autotools EfficiOS" and is part of an
effort to standardize our custom macros across all our autotools based
projects.
Change-Id: I35268e36e70b2dd826876939e663d63d3123fa9f Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Thu, 18 Mar 2021 18:16:40 +0000 (14:16 -0400)]
Centralize arch detection in a public header
Add a public header with centralized compiler arch detection and arch
specific parameters. Namespace everything under 'LTTNG_UST_ARCH_'.
Move "LTTNG_UST_HAVE_EFFICIENT_UNALIGNED_ACCESS" from a configure time
define to a static one base on compiler arch detection.
This will simplify the build system and remove the possibility of
accidently mixing aligned and unaligned access in a multiarch
environment with shared header files.
Change-Id: Ic977d13f031ad070bea4ff5d7b2b8079843e0c26 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: bytecode linker: validate event and field array/sequence encoding
The bytecode linker should only allow linking filter expressions loading
fields which are string-encoded arrays and sequence for comparison
against a string, and reject arrays and sequences without encoding, so
the filter interpreter does not attempt to load non-NULL terminated
arrays/sequences as if they were strings.
Add a validation at channel creation to ensure that the uuid of all
channels created within a session match.
Note that we still need to keep a copy of the uuid field in the channel
private data at this stage, because the consumer daemon creates channels
with a NULL session pointer.
Introduce an "event filter" callback to be called by the instrumentation
probe, and move the bytecode list into private data structures.
This will allow much more freedom in choosing how bytecodes are combined
both in terms of logic (OR vs AND) and implementation (jits).
Currently, we keep callbacks internally as well for each bytecode
evaluation, but nothing prevents to change how this works in the future
to improve performance now that this is all private.
For filters, we add the following fields to struct lttng_ust_event_common:
int eval_filter; /* Need to evaluate filters */
int (*run_filter)(struct lttng_ust_event_common *event,
const char *stack_data,
void *filter_ctx);
"eval_filter" is a state indicating whether the filter should be
evaluated at all. It combines internal knowledge of whether the filter
bytecode list is empty, and whether there are enablers without filter
bytecode attached to the event.
For captures, a new struct lttng_ust_notification_ctx is introduced,
which is to be used as additional "context" to the notification_send()
callback. This allows passing the "eval_capture" state from the probe
to the notification callback, and fixes a bug where a sequence of:
where a tracepoint runs concurrently with add capture happens to do a
first capture list_empty check which skips the stack preparation,
whereas the second capture list_empty check within the notification
callback finds a capture entry, and thus attempts to use an
uninitialized stack. The notification callback is also modified to use
an RCU-aware list traversal.
For captures, the following field is added to struct lttng_ust_event_notifier:
int eval_capture; /* Need to evaluate capture */
which is to be read once by the probe and its state saved and used
thorough the entire probe execution.
Refactor the ABI of the bytecode interpreter, which is used by the probe
provider callbacks:
- Return a "int" rather than uint64_t,
- The return values are now:
LTTNG_UST_BYTECODE_INTERPRETER_ERROR = -1,
LTTNG_UST_BYTECODE_INTERPRETER_OK = 0,
- Introduce a bytecode "context". This context is specific for each
bytecode "class" (filter or capture). The filter class context
has a "result" (accept/reject) output, whereas the capture class
has an "output".
- The bytecode context is extensible with the struct_size scheme.
- Merge filter and capture interpreters into a single callback.
That callback uses a new "bytecode type" field within the bytecode
private data to figure out the specific bytecode class (filter or
capture).
The list of contexts active for an event can be moved to a private
structure by keeping the temporary pointer to the RCU dereferenced
context in the ring buffer client's internal context rather than within
the context shared between the probe and the ring buffer client.
The list of contexts active for a channel can be moved to a private
structure by keeping the temporary pointer to the RCU dereferenced
context in the ring buffer client's internal context rather than within
the context shared between the probe and the ring buffer client.
Now that struct lttng_channel is separate from the consumer daemon
channel config message ABI layout, we can perform a significant amount
of refactoring:
- Namespace theses structures with lttng_ust_ prefix,
- Use struct_size extensibility scheme.
- Split fields into public/private structures,
- Split public and private structures into a child (ring buffer)
and parent (common). This will allow introducing other channel
children types in the future (e.g. counters).
struct lttng_channel: split protocol ABI from instrumentation ABI
Duplicate struct lttng_channel to introduce a new struct
lttng_ust_abi_channel_config meant to hold configuration data within the
memory area belonging to the ring buffer private data. Now the
application and consumer private pointer will be a separate pointer,
for which the memory will be owned by the caller.
This will allow us to modify the layout of struct lttng_channel without
breaking the UST communication protocol.
Michael Jeanson [Wed, 17 Mar 2021 19:27:10 +0000 (15:27 -0400)]
Namespace lttng/align.h as lttng/ust-align.h
Since the 'lttng/' header directory is shared between ust and tools,
namespace this common name header with 'ust-' to match the same pattern
as the other files.
Change-Id: Iad25ad76b75e87e040b4d7dd9f461ce6522ac361 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 17 Mar 2021 19:19:37 +0000 (15:19 -0400)]
Namespace lttng/bug.h as lttng/ust-bug.h
Since the 'lttng/' header directory is shared between ust and tools,
namespace this common name header with 'ust-' to match the same pattern
as the other files.
Change-Id: I08e853d9edcce218a9bd57717316a557f49200d7 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
The public header ringbuffer-config.h contains two distinct sets of APIs
and structure declarations:
- Ring buffer configuration, which should become private (moved to
libringbuffer/ringbuffer-config.h),
- Ring buffer context for use when writing an event record into the
ring buffer. This part is moved to a new "ringbuffer-context.h" public
header.
Refactoring: Introduce extensibility scheme for tracepoint structures
- Introduce struct_size extensibility scheme for all tracepoint public
structures, except for struct lttng_ust_tracepoint_probe which is
embedded in a public array of structures, thus making it tricky for
instrumentation sites to efficiently skip over the array elements
without reading their size.
- Remove padding from those structures.
- Properly namespace public type interfaces with lttng_ust_ prefix,
- Move from union to parent embedding into children for inheritance.
- Introduce struct lttng_ust_type_common, which is fixed-size, to
contain the type selector. Used as parent for each sub-type.
- Use compound literals on tracepoint probe definition rather than
nesting into event field structure to allow each type to be extended
with a struct_size scheme.
- The parent field is required to be the first field of each sub-type,
allowing cast between parent and children types.
- Remove const-ness from various probe provider visible types to
facilitate re-use of the code for eventual dynamically allocated
structures.
- Remove "field_name" field from lttng_ust_ctx_field. Instead,
dynamically allocate field names for each context.
- Introduce get_type_max_align() in lttng-context.c now used by
lttng_context_update(). It performs a recursive traversal of the
nested types rather than erroring out on recursive cases.
- Move "encoding" from integer type to array and sequences types.
Refactoring: remove struct_size from struct lttng_ust_ctx_value
The struct_size scheme is not appropriate to extend struct
lttng_ust_ctx_value because its type selector and union already
act as a mean to extend it. When new entries are added to the union,
the size of that union may increase, thus shifting the offset of
fields following that union. It is therefore not possible to extend
it by adding fields after the union, thus making the struct_size
scheme irrelevant.
The context structures are now hidden in headers which are not
installed, but those are still part of the UST ABI. Therefore, we need
to update them to make sure those are extensible.
- Namespace theses structures with lttng_ust_ prefix,
- Use struct_size extensibility scheme. There was no prior padding, so
extensibility was an issue in the past.
- Remove padding.
- This requires that none of those structures can be nested. It also
requires that all arrays of structures must be replaced by arrays of
pointers to structures.
- Replace struct lttng_perf_counter_field pointer by a private data
pointer.
Michael Jeanson [Thu, 11 Mar 2021 21:48:47 +0000 (16:48 -0500)]
Namespace private ABI lttng_transport_find symbol
The major SONAME bump to '1' gives us the opportunity to properly
namespace public symbols. This symbol is part of the ABI between
liblttng-ust-ctl and liblltng-ust and is not part of the public API.
Change-Id: Ibdb33aff98f7b974fac3c28889718851286ce2f9 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 10 Mar 2021 19:09:52 +0000 (14:09 -0500)]
Remove LTTNG_HIDDEN macro
We already use __attribute__((visibility("hidden"))) directly in the
public API and in some parts of the code. Remove the LTTNG_HIDDEN macro
and replace it with the literal attribute.
Change-Id: I9aa0698ba08c742c2a25aec24560b7789e303eaa Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- Namespace this structure with lttng_ust_ prefix,
- Use struct_size extensibility scheme. There was no prior padding, so
extensibility was an issue in the past.